WildHeart
-
Posts
236 -
Joined
-
Last visited
Posts posted by WildHeart
-
-
5 minutes ago, diesieben07 said:
Blocks that need their metadata in the inventory need to use ItemMultiTexture or a custom ItemBlock class instead of ItemBlock.
With the blocks in the inventory no problem, the problem is that when I put the block of its variants remains the same as the first block.
-
Hi, there is one block with a meta tag from 1-15, is to take in hand this block it shows as it should, but if you put it in the variable variants shows the registered name of the block. How to fix?
Spoilerpublic class BlockCulture extends Block { public static final PropertyEnum<HarvestType> VARIANT = PropertyEnum.create("variant", HarvestType.class); public BlockCulture(String name) { super(Material.WOOD); this.setRegistryName(name); this.setUnlocalizedName(name); this.setCreativeTab(Farmland.FMCT); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, HarvestType.BEAN)); } @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) { for(HarvestType seedsDoubleType : HarvestType.values()) { list.add(new ItemStack(itemIn, 1, seedsDoubleType.getMeta())); } } @Override public int damageDropped(IBlockState state) { return state.getValue(VARIANT).getMeta(); } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(VARIANT, HarvestType.byMetadata(meta)); } @Override public int getMetaFromState(IBlockState state) { return state.getValue(VARIANT).getMeta(); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {VARIANT}); } }
-
Solved!
@SubscribeEvent public void onDrop(BlockEvent.HarvestDropsEvent e) { if(!e.getWorld().isRemote) { if(e.getWorld().getBlockState(e.getPos()).getBlock() instanceof BlockLeaves) { e.getDrops().removeIf(itemStack -> itemStack == null || itemStack.getItem() == Items.APPLE); } } }
-
Solved
@Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta & 3)).withProperty(BARREL, Boolean.valueOf((meta & 8) > 0)).withProperty(SPIGOT, Boolean.valueOf((meta & 4) > 0)); } @Override public int getMetaFromState(IBlockState state) { int i = 0; i = i | state.getValue(FACING).getHorizontalIndex(); if(state.getValue(BARREL).booleanValue()) { i |= 8; } if(state.getValue(SPIGOT).booleanValue()) { i |= 4; } return i; }
-
3 hours ago, Draco18s said:
Нет, то, что вам нужно сделать, это извлечь 2 бита метаданных.
EnumFacing.getHorizontal(Мета&3)
Where you can read more about metadata for blocks?
-
18 minutes ago, Draco18s said:
return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta))
This line won't work if meta > 4 (which BARREL and SPIGOT make it be)
Then I need not to take EnumFacing.getHorizontal, to do it my way?
-
Hello, i have a problem. If you arrange the blocks to the North or to the East after rejoining the game, everything is fine, but if placed on a South or West some of the blocks shifted. What could be the problem?
Spoilerpublic class BlockStand extends BlockSide { public static final PropertyBool BARREL = PropertyBool.create("barrel"), UPPER = PropertyBool.create("upper"), SPIGOT = PropertyBool.create("spigot"); protected static final AxisAlignedBB[] SIDE_AABB = new AxisAlignedBB[] {new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 1.0D, 0.9375D), new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 1.0D, 0.9375D), new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 1.0D, 0.9375D), new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 1.0D, 0.9375D)}; public BlockStand(String name) { super(name, Material.WOOD, SIDE_AABB); this.setHardness(1.2F); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(BARREL, false).withProperty(UPPER, false).withProperty(SPIGOT, false)); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if(!worldIn.isRemote) { if(playerIn.getHeldItem(hand).getItem() == Item.getItemFromBlock(BlocksRegister.BARREL) || playerIn.getHeldItem(hand).getItem() == ItemsRegister.SPIGOT) { if(state.getValue(BARREL) && !state.getValue(SPIGOT) && playerIn.getHeldItem(hand).getItem() != Item.getItemFromBlock(BlocksRegister.BARREL)) { worldIn.setBlockState(pos, state.withProperty(SPIGOT, true), 4); if(!playerIn.isCreative()) playerIn.getHeldItem(hand).shrink(1); } else if(!state.getValue(BARREL) && playerIn.getHeldItem(hand).getItem() != ItemsRegister.SPIGOT) { worldIn.setBlockState(pos, state.withProperty(BARREL, true), 4); if(!playerIn.isCreative()) playerIn.getHeldItem(hand).shrink(1); } } else if(playerIn.getHeldItem(hand).getItem().getContainerItem() == null || playerIn.getHeldItem(hand).getItem() == null) { if(playerIn.isSneaking()) { if(state.getValue(SPIGOT)) { worldIn.setBlockState(pos, state.withProperty(SPIGOT, false), 4); if(!playerIn.isCreative()) playerIn.inventory.addItemStackToInventory(new ItemStack(ItemsRegister.SPIGOT)); } } else { if(state.getValue(BARREL) && state.getValue(SPIGOT)) { worldIn.setBlockState(pos, state.withProperty(BARREL, false).withProperty(SPIGOT, false), 4); if(!playerIn.isCreative()) { worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ItemsRegister.SPIGOT))); worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(BlocksRegister.BARREL))); } } if(state.getValue(BARREL) && !state.getValue(SPIGOT)) { worldIn.setBlockState(pos, state.withProperty(BARREL, false), 4); if(!playerIn.isCreative()) worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(BlocksRegister.BARREL))); } } } } return true; } @Override public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune) { super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune); if(state.getValue(BARREL) && state.getValue(SPIGOT)) { worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ItemsRegister.SPIGOT))); worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(BlocksRegister.BARREL))); } else if(state.getValue(BARREL) && !state.getValue(SPIGOT)) { worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(BlocksRegister.BARREL))); } } @Override public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) { tooltip.add(ChatFormatting.GOLD + I18n.format("tooltip.stand.line_1")); tooltip.add(ChatFormatting.GOLD + I18n.format("tooltip.stand.line_2")); } @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { Block block = worldIn.getBlockState(pos.up()).getBlock(); return state.withProperty(UPPER, Boolean.valueOf(block != Blocks.AIR)); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {FACING, BARREL, UPPER, SPIGOT}); } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta)).withProperty(BARREL, Boolean.valueOf((meta & 8) > 0)).withProperty(SPIGOT, Boolean.valueOf((meta & 4) > 0)); } @Override public int getMetaFromState(IBlockState state) { int i = 0; i = i | state.getValue(FACING).getIndex(); if(state.getValue(BARREL).booleanValue()) { i |= 8; } if(state.getValue(SPIGOT).booleanValue()) { i |= 4; } return i; } }
BlockSide:
Spoilerpublic class BlockSide extends BlockHorizontal { private AxisAlignedBB[] SIDE_AABB; public BlockSide(String name, Material material, AxisAlignedBB[] aabb) { super(material); this.setRegistryName(name); this.setUnlocalizedName(name); this.setCreativeTab(Farmland.FMCT); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); this.SIDE_AABB = aabb; } @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { switch (state.getValue(FACING)) { case SOUTH: return this.SIDE_AABB[0]; case NORTH: default: return this.SIDE_AABB[1]; case WEST: return this.SIDE_AABB[2]; case EAST: return this.SIDE_AABB[3]; } } @Override public boolean isFullCube(IBlockState state) { return false; } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate(state.getValue(FACING))); } @Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation(state.getValue(FACING))); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { EnumFacing enumfacing = EnumFacing.fromAngle((double)placer.rotationYaw); worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2); } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta)); } @Override public int getMetaFromState(IBlockState state) { int i = 0; i = i | state.getValue(FACING).getHorizontalIndex(); return i; } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {FACING}); } }
-
3 minutes ago, Draco18s said:
ModelLoader.setCustomModelResourceLocation(item, metadata, modelResourceLocation);
Hmm...
Oh, I forgot to unsubscribe that everything is found and made their own, but thanks anyway! Close topic.
-
Hello, I did the thing which has metadata, about 12 pieces. How now quickly register the renderer(in addition to the creation of a new render with the change of parameter meta)?
-
Worked, thank you!
-
5 minutes ago, diesieben07 said:
If you are using the default state mapper, those variants will never exist. The default state mapper orders properties a-z, so facing must come before juice_level.
Wow, didn't know that everything is so thoughtfully. I'll try to move.
-
Hello, there is a model Collector resin and I'm trying to do, that he was raised in the opinion of the player, but there is a problem. When done, the model stops working. In the console and logs nothing.
Code:
Spoilerpublic class BlockCollector extends BlockHorizontal { public static final PropertyInteger LEVEL = PropertyInteger.create("juice_level", 0, 3); protected static final AxisAlignedBB COLLECTOR_EAST_AABB = new AxisAlignedBB(0.6875D, 0.4375D, 0.375D, 0.9375D, 0.75D, 0.625D), COLLECTOR_WEST_AABB = new AxisAlignedBB(0.0625D, 0.4375D, 0.375D, 0.625D, 0.75D, 0.3125D), COLLECTOR_NORTH_AABB = new AxisAlignedBB(0.375D, 0.4375D, 0.0625D, 0.625D, 0.75D, 0.3125D), COLLECTOR_SOUTH_AABB = new AxisAlignedBB(0.375D, 0.4375D, 0.6875D, 0.625D, 0.75D, 0.9375D); public BlockCollector(String name) { super(Material.WOOD); this.setRegistryName(name); this.setUnlocalizedName(name); this.setCreativeTab(Farmland.FMCT); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(LEVEL, Integer.valueOf(0))); } @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { switch ((EnumFacing)state.getValue(FACING)) { case SOUTH: return COLLECTOR_SOUTH_AABB; case NORTH: default: return COLLECTOR_NORTH_AABB; case WEST: return COLLECTOR_WEST_AABB; case EAST: return COLLECTOR_EAST_AABB; } } @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 public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { EnumFacing enumfacing = EnumFacing.fromAngle((double)placer.rotationYaw); worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2); } @Override public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { if (!facing.getAxis().isHorizontal()) { facing = EnumFacing.NORTH; } return this.getDefaultState().withProperty(FACING, facing.getOpposite()).withProperty(LEVEL, Integer.valueOf(0)); } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public boolean isFullCube(IBlockState state) { return false; } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta)).withProperty(LEVEL, Integer.valueOf((meta & 15) >> 2)); } @Override public int getMetaFromState(IBlockState state) { int i = 0; i = i | ((EnumFacing)state.getValue(FACING)).getHorizontalIndex(); i = i | ((Integer)state.getValue(LEVEL)).intValue() << 2; return i; } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {LEVEL, FACING}); } }
Blockstates:
Spoiler{ "variants": { "juice_level=0,facing=south": { "model": "fm:collector" }, "juice_level=0,facing=west": { "model": "fm:collector", "y": 90 }, "juice_level=0,facing=north": { "model": "fm:collector", "y": 180 }, "juice_level=0,facing=east": { "model": "fm:collector", "y": 270 }, "juice_level=1,facing=south": { "model": "fm:collector" }, "juice_level=1,facing=west": { "model": "fm:collector", "y": 90 }, "juice_level=1,facing=north": { "model": "fm:collector", "y": 180 }, "juice_level=1,facing=east": { "model": "fm:collector", "y": 270 }, "juice_level=2,facing=south": { "model": "fm:collector" }, "juice_level=2,facing=west": { "model": "fm:collector", "y": 90 }, "juice_level=2,facing=north": { "model": "fm:collector", "y": 180 }, "juice_level=2,facing=east": { "model": "fm:collector", "y": 270 }, "juice_level=3,facing=south": { "model": "fm:collector" }, "juice_level=3,facing=west": { "model": "fm:collector", "y": 90 }, "juice_level=3,facing=north": { "model": "fm:collector", "y": 180 }, "juice_level=3,facing=east": { "model": "fm:collector", "y": 270 } } }
Please help.
-
while (apples.hasNext()) { if(apples.next() instanceof ItemFood) { apples.remove(); } }
?
-
13 minutes ago, Draco18s said:
Maybe?:
if(e.getWorld().getBlockState(e.getPos()).getBlock() instanceof BlockLeaves) { Iterator apples = e.getDrops().iterator(); while (apples.hasNext()) { if(e.getDrops() instanceof ItemFood) { e.setCanceled(true); break; } } }
-
Hmm, now how to remove specifically apples?
@SubscribeEvent public void onDrop(BlockEvent.HarvestDropsEvent e) { if(e.getWorld().isRemote) return; if(e.getWorld().getBlockState(e.getPos()).getBlock() instanceof BlockLeaves) { e.getDrops() } }
-
Hello, how to remove drop from the leaves?
@SubscribeEvent public void onDrop(LivingDropsEvent e) { if(e.getEntity().worldObj.isRemote) return; for(EntityItem entityItem : e.getDrops()) { if(entityItem.getEntityItem().getItem() instanceof ItemFood) { if(entityItem.getEntityItem().getItem() == Items.APPLE) { } } } }
-
I rewrite mod is not a veteran of older versions, and as a modern encoder for 1.8+ versions. Ie I with 1.6.4 and below was not working for me remains a mystery packets that I threw and buildcraft api which has changed over time.
-
Hello, I rewrite my mod to a newer version and faced the problem. What is replaced by this package: Packet250CustomPayload?
And now a question for those who are versed in buildcraft. What now comes as a replacement for these classes: IPowerReceptor, PowerHandler, PowerReceiver and etc?
-
10 hours ago, diesieben07 said:
Am I understanding you correctly in that you are porting a 1.6.4 mod to 1.7.10? If so, you should update to 1.11.x.
You can find the documentation for custom packets here.
Yes, you correctly understood me, but the fact that I use a bunch of servers with mods and plugins. I.e. Cauldron. The version of my project is 1.7.10. Once the sponge will be released in a stable state, I'll update all to the latest versions. In the meantime, I would like to know the solution for 1.7.10 version, thank you!
-
Started to port the old fashion for my project, but I ran into a problem. Packet250CustomPayload what is the replacement for this package in titleentity?
-
1 hour ago, diesieben07 said:
Same answer.
So, I did what you wanted and works as I need. What did I do? I started using getActualState checking the block on the bottom. Finally works as I intended. Special thanks to diesieben07 for your help and nerves of steel. I will continue to explore Properties, in order not to ask such questions, thanks to all!
-
21 minutes ago, diesieben07 said:
No. You need to learn bitwise operators.
Begin to understand mc code I found this code. He in fact is the answer to my question?
/** * Convert the given metadata into a BlockState for this Block */ public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(FACING, EnumFacing.getFront(meta & 7)).withProperty(NODROP, Boolean.valueOf((meta & 8) > 0)); } /** * Convert the BlockState into the correct metadata value */ public int getMetaFromState(IBlockState state) { int i = 0; i = i | ((EnumFacing)state.getValue(FACING)).getIndex(); if (((Boolean)state.getValue(NODROP)).booleanValue()) { i |= 8; } return i; }
-
Forgot to say, I changed the age. Now he is 4 instead of 8.
-
10 minutes ago, diesieben07 said:
That will not work, now you only save the HALF property. You need to save both HALF and AGE.
Right?
@Override public IBlockState getStateFromMeta(int meta) { return getDefaultState().withProperty(HALF, meta == 0 ? EnumCropHalf.LOWER : EnumCropHalf.UPPER).withProperty(AGE_DOUBLE, Integer.valueOf(meta)); } @Override public int getMetaFromState(IBlockState state) { EnumCropHalf type = state.getValue(HALF); return type.getMeta() & ((Integer)state.getValue(AGE_DOUBLE)).intValue(); }
[Solved][1.11] Block Variants.
in Modder Support
Posted
So it turns out I need to write my ItemBlock nbt storage, and to store the meta for each block there?