Yamahari
Members-
Posts
47 -
Joined
-
Last visited
Everything posted by Yamahari
-
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
-
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 )
-
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?
-
fixed it myself
-
oh yea and forget that part in onRegisterTileEntity, that was me trying to fix it for myself but that line crashes the game
-
there are no 1.14 versions of these mods, where did you get them from
-
Here's the github if you wanna take a look https://github.com/Yamahari/ILikeWood
-
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.
-
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
-
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
-
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
-
noone got a clue? cause I don't x)
-
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?
-
[Solved] [1.13.2] Why is this code not working?
Yamahari replied to Tameet's topic in Modder Support
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) -
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
-
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!
-
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)
-
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.
-
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); } } } } }
-
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?
-
something like this I suppose for(EnumDyeColor color: EnumDyeColor.values()) { // ... }
-
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
-
At least he's doing something x) I got my mod up and running thanks to him
-
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