Jump to content

Cadiboo

Members
  • Posts

    3624
  • Joined

  • Last visited

  • Days Won

    58

Posts posted by Cadiboo

  1. 5 minutes ago, Stenbergcsgo said:

    @SubscribeEvent public static void onModelRegister(ModelRegistryEvent event) { for(Item item : ModItems.ITEMS) { if(item instanceof IHasModel) { ((IHasModel)item).registerModels(); } } }

    Remove this from RegistryHandleer

  2. 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
          }
        }
      }
    }

     

  3. 1 minute ago, #ÖCT said:

    For the Tile-Entities I used a tutorial and change the block for my things, further i haven`t got any idea how does it exactly works... :(

     

    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

  4. 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

     

  5. 2 minutes ago, #ÖCT said:

    I'm very new in Forge modding. The Basics i can do, but I think that what i wanna to too complicated for me...

     

    But I try to figure that out, i wanna to learn programming...

    I'm only 13 years old, sorry that I annoy you, but I wanna to figure that out!!!

     

    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

  6. 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]
            }
        }
    }

     

  7. Title says it all basically, probably some small thing that I've failed to do

    Slot 1 renders slot 9's itemstack

    5aa6656db9c5e_ScreenShot2018-03-12at10_27_20pm.png.0bd741bded03f1f567fe695350dfb48f.png5aa6646a40ef0_ScreenShot2018-03-12at10_27_12pm.png.53d7724a16bf595a905e4cbfab5ac86b.png5aa66468e6d20_ScreenShot2018-03-12at10_27_20pm.png.d0b975e96bcf86284704b2a90906e950.png5aa6646b1027b_ScreenShot2018-03-12at10_27_08pm.png.cf85ec4ffef5c3384ed1c1ca70d95739.png

     

    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();
    	}
    
    }

     

  8. 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;
    	}

     

  9. go to \%AppData% not \AppData

    AppData is a hidden system directory that is used to store program data files.

     

    You can get to your Mods folder by opening minecraft and using to to open your Resource Packs folder, then going up a folder. In that folder there should be an empty folder named Mods. Create a desktop shortcut to it, whatever you like - your mods go here

  10. To anyone with the same problem, I fixed it by creating an entirely new mod. I made every file through eclipse's New Class option, didn't copy/paste any old files and then pasted in the code from my old mod. I think that this issue may have been caused by some issue with the encoding of the file or invisible info text at the start of the file.

    Something interesting is that the file that works is 3bytes smaller that the file that doesn't. However the contents of the 2 lang files are exactly the same. The Icon of the non-working file is an executable whereas the Icon of the working file is a blank page. The type of the non-working file is "text" and the type of the working file is "TextEdit".

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.