diff --git a/src/main/java/techreborn/init/ModItems.java b/src/main/java/techreborn/init/ModItems.java index c9b84f1a2..bc8e03e3a 100644 --- a/src/main/java/techreborn/init/ModItems.java +++ b/src/main/java/techreborn/init/ModItems.java @@ -28,18 +28,11 @@ import techreborn.api.Reference; public class ModItems { - // This are deprected to stop people using them in the recipes. - @Deprecated public static Item gems; - @Deprecated public static Item ingots; - @Deprecated public static Item nuggets; - @Deprecated public static Item dusts; - @Deprecated public static Item smallDusts; - @Deprecated public static Item parts; @Deprecated public static Item cells; @@ -52,8 +45,6 @@ public class ModItems public static Item manual; public static Item uuMatter; public static Item plate; - public static Item crushedOre; - public static Item purifiedCrushedOre; public static Item cloakingDevice; public static Item reBattery; @@ -124,6 +115,9 @@ public class ModItems public static Item missingRecipe; public static Item debug; + public static Item emptyCell; + public static DynamicCell dynamicCell; + public static void init() throws InstantiationException, IllegalAccessException { gems = new ItemGems(); @@ -312,6 +306,12 @@ public class ModItems debug = new ItemDebugTool(); GameRegistry.registerItem(debug, "debug"); + emptyCell = new EmptyCell(); + GameRegistry.registerItem(emptyCell, "emptyCell"); + + dynamicCell = new DynamicCell(); + GameRegistry.registerItem(dynamicCell, "dynamicCell"); + MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE); Core.logHelper.info("TechReborns Items Loaded"); diff --git a/src/main/java/techreborn/init/RecipeCompact.java b/src/main/java/techreborn/init/RecipeCompact.java index bf40656cb..3684da3e5 100644 --- a/src/main/java/techreborn/init/RecipeCompact.java +++ b/src/main/java/techreborn/init/RecipeCompact.java @@ -3,6 +3,7 @@ package techreborn.init; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; import techreborn.api.recipe.IRecipeCompact; import techreborn.blocks.BlockMachineFrame; import techreborn.items.*; @@ -36,8 +37,8 @@ public class RecipeCompact implements IRecipeCompact recipes.put("iridiumOre", ItemIngots.getIngotByName("iridium")); recipes.put("plateiron", ItemPlates.getPlateByName("iron")); recipes.put("iridiumPlate", ItemPlates.getPlateByName("iridium")); - recipes.put("cell", ItemCells.getCellByName("empty")); - recipes.put("airCell", ItemCells.getCellByName("empty")); + recipes.put("cell", new ItemStack(ModItems.emptyCell)); + recipes.put("airCell", new ItemStack(ModItems.emptyCell)); recipes.put("electronicCircuit", ItemParts.getPartByName("electronicCircuit")); recipes.put("advancedCircuit", ItemParts.getPartByName("advancedCircuit")); recipes.put("rubberWood", new ItemStack(ModBlocks.rubberLog)); @@ -52,8 +53,8 @@ public class RecipeCompact implements IRecipeCompact recipes.put("diamondDrill", new ItemStack(ModItems.diamondDrill)); recipes.put("miningDrill", new ItemStack(ModItems.ironDrill)); recipes.put("solarPanel", new ItemStack(ModBlocks.solarPanel)); - recipes.put("waterCell", ItemCells.getCellByName("water")); - recipes.put("lavaCell", ItemCells.getCellByName("lava")); + recipes.put("waterCell", DynamicCell.getCellWithFluid(FluidRegistry.WATER)); + recipes.put("lavaCell", DynamicCell.getCellWithFluid(FluidRegistry.LAVA)); recipes.put("pump", new ItemStack(ModBlocks.pump)); // recipes.put("teleporter", new ItemStack(ModItems.missingRecipe)); recipes.put("advancedAlloy", ItemIngots.getIngotByName("advancedAlloy")); diff --git a/src/main/java/techreborn/init/SubItemRetriever.java b/src/main/java/techreborn/init/SubItemRetriever.java index 89ace0718..d97f18779 100644 --- a/src/main/java/techreborn/init/SubItemRetriever.java +++ b/src/main/java/techreborn/init/SubItemRetriever.java @@ -4,15 +4,7 @@ import net.minecraft.item.ItemStack; import techreborn.api.ISubItemRetriever; import techreborn.blocks.BlockOre; import techreborn.blocks.BlockStorage; -import techreborn.items.ItemCells; -import techreborn.items.ItemDusts; -import techreborn.items.ItemDustsSmall; -import techreborn.items.ItemGems; -import techreborn.items.ItemIngots; -import techreborn.items.ItemNuggets; -import techreborn.items.ItemParts; -import techreborn.items.ItemPlates; -import techreborn.items.ItemUpgrades; +import techreborn.items.*; /** * Created by Mark on 03/04/2016. diff --git a/src/main/java/techreborn/items/DynamicCell.java b/src/main/java/techreborn/items/DynamicCell.java new file mode 100644 index 000000000..308fcbc59 --- /dev/null +++ b/src/main/java/techreborn/items/DynamicCell.java @@ -0,0 +1,94 @@ +package techreborn.items; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; +import net.minecraft.world.World; +import net.minecraftforge.event.entity.player.FillBucketEvent; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.UniversalBucket; +import techreborn.client.TechRebornCreativeTab; +import techreborn.init.ModItems; + +/** + * Created by modmuss50 on 17/05/2016. + */ +public class DynamicCell extends UniversalBucket{ + + public DynamicCell() { + super(1000, new ItemStack(ModItems.emptyCell), false); + setCreativeTab(TechRebornCreativeTab.instance); + setUnlocalizedName("techreborn.cellFilled"); + } + + @Override + public ActionResult onItemRightClick(ItemStack itemstack, World world, EntityPlayer player, EnumHand hand) { + return ActionResult.newResult(EnumActionResult.FAIL, itemstack); + } + + @Override + public void onFillBucket(FillBucketEvent event) { + return; + } + + @Override + public String getItemStackDisplayName(ItemStack stack) + { + FluidStack fluidStack = getFluid(stack); + if (fluidStack == null) + { + if(getEmpty() != null) + { + return getEmpty().getDisplayName(); + } + return super.getItemStackDisplayName(stack); + } + + return fluidStack.getLocalizedName() + " Cell"; + } + + @Override + public int fill(ItemStack container, FluidStack resource, boolean doFill) + { + // has to be exactly 1, must be handled from the caller + if (container.stackSize != 1) + { + return 0; + } + + // can only fill exact capacity + if (resource == null || resource.amount != getCapacity()) + { + return 0; + } + // fill the container + if (doFill) + { + NBTTagCompound tag = container.getTagCompound(); + if (tag == null) + { + tag = new NBTTagCompound(); + } + resource.writeToNBT(tag); + container.setTagCompound(tag); + } + return getCapacity(); + } + + public static ItemStack getCellWithFluid(Fluid fluid, int stackSize){ + ItemStack stack = new ItemStack(ModItems.dynamicCell, stackSize); + ModItems.dynamicCell.fill(stack, new FluidStack(fluid, ModItems.dynamicCell.getCapacity()), true); + return stack; + } + + public static ItemStack getCellWithFluid(Fluid fluid){ + ItemStack stack = new ItemStack(ModItems.dynamicCell); + ModItems.dynamicCell.fill(stack, new FluidStack(fluid, ModItems.dynamicCell.getCapacity()), true); + return stack; + } + +} diff --git a/src/main/java/techreborn/items/EmptyCell.java b/src/main/java/techreborn/items/EmptyCell.java new file mode 100644 index 000000000..1c320c6bc --- /dev/null +++ b/src/main/java/techreborn/items/EmptyCell.java @@ -0,0 +1,25 @@ +package techreborn.items; + +import techreborn.client.TechRebornCreativeTab; +import techreborn.lib.ModInfo; + +/** + * Created by modmuss50 on 17/05/2016. + */ +public class EmptyCell extends ItemTextureBase { + + public EmptyCell() + { + setUnlocalizedName("techreborn.cell"); + setCreativeTab(TechRebornCreativeTab.instance); + } + @Override + public String getTextureName(int damage) { + return ModInfo.MOD_ID + ":items/cell_base"; + } + + @Override + public int getMaxMeta() { + return 0; + } +} diff --git a/src/main/java/techreborn/items/ItemCells.java b/src/main/java/techreborn/items/ItemCells.java index db0233b57..4be0f0ce2 100644 --- a/src/main/java/techreborn/items/ItemCells.java +++ b/src/main/java/techreborn/items/ItemCells.java @@ -14,6 +14,7 @@ import techreborn.client.TechRebornCreativeTab; import techreborn.init.ModItems; import techreborn.lib.ModInfo; +@Deprecated public class ItemCells extends ItemTextureBase implements IFluidContainerItem { diff --git a/src/main/java/techreborn/proxies/ClientProxy.java b/src/main/java/techreborn/proxies/ClientProxy.java index 9c1168385..e72e08e4a 100644 --- a/src/main/java/techreborn/proxies/ClientProxy.java +++ b/src/main/java/techreborn/proxies/ClientProxy.java @@ -3,15 +3,20 @@ package techreborn.proxies; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; +import net.minecraft.client.renderer.block.model.ModelBakery; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.statemap.StateMap; import net.minecraft.client.renderer.block.statemap.StateMapperBase; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.resources.IResourceManager; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Util; +import net.minecraftforge.client.model.ICustomModelLoader; +import net.minecraftforge.client.model.IModel; +import net.minecraftforge.client.model.ModelDynBucket; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.registry.ClientRegistry; @@ -34,6 +39,7 @@ import techreborn.client.keybindings.KeyBindings; import techreborn.client.render.entitys.RenderNukePrimed; import techreborn.entitys.EntityNukePrimed; import techreborn.init.ModBlocks; +import techreborn.init.ModItems; import techreborn.init.ModSounds; import techreborn.lib.ModInfo; import techreborn.manual.loader.ManualLoader; @@ -46,6 +52,8 @@ public class ClientProxy extends CommonProxy public static MultiblockRenderEvent multiblockRenderEvent; + public static final ModelResourceLocation MODEL_DYNAMIC_CELL = new ModelResourceLocation(new ResourceLocation("techreborn", "dyncell"), "inventory"); + @Override public void preInit(FMLPreInitializationEvent event) { @@ -69,6 +77,16 @@ public class ClientProxy extends CommonProxy registerItemModel(Item.getItemFromBlock(base)); } } + + ModelLoader.setCustomMeshDefinition(ModItems.dynamicCell, new ItemMeshDefinition() + { + @Override + public ModelResourceLocation getModelLocation(ItemStack stack) + { + return MODEL_DYNAMIC_CELL; + } + }); + ModelBakery.registerItemVariants(ModItems.dynamicCell, MODEL_DYNAMIC_CELL); } @Override diff --git a/src/main/java/techreborn/utils/RecipeUtils.java b/src/main/java/techreborn/utils/RecipeUtils.java index 7116e2f71..3db8c49be 100644 --- a/src/main/java/techreborn/utils/RecipeUtils.java +++ b/src/main/java/techreborn/utils/RecipeUtils.java @@ -1,7 +1,7 @@ package techreborn.utils; import net.minecraft.item.ItemStack; -import techreborn.items.ItemCells; +import techreborn.init.ModItems; public class RecipeUtils { @@ -12,7 +12,7 @@ public class RecipeUtils // cell.stackSize = stackSize; // return cell; // } else { - return ItemCells.getCellByName("empty", stackSize); + return new ItemStack(ModItems.emptyCell); // } } } diff --git a/src/main/resources/assets/techreborn/blockstates/dyncell.json b/src/main/resources/assets/techreborn/blockstates/dyncell.json new file mode 100644 index 000000000..530221d06 --- /dev/null +++ b/src/main/resources/assets/techreborn/blockstates/dyncell.json @@ -0,0 +1,18 @@ +{ + "forge_marker": 1, + "variants": { + "inventory": { + "model": "forge:forgebucket", + "textures": { + "base": "techreborn:items/cell_base", + "fluid": "techreborn:items/cell_fluid", + "cover": "techreborn:items/cell_cover" + }, + "transform": "forge:default-item", + "custom": { + "fluid": "water", + "flipGas": true + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/techreborn/models/item/cell.json b/src/main/resources/assets/techreborn/models/item/cell.json new file mode 100644 index 000000000..4a8c26d79 --- /dev/null +++ b/src/main/resources/assets/techreborn/models/item/cell.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "forge:items/bucket_base" + } +} diff --git a/src/main/resources/assets/techreborn/textures/items/cell_base.png b/src/main/resources/assets/techreborn/textures/items/cell_base.png new file mode 100644 index 000000000..538b65c51 Binary files /dev/null and b/src/main/resources/assets/techreborn/textures/items/cell_base.png differ diff --git a/src/main/resources/assets/techreborn/textures/items/cell_cover.png b/src/main/resources/assets/techreborn/textures/items/cell_cover.png new file mode 100644 index 000000000..739f2d573 Binary files /dev/null and b/src/main/resources/assets/techreborn/textures/items/cell_cover.png differ diff --git a/src/main/resources/assets/techreborn/textures/items/cell_fluid.png b/src/main/resources/assets/techreborn/textures/items/cell_fluid.png new file mode 100644 index 000000000..6818cd013 Binary files /dev/null and b/src/main/resources/assets/techreborn/textures/items/cell_fluid.png differ