• 1

    posted a message on Functional structure only when fully built?...

    Override onBlockActivated in your custom block to check for your structure, and if it is valid, open a gui.

    Posted in: Modification Development
  • 1

    posted a message on Replacement for RenderItem#getItemModelMesher

    ModelLoader.setCustomModelResourceLocation takes the same arguments, must be called in preInit.

    Posted in: Modification Development
  • 1

    posted a message on My mod not working with my server

    That's a problem. Both client AND server need to know what your blocks are.


    Move the call to init() to your common proxy

    Posted in: Modification Development
  • 1

    posted a message on [SOLVED] null pointer exception crash on spawning entity in custom structure

    Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode


    This will crash the server. Minecraft.class is client-only. If you want to alert nearby players that the entity spawned, use World#getEntitiesWithinAABB(EntityPlayer.class, entity.boundingBox.expand(RANGE, RANGE, RANGE) and iterate through that list of players.

    Posted in: Modification Development
  • 1

    posted a message on Detect surface blocks

    I have this old method you can use:

    public static int getNonAirNonLiquidFromAbove(World world, int x, int z)
    {
    	int y = 255;
    	boolean foundGround = false;
    	while(!foundGround && y-- >= 0)
    	{
    		Block blockAt = world.getBlock(x,y,z);
    		// "ground" for our purposes is anything but air, liquid, leaves
    		foundGround = blockAt != Blocks.air && !blockAt.getMaterial().isLiquid() && !(blockAt instanceof BlockLeaves);
    	}
    
    	return y;
    }


    If you want to get the first air block from below, just switch a few things around:

    public static int getFirstAirFromBelow(World world, int x, int z)
    {
    	int y = 0;
    	boolean foundAir = false;
    	while(!foundAir && y++ < 255)
    	{
    		Block blockAt = world.getBlock(x,y,z);
    		foundAir = blockAt == Blocks.air;
    	}
    
    	return y;
    }

    Feel free to use these and modify them for your purposes. If you do use them, make sure to check that y is indeed between 0 and 255 before doing anything.

    Posted in: Modification Development
  • 1

    posted a message on [SOLVED] ItemBlock.onItemUse() only being called on block placement

    Well... you could have one call the other. I don't think it would cause any looping or anything terrible.

    public EnumActionResult onItemUse(ItemStack itemStackIn, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) 
    {
    	this.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
    	return super.onItemUse(itemStackIn, playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ);
    }
    Posted in: Modification Development
  • 1

    posted a message on [SOLVED] ItemBlock.onItemUse() only being called on block placement

    The Item class has a method for getting the player's look vector. Call this from onItemRightClick before returning an ActionResult.

    RayTraceResult rtr = this.rayTrace(worldIn, player, true);

    Then check that it hit a block like this:

    if (rtr == null)
    {
        return ActionResult.newActionResult(EnumActionResult.FAIL, itemStackIn);
    }
    else if(rtr.typeOfHit == RayTraceResult.Type.BLOCK)
    {
        BlockPos hitPos = rtr.getBlockPos();
        // other stuff
    }

    I do not know if this works flawlessly for blocks that do not have a selection box -- specifically air, fire, etc. In your case, detecting clicking on fire is very important. You may want to set hitPos to rtr.getBlockPos().offset(rtr.sideHit, 1) and see how that works.

    Posted in: Modification Development
  • 1

    posted a message on How do Minecraft versions affect mods? Is there any way to rebuild them to work with newer versions?
    Quote from EchoReaper»

    How much effort do you estimate it would take to port a mod the size of Mo' Creatures from 1.8 to 1.10?


    The mod author of Mo' Creatures is very private about their code and mods, so that specific mod may not be a good example. My best guess is that it will take changes to every single class (if nothing else, organizing imports). Also MOC adds a dimension, and my dimension-adding mod took a bit of a beating in the 1.8.x -> 1.9 update.

    My Extra Golems mod is comparable, though, since it mainly adds Entities. It did not take much effort to update from 1.8 -> 1.8.9 -> 1.9 -> 1.9.4 -> 1.10. The only major changes were my adding of new features and re-doing code that was using methods of a different name or methods that had been removed or deprecated. (deprecated = marked for removal in next release)
    The 1.9 update, though, required a lot of method signatures to include an EnumHand argument and some returned an ActionResult instead of a boolean as before. Also in 1.9.4 the class everyone was using for translation was deprecated and its replacement was a bit tricky to find.

    The 1.7.10 -> 1.8.x update, as you've no doubt heard, was also very tough. Blocks had to be redone to use IBlockState and Property things instead of direct integer metadata. Entity rendering had to be redone from this to this. DataWatcher ids were replaced by a generic DataParameter somewhere between 1.8 and 1.9. And not all these changes took place in one version, which is helpful for me but not for the person trying to update by skipping several versions.
    Posted in: Modification Development
  • 1

    posted a message on Mod items not showing up in creative tabs when running on server

    A few things:

    - Items should be registered in preInit. I didn't know it even worked to try to register them in init

    - You should be using ModelLoader.setCustomModelResourceLocation instead of Minecraft.getMinecraft().getRenderItem()...

    - - the ModelLoader method should be called from preInit as well. It takes the same arguments.

    - You should not be using LanguageRegistry

    - - use the .lang file instead, adding an entry to translate the unlocalized name. See here for instructions.

    Posted in: Modification Development
  • 1

    posted a message on Tile Entity inventory resets on world reload.

    Actually, looking at your writeToNBT, it doesn't look like you're writing the items tag to the main NBTTagCompound.

    That would explain why it's not entering the for loop -- NBTTagCompound#getTagList returns an empty list if it does not find the tag compound.


    public void writeToNBT(NBTTagCompound tagCompound){
                super.writeToNBT(tagCompound);
                NBTTagList items = new NBTTagList();
                for (int i = 0; i < getSizeInventory(); i++){
                    ItemStack stack = this.getStackInSlot(i);
                    if (stack != null){
                        NBTTagCompound writeitem = new NBTTagCompound();
                        writeitem.setByte("Slot", (byte) i);
                        stack.writeToNBT(writeitem);
                        items.appendTag(writeitem);
                    }
                }
                // right here  you should call tagCompound.setTag("Items", items); unless it's called something else
                tagCompound.setInteger("BurnTime", this.furnaceBurnTime);
                tagCompound.setInteger("CookTime", this.furnaceBurnTime);
            }

    Posted in: Modification Development
  • To post a comment, please .