SHARE
TWEET

ModelFluidDebug.java

circuitdh Jun 15th, 2016 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package net.minecraftforge.debug;
  2.  
  3. import net.minecraft.block.material.Material;
  4. import net.minecraft.block.state.IBlockState;
  5. import net.minecraft.client.renderer.ItemMeshDefinition;
  6. import net.minecraft.client.renderer.block.model.ModelBakery;
  7. import net.minecraft.client.renderer.block.model.ModelResourceLocation;
  8. import net.minecraft.client.renderer.block.statemap.StateMapperBase;
  9. import net.minecraft.creativetab.CreativeTabs;
  10. import net.minecraft.item.Item;
  11. import net.minecraft.item.ItemStack;
  12. import net.minecraft.util.ResourceLocation;
  13. import net.minecraftforge.client.model.ModelLoader;
  14. import net.minecraftforge.fluids.BlockFluidClassic;
  15. import net.minecraftforge.fluids.Fluid;
  16. import net.minecraftforge.fluids.FluidRegistry;
  17. import net.minecraftforge.fml.common.Mod;
  18. import net.minecraftforge.fml.common.Mod.EventHandler;
  19. import net.minecraftforge.fml.common.SidedProxy;
  20. import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
  21. import net.minecraftforge.fml.common.registry.GameRegistry;
  22.  
  23. @Mod(modid = ModelFluidDebug.MODID, version = ModelFluidDebug.VERSION)
  24. public class ModelFluidDebug
  25. {
  26.     public static final String MODID = "ForgeDebugModelFluid";
  27.     public static final String VERSION = "1.0";
  28.  
  29.     @SidedProxy(serverSide = "net.minecraftforge.debug.ModelFluidDebug$CommonProxy", clientSide = "net.minecraftforge.debug.ModelFluidDebug$ClientProxy")
  30.     public static CommonProxy proxy;
  31.  
  32.     @EventHandler
  33.     public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); }
  34.  
  35.     public static class CommonProxy
  36.     {
  37.         public void preInit(FMLPreInitializationEvent event)
  38.         {
  39.             FluidRegistry.registerFluid(TestFluid.instance);
  40.             FluidRegistry.registerFluid(TestGas.instance);
  41.             GameRegistry.registerBlock(TestFluidBlock.instance, TestFluidBlock.name);
  42.             GameRegistry.registerBlock(TestGasBlock.instance, TestGasBlock.name);
  43.         }
  44.     }
  45.  
  46.     public static class ClientProxy extends CommonProxy
  47.     {
  48.         private static ModelResourceLocation fluidLocation = new ModelResourceLocation(MODID.toLowerCase() + ":" + TestFluidBlock.name, "fluid");
  49.         private static ModelResourceLocation gasLocation = new ModelResourceLocation(MODID.toLowerCase() + ":" + TestFluidBlock.name, "gas");
  50.  
  51.         @Override
  52.         public void preInit(FMLPreInitializationEvent event)
  53.         {
  54.             super.preInit(event);
  55.             Item fluid = Item.getItemFromBlock(TestFluidBlock.instance);
  56.             Item gas = Item.getItemFromBlock(TestGasBlock.instance);
  57.             ModelBakery.registerItemVariants(fluid);
  58.             ModelBakery.registerItemVariants(gas);
  59.             ModelLoader.setCustomMeshDefinition(fluid, new ItemMeshDefinition()
  60.             {
  61.                 public ModelResourceLocation getModelLocation(ItemStack stack)
  62.                 {
  63.                     return fluidLocation;
  64.                 }
  65.             });
  66.             ModelLoader.setCustomMeshDefinition(gas, new ItemMeshDefinition()
  67.             {
  68.                 public ModelResourceLocation getModelLocation(ItemStack stack)
  69.                 {
  70.                     return gasLocation;
  71.                 }
  72.             });
  73.             ModelLoader.setCustomStateMapper(TestFluidBlock.instance, new StateMapperBase()
  74.             {
  75.                 protected ModelResourceLocation getModelResourceLocation(IBlockState state)
  76.                 {
  77.                     return fluidLocation;
  78.                 }
  79.             });
  80.             ModelLoader.setCustomStateMapper(TestGasBlock.instance, new StateMapperBase()
  81.             {
  82.                 protected ModelResourceLocation getModelResourceLocation(IBlockState state)
  83.                 {
  84.                     return gasLocation;
  85.                 }
  86.             });
  87.         }
  88.     }
  89.  
  90.     public static final class TestFluid extends Fluid
  91.     {
  92.         public static final String name = "testfluid";
  93.         public static final TestFluid instance = new TestFluid();
  94.  
  95.         private TestFluid()
  96.         {
  97.             super(name, new ResourceLocation("blocks/water_still"), new ResourceLocation("blocks/water_flow"));
  98.         }
  99.  
  100.         @Override
  101.         public int getColor()
  102.         {
  103.             return 0x66FF00;
  104.         }
  105.     }
  106.  
  107.     public static final class TestGas extends Fluid
  108.     {
  109.         public static final String name = "testgas";
  110.         public static final TestGas instance = new TestGas();
  111.  
  112.         private TestGas()
  113.         {
  114.             super(name, new ResourceLocation("blocks/lava_still"), new ResourceLocation("blocks/lava_flow"));
  115.             density = -1000;
  116.             isGaseous = true;
  117.         }
  118.  
  119.         @Override
  120.         public int getColor()
  121.         {
  122.             return 0x66FF00;
  123.         }
  124.     }
  125.  
  126.     public static final class TestFluidBlock extends BlockFluidClassic
  127.     {
  128.         public static final TestFluidBlock instance = new TestFluidBlock();
  129.         public static final String name = "TestFluidBlock";
  130.  
  131.         private TestFluidBlock()
  132.         {
  133.             super(TestFluid.instance, Material.WATER);
  134.             setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
  135.             setUnlocalizedName(MODID + ":" + name);
  136.         }
  137.     }
  138.  
  139.     public static final class TestGasBlock extends BlockFluidClassic
  140.     {
  141.         public static final TestGasBlock instance = new TestGasBlock();
  142.         public static final String name = "TestGasBlock";
  143.  
  144.         private TestGasBlock()
  145.         {
  146.             super(TestGas.instance, Material.LAVA);
  147.             setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
  148.             setUnlocalizedName(MODID + ":" + name);
  149.         }
  150.     }
  151. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top