-
Recently Browsing
- No registered users viewing this page.
-
Posts
-
Don't use OnlyIn. That is meant to mark vanilla code so you know which side it belongs to. What you did is remove the method from the class on the client version of minecraft. In your tick method add an isClientSide check. Ticking in the client is usually only used for modifying variables related to animations.
-
By MaiTheLord · Posted
what about a raw NBT tag? I only need to store a boolean, after all -
There are at least 2 different ways to do this. net.minecraft.world.entity.ai.attributes.Attributes This is not something I've not played with. So I can't say much about it. The basic idea is each entity has a set of attributes. Which can also have permanent or transient AttributeModifiers. These modifiers are linked to ArmorItems or MobEffects, or they could be "ad hoc". Forge has some events that let you configure attributes for entities: EntityAttribute(Creation/Modification)Event. Of course you need to register any custom attributes you make. From what I can tell, these attributes are meant to be number ranges. Forge's capabilities: https://forge.gemwire.uk/wiki/Capabilities These are much more general and let you attach any data to most important in game things, but they also provide an "interface" for mod communication. It is good to learn this system, things like item handling across mods or FE (forge energy) uses capabilities. The major drawback with capabilities is they don't automatically synchronize with the client, so you have to do this yourself. Which is something people can struggle with until they understand it. The issue is due to capabilities being flexible, forge can't really know what/how/when you want to synchronize.
-
Thanks, I have tried to put @OnlyIn(Dist.DEDICATED_SERVER) but the error still there [22:36:11] [Server thread/FATAL] [ne.mi.co.ForgeMod/]: Preparing crash report with UUID 58d395eb-597b-4c88-9114-f856748e3ed2 [22:36:11] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception net.minecraft.crash.ReportedException: Ticking block 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:750) [?:1.8.0_332] {} Caused by: java.lang.NoSuchMethodError: manueh.marvel_themod.common.entity.TimeGemBlockEntity.tickBlockArea()V at manueh.marvel_themod.common.entity.TimeGemBlockEntity.tick(TimeGemBlockEntity.java:96) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.world.World.tickBlockEntities(World.java:491) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:371) ~[forge:?] {re:classloading} at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:851) ~[forge:?] {re:classloading,pl:accesstransformer:B} ... 5 more @Override public void tick() { if (this.speed == 0 || (this.xRange == 0 && this.yRange == 0 && this.zRange == 0)) return; if (this.getLevel().isClientSide()) return; randomTicks = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); tickBlockArea(); } @OnlyIn(Dist.DEDICATED_SERVER) private void tickBlockArea() { this.area.forEach(this::tickBlock); } @OnlyIn(Dist.DEDICATED_SERVER) private void tickBlock(BlockPos pos) { if (this.getLevel().isClientSide()) return; ITickableTileEntity tickableBlockEntity; BlockState blockState = this.level.getBlockState(pos); Block block = blockState.getBlock(); if (TimeGemAPI.INSTANCE.isBlockBlacklisted(block)) return; if (this.level instanceof ServerWorld && block.isRandomlyTicking(blockState) && this.level.getRandom().nextInt(MathHelper.clamp(4096 / this.speed * 4, 1, 4096)) < randomTicks) blockState.randomTick((ServerWorld)this.level, pos, this.level.getRandom()); TileEntity blockEntity = this.level.getBlockEntity(pos); if (blockEntity != null && !blockEntity.isRemoved() && !TimeGemAPI.INSTANCE.isBlockEntityBlacklisted(blockEntity.getType())) { TileEntity tileEntity = blockEntity; if (tileEntity instanceof ITickableTileEntity) { tickableBlockEntity = (ITickableTileEntity)tileEntity; } else { return; } } else { return; } for (int i = 0; i < this.speed && !blockEntity.isRemoved(); i++) tickableBlockEntity.tick(); }
-
Topics
Recommended Posts