Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Yamahari

Members
  • Posts

    47
  • Joined

  • Last visited

Everything posted by Yamahari

  1. Omg this actually fixed it, thanks! ( You have no idea how hard I tried to fix this, I think I lost 50% of my hair ) @Override public boolean isReplaceable(BlockState blockStateIn, BlockItemUseContext blockItemUseContextIn) { //return blockItemUseContextIn.getItem().getItem() == this.asItem(); for(Block block : Constants.SCAFFOLDINGS) { if(blockItemUseContextIn.getItem().getItem() == Item.getItemFromBlock(block)) return true; } return false; } My question now is, why did this fix this, I don't get it
  2. Normally I wait until mapping catch up, but I want help so I updated the names as far as I could without intentionally changing the meaning ( I hope )
  3. Hi, I made a custom scaffolding block and a corresponding item class that you can have a look at here: https://github.com/Yamahari/ILikeWood/blob/master/src/main/java/yamahari/ilikewood/blocks/WoodenScaffoldingBlock.java https://github.com/Yamahari/ILikeWood/blob/master/src/main/java/yamahari/ilikewood/items/WoodenScaffoldingItem.java My issue is the following: https://imgur.com/jdwOKtN Basically when I try to place a scaffolding block that is not of the same wood type as the block I aimed at, the autostacking feature doesn't work. I tracked it down to the following issue: When I use the "appropiate" scaffolding the "getBlockItemUseContext" method of my custom item is called with a BlockItemUseContext that has the position of the scaffolding block I aimed at. But if I use another wood type the function gets called with a context that contains the block that is one block off in the direction of the face I was aiming at, e.g. in the video that's an air block. This causes my "instanceof" checks in the "getBlockItemUseContext" method to fail. But I can't figure out why it's not passing the scaffolding block position in the context when it's a different wood type. Does BlockItem somehow change the logic of chosing the forwarded block position depending on whether or not the used item corresponds to the block that was registered to the BlockItem?
  4. oh yea and forget that part in onRegisterTileEntity, that was me trying to fix it for myself but that line crashes the game
  5. there are no 1.14 versions of these mods, where did you get them from
  6. Here's the github if you wanna take a look https://github.com/Yamahari/ILikeWood
  7. there's no related code but what I already mentioned for(String wood : new String[]{"oak", "dark_oak", "spruce", "birch", "jungle", "acacia"}) { event.getRegistry().register(new BarrelBlock( Block.Properties.create(Material.WOOD).hardnessAndResistance(2.5f).sound(SoundType.WOOD)).setRegistryName(wood + "_barrel")); } and the appropiate BlockItems in register Items. My guess it's some issue between client and server, but I have never worked with containers so I have no idea what to do.
  8. Hi, I am trying to make a custom barrel block. So i registered a new instance of BarrelBlock and setup all the models etc. correctly. My block appears in-game and if I click it a GUI shows up. BUT, if I put items in the barrel they disappear and if I close the GUI the barrel stays in the "open" state. ( the lid is open ). I am sure I forgot something but I don't know what. Any ideas
  9. In my case, on 1.12.2 Forge didn't create a launcher profile, I had to make a new profile and select the version if Forge I just installed
  10. Hm, just as I say that I think I got it. The event is not called with the position of the stem but the position of the melon/pumpkin. Why? Now that's gonna be annoying to fix. Is this intentional? Because the same code works as intented on 1.13.2
  11. Hi, I have this event handler @SubscribeEvent public static void onCropGrowPost(final BlockEvent.CropGrowEvent.Post event) { World world = event.getWorld(); IBlockState blockState = event.getState(); Block block = blockState.getBlock(); BlockPos pos = event.getPos(); if(block instanceof BlockCrops) { int age = blockState.getValue(((BlockCrops) block).AGE); int maxAge = ((BlockCrops) block).getMaxAge(); if (age == maxAge) { IBlockState soil = world.getBlockState(pos.down()); Block soilBlock = soil.getBlock(); if (soilBlock == BlockList.dry_farmland) { if(!world.isRemote) world.setBlockState(pos.down(), soil.withProperty(((BlockDryFarmland) soilBlock).getNutrition(), Boolean.valueOf(false)),1 | 2); } } else if (block != BlockList.weeds) { if (world.rand.nextInt(10) == 0) { if(!world.isRemote) world.setBlockState(pos, BlockList.weeds.getDefaultState().withProperty(((BlockCrops) block).AGE, (int)Math.floor(((float)age / (float)maxAge) * 7.f)), 1 | 2); } } } else if (block instanceof BlockStem) { if (blockState.getValue(((BlockStem) block).AGE) == 7) { IBlockState soil = world.getBlockState(pos.down()); Block soilBlock = soil.getBlock(); if (soilBlock == BlockList.dry_farmland) { if(!world.isRemote) world.setBlockState(pos.down(), soil.withProperty(((BlockDryFarmland) soilBlock).getNutrition(), Boolean.valueOf(false)), 1 | 2); } } } event.setResult(Event.Result.DEFAULT); } But for some reason stems only reset the nutrition of my custom farmland block when they grow to age 7, not when they grow a fruit. Does anyone know why?
  12. In java "==" does mean something different than in other languages, "==" compares if both references reference the same instance, if you wanna compare if 2 objects are equal, you can use .equals() method or as provided by Forge a reference to the registered Item/Block in Items.<name of block>, Blocks.<name of block> ( note that as pointed out by @TheOnlyTrueEnte you can use == here because the getItem() method you're using returns a reference to some item in Items or your custom item list not a new instance of that item)
  13. i tried overwriting the farmland block in 1.13.2 with the result of an runtime exception - illegal vanilla overwrite or smth like that, changed my code since then don't remember exactly
  14. this seems to have done the trick IBlockState blockState = this.entityWorld.getBlockState(new BlockPos(this.soilMakerEntity.posX, Math.ceil(this.soilMakerEntity.posY), this.soilMakerEntity.posZ).down()); BlockPos pos = new BlockPos(this.soilMakerEntity.posX, Math.ceil(this.soilMakerEntity.posY), this.soilMakerEntity.posZ).down(); thanks!
  15. That helped thanks! Because farmland is not a full block the position checked is actually the block below the farmland! Now a good question is how do I fix that x)
  16. Hi, I have this AI task package yamahari.weeds.entities.ai; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.util.Constants; import net.minecraftforge.event.ForgeEventFactory; import yamahari.weeds.blocks.BlockDryFarmland; import yamahari.weeds.lists.BlockList; public class EntityAIMakeSoil extends EntityAIBase { private final EntityLiving soilMakerEntity; private final World entityWorld; private int makingSoilTimer; public EntityAIMakeSoil(EntityLiving soilMakerEntity) { this.soilMakerEntity = soilMakerEntity; this.entityWorld = soilMakerEntity.world; this.setMutexBits(7); } @Override public boolean shouldExecute() { if(this.soilMakerEntity.getRNG().nextInt(this.soilMakerEntity.isChild() ? 100 : 200) == 0) { IBlockState blockState = this.entityWorld.getBlockState(this.soilMakerEntity.getPosition().down()); Block block = blockState.getBlock(); return block == Blocks.GRASS_BLOCK || block == Blocks.DIRT || block == BlockList.dry_farmland || block == Blocks.COARSE_DIRT; } return false; } @Override public void startExecuting() { this.makingSoilTimer = 40; this.soilMakerEntity.getNavigator().clearPath(); } @Override public void resetTask() { this.makingSoilTimer = 0; } @Override public boolean shouldContinueExecuting() { return this.makingSoilTimer > 0; } public int getMakingSoilTimer() { return this.makingSoilTimer; } @Override public void tick() { this.makingSoilTimer = Math.max(0, this.makingSoilTimer - 1); if(this.makingSoilTimer == 4) { BlockPos pos = new BlockPos(this.soilMakerEntity).down(); IBlockState blockState = this.entityWorld.getBlockState(pos); if(ForgeEventFactory.getMobGriefingEvent(this.entityWorld, this.soilMakerEntity)) { if(blockState.getBlock() == Blocks.GRASS_BLOCK || blockState.getBlock() == Blocks.DIRT) { this.entityWorld.playEvent(Constants.WorldEvents.BREAK_BLOCK_EFFECTS, pos, Block.getStateId(blockState.getBlock().getDefaultState())); this.entityWorld.setBlockState(pos, BlockList.dry_farmland.getDefaultState(), Constants.BlockFlags.NOTIFY_LISTENERS); } else if(blockState.getBlock() == Blocks.COARSE_DIRT) { this.entityWorld.playEvent(Constants.WorldEvents.BREAK_BLOCK_EFFECTS, pos, Block.getStateId(blockState.getBlock().getDefaultState())); this.entityWorld.setBlockState(pos, Blocks.DIRT.getDefaultState(), Constants.BlockFlags.NOTIFY_LISTENERS); } else if(blockState.getBlock() == BlockList.dry_farmland && !blockState.get(((BlockDryFarmland) blockState.getBlock()).getNutrition())) { this.entityWorld.playEvent(Constants.WorldEvents.BREAK_BLOCK_EFFECTS, pos, Block.getStateId(blockState.getBlock().getDefaultState())); this.entityWorld.setBlockState(pos, blockState.with(((BlockDryFarmland) blockState.getBlock()).getNutrition(), Boolean.valueOf(true)), Constants.BlockFlags.NOTIFY_LISTENERS); } } } } } that is attached to pigs when they spawn. It works like the EatGrass AI task for sheeps, but it turns dirt/grass block into my farmblock with no nutrition, and my farmblock with no nutrition into one with nutrition. Everything seems to work like I want it to but for some reason the first case if(blockState.getBlock() == Blocks.GRASS_BLOCK || blockState.getBlock() == Blocks.DIRT) { this.entityWorld.playEvent(Constants.WorldEvents.BREAK_BLOCK_EFFECTS, pos, Block.getStateId(blockState.getBlock().getDefaultState())); this.entityWorld.setBlockState(pos, BlockList.dry_farmland.getDefaultState(), Constants.BlockFlags.NOTIFY_LISTENERS); } is called often even though the pig is not standing on dirt, you can just hear the sound playing. It's not caused by trampling the underlying farmland, I tried that already.
  17. ah, so there's no point in calling this in my AI task that is attached to a EntityPig public class EntityAIMakeSoil extends EntityAIBase { private final EntityLiving soilMakerEntity; private final World entityWorld; private int makingSoilTimer; public EntityAIMakeSoil(EntityLiving soilMakerEntity) { this.soilMakerEntity = soilMakerEntity; this.entityWorld = soilMakerEntity.world; this.setMutexBits(7); } @Override public boolean shouldExecute() { if(this.soilMakerEntity.getRNG().nextInt(this.soilMakerEntity.isChild() ? 100 : 200) == 0) { Block block = this.entityWorld.getBlockState(this.soilMakerEntity.getPosition().down()).getBlock(); return block == Blocks.GRASS_BLOCK || block == Blocks.DIRT || block == BlockList.dry_farmland || block == Blocks.COARSE_DIRT; } return false; } @Override public void startExecuting() { this.makingSoilTimer = 40; this.entityWorld.setEntityState(this.soilMakerEntity, (byte)10); this.soilMakerEntity.getNavigator().clearPath(); } @Override public void resetTask() { this.makingSoilTimer = 0; } @Override public boolean shouldContinueExecuting() { return this.makingSoilTimer > 0; } public int getMakingSoilTimer() { return this.makingSoilTimer; } @Override public void tick() { this.makingSoilTimer = Math.max(0, this.makingSoilTimer - 1); if(this.makingSoilTimer == 4) { BlockPos pos = new BlockPos(this.soilMakerEntity).down(); IBlockState blockState = this.entityWorld.getBlockState(pos); if(ForgeEventFactory.getMobGriefingEvent(this.entityWorld, this.soilMakerEntity)) { if(blockState.getBlock() == Blocks.GRASS_BLOCK || blockState.getBlock() == Blocks.DIRT) { this.entityWorld.playEvent(Constants.WorldEvents.BREAK_BLOCK_EFFECTS, pos, Block.getStateId(blockState.getBlock().getDefaultState())); this.entityWorld.setBlockState(pos, BlockList.dry_farmland.getDefaultState(), Constants.BlockFlags.NOTIFY_LISTENERS); } else if(blockState.getBlock() == Blocks.COARSE_DIRT) { this.entityWorld.playEvent(Constants.WorldEvents.BREAK_BLOCK_EFFECTS, pos, Block.getStateId(blockState.getBlock().getDefaultState())); this.entityWorld.setBlockState(pos, Blocks.DIRT.getDefaultState(), Constants.BlockFlags.NOTIFY_LISTENERS); } else if(blockState.getBlock() == BlockList.dry_farmland && !blockState.get(((BlockDryFarmland) blockState.getBlock()).getNutrition())) { this.entityWorld.playEvent(Constants.WorldEvents.BREAK_BLOCK_EFFECTS, pos, Block.getStateId(blockState.getBlock().getDefaultState())); this.entityWorld.setBlockState(pos, BlockList.dry_farmland.getDefaultState() .with(((BlockDryFarmland) blockState.getBlock()).getNutrition(), Boolean.valueOf(true)) .with(BlockStateProperties.MOISTURE_0_7, blockState.get(BlockStateProperties.MOISTURE_0_7)), Constants.BlockFlags.NOTIFY_LISTENERS); } } } } }
  18. Hi, I am trying to make my custom AI task for pigs that works similiary to the EntityAIEatGrass task of sheeps so I am just copying code from there. But I don't want to copy code I don't understand so what does this.entityWorld.setEntityState(this.grassEaterEntity, (byte)10); do? What is the opcode 10?
  19. something like this I suppose for(EnumDyeColor color: EnumDyeColor.values()) { // ... }
  20. http://jabelarminecraft.blogspot.com/ this seems like a nice blog, don't know how up-to-date it is though, but there are tuts on everything
  21. Hi, in the tick function of BlockStem, the CropGrowEvent.Post can fire even though nothing happened. Contrary to what the source code comment on CropGrowEvent.Post says, which suggests that it is only fired on succesful growth. This leads to some unexpected behaviour when handling that event.
  22. At least he's doing something x) I got my mod up and running thanks to him
  23. Hi, I made a custom farmland block and I overwrote the canSustainPlant method to return true when the plantable type is 'Crop'. But I can't plant melon or pumpkin seeds now? Wheat, Carrots etc. work
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.