Skip to content

Commit

Permalink
Fix entities vanishing
Browse files Browse the repository at this point in the history
  • Loading branch information
AViewFromTheTop committed Dec 21, 2024
1 parent 60ea82f commit 329284d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ hi
- Updated Polish translations slightly, thanks to Eggmanplant! ([#4](https://github.com/FrozenBlock/TrailierTales/pull/4))

#### Bugfixes
- Fixed a critical issue with mobs suddenly vanishing.
- Fixed a vanilla bug where Powered Rails, Activator Rails, and Detector Rails wouldn't rotate properly in structure generation.
- Cracked and Chiseled Purpur Blocks can now be broken faster with a pickaxe. ([#10](https://github.com/FrozenBlock/TrailierTales/issues/10))
- Fixed an issue where modded boats that aren't implemented the same way as vanilla cause a crash. ([#9](https://github.com/FrozenBlock/TrailierTales/issues/9))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.VisibleForDebug;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.player.Player;
Expand All @@ -39,6 +40,10 @@ public UUID getCoffinUUID() {
return this.coffinUUID;
}

public static boolean entityHasCoffinData(@NotNull Entity entity) {
return entity instanceof EntityCoffinInterface entityCoffinInterface && entityCoffinInterface.trailierTales$getCoffinData() != null;
}

public void tick(LivingEntity entity, @NotNull Level level) {
if (level instanceof ServerLevel serverLevel) {
long gameTime = level.getGameTime();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.frozenblock.trailiertales.mixin.common.coffin;

import net.frozenblock.trailiertales.block.CoffinBlock;
import net.frozenblock.trailiertales.block.entity.coffin.impl.EntityCoffinInterface;
import net.frozenblock.trailiertales.block.entity.coffin.impl.EntityCoffinData;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.portal.DimensionTransition;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -14,15 +14,15 @@ public class EntityMixin {

@Inject(method = "changeDimension", at = @At("HEAD"))
public void trailierTales$changeDimension(DimensionTransition dimensionTransition, CallbackInfoReturnable<Entity> info) {
CoffinBlock.onCoffinUntrack(Entity.class.cast(this), null, true);
if (EntityCoffinData.entityHasCoffinData(Entity.class.cast(this))) {
CoffinBlock.onCoffinUntrack(Entity.class.cast(this), null, true);
}
}

@Inject(method = "canUsePortal", at = @At("HEAD"), cancellable = true)
public void trailierTales$canUsePortal(CallbackInfoReturnable<Boolean> info) {
if (Entity.class.cast(this) instanceof EntityCoffinInterface entityCoffinInterface) {
if (entityCoffinInterface.trailierTales$getCoffinData() != null) {
info.setReturnValue(false);
}
if (EntityCoffinData.entityHasCoffinData(Entity.class.cast(this))) {
info.setReturnValue(false);
}
}

Expand Down

0 comments on commit 329284d

Please sign in to comment.