• Recently Browsing

    No registered users viewing this page.

  • Posts

    • Here is the new topic.
    • You could copy the EFFECTIVE_ON field from AxeItem, ShovelItem or PickaxeItem and pass it into the ToolType constructor, or if you're super paranoid like me, use some reflection or AT's to get direct access to the field so you don't have to copy Mojang's code.
    • I went through the tedious process of removing the mods one by one and for some reason the mod "Just Another Quarry Mod" (Jaqm) caused the players not being able to join.
    • So I have a custom plant that works perfectly normally when placed, and I can interact with it perfectly fine, and it renders just fine. This block has a custom blockstate called isflowered, when the player right clicks the plant the little fruit is removed. By default the fruit is always there when placed. However, when I go to generate this block when subscribed to the biome decoration event, this happens:   The block on the left is one I placed from the inventory, and the janky ones are the ones generated by the biome decoration event. I can still interact with the block, if I right click it it performs the effect that it's supposed to (it makes a slime sound and drops an item).   So two things that went wrong:   1. The block obviously doesn't render properly   2. The block disappears when I save and exit the game, and randomly shows up here and there.   Anyone have any idea what it might be?   The event: @SubscribeEvent public void onBiomeDecorate(DecorateBiomeEvent.Pre event) { World world = event.getWorld(); Biome biome = world.getBiomeForCoordsBody(event.getPos()); Random rand = event.getRand(); if (rand.nextDouble() > 0.1) return; int x = rand.nextInt(16) + 8; int y = rand.nextInt(16) + 8; WorldGenRepitifleur gen = new WorldGenRepitifleur(); gen.generate(world, rand, world.getHeight(event.getPos().add(x, 0, y))); }   The generator: public class WorldGenRepitifleur extends WorldGenerator { public WorldGenRepitifleur() {} @Override public boolean generate(World worldIn, Random rand, BlockPos position) { BlockRepitifleur tPlant = new BlockRepitifleur(); for (int i = 0; i < 64; ++i) { BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8)); if (worldIn.isAirBlock(blockpos) && (!worldIn.provider.isNether() || blockpos.getY() < 255) && tPlant.canBlockStay(worldIn, blockpos, tPlant.getDefaultState())) { worldIn.setBlockState(blockpos, tPlant.getDefaultState(), 2); } } return true; } }   and the block: public class BlockRepitifleur extends BlockBush { public static final PropertyInteger IS_FLOWERED = PropertyInteger.create("isflowered", 0, 1); public BlockRepitifleur() { super(Material.PLANTS); this.setRegistryName("repitifleur"); this.setDefaultState(this.blockState.getBaseState().withProperty(IS_FLOWERED, Integer.valueOf(1))); this.setCreativeTab(CreativeTabs.DECORATIONS); this.setUnlocalizedName("repitifleur"); this.setTickRandomly(true); this.setSoundType(SoundType.PLANT); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (state.getValue(IS_FLOWERED) == 0) { worldIn.setBlockState(pos, state.withProperty(IS_FLOWERED, Integer.valueOf(1)), 3); if (playerIn.world.isRemote) { PlayerData data = (PlayerData) NecropolisPlayerData.get(playerIn); data.setPlayerStamina(400); playerIn.playSound(SoundEvents.BLOCK_SLIME_BREAK, 0.6F, 1.0F); return true; } playerIn.playSound(SoundEvents.BLOCK_SLIME_BREAK, 0.6F, 1.0F); } return true; } public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { super.updateTick(worldIn, pos, state, rand); if (!worldIn.isAreaLoaded(pos, 1)) return; if (state.getValue(IS_FLOWERED) == 1) { if (worldIn.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(3) == 0) { worldIn.setBlockState(pos, state.withProperty(IS_FLOWERED, Integer.valueOf(0)), 3); } } } @Override public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { IBlockState soil = worldIn.getBlockState(pos.down()); return super.canPlaceBlockAt(worldIn, pos) && this.canSustainBush(soil); } @Override protected boolean canSustainBush(IBlockState state) { return state.getBlock() == Blocks.GRASS; } @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return null; } @Override public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack) { if (worldIn.isRemote) return; if (stack.getItem() == Items.SHEARS && state.getValue(IS_FLOWERED) == 0) { player.addStat(StatList.getBlockStats(this)); worldIn.setBlockToAir(pos); spawnAsEntity(worldIn, pos, new ItemStack(BlockHandler.REPITIFLEUR, 1)); } else { return; //super.harvestBlock(worldIn, player, pos, state, te, stack); } } @Nullable public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { return NULL_AABB; } @Override public boolean canPlaceTorchOnTop(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT_MIPPED; } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {IS_FLOWERED}); } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(IS_FLOWERED, Integer.valueOf(meta)); } @Override public int getMetaFromState(IBlockState state) { return ((Integer)state.getValue(IS_FLOWERED)).intValue(); } public IBlockState getPlantState() { return this.blockState.getBaseState().withProperty(IS_FLOWERED, Integer.valueOf(1)); } @Override public boolean isFullCube(IBlockState state) { return false; } }  
    • So my goal is to make a item that can random into other item that I made when player rightclick on it So I create class (which is item) that have random generator of with list of item (it also other item that I made) I want it to become by using  int rand = generator.nextInt then I try to code when player rightclick on item it will start doing random then pick a item from "rand" then put in player inventory public void onItemRightClick(World worldIn, PlayerEntity player, Hand handIn) but after this code I stuck because I don't know which code or how should I use  I try using player.addItemtoInventory or dropItem which seem to require ItemStack in () instead, so I try create new class and put same rand code in it, but it seem to can only pick one of item instead of full of item list to do random so I have no idea anymore what I supported to do I need really advice on this ps. my reference also 1.12.2 version so I encounter lot of problem even if try to copy it as well
  • Topics

  • Who's Online (See full list)