Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Spring

Members
  • Joined

  • Last visited

Everything posted by Spring

  1. When the player owns certain items, prevent monsters from attacking the player like this : look this @SubscribeEvent public static void onTarget(final LivingSetAttackTargetEvent event) { LivingEntity target = event.getTarget(); if (target instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) target; if (invalid(player)) { event.setCanceled(true); } } } [19:06:23] [Server thread/ERROR] [ne.mi.ev.EventBus/EVENTBUS]: Exception caught during firing event: Attempted to call Event#setCanceled() on a non-cancelable event of type: net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent Index: 1 Listeners: 0: NORMAL 1: ASM: class ocean.chinacraft.common.item.armor.SilkNightArmor$RenderNightArmor onPreRenderPlayer(Lnet/minecraftforge/event/entity/living/LivingSetAttackTargetEvent;)V java.lang.UnsupportedOperationException: Attempted to call Event#setCanceled() on a non-cancelable event of type: net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent at net.minecraftforge.eventbus.api.Event.setCanceled(Event.java:95) at ocean.chinacraft.common.item.armor.SilkNightArmor$RenderNightArmor.onPreRenderPlayer(SilkNightArmor.java:79) at net.minecraftforge.eventbus.ASMEventHandler_16_RenderNightArmor_onPreRenderPlayer_LivingSetAttackTargetEvent.invoke(.dynamic) at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) at net.minecraftforge.common.ForgeHooks.onLivingSetAttackTarget(ForgeHooks.java:335) at net.minecraft.entity.MobEntity.setTarget(MobEntity.java:201) at net.minecraft.entity.ai.goal.TargetGoal.canContinueToUse(TargetGoal.java:65) at net.minecraft.entity.ai.goal.PrioritizedGoal.canContinueToUse(PrioritizedGoal.java:25) at net.minecraft.entity.ai.goal.GoalSelector.lambda$tick$2(GoalSelector.java:52) at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176) at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) at net.minecraft.entity.ai.goal.GoalSelector.tick(GoalSelector.java:53) at net.minecraft.entity.MobEntity.serverAiStep(MobEntity.java:679) at net.minecraft.entity.LivingEntity.aiStep(LivingEntity.java:2411) at net.minecraft.entity.MobEntity.aiStep(MobEntity.java:488) at net.minecraft.entity.monster.MonsterEntity.aiStep(MonsterEntity.java:40) at net.minecraft.entity.monster.ZombieEntity.aiStep(ZombieEntity.java:231) at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2158) at net.minecraft.entity.MobEntity.tick(MobEntity.java:300) at net.minecraft.entity.monster.ZombieEntity.tick(ZombieEntity.java:205) at net.minecraft.world.server.ServerWorld.tickNonPassenger(ServerWorld.java:611) at net.minecraft.world.World.guardEntityTick(World.java:554) at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:404) at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:851) at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:787) at net.minecraft.server.integrated.IntegratedServer.tickServer(IntegratedServer.java:78) at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:642) at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:232) at java.base/java.lang.Thread.run(Thread.java:829) [19:06:23] [Server thread/FATAL] [ne.mi.co.ForgeMod/]: Preparing crash report with UUID 3b7c1cee-90fc-4e08-93d0-bbc4cda9dac9 [19:06:23] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception net.minecraft.crash.ReportedException: Ticking entity at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:855) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:787) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.integrated.IntegratedServer.tickServer(IntegratedServer.java:78) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:642) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:232) ~[forge:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:829) [?:?] {} Caused by: java.lang.UnsupportedOperationException: Attempted to call Event#setCanceled() on a non-cancelable event of type: net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent at net.minecraftforge.eventbus.api.Event.setCanceled(Event.java:95) ~[eventbus-4.0.0.jar:?] {} at ocean.chinacraft.common.item.armor.SilkNightArmor$RenderNightArmor.onPreRenderPlayer(SilkNightArmor.java:79) ~[main/:?] {re:classloading} at net.minecraftforge.eventbus.ASMEventHandler_16_RenderNightArmor_onPreRenderPlayer_LivingSetAttackTargetEvent.invoke(.dynamic) ~[?:?] {} at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.common.ForgeHooks.onLivingSetAttackTarget(ForgeHooks.java:335) ~[forge:?] {re:classloading} at net.minecraft.entity.MobEntity.setTarget(MobEntity.java:201) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.entity.ai.goal.TargetGoal.canContinueToUse(TargetGoal.java:65) ~[forge:?] {re:classloading} at net.minecraft.entity.ai.goal.PrioritizedGoal.canContinueToUse(PrioritizedGoal.java:25) ~[forge:?] {re:classloading} at net.minecraft.entity.ai.goal.GoalSelector.lambda$tick$2(GoalSelector.java:52) ~[forge:?] {re:classloading} at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176) ~[?:?] {} at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) ~[?:?] {} at java.util.Iterator.forEachRemaining(Iterator.java:133) ~[?:?] {} at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[?:?] {} at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[?:?] {} at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?] {} at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?] {} at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?] {} at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?] {} at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) ~[?:?] {} at net.minecraft.entity.ai.goal.GoalSelector.tick(GoalSelector.java:53) ~[forge:?] {re:classloading} at net.minecraft.entity.MobEntity.serverAiStep(MobEntity.java:679) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.entity.LivingEntity.aiStep(LivingEntity.java:2411) ~[forge:?] {re:classloading} at net.minecraft.entity.MobEntity.aiStep(MobEntity.java:488) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.entity.monster.MonsterEntity.aiStep(MonsterEntity.java:40) ~[forge:?] {re:classloading} at net.minecraft.entity.monster.ZombieEntity.aiStep(ZombieEntity.java:231) ~[forge:?] {re:classloading} at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2158) ~[forge:?] {re:classloading} at net.minecraft.entity.MobEntity.tick(MobEntity.java:300) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.entity.monster.ZombieEntity.tick(ZombieEntity.java:205) ~[forge:?] {re:classloading} at net.minecraft.world.server.ServerWorld.tickNonPassenger(ServerWorld.java:611) ~[forge:?] {re:classloading} at net.minecraft.world.World.guardEntityTick(World.java:554) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:404) ~[forge:?] {re:classloading} at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:851) ~[forge:?] {re:classloading,pl:accesstransformer:B} ... 5 more Disconnected from the target VM, address: '127.0.0.1:62991', transport: 'socket' AL lib: (EE) alc_cleanup: 1 device not closed Process finished with exit code -1
  2. Spring replied to Spring's topic in Modder Support
    like this ? @Override public void onArmorTick(ItemStack stack, World world, PlayerEntity player) { if (invalid(player)) { List<MobEntity> mobEntities = getNearbyEntities(player); for (MobEntity mob : mobEntities) { if (mob.getTarget() != null && mob.getTarget().getUUID().equals(player.getUUID())) { mob.goalSelector.removeGoal(new NearestAttackableTargetGoal<>(mob, PlayerEntity.class, true)); } } } }
  3. @OnlyIn(Dist.CLIENT) @SubscribeEvent public static void onPreRenderPlayer(final RenderPlayerEvent.Pre event) { System.out.println("on client: " + player.level.isNight()); } @Override public void onArmorTick(ItemStack stack, World world, PlayerEntity player) { System.out.println("on server: " + player.level.isNight()); } I want to know if it's day or night On the server, this is valid but client,invalid [12十二月2021 12:43:55.102] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$RenderNightArmor:onPreRenderPlayer:79]: on client: false [12十二月2021 12:43:55.118] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$RenderNightArmor:onPreRenderPlayer:79]: on client: false [12:45:31] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:61]: on server: true [12:45:31] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:61]: on server: true [12:45:31] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:61]: on server: true
  4. Yes, but I want to get the time now, is it day or night? How to get it? on client get server time
  5. i use player.level.isNight() method return true and false。why? @Override public void onArmorTick(ItemStack stack, World world, PlayerEntity player) { System.out.println(player.level.isNight()); if (invalid(player)) { List<MobEntity> mobEntities = getNearbyEntities(player); for (MobEntity mob : mobEntities) { if (mob.getTarget() != null && mob.getTarget().getUUID().equals(player.getUUID())) { mob.setTarget(null); } } } } [00:42:31] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: true [00:42:31] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: false [00:42:31] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: true [00:42:31] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: false [00:42:32] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: true [00:42:32] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: false [00:42:32] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: true [00:42:32] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: false [00:42:32] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: true [00:42:32] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: false [00:42:32] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: true [00:42:32] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: false [00:42:32] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: true [00:42:32] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: false [00:42:32] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: true [00:42:32] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: false [00:42:32] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: true [00:42:32] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: false [00:42:32] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: true [00:42:32] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: false [00:42:32] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: true [00:42:32] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: false [00:42:32] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: true [00:42:32] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: false [00:42:32] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: true [00:42:32] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: false [00:42:32] [Server thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: true [00:42:32] [Render thread/INFO] [STDOUT/]: [ocean.chinacraft.common.item.armor.SilkNightArmor$NightArmor:onArmorTick:60]: false
  6. Spring replied to Spring's topic in Modder Support
    It's all right. I forgot to add tags
  7. hello,The other wood_window is correct, but there is a problem with this one, what happened The left is correct. right is error. The middle of it should be white,Why is it like this public abstract class AbstractWoodWindow extends FourWayBlock { public AbstractWoodWindow(Properties properties) { super(1.0F, 1.0F, 16.0F, 16.0F, 16.0F, properties); this.registerDefaultState(this.stateDefinition.any().setValue(NORTH, Boolean.FALSE).setValue(EAST, Boolean.FALSE).setValue(SOUTH, Boolean.FALSE).setValue(WEST, Boolean.FALSE).setValue(WATERLOGGED, Boolean.FALSE)); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { IBlockReader iblockreader = context.getLevel(); BlockPos blockpos = context.getClickedPos(); FluidState fluidstate = context.getLevel().getFluidState(context.getClickedPos()); BlockPos blockpos1 = blockpos.north(); BlockPos blockpos2 = blockpos.south(); BlockPos blockpos3 = blockpos.west(); BlockPos blockpos4 = blockpos.east(); BlockState blockstate = iblockreader.getBlockState(blockpos1); BlockState blockstate1 = iblockreader.getBlockState(blockpos2); BlockState blockstate2 = iblockreader.getBlockState(blockpos3); BlockState blockstate3 = iblockreader.getBlockState(blockpos4); return this.defaultBlockState().setValue(NORTH, this.attachTo(blockstate, blockstate.isFaceSturdy(iblockreader, blockpos1, Direction.SOUTH))).setValue(SOUTH, this.attachTo(blockstate1, blockstate1.isFaceSturdy(iblockreader, blockpos2, Direction.NORTH))).setValue(WEST, this.attachTo(blockstate2, blockstate2.isFaceSturdy(iblockreader, blockpos3, Direction.EAST))).setValue(EAST, this.attachTo(blockstate3, blockstate3.isFaceSturdy(iblockreader, blockpos4, Direction.WEST))).setValue(WATERLOGGED, fluidstate.getType() == Fluids.WATER); } @Override public BlockState updateShape(BlockState state1, Direction direction, BlockState state, IWorld world, BlockPos pos, BlockPos pos1) { if (state1.getValue(WATERLOGGED)) { world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } return direction.getAxis().isHorizontal() ? state1.setValue(PROPERTY_BY_DIRECTION.get(direction), this.attachTo(state, state.isFaceSturdy(world, pos1, direction.getOpposite()))) : super.updateShape(state1, direction, state, world, pos, pos1); } @Override public VoxelShape getVisualShape(BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext context) { return VoxelShapes.empty(); } @Override public boolean skipRendering(BlockState state, BlockState p_200122_2_, Direction direction) { if (p_200122_2_.is(this)) { if (!direction.getAxis().isHorizontal()) { return true; } if (state.getValue(PROPERTY_BY_DIRECTION.get(direction)) && p_200122_2_.getValue(PROPERTY_BY_DIRECTION.get(direction.getOpposite()))) { return true; } } return super.skipRendering(state, p_200122_2_, direction); } public boolean attachTo(BlockState state, boolean flag) { Block block = state.getBlock(); return !isExceptionForConnection(block) && flag || block instanceof AbstractWoodWindow || block.is(BlockTags.WALLS); } @Override protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> p_206840_1_) { p_206840_1_.add(NORTH, EAST, WEST, SOUTH, WATERLOGGED); } } public class WoodWindow extends AbstractWoodWindow { public WoodWindow() { super(PropertiesMisc.defaultWindow()); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { IBlockReader iblockreader = context.getLevel(); BlockPos blockpos = context.getClickedPos(); FluidState fluidstate = context.getLevel().getFluidState(context.getClickedPos()); BlockPos blockpos1 = blockpos.north(); BlockPos blockpos2 = blockpos.south(); BlockPos blockpos3 = blockpos.west(); BlockPos blockpos4 = blockpos.east(); BlockState blockstate = iblockreader.getBlockState(blockpos1); BlockState blockstate1 = iblockreader.getBlockState(blockpos2); BlockState blockstate2 = iblockreader.getBlockState(blockpos3); BlockState blockstate3 = iblockreader.getBlockState(blockpos4); return this.defaultBlockState().setValue(NORTH, this.attachTo(blockstate, blockstate.isFaceSturdy(iblockreader, blockpos1, Direction.SOUTH))).setValue(SOUTH, this.attachTo(blockstate1, blockstate1.isFaceSturdy(iblockreader, blockpos2, Direction.NORTH))).setValue(WEST, this.attachTo(blockstate2, blockstate2.isFaceSturdy(iblockreader, blockpos3, Direction.EAST))).setValue(EAST, this.attachTo(blockstate3, blockstate3.isFaceSturdy(iblockreader, blockpos4, Direction.WEST))).setValue(WATERLOGGED, fluidstate.getType() == Fluids.WATER); } @Override public boolean attachTo(BlockState state, boolean flag) { Block block = state.getBlock(); return !isExceptionForConnection(block) && flag || block instanceof WoodWindow || block.is(BlockTags.WALLS); } Please help me, thanks !!!!!!!!!!!!!!!
  8. package ocean.chinacraft.common.block.decoration; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.FourWayBlock; import net.minecraft.block.PaneBlock; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; import net.minecraft.item.BlockItemUseContext; import net.minecraft.state.StateContainer; import net.minecraft.tags.BlockTags; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import ocean.chinacraft.common.block.properties.PropertiesMisc; /** * 木窗格 * * @author zhang * @since 2021/12/9 */ public class WoodWindow extends FourWayBlock { public WoodWindow() { super(1.0F, 1.0F, 16.0F, 16.0F, 16.0F, PropertiesMisc.defaultWindow()); this.registerDefaultState(this.stateDefinition.any().setValue(NORTH, Boolean.FALSE).setValue(EAST, Boolean.FALSE).setValue(SOUTH, Boolean.FALSE).setValue(WEST, Boolean.FALSE).setValue(WATERLOGGED, Boolean.FALSE)); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { IBlockReader iblockreader = context.getLevel(); BlockPos blockpos = context.getClickedPos(); FluidState fluidstate = context.getLevel().getFluidState(context.getClickedPos()); BlockPos blockpos1 = blockpos.north(); BlockPos blockpos2 = blockpos.south(); BlockPos blockpos3 = blockpos.west(); BlockPos blockpos4 = blockpos.east(); BlockState blockstate = iblockreader.getBlockState(blockpos1); BlockState blockstate1 = iblockreader.getBlockState(blockpos2); BlockState blockstate2 = iblockreader.getBlockState(blockpos3); BlockState blockstate3 = iblockreader.getBlockState(blockpos4); return this.defaultBlockState().setValue(NORTH, this.attachsTo(blockstate, blockstate.isFaceSturdy(iblockreader, blockpos1, Direction.SOUTH))).setValue(SOUTH, this.attachsTo(blockstate1, blockstate1.isFaceSturdy(iblockreader, blockpos2, Direction.NORTH))).setValue(WEST, this.attachsTo(blockstate2, blockstate2.isFaceSturdy(iblockreader, blockpos3, Direction.EAST))).setValue(EAST, this.attachsTo(blockstate3, blockstate3.isFaceSturdy(iblockreader, blockpos4, Direction.WEST))).setValue(WATERLOGGED, fluidstate.getType() == Fluids.WATER); } @Override public BlockState updateShape(BlockState p_196271_1_, Direction p_196271_2_, BlockState p_196271_3_, IWorld p_196271_4_, BlockPos p_196271_5_, BlockPos p_196271_6_) { if (p_196271_1_.getValue(WATERLOGGED)) { p_196271_4_.getLiquidTicks().scheduleTick(p_196271_5_, Fluids.WATER, Fluids.WATER.getTickDelay(p_196271_4_)); } return p_196271_2_.getAxis().isHorizontal() ? p_196271_1_.setValue(PROPERTY_BY_DIRECTION.get(p_196271_2_), Boolean.valueOf(this.attachsTo(p_196271_3_, p_196271_3_.isFaceSturdy(p_196271_4_, p_196271_6_, p_196271_2_.getOpposite())))) : super.updateShape(p_196271_1_, p_196271_2_, p_196271_3_, p_196271_4_, p_196271_5_, p_196271_6_); } @Override public VoxelShape getVisualShape(BlockState p_230322_1_, IBlockReader p_230322_2_, BlockPos p_230322_3_, ISelectionContext p_230322_4_) { return VoxelShapes.empty(); } @Override @OnlyIn(Dist.CLIENT) public boolean skipRendering(BlockState p_200122_1_, BlockState p_200122_2_, Direction p_200122_3_) { if (p_200122_2_.is(this)) { if (!p_200122_3_.getAxis().isHorizontal()) { return true; } if (p_200122_1_.getValue(PROPERTY_BY_DIRECTION.get(p_200122_3_)) && p_200122_2_.getValue(PROPERTY_BY_DIRECTION.get(p_200122_3_.getOpposite()))) { return true; } } return super.skipRendering(p_200122_1_, p_200122_2_, p_200122_3_); } public final boolean attachsTo(BlockState p_220112_1_, boolean p_220112_2_) { Block block = p_220112_1_.getBlock(); return !isExceptionForConnection(block) && p_220112_2_ || block instanceof PaneBlock || block.is(BlockTags.WALLS); } @Override protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> p_206840_1_) { p_206840_1_.add(NORTH, EAST, WEST, SOUTH, WATERLOGGED); } } status: { "multipart": [ { "apply": { "model": "chinacraft:block/wood_window_post" } }, { "when": { "north": "true" }, "apply": { "model": "chinacraft:block/wood_window_side" } }, { "when": { "east": "true" }, "apply": { "model": "chinacraft:block/wood_window_side", "y": 90 } }, { "when": { "south": "true" }, "apply": { "model": "chinacraft:block/wood_window_side_alt" } }, { "when": { "west": "true" }, "apply": { "model": "chinacraft:block/wood_window_side_alt", "y": 90 } }, { "when": { "north": "false" }, "apply": { "model": "chinacraft:block/wood_window_noside" } }, { "when": { "east": "false" }, "apply": { "model": "chinacraft:block/wood_window_noside_alt" } }, { "when": { "south": "false" }, "apply": { "model": "chinacraft:block/wood_window_noside_alt", "y": 90 } }, { "when": { "west": "false" }, "apply": { "model": "chinacraft:block/wood_window_noside", "y": 270 } } ] }
  9. hello,I am making an object similar to glass_pane.But their status seems to be a bit problematic
  10. my code @Override public void onArmorTick(ItemStack stack, World world, PlayerEntity player) { if (player.isAlive() && Screen.hasShiftDown()) { --59 } super.onArmorTick(stack, world, player); } He crashed when I was running on the server https://paste.ubuntu.com/p/tkSGkzDB23/
  11. Spring replied to Spring's topic in Modder Support
    so complicated
  12. Spring replied to Spring's topic in Modder Support
    What to replace the entity with?
  13. Spring replied to Spring's topic in Modder Support
    Found the problem, getNearbyEntities parameter problem. But now the monster will look at me, is there a way to avoid it?
  14. Spring posted a topic in Modder Support
    I want the monster not to attack the player, this is my code @Override public void onArmorTick(ItemStack stack, World world, PlayerEntity player) { if (player.isAlive() && Screen.hasShiftDown()) { if (hasFullArmor(player) && hasCorrectArmorOn(ArmorMaterial.SILK_NIGHT_ARMOR, player)) { List<MobEntity> mobEntities = getNearbyEntities(player); for (MobEntity mobEntity : mobEntities) { Optional<LivingEntity> target = Optional.ofNullable(mobEntity.getTarget()); target.ifPresent(res -> { if (target.get().getUUID().equals(player.getUUID())) { mobEntity.setTarget(null); } }); } } } super.onArmorTick(stack, world, player); } I don't know how to explain this situation, please watch my video https://error-1254387167.cos.ap-chengdu.myqcloud.com/bugs-video.mp4 Sometimes it’s useful, sometimes it’s not. All code has been executed
  15. He doesn't seem to work on Skeleton ? Zombies can
  16. Maybe the method is not suitable for onArmorTick I want to set the monster not to attack the player @Override public void onArmorTick(ItemStack stack, World world, PlayerEntity player) { List<MobEntity> mobEntities = getNearbyEntities(player); for (MobEntity mobEntity : mobEntities) { Optional<LivingEntity> target = Optional.ofNullable(mobEntity.getTarget()); target.ifPresent(res -> { if (res instanceof PlayerEntity) { PlayerEntity targetPlayer = (PlayerEntity) res; if (targetPlayer.getUUID().equals(player.getUUID())) { mobEntity.setTarget(null); } } }); }
  17. It’s weird that it doesn’t work sometimes,getNearbyEntities() return Empty collection
  18. no problem
  19. not null,bug size() is ZERO。I just want to know how to use it correctly
  20. i try use private static final EntityPredicate PREDICATE = (new EntityPredicate()).allowUnseeable().ignoreInvisibilityTesting(); private static List<MobEntity> getNearbyEntities(PlayerEntity player) { double x = player.getX(); double y = player.getY(); double z = player.getZ(); return player.level.getNearbyEntities(MobEntity.class, PREDICATE, player, new AxisAlignedBB(x, y, z, x + 50, y + 50, z + 50)); } but it never return null 。size() is ZERO
  21. More details?
  22. in you item class add code: @Override public ItemStack getContainerItem(ItemStack itemStack) { return itemStack.copy(); } @Override public boolean hasContainerItem(ItemStack stack) { return true; }
  23. I only made a custom sword, but it is too small, I want to make it a little bigger
  24. solved ! thanks

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.