2015-09-02 07:26:42 +03:00
|
|
|
package net.minecraftforge.debug;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.block.BlockContainer;
|
|
|
|
|
import net.minecraft.block.material.Material;
|
2016-03-05 04:43:41 +03:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2015-09-02 07:26:42 +03:00
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
|
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
2016-03-01 04:58:03 -08:00
|
|
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
2015-09-02 07:26:42 +03:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
import net.minecraftforge.client.ForgeHooksClient;
|
|
|
|
|
import net.minecraftforge.client.event.ModelBakeEvent;
|
|
|
|
|
import net.minecraftforge.client.model.ModelLoader;
|
|
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
|
|
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
|
|
|
|
import net.minecraftforge.fml.common.Mod;
|
|
|
|
|
import net.minecraftforge.fml.common.Mod.EventHandler;
|
|
|
|
|
import net.minecraftforge.fml.common.SidedProxy;
|
2015-10-27 19:02:22 +03:00
|
|
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
2015-09-02 07:26:42 +03:00
|
|
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
|
|
|
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
|
|
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
|
|
|
|
import static org.lwjgl.opengl.GL11.*;
|
|
|
|
|
|
|
|
|
|
@Mod(modid = ItemTileDebug.MODID)
|
|
|
|
|
public class ItemTileDebug
|
|
|
|
|
{
|
|
|
|
|
public static final String MODID = "ForgeDebugItemTile";
|
|
|
|
|
|
|
|
|
|
private static String blockName = MODID.toLowerCase() + ":" + TestBlock.name;
|
|
|
|
|
|
2016-01-02 09:59:14 +03:00
|
|
|
@SidedProxy
|
2015-09-02 07:26:42 +03:00
|
|
|
public static CommonProxy proxy;
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); }
|
|
|
|
|
|
2015-10-27 19:02:22 +03:00
|
|
|
@EventHandler
|
|
|
|
|
public void init(FMLInitializationEvent event) { proxy.init(event); }
|
|
|
|
|
|
2015-09-02 07:26:42 +03:00
|
|
|
public static class CommonProxy
|
|
|
|
|
{
|
|
|
|
|
public void preInit(FMLPreInitializationEvent event)
|
|
|
|
|
{
|
|
|
|
|
GameRegistry.registerBlock(TestBlock.instance, TestBlock.name);
|
|
|
|
|
GameRegistry.registerTileEntity(CustomTileEntity.class, MODID.toLowerCase() + ":custom_tile_entity");
|
|
|
|
|
}
|
2015-10-27 19:02:22 +03:00
|
|
|
|
|
|
|
|
public void init(FMLInitializationEvent event) {}
|
2015-09-02 07:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
2016-01-02 09:59:14 +03:00
|
|
|
public static class ServerProxy extends CommonProxy {}
|
|
|
|
|
|
2015-09-02 07:26:42 +03:00
|
|
|
public static class ClientProxy extends CommonProxy
|
|
|
|
|
{
|
2016-03-16 01:42:01 +03:00
|
|
|
private static ModelResourceLocation itemLocation = new ModelResourceLocation(blockName, "normal");
|
2015-09-02 07:26:42 +03:00
|
|
|
|
2015-11-26 19:38:21 -08:00
|
|
|
@SuppressWarnings("deprecation")
|
2015-09-02 07:26:42 +03:00
|
|
|
@Override
|
|
|
|
|
public void preInit(FMLPreInitializationEvent event)
|
|
|
|
|
{
|
|
|
|
|
super.preInit(event);
|
|
|
|
|
Item item = Item.getItemFromBlock(TestBlock.instance);
|
|
|
|
|
ForgeHooksClient.registerTESRItemStack(item, 0, CustomTileEntity.class);
|
|
|
|
|
ModelLoader.setCustomModelResourceLocation(item, 0, itemLocation);
|
|
|
|
|
MinecraftForge.EVENT_BUS.register(BakeEventHandler.instance);
|
|
|
|
|
}
|
2015-10-27 19:02:22 +03:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void init(FMLInitializationEvent event) {
|
|
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(CustomTileEntity.class, TestTESR.instance);
|
|
|
|
|
}
|
2015-09-02 07:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class BakeEventHandler
|
|
|
|
|
{
|
|
|
|
|
public static final BakeEventHandler instance = new BakeEventHandler();
|
|
|
|
|
|
|
|
|
|
private BakeEventHandler() {};
|
|
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
|
public void onModelBakeEvent(ModelBakeEvent event)
|
|
|
|
|
{
|
2016-03-06 02:51:39 +03:00
|
|
|
event.getModelManager().getBlockModelShapes().registerBuiltInBlocks(TestBlock.instance);
|
2015-09-02 07:26:42 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-26 19:38:21 -08:00
|
|
|
public static class TestTESR extends TileEntitySpecialRenderer<CustomTileEntity>
|
2015-09-02 07:26:42 +03:00
|
|
|
{
|
|
|
|
|
private static final TestTESR instance = new TestTESR();
|
|
|
|
|
|
|
|
|
|
private TestTESR() {}
|
|
|
|
|
|
|
|
|
|
@Override
|
2015-11-26 19:38:21 -08:00
|
|
|
public void renderTileEntityAt(CustomTileEntity p_180535_1_, double x, double y, double z, float p_180535_8_, int p_180535_9_)
|
2015-09-02 07:26:42 +03:00
|
|
|
{
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
glTranslated(x, y, z);
|
|
|
|
|
GlStateManager.disableTexture2D();
|
|
|
|
|
GlStateManager.disableLighting();
|
|
|
|
|
glColor4f(.2f, 1, .1f, 1);
|
|
|
|
|
glBegin(GL_QUADS);
|
|
|
|
|
glVertex3f(0, .5f, 0);
|
|
|
|
|
glVertex3f(0, .5f, 1);
|
|
|
|
|
glVertex3f(1, .5f, 1);
|
|
|
|
|
glVertex3f(1, .5f, 0);
|
|
|
|
|
glEnd();
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
GlStateManager.enableTexture2D();
|
|
|
|
|
GlStateManager.enableLighting();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class TestBlock extends BlockContainer
|
|
|
|
|
{
|
|
|
|
|
public static final TestBlock instance = new TestBlock();
|
|
|
|
|
public static final String name = "custom_model_block";
|
|
|
|
|
|
|
|
|
|
private TestBlock()
|
|
|
|
|
{
|
|
|
|
|
super(Material.iron);
|
|
|
|
|
setCreativeTab(CreativeTabs.tabBlock);
|
|
|
|
|
setUnlocalizedName(MODID + ":" + name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2016-03-05 04:43:41 +03:00
|
|
|
public boolean isOpaqueCube(IBlockState state) { return false; }
|
2015-09-02 07:26:42 +03:00
|
|
|
|
|
|
|
|
@Override
|
2016-03-05 04:43:41 +03:00
|
|
|
public boolean isFullCube(IBlockState state) { return false; }
|
2015-09-02 07:26:42 +03:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isVisuallyOpaque() { return false; }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public TileEntity createNewTileEntity(World world, int meta)
|
|
|
|
|
{
|
|
|
|
|
return new CustomTileEntity();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class CustomTileEntity extends TileEntity {}
|
|
|
|
|
}
|