fixed broken movable TEs under Java 16

This commit is contained in:
gnembon committed 2021-05-31 15:40:44 -03:00
1 parent 83109eda9a
commit c55019d048
3 files changed
+22 -5

No files matched your search

@@ -0,0 +1,8 @@
package carpet.fakes;
import net.minecraft.util.math.BlockPos;
public interface BlockEntityInterface
{
void setCMPos(BlockPos pos);
}
@@ -1,13 +1,21 @@
package carpet.mixins;
import carpet.fakes.BlockEntityInterface;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(BlockEntity.class)
public interface BlockEntity_movableBEMixin
public abstract class BlockEntity_movableBEMixin implements BlockEntityInterface
{
@Accessor
void setPos(BlockPos pos);
@Mutable
@Shadow @Final protected BlockPos pos;
public void setCMPos(BlockPos newPos)
{
pos = newPos;
};
}
@@ -1,6 +1,7 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.fakes.BlockEntityInterface;
import carpet.fakes.PistonBlockEntityInterface;
import carpet.fakes.WorldInterface;
import net.minecraft.block.Block;
@@ -57,7 +58,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
this.carriedBlockEntity = blockEntity;
if (this.carriedBlockEntity != null)
{
((BlockEntity_movableBEMixin)carriedBlockEntity).setPos(pos);
((BlockEntityInterface)carriedBlockEntity).setCMPos(pos);
// this might be little dangerous since pos is final for a hashing reason?
if (world != null) carriedBlockEntity.setWorld(world);
}