• 0

    posted a message on [mod idea] a new way to automate.

    Ehh, perhaps I'll make a manipulator of sorts in my current mod later down the line. I don't think it would be nearly as hacky as you might think at first glance. But nevertheless, it wouldn't be impossible. The GUI doesn't store data on its own, so every client with the mod has it. All you have to do is get the block and call the onRightClick method using your player to make your client open the GUI of the block, despite however far away you may be. Should be fairly simple to implement using either coordinate programming or block linking back to the manipulator. How do you think stuff like wireless access terminals in Applied Energistics works? It shouldn't have to be manually added either, despite what I was originally thinking.

    Posted in: Requests / Ideas For Mods
  • 0

    posted a message on [mod idea] a new way to automate.

    Still could if you recreated an instance of the TE's gui / container and built it up and as you mess with it it changes the new instance, then on completion of using the recreated gui it saves the data back into the original Tile Entity, but I'm not sure if there would be an easy way to make it generic... you might have to add each mod support individually.

    Posted in: Requests / Ideas For Mods
  • 0

    posted a message on [mod idea] a new way to automate.

    While GUI's are server side, you could always get the inventory and reconstruct the GUI in a generic sense of manipulating "any" GUI, at least as far as item-slots go. Possibly link multiple together into one single "GUI" for the block. It definitely is possible, I just don't want to start digging around and doing it myself. But maybe later down the line if no one else jumps on this. Currently I'm busy with other projects.

    Posted in: Requests / Ideas For Mods
  • 0

    posted a message on Coal Bomb

    Would you be opposed to this being included in a larger mod? I currently have a cheaper "tnt" in my upcoming 1.10.2 mod (soon to be ported to 1.11.2) called "Blockhole". It is very early in development, but also very stable from what I've tested. I haven't done much in cross mod compatibility, though.


    I'm not sure if I should be linking you to it in this thread or if that is breaking terms or not, so feel free to check


    https://minecraft.curseforge.com/


    and make sure to search for "Blockhole" in the projects search bar. It is the only result when you search that, and I recently put out a public alpha build :)

    Posted in: Requests / Ideas For Mods
  • 0

    posted a message on neighborChanged() only updating on server, not client. Causing ghost block duplication

    Bump because I debugged the code heavily and came up with what is actually going wrong, so I need some fresh eyes to get in on this. Question has been rewritten above and in thread title. github link is up-to-date

    Posted in: Modification Development
  • 0

    posted a message on Getting number of times a player hits a block with an item?

    Probably best bet is to shift into tile entity.


    I have some weird idea in the back of my head about doubling up two ints on metadata, but I am currently tracing a bug in my own mod at the moment. If I have time before you get this resolved, I'll see if I can come up with something.

    Posted in: Modification Development
  • 0

    posted a message on neighborChanged() only updating on server, not client. Causing ghost block duplication

    So I have an issue with my neighborChanged() function in my block. What the block should do is accept blocks on right click (using the activation function) and store them in a queue. Then, when redstone is applied, the block is teleported to the programmed location. I have the queue building correctly, and the adding and removing from the queue working (sort of). The problem I have traced down to the neighborChanged() function in the block.

    Here is the function:



    @SuppressWarnings("deprecation")
    @Override
    public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block) 
    {
    	TileEntityTeleporter tile = (TileEntityTeleporter)world.getTileEntity(pos);
    	BlockPos tploc = new BlockPos(tile.tp_x, tile.tp_y, tile.tp_z);
    		
    	if (pos != tploc)
    	{
    		if (world.isBlockIndirectlyGettingPowered(pos) > 0)
    		{
    			if (tile.isOn == false)
    			{
    				if ((world.getBlockState(tploc) == null || world.getBlockState(tploc).getBlock() == Blocks.AIR) && tile.queue.getFront() != null)
    				{
    					ItemStack stack = tile.queue.pop_front();
    						
    					world.setBlockState(tploc, Block.getBlockFromItem(stack.getItem()).getStateFromMeta(stack.getMetadata()));
    						
    					if (world.isRemote)
    					{
    					      System.out.println("PLACED BLOCK IN WORLD");
    						for (int test = 1; test < tile.queue.getSize() + 1; test++)
    						{
    							System.out.println(tile.queue.getStackAtNode(test));
    						}
    					}
    				}
    
    				tile.isOn = true;
    			}
    		}
    		else if (world.isBlockIndirectlyGettingPowered(pos) == 0)
    		{
    			if (tile.isOn == true)
    			{
    				if (world.getBlockState(tploc) != null && world.getBlockState(tploc).getBlock() != Blocks.AIR)
    				{
    					tile.queue.insert_front(new ItemStack(world.getBlockState(tploc).getBlock(), 1, world.getBlockState(tploc).getBlock().getMetaFromState(world.getBlockState(tploc))));
    
    					world.setBlockState(tploc, Blocks.AIR.getDefaultState());
    						
    					if (world.isRemote)
    					{
    						System.out.println("PLACED BLOCK IN QUEUE");
    						for (int test = 1; test < tile.queue.getSize() + 1; test++)
    						{
    							System.out.println(tile.queue.getStackAtNode(test));
    						}
    					}
    				}
    					
    				tile.isOn = false;
    			}
    		}
    	}
    }





    Basically, something really strange is happening. In the following chunk:

    if ((world.getBlockState(tploc) == null || world.getBlockState(tploc).getBlock() == Blocks.AIR) && tile.queue.getFront() != null)
    {
     ItemStack stack = tile.queue.pop_front();
     
     world.setBlockState(tploc, Block.getBlockFromItem(stack.getItem()).getStateFromMeta(stack.getMetadata()));
     
     if (world.isRemote)
     {
     System.out.println("PLACED BLOCK IN WORLD");
     for (int test = 1; test < tile.queue.getSize() + 1; test++)
     {
     System.out.println(tile.queue.getStackAtNode(test));
     }
     }
    }

    The block gets placed correctly with correct meta data, so that means that "stack" is getting set to tile.queue.pop_front() correctly.
    However, the print-out in this function never appears (so the program is stopping between setBlockState and the print loop) but when I use print outs when adding or removing blocks from the queue manually, it shows that the block was never removed from the queue. So one would think that pop_front() isn't programmed correctly, right?

    Here is the kicker. If you right click to remove the blocks, and remove all of them, you are able to remove the block that you supposedly placed. However, when you withdraw the block placed by turning the redstone off and adding it back to the queue, you aren't able to take it out of the queue manually again, nor activate the redstone to place it.

    Also, if you remove all of the blocks from the queue including the "placed" block, then DESTROY the placed block, it gives you an itemstack of size 0 back.

    If you destroy the block first, then remove the blocks from the queue, it gives you an itemstack of size 1 and you can duplicate the "placed" block giving you a net gain of 1 block.

    I cant seem to figure out WHY it has these weird properties about it. I am almost 100% sure the pop function is written correctly. I am almost 100% sure the activation functions are written correctly. I think the logic behind the neighborChanged function is written correctly. However, the only thing I can come up with is that either:

    1, the readNBT is getting read after I called "pop" but before it has called writeNBT, thus resetting the queue.
    2, when a block is placed in the world, it is short circuiting the neighborChanged function and causing it to not finish

    Or both. I hope someone can clarify how exactly the neighborChanged works and if it could possibly be short circuiting, and if the NBT is being a problem here.

    If you want your hands on all of my code, I will be pushing the changes to my git repository.


    I have managed to debug it down to the point where the "duplication" is happening because the neighborChanged() function is only updating the queue on server side, while the activation function is updating the client side. Could sure use some help figuring out how to update the tile entity from within the neighborChanged function, kinda lost what to try next. How do I get the server to send the client its' updated tag compound if I can't access the client from this function. Likewise, in the onBlockActivated function, I tried:

    DoubleLinkedQueue server = tile.queue;
    if (!world.isRemote)
            server = tile.queue; //to get the server instance of it, correct?
    
    tile.queue = server;

    Am I wrong in thinking this? Not to mention, if I wanted to have the client updated for any other function I would have to keep doing the same snippet of code (i.e. on block break have an explosion based on size of queue * average hardness of blocks etc)... there has to be a way to update it from within the neighborChanged function.

    Posted in: Modification Development
  • 0

    posted a message on [SOLVED] (NULL POINTER EXCEPTION) writeFromNBT crashes world upon loading the world?

    Thanks guys, that was "sort of" the problem. It was indeed erroring on node = node.next because next was null and I was still trying to set a null node's block. However, the true problem was the fact that it was continuing in the for loop to begin with. In the read function, I was setting size to equal the stored size in the NBT data to use for the loop. However, I was using my insert function to replace the blocks in order into the queue, which also was incrementing the size. This was causing my loops to run for twice as long with half the blocks, i.e. reading in 8 blocks for every 4 I put in. Then when it went to write, the last half of the queue had node.next equal to null. So I just made a temporary variable inside the read function for the size instead of using the queue's size variable :P

    Thanks for helping me spot this, it was kind of hard for you to catch the real cause yourselves when I only provided the reads! Haha!

    Also, I didn't know you could turn a BlockPos to a Long! Thanks for the tip :D

    Posted in: Modification Development
  • 0

    posted a message on Getting number of times a player hits a block with an item?

    Not entirely sure if it's the only way or the most "memory" friendly way, but you could always create an empty inventory for the item and use NBT to save the number of hits, and the coordinates of the block x,y,z, then get the NBTTagCompound if one exists, and increment it. If you hit a block in a different coordinate location, reset the hits, etc.

    Currently, hits is being reset to 0 each time you "use" the item, and it never works its way through the if, else if statements because it always does the first one, then there is no ELSE to do.

    However, you obviously (i think) want it to add hits as you actually hit it, not all in the one hit, so you would need a class variable. But since it is an item, it would be true across all of the same classes, messing up with other people's hits in game. So the best solution would be an Inventory for the item, "possibly" metadata so long as the max hits ever recorded would be small.

    Posted in: Modification Development
  • 0

    posted a message on [SOLVED] (NULL POINTER EXCEPTION) writeFromNBT crashes world upon loading the world?

    So the writeFromNBT crashes upon world load, but not during world saving. However, it is my special writeNBT function that is doing the crashing. I know it is a null pointer crash from the crash log, but I can't seem to track it down myself.

    The short story is I'm creating a queue of blocks that you can right click to store internally in the TileEntity inside a "Queue" class.

    Inside of the queue, I have a function that you can pass the NBTTagCompound from the TileEntity into when writing inside the Tile Entity to write what is inside the Queue as well.


    You can put items in, pause the game, and watch them successfully write to the TileEntity's NBTTagCompound.


    You can save the game, and watch it go to the main menu error free.


    However, when you load the game, it places in an empty NBT data, then reads in the old data, but then errors right before it finishes writing the new Queue portion of the data.


    Here is a successful write message in console:

    SUCCESS


    Here is the error message in the console:

    ERROR


    Here is the crash log:

    CRASH LOG


    Obviously it is telling me what line and everything is crashing, but I still can't seem to figure out WHAT is wrong with how I am saving the Block to NBT internally.

    Here are the Write Functions for both the TileEntity and the Queue. If you need any more than that, feel free to ask!




    TileEntity
    
    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound) 
    {
    	compound.setInteger("tp_x", this.tp_x);
    	compound.setInteger("tp_y", this.tp_y);
    	compound.setInteger("tp_z", this.tp_z);
    	compound.setInteger("loc_x", loc.getX());
    	compound.setInteger("loc_y", loc.getY());
    	compound.setInteger("loc_z", loc.getZ());
    		
    	queue.writeNBT(compound);
    		
    	return super.writeToNBT(compound);
    }
    
    Queue
    
    public void writeNBT(NBTTagCompound compound) 
    {
    	System.out.println("NODE DATA STARTING SAVE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    		
    	compound.setInteger("size", size);
    		
    	Node node = headptr;
    		
    	for (int i = 0; i < size; i++)
    	{
    		compound.setTag("block" + i, new ItemStack(node.block).writeToNBT(new NBTTagCompound()));
    		System.out.println(node.block + "   .write.");
    		node = node.next;
    	}
    		
    	System.out.println("NODE DATA STOPPING SAVE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    }








    Any help is appreciated, even if it is just another set of eyes on the code.

    Posted in: Modification Development
  • 1

    posted a message on Trying to learn how to code, looking for advice, tips and tricks

    Well, I agree that the people here shouldn't have to teach you java, but I disagree with the idea that you can't or shouldn't learn it by coding mods for Minecraft... Maybe I just got lucky and really had a knack for programming, but I started programming in java (my FIRST language) by coding Minecraft mods. Nothing releasable, but something. I slowly got better and started understanding how it worked. Yes, it took me from freshman year of high school until senior year to really understand logic behind coding, but let me tell you this: I was miles ahead of most freshman CSC majors going into college this year. Don't let people tell you not to start with Minecraft, but if you run into a JAVA problem, don't ask it here.

    Do I know Java better than everyone on here? No, not even close. Do I know enough to get by and do what I want to get done and accomplish things? Yes.

    Posted in: Modification Development
  • 1

    posted a message on Metadata doesn't appear to be saving

    I took the liberty to re-work some of your Tile Entity functions to remove the saving of metadata which is done by the block and to tidy up the code kinda so it was easier to look for errors.


    I found some small things in the reading and writing that could have been causing it, check this pastebin for a comparison between the rewritten and your old function. http://pastebin.com/M6dN3CVQ

    Posted in: Modification Development
  • 1

    posted a message on Metadata doesn't appear to be saving
    Hmm, I see some slight differences still with your updateBlockState from your lastest spoiler containing it from mine. I'll try to show where you have something versus where I have something. I think it COULD be because of this but I still doubt it.
    public static void updateBlockState(boolean bool, World world, int x, int y, int z)
    	{
    		int l = world.getBlockMetadata(x, y, z);
    
    		TileEntity tileentity = world.getTileEntity(x, y, z);
    		isBurning = true;
    
    		if (bool)
    		{
    			world.setBlock(x, y, z, Construct.machineCarbonCondenserActive);
                            <span style="color: #ff0000;">// You placed it here and...</span>
    		}
    		else
    		{
    			world.setBlock(x, y, z, Construct.machineCarbonCondenser);
                            <span style="color: #ff0000;">// here.</span>
    		}
    
    		isBurning = false;
                   <span style="color: #ff0000;"> // I placed it here. Shouldn't matter thought because you get metadata set either way.</span>
    		world.setBlockMetadataWithNotify(x, y, z, l, 2);
    
    		if (tileentity != null)
    		{
    			tileentity.validate();
    			world.setTileEntity(x, y, z, (TileEntityCarbonCondenser) tileentity);
                                                          <span style="color: #ff0000;">// TRY CASTING THE T.E. and see if that helps</span>
    		}
    	}


    I still doubt it is the casting doing it, at most that would be the reason the T.E. isn't saving inventory. Hmm, perhaps post your BLOCK class and your up to date TILEENTITY class, subtracting any specialized methods for your specific Autoclave functionality. I'm more just interested in the inherited methods so I can kinda read through it more carefully instead of bits and pieces. If you aren't comfortable with posting it online, maybe send me a link to a private pastebin? Sorry I haven't been more of a help.
    Posted in: Modification Development
  • 1

    posted a message on Metadata doesn't appear to be saving

    For the changing direction issue, assuming you are still coding in 1.7.10 like the post suggests, you need 2 functions. Pretty straight forward if you understand the code, so I don't feel bad just handing this over. Pretty much taken straight from original furnace, it's from my machine but I don't think I changed anything.





    public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack p_149689_6_)
    {
    	int l = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
    
    	if (l == 0)
    	{
    		world.setBlockMetadataWithNotify(x, y, z, 2, 2);
    	}
    
    	if (l == 1)
    	{
    		world.setBlockMetadataWithNotify(x, y, z, 5, 2);
    	}
    
    	if (l == 2)
    	{
    		world.setBlockMetadataWithNotify(x, y, z, 3, 2);
    	}
    
    	if (l == 3)
    	{
    		world.setBlockMetadataWithNotify(x, y, z, 4, 2);
    	}
    
    }





    And the other:




    private void func_149930_e(World world, int x, int y, int z)
    {
    if (!world.isRemote)
    {
    Block block = world.getBlock(x, y, z - 1);
    Block block1 = world.getBlock(x, y, z + 1);
    Block block2 = world.getBlock(x - 1, y, z);
    Block block3 = world.getBlock(x + 1, y, z);
    byte b0 = 3;
    
    if (block.func_149730_j() && !block1.func_149730_j())
    {
    b0 = 3;
    }
    
    if (block1.func_149730_j() && !block.func_149730_j())
    {
    b0 = 2;
    }
    
    if (block2.func_149730_j() && !block3.func_149730_j())
    {
    b0 = 5;
    }
    
    if (block3.func_149730_j() && !block2.func_149730_j())
    {
    b0 = 4;
    }
    
    world.setBlockMetadataWithNotify(x, y, z, b0, 2);
    }
    }


    EDIT:
    Also, off the top of my head, it doesn't look like you are calling markDirty() inside of getStackInSlotOnClosing() which would be a problem, I don't know if there is more than that though for why it doesn't save the slots.

    Posted in: Modification Development
  • 0

    posted a message on How to change inventory data from within GUI?

    So, I have power being stored and written correctly to an inventory's NBT data. However, the GUI for the container that is opened has some buttons, and when they are activated, I want to drain some power from the inventory/item.


    Here is what I tried:

     

    // At the top of the GUI:
    private InventoryCalculatorBasic calcRef = new InventoryCalculatorBasic(Minecraft.getMinecraft().thePlayer.getHeldItem(), Minecraft.getMinecraft().thePlayer)
    
    // In the constructor:
    this.calcRef = calculator.calculator;
    
    // Inside the function that detects when a button is pushed in the GUI:				
    boolean usedPower = false;
    				
    if (Minecraft.getMinecraft().thePlayer.getHeldItem().getItem() instanceof ItemCalculatorBasic && Minecraft.getMinecraft().thePlayer.getHeldItem().hasTagCompound())
    
            for (int i = 0; i < 1000; i++)
            {
    		this.calcRef.batteryDecUsage();
                    // Also tried accessing .batteryDecUsage(); this way:
                    // ((InventoryCalculatorBasic)((ContainerCalculatorBasic)Minecraft.getMinecraft().thePlayer.openContainer).calculator).batteryDecUsage();
    
    		usedPower = true;
    	}
    				
    		if (usedPower)
    		       this.calcRef.markDirty(); // calls the write to NBT function inside it

    All of these attempts show a short visual change in the power, but the power level reverts and never actually changes it.

    Posted in: Modification Development
  • To post a comment, please or register a new account.