Added Universal Cell

This commit is contained in:
modmuss50 2016-05-17 21:12:33 +01:00
parent 9035f2a21c
commit e38c800f21
13 changed files with 179 additions and 24 deletions

View file

@ -28,18 +28,11 @@ import techreborn.api.Reference;
public class ModItems public class ModItems
{ {
// This are deprected to stop people using them in the recipes.
@Deprecated
public static Item gems; public static Item gems;
@Deprecated
public static Item ingots; public static Item ingots;
@Deprecated
public static Item nuggets; public static Item nuggets;
@Deprecated
public static Item dusts; public static Item dusts;
@Deprecated
public static Item smallDusts; public static Item smallDusts;
@Deprecated
public static Item parts; public static Item parts;
@Deprecated @Deprecated
public static Item cells; public static Item cells;
@ -52,8 +45,6 @@ public class ModItems
public static Item manual; public static Item manual;
public static Item uuMatter; public static Item uuMatter;
public static Item plate; public static Item plate;
public static Item crushedOre;
public static Item purifiedCrushedOre;
public static Item cloakingDevice; public static Item cloakingDevice;
public static Item reBattery; public static Item reBattery;
@ -124,6 +115,9 @@ public class ModItems
public static Item missingRecipe; public static Item missingRecipe;
public static Item debug; public static Item debug;
public static Item emptyCell;
public static DynamicCell dynamicCell;
public static void init() throws InstantiationException, IllegalAccessException public static void init() throws InstantiationException, IllegalAccessException
{ {
gems = new ItemGems(); gems = new ItemGems();
@ -312,6 +306,12 @@ public class ModItems
debug = new ItemDebugTool(); debug = new ItemDebugTool();
GameRegistry.registerItem(debug, "debug"); GameRegistry.registerItem(debug, "debug");
emptyCell = new EmptyCell();
GameRegistry.registerItem(emptyCell, "emptyCell");
dynamicCell = new DynamicCell();
GameRegistry.registerItem(dynamicCell, "dynamicCell");
MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE); MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE);
Core.logHelper.info("TechReborns Items Loaded"); Core.logHelper.info("TechReborns Items Loaded");

View file

@ -3,6 +3,7 @@ package techreborn.init;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidRegistry;
import techreborn.api.recipe.IRecipeCompact; import techreborn.api.recipe.IRecipeCompact;
import techreborn.blocks.BlockMachineFrame; import techreborn.blocks.BlockMachineFrame;
import techreborn.items.*; import techreborn.items.*;
@ -36,8 +37,8 @@ public class RecipeCompact implements IRecipeCompact
recipes.put("iridiumOre", ItemIngots.getIngotByName("iridium")); recipes.put("iridiumOre", ItemIngots.getIngotByName("iridium"));
recipes.put("plateiron", ItemPlates.getPlateByName("iron")); recipes.put("plateiron", ItemPlates.getPlateByName("iron"));
recipes.put("iridiumPlate", ItemPlates.getPlateByName("iridium")); recipes.put("iridiumPlate", ItemPlates.getPlateByName("iridium"));
recipes.put("cell", ItemCells.getCellByName("empty")); recipes.put("cell", new ItemStack(ModItems.emptyCell));
recipes.put("airCell", ItemCells.getCellByName("empty")); recipes.put("airCell", new ItemStack(ModItems.emptyCell));
recipes.put("electronicCircuit", ItemParts.getPartByName("electronicCircuit")); recipes.put("electronicCircuit", ItemParts.getPartByName("electronicCircuit"));
recipes.put("advancedCircuit", ItemParts.getPartByName("advancedCircuit")); recipes.put("advancedCircuit", ItemParts.getPartByName("advancedCircuit"));
recipes.put("rubberWood", new ItemStack(ModBlocks.rubberLog)); 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("diamondDrill", new ItemStack(ModItems.diamondDrill));
recipes.put("miningDrill", new ItemStack(ModItems.ironDrill)); recipes.put("miningDrill", new ItemStack(ModItems.ironDrill));
recipes.put("solarPanel", new ItemStack(ModBlocks.solarPanel)); recipes.put("solarPanel", new ItemStack(ModBlocks.solarPanel));
recipes.put("waterCell", ItemCells.getCellByName("water")); recipes.put("waterCell", DynamicCell.getCellWithFluid(FluidRegistry.WATER));
recipes.put("lavaCell", ItemCells.getCellByName("lava")); recipes.put("lavaCell", DynamicCell.getCellWithFluid(FluidRegistry.LAVA));
recipes.put("pump", new ItemStack(ModBlocks.pump)); recipes.put("pump", new ItemStack(ModBlocks.pump));
// recipes.put("teleporter", new ItemStack(ModItems.missingRecipe)); // recipes.put("teleporter", new ItemStack(ModItems.missingRecipe));
recipes.put("advancedAlloy", ItemIngots.getIngotByName("advancedAlloy")); recipes.put("advancedAlloy", ItemIngots.getIngotByName("advancedAlloy"));

View file

@ -4,15 +4,7 @@ import net.minecraft.item.ItemStack;
import techreborn.api.ISubItemRetriever; import techreborn.api.ISubItemRetriever;
import techreborn.blocks.BlockOre; import techreborn.blocks.BlockOre;
import techreborn.blocks.BlockStorage; import techreborn.blocks.BlockStorage;
import techreborn.items.ItemCells; import techreborn.items.*;
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;
/** /**
* Created by Mark on 03/04/2016. * Created by Mark on 03/04/2016.

View file

@ -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<ItemStack> 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;
}
}

View file

@ -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;
}
}

View file

@ -14,6 +14,7 @@ import techreborn.client.TechRebornCreativeTab;
import techreborn.init.ModItems; import techreborn.init.ModItems;
import techreborn.lib.ModInfo; import techreborn.lib.ModInfo;
@Deprecated
public class ItemCells extends ItemTextureBase implements IFluidContainerItem public class ItemCells extends ItemTextureBase implements IFluidContainerItem
{ {

View file

@ -3,15 +3,20 @@ package techreborn.proxies;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.ItemMeshDefinition; 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.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.StateMap; import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.client.renderer.block.statemap.StateMapperBase; import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util; 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.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.ClientRegistry;
@ -34,6 +39,7 @@ import techreborn.client.keybindings.KeyBindings;
import techreborn.client.render.entitys.RenderNukePrimed; import techreborn.client.render.entitys.RenderNukePrimed;
import techreborn.entitys.EntityNukePrimed; import techreborn.entitys.EntityNukePrimed;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.init.ModItems;
import techreborn.init.ModSounds; import techreborn.init.ModSounds;
import techreborn.lib.ModInfo; import techreborn.lib.ModInfo;
import techreborn.manual.loader.ManualLoader; import techreborn.manual.loader.ManualLoader;
@ -46,6 +52,8 @@ public class ClientProxy extends CommonProxy
public static MultiblockRenderEvent multiblockRenderEvent; public static MultiblockRenderEvent multiblockRenderEvent;
public static final ModelResourceLocation MODEL_DYNAMIC_CELL = new ModelResourceLocation(new ResourceLocation("techreborn", "dyncell"), "inventory");
@Override @Override
public void preInit(FMLPreInitializationEvent event) public void preInit(FMLPreInitializationEvent event)
{ {
@ -69,6 +77,16 @@ public class ClientProxy extends CommonProxy
registerItemModel(Item.getItemFromBlock(base)); 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 @Override

View file

@ -1,7 +1,7 @@
package techreborn.utils; package techreborn.utils;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import techreborn.items.ItemCells; import techreborn.init.ModItems;
public class RecipeUtils public class RecipeUtils
{ {
@ -12,7 +12,7 @@ public class RecipeUtils
// cell.stackSize = stackSize; // cell.stackSize = stackSize;
// return cell; // return cell;
// } else { // } else {
return ItemCells.getCellByName("empty", stackSize); return new ItemStack(ModItems.emptyCell);
// } // }
} }
} }

View file

@ -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
}
}
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "forge:items/bucket_base"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB