Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Cadiboo

Members
  • Posts

    3624
  • Joined

  • Last visited

  • Days Won

    58

Everything posted by Cadiboo

  1. Can you post ClientProxy CommonProxy ModItems ItemPaste RegistryHandler Paste.json Forge Log
  2. No, Registration has to be done on both client and server therefore it is in CommonProxy
  3. WHY WHY WHY NO NO NO should have seen this earlier This fails so many ways 1) apparently cant event turn ModItems.ITEMS into an array maybe because it has to be used like this ModItems.ITEMS.toArray() with nothing inside the () 2) No idea what it would try to do with (new Item[0]), but it would fail absolutely horribly and fatally. Do you know java or any other Object Oriented language? if so you will know that toArray(new Item[0]) is completely non-sensical and guaranteed to crash everything event.getRegistry().registerAll(ModItems.ITEMS);
  4. Please keep in mind that all of this is how I do it, It might not be the best way, but it looks clean and I can't find any problems with it. For me, my common proxy is a mix of RegistryHandler and Common Proxy, and my Client Proxy is pretty much only used for registering models and renders etc
  5. @Mod.EventBusSubscriber public class COMMON_PROXY_OR_SIMILAR { @SubscribeEvent public static void registerItems(RegistryEvent.Register<Item> event) { event.getRegistry().registerAll(Items.ITEMS); } }
  6. Remove this from RegistryHandleer
  7. package com.mta.utzonmod.item; public class ItemPaste extends ItemBase { public ItemPaste(String name) { super(name); } } package com.mta.utzonmod.item;
  8. I'm not sure if its actually that bad, but I know that it leads to less clean code and lots of copy/pasted & repetitive code
  9. ItemBase.java package com.mta.utzonmod.item; import com.mta.utzonmod.Reference; import net.minecraft.item.Item; public class ItemBase extends Item { public ItemBase(String name) { super(); this.setRegistryName(Reference.ID, name); this.setUnlocalizedName(name); } } ItemPaste.java package com.mta.utzonmod.item; public class ItemPaste extends ItemBase { public ItemPaste(String name) { super(name); } } ModItems.java package com.mta.utzonmod.init; import com.mta.utzonmod.item.ItemPaste; import net.minecraft.item.Item; public class ModItems { public static final ItemPaste PASTE = new ItemPaste("paste"); public static final Item[] ITEMS = { PASTE, }; } Client Registry Class (Client Proxy or similar) @Mod.EventBusSubscriber public class CLIENT_PROXY_CLASS extends COMMON_PROXY_CLASS_OR_SIMILAR { @SubscribeEvent public static void registerModels(ModelRegistryEvent event) { for (Item item: Items.ITEMS) { if(!item.getHasSubtypes()) { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); } else { //do stuff } } } }
  10. Not sure, I didn't make Tinkers Construct
  11. Oh no, they register stuff inside the item class...
  12. Just remembered that Tinkers Construct has debug commands, Have a look at how they do it https://github.com/SlimeKnights/TinkersConstruct/blob/e433db03b3a364fdcf4b68241cfdafd50606b2cb/src/main/java/slimeknights/tconstruct/debug/ListValidModifiers.java
  13. I Don't really know how to help, try having a look at this
  14. Advanced Tile Entities (stuff like modded furnaces etc) use forges Capability system which would be helpful for you to know, but not necessary. TileEntities are synced between the Server and Client using Network event, You should learn how these work as they are similar to what you are trying to use
  15. This is how I do it @SubscribeEvent public static void registerModels(ModelRegistryEvent event) { for (Block block: Blocks.BLOCKS) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory")); } for (Item item: Items.ITEMS) { if(!item.getHasSubtypes()) { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); } else { //register items with subtypes } } } Blocks is a Block[] with all my blocks in it and Items is an Item[] with all my items in it
  16. and this does... what? please post that code
  17. Have you done Tile Entities with Capabilities and Network Handlers?
  18. If that doesn't fix the problem, please post In-game screenshots, the contents of paste.json and your item registration and model registration code
  19. You should probably start off small - learning how to create an item, then a block, then textures, then recipes, then tile entities and capabilities and then network events. If you follow that process you will know enough to do what your trying to do. Have you looked up how other mods add commands? Their code would probably be very similar to any code that your trying to create
  20. 1) textures/items/schematic_sign.png.png has two file endings, is this intended? 2) You shouldn't add file endings to your json files (don't know if your doing this, the forge log could just be being specific) 3)are you prefixing your texture locations with <MODID>:<PATH> for example my mod's id is wiptech { "parent": "item/generated", "textures": { "layer0": "wiptech:items/copper_ingot" }, "display": { "thirdperson": { "rotation": [-90,0,0], "translation": [0,1,-3], "scale": [0.55,0.55,0.55] }, "firstperson": { "rotation": [0,-135,25], "translation": [0,4,2], "scale": [1.7,1.7,1.7] } } }
  21. Have a look at net.minecraft.server.management.PlayerInteractionManager
  22. Title says it all basically, probably some small thing that I've failed to do Slot 1 renders slot 9's itemstack ContainerCoiler.java package cadiboo.wiptech.block.coiler; import javax.annotation.Nonnull; import cadiboo.wiptech.WIPTech; import cadiboo.wiptech.init.Items; import cadiboo.wiptech.init.Recipes; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.SlotItemHandler; public class ContainerCoiler extends Container { public ContainerCoiler(InventoryPlayer playerInv, final TileEntityCoiler coiler) { IItemHandler inventory = coiler.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH); for(int i=0; i<10; i++) { if ( (i & 1) == 0 ) // even - Input slot { addSlotToContainer(new SlotItemHandler(inventory, i, 19 + 30*i/2, 17) { @Override public void onSlotChanged() { coiler.markDirty(); } }); } else { addSlotToContainer(new SlotItemHandler(inventory, i, 19 + 30*((i-1)/2), 53) { /*@Override public void onSlotChanged() { coiler.markDirty(); } @Override public boolean isItemValid(@Nonnull ItemStack stack){ return Recipes.getCoilResult(stack)!=null && Recipes.getCoilResult(stack).size()>0; }*/ }); } } for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int k = 0; k < 9; k++) { addSlotToContainer(new Slot(playerInv, k, 8 + k * 18, 142)); } } @Override public boolean canInteractWith(EntityPlayer player) { return true; } @Override public ItemStack transferStackInSlot(EntityPlayer player, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); int containerSlots = inventorySlots.size() - player.inventory.mainInventory.size(); if (index < containerSlots) { if (!this.mergeItemStack(itemstack1, containerSlots, inventorySlots.size(), true)) { return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 0, containerSlots, false)) { return ItemStack.EMPTY; } if (itemstack1.getCount() == 0) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } slot.onTake(player, itemstack1); } return itemstack; } } BlockCoiler.java package cadiboo.wiptech.block.coiler; import java.util.List; import java.util.Random; import javax.annotation.Nullable; import cadiboo.wiptech.ModGuiHandler; import cadiboo.wiptech.WIPTech; import cadiboo.wiptech.block.BlockTileEntity; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; public class BlockCoiler extends BlockTileEntity<TileEntityCoiler>{ public BlockCoiler (String name, Material material) { super(name, material); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); this.setTileEntity(); this.setNonSolidBlock(); } @Override public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) { tooltip.add("\u00A76\u00A7o"+"Takes Spools and winds them into high performance coils."); } public static final PropertyDirection FACING = BlockHorizontal.FACING; @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { if (TileEntityCoiler.isWinding(this.getTileEntity(worldIn, pos))) { EnumFacing enumfacing = (EnumFacing)stateIn.getValue(FACING); double x = (double)pos.getX() + 0.5D; double y = (double)pos.getY() + 0.5D; double z = (double)pos.getZ() + 0.5D; double d4 = rand.nextDouble() * 0.6D - 0.3D; if (rand.nextDouble() < 0.1D) { worldIn.playSound((double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, SoundEvents.BLOCK_PISTON_EXTEND, SoundCategory.BLOCKS, 1.0F, 1.0F, false); } worldIn.spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, x + d4, y+0.4+(d4/10), y + d4, 0.0D, 0.0D, 0.0D); } } private double randomBetween(int min, int max) { return new Random().nextInt((int) ((max - min)+1) )+min; } @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { TileEntityCoiler tile = getTileEntity(world, pos); IItemHandler itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side); WIPTech.logger.info("player.isSneaking(): "+player.isSneaking()); if (!player.isSneaking()) { player.openGui(WIPTech.instance, ModGuiHandler.COILER, world, pos.getX(), pos.getY(), pos.getZ()); } } return true; } public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { this.setDefaultFacing(worldIn, pos, state); } private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState iblockstate = worldIn.getBlockState(pos.north()); IBlockState iblockstate1 = worldIn.getBlockState(pos.south()); IBlockState iblockstate2 = worldIn.getBlockState(pos.west()); IBlockState iblockstate3 = worldIn.getBlockState(pos.east()); EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock()) { enumfacing = EnumFacing.SOUTH; } else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock()) { enumfacing = EnumFacing.NORTH; } else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock()) { enumfacing = EnumFacing.EAST; } else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock()) { enumfacing = EnumFacing.WEST; } worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2); } } public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2); } public IBlockState getStateFromMeta(int meta) { EnumFacing enumfacing = EnumFacing.getFront(meta); if (enumfacing.getAxis() == EnumFacing.Axis.Y) { enumfacing = EnumFacing.NORTH; } return this.getDefaultState().withProperty(FACING, enumfacing); } /** * Convert the BlockState into the correct metadata value */ public int getMetaFromState(IBlockState state) { return ((EnumFacing)state.getValue(FACING)).getIndex(); } /** * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed * blockstate. */ public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); } /** * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed * blockstate. */ public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); } protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {FACING}); } @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntityCoiler tile = getTileEntity(world, pos); IItemHandler itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH); for(int i = 0; i<2; i++) { ItemStack stack = itemHandler.getStackInSlot(i); if (!stack.isEmpty()) { EntityItem item = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), stack); world.spawnEntity(item); } } super.breakBlock(world, pos, state); } @Nullable @Override public TileEntityCoiler createTileEntity(World world, IBlockState state) { return new TileEntityCoiler(); } } TileEntityCoiler.java package cadiboo.wiptech.block.coiler; import java.util.ArrayList; import javax.annotation.Nullable; import cadiboo.wiptech.WIPTech; import cadiboo.wiptech.block.coiler.TileEntityCoiler; import cadiboo.wiptech.init.Items; import cadiboo.wiptech.init.Recipes; import cadiboo.wiptech.network.PacketRequestUpdateCoiler; import cadiboo.wiptech.network.PacketUpdateCoiler; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; public class TileEntityCoiler extends TileEntity implements ITickable { public float WindTime; //private int activeSlot = -1; public long lastChangeTime; public ItemStackHandler inventory = new ItemStackHandler(10) { @Override protected void onContentsChanged(int slot) { if (!world.isRemote) { lastChangeTime = world.getTotalWorldTime(); WIPTech.network.sendToAllAround(new PacketUpdateCoiler(TileEntityCoiler.this), new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 64)); } }; }; @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound.setTag("inventory", inventory.serializeNBT()); compound.setLong("lastChangeTime", lastChangeTime); compound.setFloat("WindTime", WindTime); return super.writeToNBT(compound); } @Override public void readFromNBT(NBTTagCompound compound) { inventory.deserializeNBT(compound.getCompoundTag("inventory")); lastChangeTime = compound.getLong("lastChangeTime"); WindTime = compound.getFloat("WindTime"); super.readFromNBT(compound); } @Override public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); } @Nullable @Override public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? (T)inventory : super.getCapability(capability, facing); } @Override public void onLoad() { if (world.isRemote) { WIPTech.network.sendToServer(new PacketRequestUpdateCoiler(this)); } } @Override public AxisAlignedBB getRenderBoundingBox() { return new AxisAlignedBB(getPos(), getPos().add(1, 1, 1)); } @Override public void update() { if(world.getBlockState(pos).getBlock() != this.getBlockType()) return; if(WindTime > 0) { --WindTime; if(!canCoil()) { WindTime = 0; } else if (WindTime <= 0) { WindItem(); } } else { if(canCoil()) { this.setWindTime((int) Recipes.getCoilResult(inventory.getStackInSlot(1)).get(7) * 1.0F); } else { WindTime = 0; } } } private void WindItem() { if(inventory.getStackInSlot(0) != null && !inventory.getStackInSlot(1).isEmpty()){ /*ItemStack stack = inventory.getStackInSlot(0); ArrayList resultList = (ArrayList) Recipes.getCoilResult(inventory.getStackInSlot(1)); if(resultList !=null) { inventory.insertItem(2, ((ItemStack) resultList.get(1)).copy(), false); inventory.insertItem(3, ((ItemStack) resultList.get(2)).copy(), false); inventory.insertItem(4, ((ItemStack) resultList.get(3)).copy(), false); inventory.insertItem(5, ((ItemStack) resultList.get(4)).copy(), false); inventory.insertItem(6, ((ItemStack) resultList.get(5)).copy(), false); inventory.insertItem(7, ((ItemStack) resultList.get(6)).copy(), false); inventory.extractItem(1, 1, false); } else { WIPTech.logger.info("ERROR resultList =null so could NOT Coil ITEM"); } return;*/ } else { WIPTech.logger.info("ERROR COULD NOT Coil ITEM"); WindTime = 0; return; } } private boolean canCoil() { if(inventory.getStackInSlot(0) != null && !inventory.getStackInSlot(0).isEmpty()) { /*ItemStack stack = inventory.getStackInSlot(0); ArrayList resultsList = (ArrayList) Recipes.getCoilResult(inventory.getStackInSlot(1)); boolean recipeExists = resultsList!=null; if(recipeExists) { boolean slot0 = !inventory.getStackInSlot(0).isEmpty(); boolean slot1 = !inventory.getStackInSlot(1).isEmpty(); boolean slot2 = inventory.getStackInSlot(2).getCount() < inventory.getStackInSlot(2).getMaxStackSize(); boolean slot3 = inventory.getStackInSlot(3).getCount() < inventory.getStackInSlot(3).getMaxStackSize(); boolean slot4 = inventory.getStackInSlot(4).getCount() < inventory.getStackInSlot(4).getMaxStackSize(); boolean slot5 = inventory.getStackInSlot(5).getCount() < inventory.getStackInSlot(5).getMaxStackSize(); boolean slot6 = inventory.getStackInSlot(6).getCount() < inventory.getStackInSlot(6).getMaxStackSize(); boolean slot7 = inventory.getStackInSlot(7).getCount() < inventory.getStackInSlot(7).getMaxStackSize(); if(slot0 && slot1 && slot2 && slot3 && slot4 && slot5 && slot6 && slot7) { recipeExists = recipeExists && resultsList.size()>0; if(recipeExists) { recipeExists = recipeExists && resultsList.get(0)!=null; if(recipeExists) { slot2 = slot2&& (ItemStack) resultsList.get(1)!=null; slot3 = slot3&& (ItemStack) resultsList.get(2)!=null; slot4 = slot4&& (ItemStack) resultsList.get(3)!=null; slot5 = slot5&& (ItemStack) resultsList.get(4)!=null; slot6 = slot6&& (ItemStack) resultsList.get(5)!=null; slot7 = slot7&& (ItemStack) resultsList.get(6)!=null; if(slot0 && slot1 && slot2 && slot3 && slot4 && slot5 && slot6 && slot7) { slot2 = slot2&& inventory.insertItem(2, ((ItemStack) resultsList.get(1)).copy(), true).isEmpty(); slot3 = slot3&& inventory.insertItem(3, ((ItemStack) resultsList.get(2)).copy(), true).isEmpty(); slot4 = slot4&& inventory.insertItem(4, ((ItemStack) resultsList.get(3)).copy(), true).isEmpty(); slot5 = slot5&& inventory.insertItem(5, ((ItemStack) resultsList.get(4)).copy(), true).isEmpty(); slot6 = slot6&& inventory.insertItem(6, ((ItemStack) resultsList.get(5)).copy(), true).isEmpty(); slot7 = slot7&& inventory.insertItem(7, ((ItemStack) resultsList.get(6)).copy(), true).isEmpty(); if(slot0 && slot1 && slot2 && slot3 && slot4 && slot5 && slot6 && slot7) { return true; } } } } } }*/ } return false; } public static boolean isWinding(TileEntityCoiler tileEntity) { //return ((BlockCoiler) tileEntity.getWorld().getBlockState(tileEntity.getPos()).getBlock()).isCoiling(); return tileEntity.isWinding(); } private boolean isWinding() { return WindTime > 0; } public static float getCoilTime(TileEntityCoiler tileEntity) { //return (tileEntity.getWorld().getBlockState(tileEntity.getPos()).getBlock()); return tileEntity.getWindTime(); } private float getWindTime() { return WindTime; } public void setWindTime(TileEntityCoiler tileEntity, float time) { tileEntity.setWindTime(time); } private void setWindTime(float time) { WindTime = time; } public static int getTotalWindTime(TileEntityCoiler tileEntity) { return tileEntity.getTotalWindTime(); } private int getTotalWindTime() { return (int) (!inventory.getStackInSlot(1).isEmpty()?Recipes.getCoilResult(inventory.getStackInSlot(1)).get(7):0); } public static int getPercentageOfWindTimeComplete(TileEntityCoiler tileEntity) { return tileEntity.getPercentageOfWindTimeComplete(); } private int getPercentageOfWindTimeComplete() { return (int) Math.round(getFractionOfWindTimeComplete()*100); } public static double getFractionOfWindTimeComplete(TileEntityCoiler tileEntity) { return tileEntity.getFractionOfWindTimeComplete(); } private double getFractionOfWindTimeComplete() { if(getWindTime()>0) return (getTotalWindTime() - getWindTime())/getTotalWindTime(); else return 0; } public static int getPercentageOfWindTimeRemaining(TileEntityCoiler tileEntity) { return tileEntity.getPercentageOfWindTimeRemaining(); } private int getPercentageOfWindTimeRemaining() { return (int) Math.round(getFractionOfWindTimeRemaining()*100); } public static double getFractionOfWindTimeRemaining(TileEntityCoiler tileEntity) { return tileEntity.getFractionOfWindTimeRemaining(); } private double getFractionOfWindTimeRemaining() { //Utils.getLogger().info("getFractionOfWindTimeRemaining: "+getWindTime() / getTotalWindTime()); if(getWindTime()>0) return getWindTime() / getTotalWindTime(); else return getTotalWindTime(); } }
  23. One thing that I can see that is important is the transferStackInSlot function you say its crashing the game? Here is my implementation of it (for a Tile entity, it might not work for an item) @Override public ItemStack transferStackInSlot(EntityPlayer player, int index) { /* ITS POSSIBLE to have multi-line comments */ //WIPTech.logger.info("transferStackInSlot: "+ inventorySlots.get(index).getStack()); ItemStack itemstack = ItemStack.EMPTY; Slot slot = inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); int containerSlots = inventorySlots.size() - player.inventory.mainInventory.size(); if (index < containerSlots) { if (!this.mergeItemStack(itemstack1, containerSlots, inventorySlots.size(), true)) { return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 0, containerSlots, false)) { return ItemStack.EMPTY; } if (itemstack1.getCount() == 0) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } slot.onTake(player, itemstack1); } return itemstack; }
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.