Skip to content

Instantly share code, notes, and snippets.

@ustc-zzzz
Created September 4, 2018 21:16
Show Gist options
  • Save ustc-zzzz/0ea3d29ff29b21fc2ed4811b58df173f to your computer and use it in GitHub Desktop.
Save ustc-zzzz/0ea3d29ff29b21fc2ed4811b58df173f to your computer and use it in GitHub Desktop.
package com.example.sideonlylambda;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.logging.log4j.Logger;
@Mod(modid = "side" + "only" + "lambda", name = "SideOnly Lambda", version = "0.1.0")
public class SideOnlyLambda
{
private static Logger logger;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
logger = event.getModLog();
}
@EventHandler
@SideOnly(Side.SERVER)
public void initServer(FMLInitializationEvent event)
{
logger.info("Init from (physical) server.");
OreDictionary.getOres("dirt").forEach(this::printItem);
}
@EventHandler
@SideOnly(Side.CLIENT)
public void initClient(FMLInitializationEvent event)
{
logger.info("Init from (physical) client.");
OreDictionary.getOres("dirt").forEach(this::printItem);
}
private void printItem(ItemStack item)
{
String displayName = item.getDisplayName();
logger.info("DIRT ITEM >> {}", displayName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment