Jump to content

Will11690

Forge Modder
  • Posts

    44
  • Joined

  • Last visited

Posts posted by Will11690

  1. If donation/download revenue won't cut it I may also be willing to make arrangements to pay for at least an assistant that can deal with Networking(Pipe Logic & Packets), and ANYTHING rendering related that is not adding basic block models(Anything to do with OpenGL, especially in minecraft, makes my head spin and I just can't wrap my mind around it). We can discuss amounts through messages if it comes to this.

  2. I'm looking for someone who for the most part would be taking over my mods main development. With work I just can't give it the time it deserves but I think it will be a good mod to fill the void of BuildCraft while still having its own unique twist. It is currently still only on 1.16.5 only because I just haven't had the time to try and get an update plus there were features I was working on that I had wanted to hammer out first. Not to mention I'm just not very good at Java or Programming in general. I can get things done and they mostly work but I am just not skilled enough to keep my brain child alive and honestly optimized.

    My only real requirement is that if I choose to come back I want to be able to jump back in and do so(Not take over per say just add to it again from time to time). I have a basic outline of how I want things to work in general for the things not added yet that were planned features and I also have some started but not yet finished ideas in. I'm currently working on getting a repo up on github that has my most current code so that way its easier for everyone involved to contribute. I'm sure the best first step would be to update to the newest version of forge first before doing this to give the next person a good head start but I'm sure alot of my stuff needs rewritten anyways so I figured I'd do this now as it sits.

     Any other questions or details can be worked out through messages but if you are interested please drop a reply.

    Here is the link to the curseforge page which you can use to get to the github repo: https://www.curseforge.com/minecraft/mc-mods/mechanicraft

    For anyone who is interested please leave a reply. You will be added to the curseforge as a member and since I will be contributing less 80% of anything that is earned/donated because of this mod will be kicked your way(Can be controlled through curseforge, they have a way to split the earning).

     

    At the present time I am continuing to work on this but for the sake of making things easy for if/when the transition does happen I am sticking to 1.16.5 development for now.

  3. 18 hours ago, diesieben07 said:

    The thing that matters is Heightmap.Types.MOTION_BLOCKING. This determines the point at which rain "hits the ground". This means that the Material for your Block needs to have blocksMotion return false. Unfortunately setting this to false will probably have a bunch of other side effects.

    Yeah, after looking into that and playing around with it(basically that'll make the block act like a plant and things like that which without making a big, ugly, messy hack determining what things its solid for) I came up with another solution that may also work to fix my lag issue. Right now my block has 12 possible block states with 6 of them having kinda complex voxel shapes(they are pipes and draw different connections based on the block they are next to) so I am thinking that I should move a bit of functionality to a block that most likely wont have 1000 of them at any point in one chunk. Doing that I can reduce my blockstates to 6 and remove the complex voxel shapes. If that doesn't clear it up then I will stick with my current "Hack" and just live with the slight weirdness that comes with it. I did discover what causes the weirdness in mob behavior though, since the blocks are basically only solid when a Entity makes contact with them the AI doesn't see them as valid paths so they just stick to where they are.

    It's sad how poorly this game holds modders in mind when they say they fully support them lol. Like the whole locking fluid physics behind the water and lava tags and making fields related to it hard to work with, it irritates me to no end. 

  4. Welp after a short break I came up with this

    @Override
        public VoxelShape getCollisionShape(BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext ctxSupplier) {
        	
        	if(ctxSupplier.getEntity() instanceof LivingEntity || ctxSupplier.getEntity() instanceof FallingBlockEntity) {
        		
    			return this.getShape(state, reader, pos, ctxSupplier);
    		}
    		return VoxelShapes.empty();
    	}

    That kills rain interacting with any of the voxel shapes I'm drawing and removes the lag almost completely. It ain't perfect but it works good enough. There still some weirdness with the AI of mobs when they walk on it(Don't move/spin around) and using a spawn egg on top of it causes the mob to spawn inside the block. I'd love some advice to fix if its even possible.

  5. So I'm banging my head on a wall here. I've been trying to find how minecraft handles rain and the way it interacts with blocks but I'm not having any luck. I'm overriding getCollisionShape and I want to set it to empty for rain because it causes loads of lag(I go from 200+ fps to 1) with my custom model and its not a full block anyway so I wouldn't want it to stop rain from passing through anyways.

     

    Also setting the block to not have collision does indeed fix the problem but then entities like players, falling blocks, and mobs would just pass through which is also not what I want.

  6. 20 hours ago, warjort said:

    its to tell minecraft its not a simple full block - RenderType.solid() which is the default.

    It goes in your FMLClientSetupEvent.

    You don't need the enqueueWork for this, the setRenderLayer() is threadsafe.

    Thanks for the giving the explanation, I was just about to go to bed when I posted that so it was a quick and dirty copy paste just to help them out. Good tip about the setRenderLayer being thread safe. IDK why I've been doing it this way lol.

  7. On 5/15/2022 at 4:02 AM, diesieben07 said:

    Incorrect.

    You need two item handlers, one for the GUI interaction and one for automation. Automation will use getCapability on your class. Your GUI can use a normal getter on your class to get the handler for the GUI. 

    So something like this is what you meant right? I tested it and this setup works I just wanna make sure I did it correctly

    New Tile: https://pastebin.com/XHduUJcA

    InputStackHandler: https://pastebin.com/JKZiSska

  8. So I've been playing with this for a bit now but I end up getting stuck. Whenever I put a hopper or item pipe on my furnace it'll pull items from the input slot. I was wondering if I could get some recommendations on how to go about this.

    What I've tried so far is creating a custom ItemHandler class and overriding extractItem but when I do that then the player can't pull the items out which isn't ideal and I was trying to find a way to check if it was a player pulling the item out and allowing that but I can't figure out how to check for that which lead me here. I was about to create a sided inventory handler instead and just tie specific slots to specific sides but I decided against that as I'm not a big fan of specific sidedness to blocks.

    Also I know there are some hacky bits in my code that I am in need of cleaning up and doing better but I'm open for any criticism as I'm still learning, I've gotten better but learning Java almost solely on my own with a book is rough lol.

    Here is my Tile class: https://pastebin.com/nnFw8pwX

  9. As the title states, I've added these lines to my build.gradle but I dont think I have the right repository/file names. Sorry if this is an over asked or stupid question but no amount of google searches are assisting me lol.

     

    maven {
    
    	name = "Covers (COFH)"
    	url = "https://maven.covers1624.net/"
        
    }
    
    dependencies {
    
    compileOnly fg.deobf("cofh:cofhcore-1.16.5:1.3.1:deobf")
    runtimeOnly fg.deobf("cofh:cofhcore-1.16.5:1.3.1")
    
    compileOnly fg.deobf("cofh:thermal_cultivation-1.16.5:1.3.0:deobf")
    runtimeOnly fg.deobf("cofh:thermal_cultivation-1.16.5:1.3.0")
    
    compileOnly fg.deobf("cofh:thermal_expansion-1.16.5:1.3.1:deobf")
    runtimeOnly fg.deobf("cofh:thermal_expansion-1.16.5:1.3.0")
    
    compileOnly fg.deobf("cofh:thermal_foundation-1.16.5:1.3.2:deobf")
    runtimeOnly fg.deobf("cofh:thermal_foundation-1.16.5:1.3.2")
    
    compileOnly fg.deobf("cofh:thermal_innovation-1.16.5:1.3.0:deobf")
    runtimeOnly fg.deobf("cofh:thermal_innovation-1.16.5:1.3.0")
    
    compileOnly fg.deobf("cofh:thermal_locomotion-1.16.5:1.3.0:deobf")
    runtimeOnly fg.deobf("cofh:thermal_locomotion-1.16.5:1.3.0")
    
    }

     

  10. On 9/10/2018 at 5:37 PM, Animefan8888 said:

    This line in your update method is causing the problem cookTime is never able to be incremented. 

    You can combine this method and consuming fuel so you only need to call it once.

    There is no point in having this method in your Block class write the code in your TileEntity.

    You also need to override shouldRefresh and return true if the blocks are different, not the blockstates.

     

    As well as my aforementioned changes.

    Im not saying fix it for me but could you give me a couple examples? I've tried a few things with adding shouldRefresh and I can't seem to get it working. Also I have tooled around with the broken cook time section and I can get it "SEMI" working by changing this:

     

    if(this.isBurning() && this.canSmelt() && cookTime > 0)
            {
                cookTime++;
                if(cookTime == totalCookTime)
                {
                    if(handler.getStackInSlot(3).getCount() > 0)
                    {

                        handler.getStackInSlot(3).grow(1);
                    }
                    else
                    {
                        handler.insertItem(3, smelting, false);
                    }
                    
                    smelting = ItemStack.EMPTY;
                    cookTime = 0;
                    return;
                }
            }

     

    to this:

     

    if(this.isBurning() && this.canSmelt() && cookTime > 0)
            {
                cookTime++;
                if(cookTime == totalCookTime)
                {
                    if(handler.getStackInSlot(3).getCount() >= 0)
                    {

                        handler.getStackInSlot(3).grow(1);
                    }
                    else
                    {
                        handler.insertItem(3, smelting, false);
                    }
                    
                    smelting = ItemStack.EMPTY;
                    cookTime = 0;
                    return;
                }
            }

     

    but it only works if I put the output Item in the output slot. If I do that though it works 100% correct so long as the output item stays there.

     

    I tried to add the breakBlock function in to drop the items but it whines about not having IInventory implemented in the tile entity and I'm not sure of another way to do it.

     

        public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
            
            TileEntityBasicMetallicInfuser tileentity = (TileEntityBasicMetallicInfuser)worldIn.getTileEntity(pos);
            InventoryHelper.dropInventoryItems(worldIn, pos, tileentity);
            super.breakBlock(worldIn, pos, state);
            
        }

  11. 3 hours ago, Will11690 said:

    Sorry, my computer did that to me yesterday too with the left aligned thing, I didn't realize it did it again.

    I was still half asleep, I will fix it now

    Ight I fixed it the formatting and also fixed the double posting. I had to right click and copy in Eclipse instead of control c to copy for some reason lol.

  12. 2 hours ago, Animefan8888 said:

    What is the formatting on your code? Why is it all left aligned? It is such a pain to read.

    You have so many unnecessary methods in here. All you need are Block#onBlockActivated (to open the GUI), Block#breakBlock (to drop all the contained items), Block# hasTIleEntity, Block#createTileEntity, Block#getStateForPlacement (to apply the FACING property correctly), Block#getStateFromMeta, Block#getMetaFromState, and Block#createBlockState

     

    This method can be shortened massively, and I mean massively. Also it really needs to be formatted for me to look at without wanting to find a nice scenic cliff.

     

     

    You posted your Container class twice.

     

    Sorry, my computer did that to me yesterday too with the left aligned thing, I didn't realize it did it again.

    I was still half asleep, I will fix it now

  13. Okay so I have a custom furnace that smelts 2 items into 1 and I'm currently have a bit of an issue with it.

     

    The furnace is sometimes doubling the output when I only want it to output a single item. I always end up with 15 instead of 8. I believe the first one it makes is doing it right but then after that it outputs 2 instead of one.

     

    It also doesn't always work, sometimes when it is placed or after the items are taken out and the GUI closed and reopened it will no longer smelt items.

     

    Then most of the time if I pull the items it smelted out they just disappear out of the players inventory after you close the GUI.

     

    Then the last issue I'm having is when the block is broken the items won't drop on the ground, they just vanish into thin air.

     

    All of the source code for my furnace will be listed below(if i missed anything you need please let me know), if anybody could help me out that would be greatly appreciated and you will be mentioned in the credits of my finished mod once it's able to be released.

     

    BLOCK CLASS:

    Spoiler
    
    import java.util.Random;
    
    import will11690.mechanicraft.Main;
    import will11690.mechanicraft.util.Reference;
    import will11690.mechanicraft.blocks.BlockBase;
    import will11690.mechanicraft.blocks.machines.basicinfuser.TileEntityBasicMetallicInfuser;
    import will11690.mechanicraft.init.ModBlocks;
    import net.minecraft.block.BlockHorizontal;
    import net.minecraft.block.ITileEntityProvider;
    import net.minecraft.block.SoundType;
    import net.minecraft.block.material.Material;
    import net.minecraft.block.properties.IProperty;
    import net.minecraft.block.properties.PropertyBool;
    import net.minecraft.block.properties.PropertyDirection;
    import net.minecraft.block.state.BlockStateContainer;
    import net.minecraft.block.state.IBlockState;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.item.EntityItem;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.inventory.InventoryHelper;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.EnumBlockRenderType;
    import net.minecraft.util.EnumFacing;
    import net.minecraft.util.EnumHand;
    import net.minecraft.util.Mirror;
    import net.minecraft.util.Rotation;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.world.World;
    
    public class BasicMetallicInfuser extends BlockBase
    {
    	public static final PropertyDirection FACING = BlockHorizontal.FACING;
    	public static final PropertyBool BURNING = PropertyBool.create("burning");
    	
    	public BasicMetallicInfuser(String name) 
    	{
    		super(name, Material.IRON);
    		setCreativeTab(Main.mechanicraftmachinestab);
    		setSoundType(SoundType.METAL);
    		this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(BURNING, false));
    	}
    	
    	@Override
    	public Item getItemDropped(IBlockState state, Random rand, int fortune) 
    	{
    		return Item.getItemFromBlock(ModBlocks.BASIC_METALLIC_INFUSER);
    	}
    	
    	@Override
    	public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
    	{
    		return new ItemStack(ModBlocks.BASIC_METALLIC_INFUSER);
    	}
    	
    	@Override
    	public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) 
    	{
    		if(!worldIn.isRemote)
    		{
    			playerIn.openGui(Main.Instance, Reference.GUI_BASIC_METALLIC_INFUSER, worldIn, pos.getX(), pos.getY(), pos.getZ());
    		}
    		
    		return true;
    	}
    	
    	@Override
    	public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) 
    	{
    		if (!worldIn.isRemote) 
            {
                IBlockState north = worldIn.getBlockState(pos.north());
                IBlockState south = worldIn.getBlockState(pos.south());
                IBlockState west = worldIn.getBlockState(pos.west());
                IBlockState east = worldIn.getBlockState(pos.east());
                EnumFacing face = (EnumFacing)state.getValue(FACING);
    
                if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) face = EnumFacing.SOUTH;
                else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) face = EnumFacing.NORTH;
                else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) face = EnumFacing.EAST;
                else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) face = EnumFacing.WEST;
                worldIn.setBlockState(pos, state.withProperty(FACING, face), 2);
            }
    	}
    	
    	public static void setState(boolean active, World worldIn, BlockPos pos) 
    	{
    		IBlockState state = worldIn.getBlockState(pos);
    		TileEntity tileentity = worldIn.getTileEntity(pos);
    		
    		if(active) worldIn.setBlockState(pos, ModBlocks.BASIC_METALLIC_INFUSER.getDefaultState().withProperty(FACING, state.getValue(FACING)).withProperty(BURNING, true), 3);
    		else worldIn.setBlockState(pos, ModBlocks.BASIC_METALLIC_INFUSER.getDefaultState().withProperty(FACING, state.getValue(FACING)).withProperty(BURNING, false), 3);
    		
    		if(tileentity != null) 
    		{
    			tileentity.validate();
    			worldIn.setTileEntity(pos, tileentity);
    		}
    	}
    	
    	@Override
    	public boolean hasTileEntity(IBlockState state) 
    	{
    		return true;
    	}
    	
    	@Override
    	public TileEntity createTileEntity(World world, IBlockState state) 
    	{
    		return new TileEntityBasicMetallicInfuser();
    	}
    	
    	@Override
    	public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) 
    	{
    		return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
    	}
    	
    	@Override
    	public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) 
    	{
    		worldIn.setBlockState(pos, this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
    	}
    	
    	@Override
    	public EnumBlockRenderType getRenderType(IBlockState state) 
    	{
    		return EnumBlockRenderType.MODEL;
    	}
    	
    	@Override
    	public IBlockState withRotation(IBlockState state, Rotation rot)
    	{
    		return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING)));
    	}
    	
    	@Override
    	public IBlockState withMirror(IBlockState state, Mirror mirrorIn) 
    	{
    		return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING)));
    	}
    	
    	@Override
    	protected BlockStateContainer createBlockState() 
    	{
    		return new BlockStateContainer(this, new IProperty[] {BURNING,FACING});
    	}
    	
    	@Override
    	public IBlockState getStateFromMeta(int meta) 
    	{
    		EnumFacing facing = EnumFacing.getFront(meta);
    		if(facing.getAxis() == EnumFacing.Axis.Y) facing = EnumFacing.NORTH;
    		return this.getDefaultState().withProperty(FACING, facing);
    	}
    	
    	@Override
    	public int getMetaFromState(IBlockState state) 
    	{
    		return ((EnumFacing)state.getValue(FACING)).getIndex();
    	}	
    }

     

     

     

    RECIPE CLASS{the recipes in here are for testing purposes}:

    Spoiler
    
    package will11690.mechanicraft.blocks.machines.basicinfuser;
    
    import java.util.Map;
    import java.util.Map.Entry;
    
    import com.google.common.collect.HashBasedTable;
    import com.google.common.collect.Maps;
    import com.google.common.collect.Table;
    
    import net.minecraft.init.Blocks;
    import net.minecraft.item.ItemStack;
    import will11690.mechanicraft.init.ModBlocks;
    
    public class BasicMetallicInfuserRecipes {
    	
    	private static final BasicMetallicInfuserRecipes INSTANCE = new BasicMetallicInfuserRecipes();
    	private final Table<ItemStack, ItemStack, ItemStack> smeltingList = HashBasedTable.<ItemStack, ItemStack, ItemStack>create();
    	private final Map<ItemStack, Float> experienceList = Maps.<ItemStack, Float>newHashMap();
    	
    	public static BasicMetallicInfuserRecipes getInstance() {
    		
    		return INSTANCE;
    		
    	}
    	
    	private BasicMetallicInfuserRecipes() {
    		
    		this.addInfuserRecipe(new ItemStack(ModBlocks.COPPER_BLOCK), new ItemStack(ModBlocks.BLOCK_IRON), new ItemStack(Blocks.ACACIA_FENCE), 5.0F);
    		this.addInfuserRecipe(new ItemStack(Blocks.ACACIA_FENCE), new ItemStack(Blocks.ACACIA_FENCE_GATE), new ItemStack(ModBlocks.ENDONIUM_CRYSTAL_BLOCK), 5.0F);
    		
    	}
    
    	
    	public void addInfuserRecipe(ItemStack input1, ItemStack input2, ItemStack result, float experience) {
    		
    		if(getInfuserResult(input1, input2) != ItemStack.EMPTY) return;
    		this.smeltingList.put(input1, input2, result);
    		this.experienceList.put(result, Float.valueOf(experience));
    		
    	}
    	
    	public ItemStack getInfuserResult(ItemStack input1, ItemStack input2) {
    		
    		for(Entry<ItemStack, Map<ItemStack, ItemStack>> entry : this.smeltingList.columnMap().entrySet()) {
    			
    			if(this.compareItemStacks(input1, (ItemStack)entry.getKey())) {
    				
    				for(Entry<ItemStack, ItemStack> ent : entry.getValue().entrySet()) {
    					
    					if(this.compareItemStacks(input2, (ItemStack)ent.getKey())) {
    						
    						return (ItemStack)ent.getValue();
    						
    					}
    					
    				}
    				
    			}
    			
    		}
    		
    		return ItemStack.EMPTY;
    	}
    	
    	private boolean compareItemStacks(ItemStack stack1, ItemStack stack2) {
    		
    		return stack2.getItem() == stack1.getItem() && (stack2.getMetadata() == 32767 || stack2.getMetadata() == stack1.getMetadata());
    		
    	}
    	
    	public Table<ItemStack, ItemStack, ItemStack> getDualSmeltingList() {
    		
    		return this.smeltingList;
    		
    	}
    	
    	public float getInfuserExperience(ItemStack stack) {
    		
    		for (Entry<ItemStack, Float> entry : this.experienceList.entrySet()) {
    			
    			if(this.compareItemStacks(stack, (ItemStack)entry.getKey())) {
    				
    				return ((Float)entry.getValue()).floatValue();
    				
    			}
    			
    		}
    		
    		return 0.0F;
    	}
    }

     

     

     

    CONTAINER CLASS:

    Spoiler
    
    package will11690.mechanicraft.blocks.machines.basicinfuser;
    
    import will11690.mechanicraft.blocks.machines.basicinfuser.BasicMetallicInfuserRecipes;
    import will11690.mechanicraft.blocks.machines.basicinfuser.slots.SlotBasicMetallicInfuserFuel;
    import will11690.mechanicraft.blocks.machines.basicinfuser.slots.SlotBasicMetallicInfuserOutput;
    import will11690.mechanicraft.blocks.machines.basicinfuser.TileEntityBasicMetallicInfuser;
    
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.inventory.Container;
    import net.minecraft.inventory.IContainerListener;
    import net.minecraft.inventory.Slot;
    import net.minecraft.item.ItemStack;
    import net.minecraftforge.fml.relauncher.Side;
    import net.minecraftforge.fml.relauncher.SideOnly;
    import net.minecraftforge.items.CapabilityItemHandler;
    import net.minecraftforge.items.IItemHandler;
    import net.minecraftforge.items.SlotItemHandler;
    
    public class ContainerBasicMetallicInfuser extends Container
    {
    	private final TileEntityBasicMetallicInfuser tileentity;
    	private int cookTime, totalCookTime, burnTime, currentBurnTime;
    	
    	public ContainerBasicMetallicInfuser(InventoryPlayer player, TileEntityBasicMetallicInfuser tileentity) 
    	{
    		this.tileentity = tileentity;
    		IItemHandler handler = tileentity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
    		
    		this.addSlotToContainer(new SlotItemHandler(handler, 0, 30, 22));
    		this.addSlotToContainer(new SlotItemHandler(handler, 1, 58, 22));
    		this.addSlotToContainer(new SlotItemHandler(handler, 2, 45, 46));
    		this.addSlotToContainer(new SlotItemHandler(handler, 3, 124, 22));
    		
    		for(int y = 0; y < 3; y++)
    		{
    			for(int x = 0; x < 9; x++)
    			{
    				this.addSlotToContainer(new Slot(player, x + y*9 + 9, 8 + x*18, 84 + y*18));
    			}
    		}
    		
    		for(int x = 0; x < 9; x++)
    		{
    			this.addSlotToContainer(new Slot(player, x, 8 + x * 18, 142));
    		}
    	}
    	
    	@Override
    	public void detectAndSendChanges() 
    	{
    		super.detectAndSendChanges();
    		
    		for(int i = 0; i < this.listeners.size(); ++i) 
    		{
    			IContainerListener listener = (IContainerListener)this.listeners.get(i);
    			
    			if(this.cookTime != this.tileentity.getField(2)) listener.sendWindowProperty(this, 2, this.tileentity.getField(2));
    			if(this.burnTime != this.tileentity.getField(0)) listener.sendWindowProperty(this, 0, this.tileentity.getField(0));
    			if(this.currentBurnTime != this.tileentity.getField(1)) listener.sendWindowProperty(this, 1, this.tileentity.getField(1));
    			if(this.totalCookTime != this.tileentity.getField(3)) listener.sendWindowProperty(this, 3, this.tileentity.getField(3));
    		}
    		
    		this.cookTime = this.tileentity.getField(2);
    		this.burnTime = this.tileentity.getField(0);
    		this.currentBurnTime = this.tileentity.getField(1);
    		this.totalCookTime = this.tileentity.getField(3);
    	}
    	
    	@Override
    	@SideOnly(Side.CLIENT)
    	public void updateProgressBar(int id, int data) 
    	{
    		this.tileentity.setField(id, data);
    	}
    	
    	@Override
    	public boolean canInteractWith(EntityPlayer playerIn) 
    	{
    		return this.tileentity.isUsableByPlayer(playerIn);
    	}
    	
    	@Override
    	public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) 
    	{
    		ItemStack stack = ItemStack.EMPTY;
    		Slot slot = (Slot)this.inventorySlots.get(index);
    		
    		if(slot != null && slot.getHasStack()) 
    		{
    			ItemStack stack1 = slot.getStack();
    			stack = stack1.copy();
    			
    			if(index == 3) 
    			{
    				if(!this.mergeItemStack(stack1, 4, 40, true)) return ItemStack.EMPTY;
    				slot.onSlotChange(stack1, stack);
    			}
    			else if(index != 2 && index != 1 && index != 0) 
    			{		
    				Slot slot1 = (Slot)this.inventorySlots.get(index + 1);
    				
    				if(!BasicMetallicInfuserRecipes.getInstance().getInfuserResult(stack1, slot1.getStack()).isEmpty())
    				{
    					if(!this.mergeItemStack(stack1, 0, 2, false)) 
    					{
    						return ItemStack.EMPTY;
    					}
    					else if(TileEntityBasicMetallicInfuser.isItemFuel(stack1))
    					{
    						if(!this.mergeItemStack(stack1, 2, 3, false)) return ItemStack.EMPTY;
    					}
    					else if(TileEntityBasicMetallicInfuser.isItemFuel(stack1))
    					{
    						if(!this.mergeItemStack(stack1, 2, 3, false)) return ItemStack.EMPTY;
    					}
    					else if(TileEntityBasicMetallicInfuser.isItemFuel(stack1))
    					{
    						if(!this.mergeItemStack(stack1, 2, 3, false)) return ItemStack.EMPTY;
    					}
    					else if(index >= 4 && index < 31)
    					{
    						if(!this.mergeItemStack(stack1, 31, 40, false)) return ItemStack.EMPTY;
    					}
    					else if(index >= 31 && index < 40 && !this.mergeItemStack(stack1, 4, 31, false))
    					{
    						return ItemStack.EMPTY;
    					}
    				}
    			} 
    			else if(!this.mergeItemStack(stack1, 4, 40, false)) 
    			{
    				return ItemStack.EMPTY;
    			}
    			if(stack1.isEmpty())
    			{
    				slot.putStack(ItemStack.EMPTY);
    			}
    			else
    			{
    				slot.onSlotChanged();
    
    			}
    			if(stack1.getCount() == stack.getCount()) return ItemStack.EMPTY;
    			slot.onTake(playerIn, stack1);
    		}
    		return stack;
    	}
    }

     

     

     

    GUI CLASS:

    Spoiler
    
    import will11690.mechanicraft.util.Reference;
    import will11690.mechanicraft.blocks.machines.basicinfuser.ContainerBasicMetallicInfuser;
    import will11690.mechanicraft.blocks.machines.basicinfuser.TileEntityBasicMetallicInfuser;
    import net.minecraft.client.gui.inventory.GuiContainer;
    import net.minecraft.client.renderer.GlStateManager;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.util.ResourceLocation;
    
    public class GuiBasicMetallicInfuser extends GuiContainer
    {
    	private static final ResourceLocation TEXTURES = new ResourceLocation(Reference.MOD_ID + ":textures/gui/basic_metallic_infuser.png");
    	private final InventoryPlayer player;
    	private final TileEntityBasicMetallicInfuser tileentity;
    	
    	public GuiBasicMetallicInfuser(InventoryPlayer player, TileEntityBasicMetallicInfuser tileentity) 
    	{
    		super(new ContainerBasicMetallicInfuser(player, tileentity));
    		this.player = player;
    		this.tileentity = tileentity;
    	}
    	
    	@Override
    	protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) 
    	{
    		String tileName = this.tileentity.getDisplayName().getUnformattedText();
    		this.fontRenderer.drawString(tileName, (this.xSize / 2 - this.fontRenderer.getStringWidth(tileName) / 2) + 0, 4, 4210752);
    		this.fontRenderer.drawString(this.player.getDisplayName().getUnformattedText(), 122, this.ySize - 96 + 2, 4210752);
    	}
    	
    	@Override
    	protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
    	{
    		GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
    		this.mc.getTextureManager().bindTexture(TEXTURES);
    		this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
    		
    		if(TileEntityBasicMetallicInfuser.isBurning(tileentity))
    		{
    			int k = this.getBurnLeftScaled(13);
    			this.drawTexturedModalRect(this.guiLeft + 47, this.guiTop + 66 + 12 - k, 176, 12 - k, 14, k + 1);
    		}
    		
    		int l = this.getCookProgressScaled(24);
    		this.drawTexturedModalRect(this.guiLeft + 84, this.guiTop + 23, 176, 14, l + 1, 16);
    	}
    	
    	private int getBurnLeftScaled(int pixels)
    	{
    		int i = this.tileentity.getField(1);
    		if(i == 0) i = 200;
    		return this.tileentity.getField(0) * pixels / i;
    	}
    	
    	private int getCookProgressScaled(int pixels)
    	{
    		int i = this.tileentity.getField(2);
    		int j = this.tileentity.getField(3);
    		return j != 0 && i != 0 ? i * pixels / j : 0;
    	}
    }

     

     

     

    TILE ENTITY:

     
    
    package will11690.mechanicraft.blocks.machines.basicinfuser;
    
    import will11690.mechanicraft.blocks.machines.basicinfuser.BasicMetallicInfuser;
    import will11690.mechanicraft.blocks.machines.basicinfuser.BasicMetallicInfuserRecipes;
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.init.Blocks;
    import net.minecraft.init.Items;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.inventory.ItemStackHelper;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemBlock;
    import net.minecraft.item.ItemHoe;
    import net.minecraft.item.ItemStack;
    import net.minecraft.item.ItemSword;
    import net.minecraft.item.ItemTool;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.EnumFacing;
    import net.minecraft.util.ITickable;
    import net.minecraft.util.NonNullList;
    import net.minecraft.util.math.MathHelper;
    import net.minecraft.util.text.ITextComponent;
    import net.minecraft.util.text.TextComponentString;
    import net.minecraft.util.text.TextComponentTranslation;
    import net.minecraftforge.common.capabilities.Capability;
    import net.minecraftforge.energy.CapabilityEnergy;
    import net.minecraftforge.fml.common.registry.GameRegistry;
    import net.minecraftforge.fml.relauncher.Side;
    import net.minecraftforge.fml.relauncher.SideOnly;
    import net.minecraftforge.items.CapabilityItemHandler;
    import net.minecraftforge.items.ItemStackHandler;
    
    public class TileEntityBasicMetallicInfuser extends TileEntity implements ITickable
    {
    	private ItemStackHandler handler = new ItemStackHandler(4);
    	private String customName;
    	private ItemStack smelting = ItemStack.EMPTY;
    	
    	private int burnTime;
    	private int currentBurnTime;
    	private int cookTime;
    	private int totalCookTime = 200;
    
    	@Override
    	public boolean hasCapability(Capability<?> capability, EnumFacing facing) 
    	{
    		if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return true;
    		else return false;
    	}
    	
    	@Override
    	public <T> T getCapability(Capability<T> capability, EnumFacing facing) 
    	{
    		if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return (T) this.handler;
    		return super.getCapability(capability, facing);
    	}
    	
    	public boolean hasCustomName() 
    	{
    		return this.customName != null && !this.customName.isEmpty();
    	}
    	
    	public void setCustomName(String customName) 
    	{
    		this.customName = customName;
    	}
    	
    	@Override
    	public ITextComponent getDisplayName() 
    	{
    		return this.hasCustomName() ? new TextComponentString(this.customName) : new TextComponentTranslation("container.basic_metallic_infuser");
    	}
    	
    	@Override
    	public void readFromNBT(NBTTagCompound compound)
    	{
    		super.readFromNBT(compound);
    		this.handler.deserializeNBT(compound.getCompoundTag("Inventory"));
    		this.burnTime = compound.getInteger("BurnTime");
    		this.cookTime = compound.getInteger("CookTime");
    		this.totalCookTime = compound.getInteger("CookTimeTotal");
    		this.currentBurnTime = getItemBurnTime((ItemStack)this.handler.getStackInSlot(2));
    		
    		if(compound.hasKey("CustomName", 8)) this.setCustomName(compound.getString("CustomName"));
    	}
    	
    	@Override
    	public NBTTagCompound writeToNBT(NBTTagCompound compound) 
    	{
    		super.writeToNBT(compound);
    		compound.setInteger("BurnTime", (short)this.burnTime);
    		compound.setInteger("CookTime", (short)this.cookTime);
    		compound.setInteger("CookTimeTotal", (short)this.totalCookTime);
    		compound.setTag("Inventory", this.handler.serializeNBT());
    		
    		if(this.hasCustomName()) compound.setString("CustomName", this.customName);
    		return compound;
    	}
    	
    	public boolean isBurning() 
    	{
    		return this.burnTime > 0;
    	}
    	
    	@SideOnly(Side.CLIENT)
    	public static boolean isBurning(TileEntityBasicMetallicInfuser te) 
    	{
    		return te.getField(0) > 0;
    	}
    	
    	public void update() 
    	{	
    		if(this.isBurning())
    		{
    			--this.burnTime;
    			BasicMetallicInfuser.setState(true, world, pos);
    		}
    		
    		ItemStack[] inputs = new ItemStack[] {handler.getStackInSlot(0), handler.getStackInSlot(1)};
    		ItemStack fuel = this.handler.getStackInSlot(2);
    		
    		if(this.isBurning() || !fuel.isEmpty() && !this.handler.getStackInSlot(0).isEmpty() || this.handler.getStackInSlot(1).isEmpty())
    		{
    			if(!this.isBurning() && this.canSmelt())
    			{
    				this.burnTime = getItemBurnTime(fuel);
    				this.currentBurnTime = burnTime;
    				
    				if(this.isBurning() && !fuel.isEmpty())
    				{
    					Item item = fuel.getItem();
    					fuel.shrink(1);
    					
    					if(fuel.isEmpty())
    					{
    						ItemStack item1 = item.getContainerItem(fuel);
    						this.handler.setStackInSlot(2, item1);
    					}
    				}
    			}
    		}
    		
    		if(this.isBurning() && this.canSmelt() && cookTime > 0)
    		{
    			cookTime++;
    			if(cookTime == totalCookTime)
    			{
    				if(handler.getStackInSlot(3).getCount() > 0)
    				{
    					handler.getStackInSlot(3).grow(1);
    				}
    				else
    				{
    					handler.insertItem(3, smelting, false);
    				}
    				
    				smelting = ItemStack.EMPTY;
    				cookTime = 0;
    				return;
    			}
    		}
    		else
    		{
    			if(this.canSmelt() && this.isBurning())
    			{
    				ItemStack output = BasicMetallicInfuserRecipes.getInstance().getInfuserResult(inputs[0], inputs[1]);
    				if(!output.isEmpty())
    				{
    					smelting = output;
    					cookTime++;
    					inputs[0].shrink(1);
    					inputs[1].shrink(1);
    					handler.setStackInSlot(0, inputs[0]);
    					handler.setStackInSlot(1, inputs[1]);
    				}
    			}
    		}
    	}
    	
    	private boolean canSmelt() 
    	{
    		if(((ItemStack)this.handler.getStackInSlot(0)).isEmpty() || ((ItemStack)this.handler.getStackInSlot(1)).isEmpty()) return false;
    		else 
    		{
    			ItemStack result = BasicMetallicInfuserRecipes.getInstance().getInfuserResult((ItemStack)this.handler.getStackInSlot(0), (ItemStack)this.handler.getStackInSlot(1));	
    			if(result.isEmpty()) return false;
    			else
    			{
    				ItemStack output = (ItemStack)this.handler.getStackInSlot(3);
    				if(output.isEmpty()) return true;
    				if(!output.isItemEqual(result)) return false;
    				int res = output.getCount() + result.getCount();
    				return res <= 64 && res <= output.getMaxStackSize();
    			}
    		}
    	}
    	
    	public static int getItemBurnTime(ItemStack fuel) 
    	{
    		if(fuel.isEmpty()) return 0;
    		else 
    		{
    			Item item = fuel.getItem();
    
    			if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR) 
    			{
    				Block block = Block.getBlockFromItem(item);
    
    				if (block == Blocks.WOODEN_SLAB) return 150;
    				if (block.getDefaultState().getMaterial() == Material.WOOD) return 300;
    				if (block == Blocks.COAL_BLOCK) return 16000;
    			}
    
    			if (item instanceof ItemTool && "WOOD".equals(((ItemTool)item).getToolMaterialName())) return 200;
    			if (item instanceof ItemSword && "WOOD".equals(((ItemSword)item).getToolMaterialName())) return 200;
    			if (item instanceof ItemHoe && "WOOD".equals(((ItemHoe)item).getMaterialName())) return 200;
    			if (item == Items.STICK) return 100;
    			if (item == Items.COAL) return 1600;
    			if (item == Items.LAVA_BUCKET) return 20000;
    			if (item == Item.getItemFromBlock(Blocks.SAPLING)) return 100;
    			if (item == Items.BLAZE_ROD) return 2400;
    
    			return GameRegistry.getFuelValue(fuel);
    		}
    	}
    		
    	public static boolean isItemFuel(ItemStack fuel)
    	{
    		return getItemBurnTime(fuel) > 0;
    	}
    	
    	public boolean isUsableByPlayer(EntityPlayer player) 
    	{
    		return this.world.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
    	}
    
    	public int getField(int id) 
    	{
    		switch(id) 
    		{
    		case 0:
    			return this.burnTime;
    		case 1:
    			return this.currentBurnTime;
    		case 2:
    			return this.cookTime;
    		case 3:
    			return this.totalCookTime;
    		default:
    			return 0;
    		}
    	}
    
    	public void setField(int id, int value) 
    	{
    		switch(id) 
    		{
    		case 0:
    			this.burnTime = value;
    			break;
    		case 1:
    			this.currentBurnTime = value;
    			break;
    		case 2:
    			this.cookTime = value;
    			break;
    		case 3:
    			this.totalCookTime = value;
    		}
    	}
    }

     

  14. I'm using the latest recommended version for minecraft 1.7.2 and it doesn't matter what I have tried I can't get the client to start and always get this error.(before it I was getting an --accessToken error but I fixed it then this showed up).

     

     

     

    [19:05:00] [main/ERROR] [LaunchWrapper]: Unable to launch

    java.lang.reflect.InvocationTargetException

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_72]

    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_72]

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_72]

    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_72]

    at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?]

    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?]

    Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path

    at java.lang.ClassLoader.loadLibrary(Unknown Source) ~[?:1.7.0_72]

    at java.lang.Runtime.loadLibrary0(Unknown Source) ~[?:1.7.0_72]

    at java.lang.System.loadLibrary(Unknown Source) ~[?:1.7.0_72]

    at org.lwjgl.Sys$1.run(Sys.java:73) ~[lwjgl-2.9.0.jar:?]

    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_72]

    at org.lwjgl.Sys.doLoadLibrary(Sys.java:66) ~[lwjgl-2.9.0.jar:?]

    at org.lwjgl.Sys.loadLibrary(Sys.java:95) ~[lwjgl-2.9.0.jar:?]

    at org.lwjgl.Sys.<clinit>(Sys.java:112) ~[lwjgl-2.9.0.jar:?]

    at net.minecraft.client.Minecraft.getSystemTime(Minecraft.java:2674) ~[Minecraft.class:?]

    at net.minecraft.client.main.Main.main(Main.java:40) ~[Main.class:?]

    ... 6 more

     

     

  15. Oh and [FEATURE]

    1.) This is probably counted in blocks but custom furnaces (EX:Ore grinders, powered machines).

    2.) A type of power system api for powered machines so that they can run off of all current types of power(EX:RF, MJ, EU, etc.).

  16. Umm.. I suggest you don't post it unless you can actually download. This won't help.

    It is nice to have a placeholder for it and to let people know about it though so even if it doesn't help right now we know that it will be released and will make it much easier for the inexperienced coders to make a mod. Not saying that I will use it but it is a cool idea.
  17. There was an issue and the screenshots got removed from the dropbox I had them synced to so I will have to retake them and reupload them soon, please bear with me I'm working hard on coding with little to show for it.

×
×
  • Create New...

Important Information

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