Jump to content

ProfitOrange

Forge Modder
  • Posts

    19
  • Joined

  • Last visited

Posts posted by ProfitOrange

  1. Particles are client sided, so by having the if(!attacker.world.isRemote()), they won't appear. Since you have the world parameter, the method won't run unless you have called it from somewhere else, you can simply just get the world from the attacker and remove the world parameter. Below is an example.

    public boolean hitEntity(ItemStack stack, LivingEntity target, LivingEntity attacker) 
    {
    	World world = attacker.world(); //get the world from the attacker
    
        if (!world.isRemote()) 
    	{
            target.addPotionEffect(new EffectInstance(Effects.SLOWNESS, 45, 1));
            world.playSound(null, attacker.getPosX(), attacker.getPosY(), attacker.getPosZ(),
                SoundEvents.BLOCK_ANCIENT_DEBRIS_BREAK, SoundCategory.PLAYERS, 1, 1);
    	}
    	
    	else
    	{
    		world.addParticle(new BlockParticleData(ParticleTypes.BLOCK, Blocks.ANCIENT_DEBRIS.getDefaultState()),
                true, target.getPosX(), target.getPosY() + 0.5D,
                target.getPosZ(), 0, 1, 0);
    	}
        return super.hitEntity(stack, target, attacker);
    }

     

  2. I added a custom item that I want to be dropped from minecraft's wither skeleton, but I can't seem to figure out how to add to loot tables, this is what I have tried:

     

    Loot Table Event Class:

    package com.ProfitOrange.MoShiz.event;
    
    import com.ProfitOrange.MoShiz.Reference;
    
    import net.minecraft.util.ResourceLocation;
    import net.minecraft.world.storage.loot.LootPool;
    import net.minecraft.world.storage.loot.TableLootEntry;
    import net.minecraftforge.event.LootTableLoadEvent;
    import net.minecraftforge.eventbus.api.SubscribeEvent;
    
    public class LootTableEvents 
    {
    	private static ResourceLocation wither_skeleton_drops = new ResourceLocation("minecraft", "entities/wither_skeleton");
    	
    	
    	@SubscribeEvent
    	public static void onLootLoad(LootTableLoadEvent event) 
    	{
    		if (event.getName().equals(wither_skeleton_drops)) 
    		{
    			event.getTable().addPool(LootPool.builder().addEntry(TableLootEntry.builder(new ResourceLocation(Reference.MOD_ID, "entities/wither_skeleton_mod"))).build());
    		}
    	}
    }

     

    And the loot table json file:

    {
      "type": "minecraft:entity",
      "pools": [
        {
          "rolls": 1,
          "entries": [
            {
              "type": "minecraft:item",
              "functions": [
                {
                  "function": "minecraft:set_count",
                  "count": {
                    "min": 0.0,
                    "max": 1.0,
                    "type": "minecraft:uniform"
                  }
                },
                {
                  "function": "minecraft:looting_enchant",
                  "count": {
                    "min": 0.0,
                    "max": 1.0
                  }
                }
              ],
              "name": "ms:nether/witherbone"
            }
          ]
        }
      ]
    }

    Any help on this issue would be much appreciated.

  3. I seem to have an issue when right clicking on the ground with custom sugar cane item.

     

    Crashlog:

    Spoiler

    [07:22:34] [Client thread/FATAL]: Unreported exception thrown!
    java.lang.NullPointerException
        at net.minecraft.world.World.mayPlace(World.java:3358) ~[World.class:?]
        at net.minecraft.item.ItemBlockSpecial.onItemUse(ItemBlockSpecial.java:45) ~[ItemBlockSpecial.class:?]
        at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:180) ~[ItemStack.class:?]
        at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:486) ~[PlayerControllerMP.class:?]
        at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1606) ~[Minecraft.class:?]
        at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2276) ~[Minecraft.class:?]
        at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2053) ~[Minecraft.class:?]
        at net.minecraft.client.Minecraft.runTick(Minecraft.java:1841) ~[Minecraft.class:?]
        at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1119) ~[Minecraft.class:?]
        at net.minecraft.client.Minecraft.run(Minecraft.java:407) [Minecraft.class:?]
        at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101]
        at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
        at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101]
        at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
        at GradleStart.main(GradleStart.java:26) [start/:?]
    [07:22:34] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:600]: ---- Minecraft Crash Report ----
    // Shall we play a game?

    Time: 5/14/17 7:22 AM
    Description: Unexpected error

    java.lang.NullPointerException: Unexpected error
        at net.minecraft.world.World.mayPlace(World.java:3358)
        at net.minecraft.item.ItemBlockSpecial.onItemUse(ItemBlockSpecial.java:45)
        at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:180)
        at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:486)
        at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1606)
        at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2276)
        at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2053)
        at net.minecraft.client.Minecraft.runTick(Minecraft.java:1841)
        at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1119)
        at net.minecraft.client.Minecraft.run(Minecraft.java:407)
        at net.minecraft.client.main.Main.main(Main.java:118)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
        at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
        at GradleStart.main(GradleStart.java:26)


    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------

    -- Head --
    Thread: Client thread
    Stacktrace:
        at net.minecraft.world.World.mayPlace(World.java:3358)
        at net.minecraft.item.ItemBlockSpecial.onItemUse(ItemBlockSpecial.java:45)
        at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:180)
        at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:486)
        at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1606)
        at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2276)
        at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2053)

    -- Affected level --
    Details:
        Level name: MpServer
        All players: 1 total; [EntityPlayerSP['Player219'/258, l='MpServer', x=-22.90, y=33.09, z=35.02]]
        Chunk stats: MultiplayerChunkCache: 625, 625
        Level seed: 0
        Level generator: ID 00 - default, ver 1. Features enabled: false
        Level generator options:
        Level spawn location: World: (-16,64,317), Chunk: (at 0,4,13 in -1,19; contains blocks -16,0,304 to -1,255,319), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
        Level time: 80063 game time, 13918 day time
        Level dimension: 0
        Level storage version: 0x00000 - Unknown?
        Level weather: Rain time: 0 (now: true), thunder time: 0 (now: false)
        Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
        Forced entities: 48 total; [EntityPigZombie['Zombie Pigman'/259, l='MpServer', x=-29.28, y=36.00, z=46.50], EntityPigZombie['Zombie Pigman'/260, l='MpServer', x=-19.10, y=35.00, z=46.44], EntityPigZombie['Zombie Pigman'/261, l='MpServer', x=-16.55, y=34.00, z=45.77], EntityPigZombie['Zombie Pigman'/262, l='MpServer', x=-29.50, y=90.00, z=46.50], EntityPigZombie['Zombie Pigman'/263, l='MpServer', x=-14.51, y=101.00, z=39.25], EntityPigZombie['Zombie Pigman'/269, l='MpServer', x=-103.44, y=13.00, z=-9.65], EntityPigZombie['Zombie Pigman'/272, l='MpServer', x=-68.50, y=84.00, z=-19.50], EntityPigZombie['Zombie Pigman'/273, l='MpServer', x=-64.50, y=18.00, z=2.50], EntityPigZombie['Zombie Pigman'/274, l='MpServer', x=-67.50, y=85.00, z=8.50], EntityPigZombie['Zombie Pigman'/275, l='MpServer', x=-67.50, y=85.00, z=9.50], EntityPigZombie['Zombie Pigman'/276, l='MpServer', x=-68.45, y=85.00, z=5.20], EntityPigZombie['Zombie Pigman'/277, l='MpServer', x=-69.50, y=85.00, z=8.50], EntityPlayerSP['Player219'/258, l='MpServer', x=-22.90, y=33.09, z=35.02], EntityPigZombie['Zombie Pigman'/287, l='MpServer', x=50.50, y=37.00, z=109.50], EntityPigZombie['Zombie Pigman'/288, l='MpServer', x=56.41, y=39.00, z=97.77], EntityPigZombie['Zombie Pigman'/292, l='MpServer', x=49.24, y=92.00, z=-4.50], EntityEnderman['Enderman'/293, l='MpServer', x=-2.52, y=93.00, z=67.61], EntityEnderman['Enderman'/294, l='MpServer', x=-11.50, y=92.00, z=69.50], EntityPigZombie['Zombie Pigman'/295, l='MpServer', x=-34.50, y=111.00, z=99.50], EntityPigZombie['Zombie Pigman'/301, l='MpServer', x=-13.50, y=103.00, z=-28.50], EntityPigZombie['Zombie Pigman'/302, l='MpServer', x=-27.43, y=89.00, z=104.26], EntityPigZombie['Zombie Pigman'/303, l='MpServer', x=-52.41, y=55.00, z=-5.66], EntityPigZombie['Zombie Pigman'/304, l='MpServer', x=-36.26, y=33.00, z=63.47], EntityPigZombie['Zombie Pigman'/305, l='MpServer', x=-33.80, y=35.00, z=58.59], EntityPigZombie['Zombie Pigman'/306, l='MpServer', x=-33.59, y=89.00, z=54.26], EntityPigZombie['Zombie Pigman'/307, l='MpServer', x=18.50, y=13.00, z=-10.50], EntityPigZombie['Zombie Pigman'/308, l='MpServer', x=-15.50, y=100.00, z=28.50], EntityPigZombie['Zombie Pigman'/309, l='MpServer', x=-64.50, y=83.00, z=103.50], EntityPigZombie['Zombie Pigman'/310, l='MpServer', x=8.81, y=7.00, z=-13.50], EntityPigZombie['Zombie Pigman'/311, l='MpServer', x=12.51, y=19.00, z=-12.19], EntityChicken['Chicken'/312, l='MpServer', x=15.36, y=99.00, z=-11.50], EntityPigZombie['Zombie Pigman'/313, l='MpServer', x=24.60, y=100.00, z=-12.18], EntityPigZombie['Zombie Pigman'/314, l='MpServer', x=25.50, y=70.00, z=-17.50], EntityPigZombie['Zombie Pigman'/315, l='MpServer', x=-15.65, y=100.00, z=38.70], EntityPigZombie['Zombie Pigman'/316, l='MpServer', x=-23.50, y=90.00, z=16.50], EntityPigZombie['Zombie Pigman'/318, l='MpServer', x=-69.50, y=85.00, z=113.50], EntityPigZombie['Zombie Pigman'/319, l='MpServer', x=30.50, y=69.00, z=26.50], EntityPigZombie['Zombie Pigman'/321, l='MpServer', x=33.50, y=35.00, z=80.50], EntityPigZombie['Zombie Pigman'/322, l='MpServer', x=40.19, y=37.00, z=92.50], EntityPigZombie['Zombie Pigman'/323, l='MpServer', x=33.50, y=35.00, z=82.50], EntityPigZombie['Zombie Pigman'/324, l='MpServer', x=34.50, y=78.00, z=92.76], EntityPigZombie['Zombie Pigman'/325, l='MpServer', x=43.50, y=37.00, z=109.50], EntityPigZombie['Zombie Pigman'/331, l='MpServer', x=2.50, y=107.00, z=87.50], EntityPigZombie['Zombie Pigman'/332, l='MpServer', x=39.50, y=34.00, z=68.50], EntityPigZombie['Zombie Pigman'/333, l='MpServer', x=39.50, y=34.00, z=69.50], EntityPigZombie['Zombie Pigman'/334, l='MpServer', x=45.22, y=38.00, z=72.50], EntityPigZombie['Zombie Pigman'/335, l='MpServer', x=33.50, y=35.00, z=79.50], EntityPigZombie['Zombie Pigman'/336, l='MpServer', x=20.76, y=79.00, z=89.50]]
        Retry entities: 0 total; []
        Server brand: fml,forge
        Server type: Integrated singleplayer server
    Stacktrace:
        at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:456)
        at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2774)
        at net.minecraft.client.Minecraft.run(Minecraft.java:436)
        at net.minecraft.client.main.Main.main(Main.java:118)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
        at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
        at GradleStart.main(GradleStart.java:26)

     

    The code in my item class for the sugar cane

    Spoiler
    
            netherReed = new ItemBlockSpecial(MoShizBlocks.netherReed).setUnlocalizedName("nether/netherReed").setRegistryName("nether/netherReed").setCreativeTab(MoShizMain.tabTest);

     

    And my Nether Reed block class

    Spoiler
    
    package com.ProfitOrange.moshiz.blocks.nether;
    
    import java.util.Random;
    import javax.annotation.Nullable;
    
    import com.ProfitOrange.moshiz.MoShizMain;
    import com.ProfitOrange.moshiz.init.MoShizBlocks;
    import com.ProfitOrange.moshiz.init.MoShizItems;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.SoundType;
    import net.minecraft.block.material.Material;
    import net.minecraft.block.properties.IProperty;
    import net.minecraft.block.properties.PropertyInteger;
    import net.minecraft.block.state.BlockStateContainer;
    import net.minecraft.block.state.IBlockState;
    import net.minecraft.init.Blocks;
    import net.minecraft.init.Items;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.BlockRenderLayer;
    import net.minecraft.util.EnumFacing;
    import net.minecraft.util.math.AxisAlignedBB;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
    import net.minecraftforge.common.EnumPlantType;
    import net.minecraftforge.common.IPlantable;
    import net.minecraftforge.fml.relauncher.Side;
    import net.minecraftforge.fml.relauncher.SideOnly;
    
    public class NetherReed extends Block implements IPlantable
    {
        public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 15);
        protected static final AxisAlignedBB REED_AABB = new AxisAlignedBB(0.125D, 0.0D, 0.125D, 0.875D, 1.0D, 0.875D);
    
        public NetherReed(String name)
        {
            super(Material.PLANTS);
            this.setUnlocalizedName(name);
            this.setRegistryName(name);
            this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)));
            this.setTickRandomly(true);
            this.blockSoundType = SoundType.PLANT;
            this.setCreativeTab(MoShizMain.tabGems);
            
        }
    
        public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
        {
            return REED_AABB;
        }
    
        public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
        {
            if (worldIn.getBlockState(pos.down()).getBlock() == MoShizBlocks.netherReed || this.checkForDrop(worldIn, pos, state))
            {
                if (worldIn.isAirBlock(pos.up()))
                {
                    int i;
    
                    for (i = 1; worldIn.getBlockState(pos.down(i)).getBlock() == this; ++i)
                    {
                        ;
                    }
    
                    if (i < 3)
                    {
                        int j = ((Integer)state.getValue(AGE)).intValue();
    
                        if(net.minecraftforge.common.ForgeHooks.onCropsGrowPre(worldIn, pos, state, true))
                        {
                        if (j == 15)
                        {
                            worldIn.setBlockState(pos.up(), this.getDefaultState());
                            worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(0)), 4);
                        }
                        else
                        {
                            worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(j + 1)), 4);
                        }
                        net.minecraftforge.common.ForgeHooks.onCropsGrowPost(worldIn, pos, state, worldIn.getBlockState(pos));
                        }
                    }
                }
            }
        }
    
        
        /*
        
        
        */
        public boolean canSustainPlants(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable)
        {
        	boolean isBeach = this == MoShizBlocks.netherSand || this == net.minecraft.init.Blocks.SOUL_SAND || this == net.minecraft.init.Blocks.NETHERRACK;
        	boolean hasWater = (world.getBlockState(pos.east()).getMaterial() == Material.LAVA ||
                            world.getBlockState(pos.west()).getMaterial() == Material.LAVA ||
                            world.getBlockState(pos.north()).getMaterial() == Material.LAVA ||
                            world.getBlockState(pos.south()).getMaterial() == Material.LAVA);
        	return isBeach && hasWater;
        }
        
        public boolean canPlaceBlockAt(World world, BlockPos pos)
        {
            IBlockState state = world.getBlockState(pos.down());
            Block block = state.getBlock();
            if (this.canSustainPlants(state, world, pos.down(), EnumFacing.UP, this)) 
            {
            	return true;
            }
    
            if (block == this)
            {
                return true;
            }
            else if (block != MoShizBlocks.netherSand && block != Blocks.SOUL_SAND && block != Blocks.NETHERRACK)
            {
                return false;
            }
            else
            {
                BlockPos blockpos = pos.down();
    
                for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
                {
                    IBlockState iblockstate = world.getBlockState(blockpos.offset(enumfacing));
    
                    if (iblockstate.getMaterial() == Material.LAVA)
                    {
                        return true;
                    }
                }
    
                return false;
            }
        }
    
        /**
         * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
         * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
         * block, etc.
         */
        public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
        {
            this.checkForDrop(worldIn, pos, state);
        }
    
        protected final boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state)
        {
            if (this.canBlockStay(worldIn, pos))
            {
                return true;
            }
            else
            {
                this.dropBlockAsItem(worldIn, pos, state, 0);
                worldIn.setBlockToAir(pos);
                return false;
            }
        }
    
        public boolean canBlockStay(World worldIn, BlockPos pos)
        {
            return this.canPlaceBlockAt(worldIn, pos);
        }
    
        @Nullable
        public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos)
        {
            return NULL_AABB;
        }
    
        /**
         * Get the Item that this Block should drop when harvested.
         */
        public Item getItemDropped(IBlockState state, Random rand, int fortune)
        {
            return MoShizItems.netherReed;
        }
    
        /**
         * Used to determine ambient occlusion and culling when rebuilding chunks for render
         */
        public boolean isOpaqueCube(IBlockState state)
        {
            return false;
        }
    
        public boolean isFullCube(IBlockState state)
        {
            return false;
        }
    
        public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
        {
            return new ItemStack(MoShizItems.netherReed);
        }
    
        /**
         * Convert the given metadata into a BlockState for this Block
         */
        public IBlockState getStateFromMeta(int meta)
        {
            return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta));
        }
    
        @SideOnly(Side.CLIENT)
        public BlockRenderLayer getBlockLayer()
        {
            return BlockRenderLayer.CUTOUT;
        }
    
        /**
         * Convert the BlockState into the correct metadata value
         */
        public int getMetaFromState(IBlockState state)
        {
            return ((Integer)state.getValue(AGE)).intValue();
        }
        
        
        /*
        @Override
        public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos)
        {
            return MoShizPlantType.NetherBeach;
        }
        */
        
        
        
        @Override
        public IBlockState getPlant(IBlockAccess world, BlockPos pos)
        {
            return this.getDefaultState();
        }
    
        protected BlockStateContainer createBlockState()
        {
            return new BlockStateContainer(this, new IProperty[] {AGE});
        }
    
    	@Override
    	public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos)
    	{
    		return net.minecraftforge.common.EnumPlantType.Nether;
    	}
        
        
    }

     

    I have the Nether Reed block to place and render correctly when using the block version of it, but the issue causes the game to crash as soon as I try placing the nether reed item.

  4. This is my food class right now:

     

    package com.ProfitOrange.moshiz.init;
    
    import com.ProfitOrange.moshiz.MoShizMain;
    import com.ProfitOrange.moshiz.Reference;
    
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.resources.model.ModelResourceLocation;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemFood;
    import net.minecraftforge.fml.common.registry.GameRegistry;
    
    public class MoShizFoods {
    
    
    
    public static Item beefSandwich;
    
    
    
    public static void init()
    {
    	beefSandwich = new ItemFood(8, 0.8F, false).setUnlocalizedName("beefSandwich").setCreativeTab(MoShizMain.tabGems);
    
    
    
    }
    
    public static void register()
    {
    	GameRegistry.registerItem(beefSandwich, beefSandwich.getUnlocalizedName().substring(5));
    
    
    }
    
    public static void registerRenders()
    {
    	registerRender(beefSandwich);
    
    
    }
    
    public static void registerRender(Item item)
    {
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));;
    }
    }

     

    Then my preInit method in my main class:

    @EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
    	MoShizFoods.init();
    	MoShizFoods.register();
    }

    In my ClientProxy class:

    @Override
    public void registerRenders()
    {
    	MoShizFoods.registerRenders();
    }

  5. It will look like an untextured block until the .JSON file is used to reference the texture.

     

    In your assets folder you need another folder called models, in the models folder you need a folder called item, place the Rubble.JSON file in that item folder.

  6. As of right now due to the sheer amount of JSON files I need to add into my mod, I was wondering on how to change the location of where the mod pulls the .JSON file from, I was able to figure out with the models/block, where it will call the files from models/block/gem. I want to be able to do the same with the models/item folder, where it would call food .JSON files from: models/item/food. That way I don't have 800+ .JSON files in one folder.

  7. I removed my old code in there. What I'm trying to ask, is how would I be able to call the class like this:

    public static Block BlackCobbleWall = new WallBlock(coloredcobble, 0).setBlockName("blackcobblewall");
    public static Block RedCobbleWall = new WallBlock(coloredcobble, 1).setBlockName("redcobblewall");
    public static Block GreenCobbleWall = new WallBlock(coloredcobble, 2).setBlockName("greencobblewall");

    And so on through the 16 colored blocks, I'm not trying to make metadata walls, I am trying to use the metadata colored cobble info to create each one of the walls, but the way they are set up by default, they don't have the ability to call metadata blocks

  8. Here is the WallBlock class:

    package net.minecraft.block;
    
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    
    import java.util.List;
    
    import com.ProfitOrange.moshiz.MoShizMain;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.client.renderer.texture.IIconRegister;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.init.Blocks;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.AxisAlignedBB;
    import net.minecraft.util.IIcon;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
    
    public class WallBlock extends BlockWall
    {
        private Block icon;
    public WallBlock(Block block)
        {
            super(block);
            this.setHardness(block.blockHardness);
            this.setResistance(block.blockResistance / 3.0F);
            this.setStepSound(block.stepSound);
            this.setCreativeTab(MoShizMain.tabDecor);
            this.icon = block;
        }
        
        @SideOnly(Side.CLIENT)
        public IIcon getIcon(int side, int meta)
        {
        	return icon.getBlockTextureFromSide(side);
        }
        
        @SideOnly(Side.CLIENT)
        public void getSubBlocks(Item item, CreativeTabs tab, List list)
        {
        	list.add(new ItemStack(item, 1, 0));
        }
    
        @SideOnly(Side.CLIENT)
        public void registerBlockIcons(IIconRegister icon) {}
        
        @Override
    public boolean canPlaceTorchOnTop(World world, int x, int y, int z) {
    	return true;
    }
    }

     

    Here is the constructor:

    public static Block ColoredCobblestoneWall = new WallBlock(coloredcobblestone).setBlockName("coloredcobblestonewall");

     

    I just wanted to be able to do something like this:

    public static Block ColoredCobblestoneWall = new WallBlock(coloredcobblestone, 1).setBlockName("coloredcobblestonewall");

     

    The 1 after the block being the metadata value for the colored cobblestone which would bring red, thus making a red cobblestone wall.

     

    I was able to get the Icons to show the correct cobblestone color, but when I placed it, it showed a black cobblestone wall, being 0 on the metadata

  9. Currently I have my WallBlock class set up so I can create walls by simply creating a constructor. When I tried creating them using my metadata colored cobblestone, I ran into a problem since Minecrafts BlockWall only uses Block, and doesn't have an integer like Minecrafts BlockStairs class does. I have had quite a bit of troubles with this, any help on the matter would be greatly appreciated.

  10. package com.ProfitOrange.armor;
    
    import com.ProfitOrange.moshiz.MoShizArmor;
    
    import cpw.mods.fml.common.eventhandler.SubscribeEvent;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.ItemArmor;
    import net.minecraft.item.ItemStack;
    import net.minecraft.potion.Potion;
    import net.minecraft.potion.PotionEffect;
    import net.minecraft.world.World;
    
    public class HellfireArmor extends ItemArmor {
    
    public HellfireArmor(ArmorMaterial par2EnumArmorMaterial, int par3, int par4) {
    	super(par2EnumArmorMaterial, par3, par4);
    }
    public String getArmorTexture(ItemStack itemstack, Entity entity, int slot, String type) {
    	if (itemstack.getItem() == MoShizArmor.HellfireHelmet || itemstack.getItem() == MoShizArmor.HellfireChest || itemstack.getItem() == MoShizArmor.HellfireBoots) {
    		return "moshiz:textures/model/armor/hellfire_layer_1.png";
    	}else if (itemstack.getItem() == MoShizArmor.HellfireLegs) {
    		return "moshiz:textures/model/armor/hellfire_layer_2.png";
    	}else{
    		return null;
    	}
    }
    
    public void onArmorTick(World world, EntityPlayer player, ItemStack itemstack){
    
    	int hellfire1=0,hellfire2=0,hellfire3=0,hellfire4=0;
    	if (player.getCurrentArmor(4)!=null){
    		ItemStack helmet=player.getCurrentArmor(4);
    		if(helmet.getItem()==MoShizArmor.HellfireHelmet){
    			hellfire1=1;
    		}
    		else{
    			hellfire1=0;
    		}
    	}
    	if (player.getCurrentArmor(3)!=null){
    		ItemStack chestplate=player.getCurrentArmor(3);
    		if(chestplate.getItem()==MoShizArmor.HellfireChest){
    			hellfire2=1;
    		}
    		else{
    			hellfire2=0;
    		}
    	}
    	if (player.getCurrentArmor(2)!=null){
    		ItemStack leggings=player.getCurrentArmor(2);
    		if(leggings.getItem()==MoShizArmor.HellfireLegs){
    			hellfire3=1;
    		}
    		else{
    			hellfire3=0;
    		}
    	}
    	if (player.getCurrentArmor(1)!=null){
    		ItemStack boots=player.getCurrentArmor(1);
    		if(boots.getItem()==MoShizArmor.HellfireBoots){
    			hellfire4=1;
    		}
    		else{
    			hellfire4=0;
    		}
    	}
    	if(hellfire1==1&&hellfire2==1&&hellfire3==1&&hellfire4==1){
    		player.addPotionEffect(new PotionEffect(Potion.fireResistance.getId(),5,0));
    	}
    }
    
    
    
    }

    Sorry for the confusion, I put the method in the armor class, as I saw other people doing it that way.

    And for the int thing, the code in there I wrote quite awhile ago and I'm not sure what I was thinking then.

    Here is the crash log:

     

    ---- Minecraft Crash Report ----

    // I let you down. Sorry :(

     

    Time: 6/25/14 10:52 AM

    Description: Ticking player

     

    java.lang.ArrayIndexOutOfBoundsException: 4

    at net.minecraft.entity.player.InventoryPlayer.armorItemInSlot(InventoryPlayer.java:693)

    at net.minecraft.entity.player.EntityPlayer.getCurrentArmor(EntityPlayer.java:2092)

    at com.ProfitOrange.armor.HellfireArmor.onArmorTick(HellfireArmor.java:32)

    at net.minecraft.entity.player.InventoryPlayer.decrementAnimations(InventoryPlayer.java:357)

    at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:625)

    at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1820)

    at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:342)

    at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:341)

    at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:326)

    at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37)

    at net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook.processPacket(C03PacketPlayer.java:271)

    at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232)

    at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)

    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:720)

    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:608)

    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)

    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)

    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:746)

     

     

    A detailed walkthrough of the error, its code path and all known details is as follows:

    ---------------------------------------------------------------------------------------

     

    -- Head --

    Stacktrace:

    at net.minecraft.entity.player.InventoryPlayer.armorItemInSlot(InventoryPlayer.java:693)

    at net.minecraft.entity.player.EntityPlayer.getCurrentArmor(EntityPlayer.java:2092)

    at com.ProfitOrange.armor.HellfireArmor.onArmorTick(HellfireArmor.java:32)

    at net.minecraft.entity.player.InventoryPlayer.decrementAnimations(InventoryPlayer.java:357)

    at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:625)

    at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1820)

    at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:342)

     

    -- Player being ticked --

    Details:

    Entity Type: null (net.minecraft.entity.player.EntityPlayerMP)

    Entity ID: 242

    Entity Name: Player733

    Entity's Exact location: 104.44, 70.00, 276.30

    Entity's Block location: World: (104,70,276), Chunk: (at 8,4,4 in 6,17; contains blocks 96,0,272 to 111,255,287), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)

    Entity's Momentum: 0.00, -0.08, 0.00

    Stacktrace:

    at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:341)

    at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:326)

    at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37)

    at net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook.processPacket(C03PacketPlayer.java:271)

    at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232)

     

    -- Ticking connection --

    Details:

    Connection: net.minecraft.network.NetworkManager@7812db78

    Stacktrace:

    at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)

    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:720)

    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:608)

    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)

    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)

    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:746)

     

    -- System Details --

    Details:

    Minecraft Version: 1.7.2

    Operating System: Windows 7 (amd64) version 6.1

    Java Version: 1.8.0_05, Oracle Corporation

    Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

    Memory: 922030232 bytes (879 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)

    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

    AABB Pool Size: 3122 (174832 bytes; 0 MB) allocated, 2863 (160328 bytes; 0 MB) used

    IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95

    FML: MCP v9.03 FML v7.2.211.1121 Minecraft Forge 10.12.2.1121 4 mods loaded, 4 mods active

    mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

    FML{7.2.211.1121} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.2.1121.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

    Forge{10.12.2.1121} [Minecraft Forge] (forgeSrc-1.7.2-10.12.2.1121.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

    Mo' Shiz{1.50} [Mo' Shiz] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

    Profiler Position: N/A (disabled)

    Vec3 Pool Size: 1201 (67256 bytes; 0 MB) allocated, 1187 (66472 bytes; 0 MB) used

    Player Count: 1 / 8; [EntityPlayerMP['Player733'/242, l='Modded World', x=104.44, y=70.00, z=276.30]]

    Type: Integrated Server (map_client.txt)

    Is Modded: Definitely; Client brand changed to 'fml,forge'

     

  11. In 1.6.4 I used the ITickHandler to add potion effects, only if the player is currently wearing all the armor. Here is my code that I have tried to implement, yet it throws up an out of bounds array error:

    public void onArmorTick(World world, EntityPlayer player, ItemStack itemstack){
    
    	int hellfire1=0,hellfire2=0,hellfire3=0,hellfire4=0;
    	if (player.getCurrentArmor(4)!=null){
    		ItemStack helmet=player.getCurrentArmor(4);
    		if(helmet.getItem()==MoShizArmor.HellfireHelmet){
    			hellfire1=1;
    		}
    		else{
    			hellfire1=0;
    		}
    	}
    	if (player.getCurrentArmor(3)!=null){
    		ItemStack chestplate=player.getCurrentArmor(3);
    		if(chestplate.getItem()==MoShizArmor.HellfireChest){
    			hellfire2=1;
    		}
    		else{
    			hellfire2=0;
    		}
    	}
    	if (player.getCurrentArmor(2)!=null){
    		ItemStack leggings=player.getCurrentArmor(2);
    		if(leggings.getItem()==MoShizArmor.HellfireLegs){
    			hellfire3=1;
    		}
    		else{
    			hellfire3=0;
    		}
    	}
    	if (player.getCurrentArmor(1)!=null){
    		ItemStack boots=player.getCurrentArmor(1);
    		if(boots.getItem()==MoShizArmor.HellfireBoots){
    			hellfire4=1;
    		}
    		else{
    			hellfire4=0;
    		}
    	}
    	if(hellfire1==1&&hellfire2==1&&hellfire3==1&&hellfire4==1){
    		player.addPotionEffect(new PotionEffect(Potion.fireResistance.getId(),5,0));
    	}
    }

×
×
  • Create New...

Important Information

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