From 2cdea92da7080d6992573feb6ae88de05ac76615 Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 6 Nov 2020 00:06:53 -0400 Subject: [PATCH] 20w45a --- gradle.properties | 4 +- .../carpet/commands/PerimeterInfoCommand.java | 4 +- .../java/carpet/commands/PlayerCommand.java | 4 +- .../carpet/fakes/ChunkHolderInterface.java | 3 +- .../carpet/fakes/ExperienceOrbInterface.java | 2 + .../java/carpet/helpers/BlockRotator.java | 4 +- .../helpers/EntityPlayerActionPack.java | 4 +- .../carpet/helpers/OptimizedExplosion.java | 4 +- src/main/java/carpet/helpers/XPcombine.java | 13 ++- ...actCauldronBlock_stackableSBoxesMixin.java | 37 +++++++ .../ArmorStandEntity_scarpetMarkerMixin.java | 4 +- .../mixins/BlockEntity_movableBEMixin.java | 13 +++ .../mixins/BlockItem_creativeNoClipMixin.java | 2 +- .../CauldronBlock_stackableSBoxesMixin.java | 4 +- ...ChunkHolder_scarpetChunkCreationMixin.java | 5 +- ...rkHandler_smoothClientAnimationsMixin.java | 3 +- .../java/carpet/mixins/ContainerMixin.java | 10 +- .../mixins/Entity_scarpetEventsMixin.java | 7 +- .../mixins/ExperienceOrbEntityMixin.java | 12 +++ .../mixins/FallingBlockEntityMixin.java | 4 +- .../carpet/mixins/GuardianEntityMixin.java | 6 +- .../carpet/mixins/HopperBlockEntityMixin.java | 36 +++---- .../java/carpet/mixins/ItemEntityMixin.java | 2 +- .../mixins/LivingEntity_creativeFlyMixin.java | 4 +- ...tonBlockEntityRenderer_movableTEMixin.java | 13 ++- .../PistonBlockEntity_movableTEMixin.java | 41 ++++--- ...PistonBlockEntity_playerHandlingMixin.java | 15 +-- .../mixins/PistonBlock_movableTEMixin.java | 30 +++--- .../PistonHandler_customStickyMixin.java | 36 +++---- .../PlayerEntity_creativeNoClipMixin.java | 6 +- ...PlayNetworkHandler_scarpetEventsMixin.java | 2 +- .../mixins/ServerWorld_fakePlayersMixin.java | 7 +- .../mixins/ServerWorld_scarpetEventMixin.java | 32 +++--- .../java/carpet/mixins/SpawnHelperMixin.java | 4 +- ...hunkStorage_scarpetChunkCreationMixin.java | 4 +- .../java/carpet/mixins/ThrownEntityMixin.java | 4 +- .../java/carpet/mixins/TntEntityMixin.java | 4 +- .../mixins/WorldChunkBEList_tickMixin.java | 47 ++++++++ .../mixins/WorldChunk_movableTEMixin.java | 33 +++--- .../carpet/mixins/World_movableTEMixin.java | 101 ++++++++---------- .../java/carpet/mixins/World_tickMixin.java | 24 ++--- .../carpet/patches/EntityPlayerMPFake.java | 4 +- .../java/carpet/script/CarpetScriptHost.java | 2 +- .../java/carpet/script/api/Auxiliary.java | 2 +- src/main/java/carpet/script/api/Entities.java | 2 +- .../java/carpet/script/api/WorldAccess.java | 2 +- .../carpet/script/utils/ShapesRenderer.java | 98 +++++++++++------ .../java/carpet/script/utils/WorldTools.java | 2 +- .../java/carpet/script/value/EntityValue.java | 6 +- .../script/value/NBTSerializableValue.java | 6 +- src/main/java/carpet/utils/BlockInfo.java | 7 +- src/main/java/carpet/utils/MobAI.java | 2 +- src/main/java/carpet/utils/SpawnReporter.java | 8 +- src/main/resources/carpet.mixins.json | 3 + src/main/resources/fabric.mod.json | 2 +- 55 files changed, 453 insertions(+), 287 deletions(-) create mode 100644 src/main/java/carpet/mixins/AbstractCauldronBlock_stackableSBoxesMixin.java create mode 100644 src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java create mode 100644 src/main/java/carpet/mixins/WorldChunkBEList_tickMixin.java diff --git a/gradle.properties b/gradle.properties index f7d835ba..8db5a2b8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=1.16.4 - yarn_mappings=1.16.4+build.1 + minecraft_version=20w45a + yarn_mappings=20w45a+build.6 loader_version=0.10.6+build.214 # Mod Properties diff --git a/src/main/java/carpet/commands/PerimeterInfoCommand.java b/src/main/java/carpet/commands/PerimeterInfoCommand.java index 901ea10e..ab6baebc 100644 --- a/src/main/java/carpet/commands/PerimeterInfoCommand.java +++ b/src/main/java/carpet/commands/PerimeterInfoCommand.java @@ -58,7 +58,7 @@ public class PerimeterInfoCommand if (!(baseEntity instanceof MobEntity)) { Messenger.m(source, "r Failed to spawn test entity"); - if (baseEntity != null) baseEntity.remove(); + if (baseEntity != null) baseEntity.discard(); // discard //remove(); return 0; } entityliving = (MobEntity) baseEntity; @@ -72,7 +72,7 @@ public class PerimeterInfoCommand { Messenger.m(source, "w ", entityliving.getDisplayName() ,"w : ","wb "+res.specific); res.samples.forEach(bp -> Messenger.m(source, "w ", Messenger.tp("c", bp))); - entityliving.remove(); + entityliving.discard(); // dicard // remove(); } return 1; } diff --git a/src/main/java/carpet/commands/PlayerCommand.java b/src/main/java/carpet/commands/PlayerCommand.java index f845b8db..fbc2085d 100644 --- a/src/main/java/carpet/commands/PlayerCommand.java +++ b/src/main/java/carpet/commands/PlayerCommand.java @@ -209,9 +209,9 @@ public class PlayerCommand private static int lookAt(CommandContext context) { return manipulate(context, ap -> { - try { + //try { ap.lookAt(Vec3ArgumentType.getVec3(context, "position")); - } catch (CommandSyntaxException ignored) {} + //} catch (CommandSyntaxException ignored) {} }); } diff --git a/src/main/java/carpet/fakes/ChunkHolderInterface.java b/src/main/java/carpet/fakes/ChunkHolderInterface.java index ae28edc9..7619279d 100644 --- a/src/main/java/carpet/fakes/ChunkHolderInterface.java +++ b/src/main/java/carpet/fakes/ChunkHolderInterface.java @@ -2,6 +2,7 @@ package carpet.fakes; import com.mojang.datafixers.util.Either; import net.minecraft.server.world.ChunkHolder; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.thread.ThreadExecutor; import net.minecraft.world.chunk.Chunk; @@ -10,5 +11,5 @@ import java.util.concurrent.CompletableFuture; public interface ChunkHolderInterface { - CompletableFuture> setDefaultProtoChunk(ChunkPos chpos, ThreadExecutor executor); + CompletableFuture> setDefaultProtoChunk(ChunkPos chpos, ThreadExecutor executor, ServerWorld world); } diff --git a/src/main/java/carpet/fakes/ExperienceOrbInterface.java b/src/main/java/carpet/fakes/ExperienceOrbInterface.java index 00179d01..f6f0485f 100644 --- a/src/main/java/carpet/fakes/ExperienceOrbInterface.java +++ b/src/main/java/carpet/fakes/ExperienceOrbInterface.java @@ -5,4 +5,6 @@ public interface ExperienceOrbInterface int getCombineDelay(); void setCombineDelay(int what); void setAmount(int what); + int getCount(); + void setCount(int i); } diff --git a/src/main/java/carpet/helpers/BlockRotator.java b/src/main/java/carpet/helpers/BlockRotator.java index da8b09bd..49af4a69 100644 --- a/src/main/java/carpet/helpers/BlockRotator.java +++ b/src/main/java/carpet/helpers/BlockRotator.java @@ -48,8 +48,8 @@ import net.minecraft.world.World; public class BlockRotator { public static boolean flipBlockWithCactus(BlockState state, World world, PlayerEntity player, Hand hand, BlockHitResult hit) - { - if (!player.abilities.allowModifyWorld || !CarpetSettings.flippinCactus || !player_holds_cactus_mainhand(player)) + { //getAbilities() + if (!player.method_31549().allowModifyWorld || !CarpetSettings.flippinCactus || !player_holds_cactus_mainhand(player)) { return false; } diff --git a/src/main/java/carpet/helpers/EntityPlayerActionPack.java b/src/main/java/carpet/helpers/EntityPlayerActionPack.java index 64083201..696ac319 100644 --- a/src/main/java/carpet/helpers/EntityPlayerActionPack.java +++ b/src/main/java/carpet/helpers/EntityPlayerActionPack.java @@ -248,7 +248,7 @@ public class EntityPlayerActionPack private void dropItemFromSlot(int slot, boolean dropAll) { - PlayerInventory inv = player.inventory; + PlayerInventory inv = player.method_31548(); // getInventory; if (!inv.getStack(slot).isEmpty()) player.dropItem(inv.removeStack(slot, dropAll ? inv.getStack(slot).getCount() : 1 @@ -257,7 +257,7 @@ public class EntityPlayerActionPack public void drop(int selectedSlot, boolean dropAll) { - PlayerInventory inv = player.inventory; + PlayerInventory inv = player.method_31548(); // getInventory; if (selectedSlot == -2) // all { for (int i = inv.size(); i >= 0; i--) diff --git a/src/main/java/carpet/helpers/OptimizedExplosion.java b/src/main/java/carpet/helpers/OptimizedExplosion.java index ddaaa92d..be910afb 100644 --- a/src/main/java/carpet/helpers/OptimizedExplosion.java +++ b/src/main/java/carpet/helpers/OptimizedExplosion.java @@ -172,7 +172,7 @@ public class OptimizedExplosion PlayerEntity player = (PlayerEntity) entity; if (!player.isSpectator() - && (!player.isCreative() || !player.abilities.flying)) { + && (!player.isCreative() || !player.method_31549().flying)) { //getAbilities e.getAffectedPlayers().put(player, new Vec3d(d5 * d10, d7 * d10, d9 * d10)); } } @@ -227,7 +227,7 @@ public class OptimizedExplosion { if (block.shouldDropItemsOnExplosion(e) && world instanceof ServerWorld) { - BlockEntity blockEntity = block.hasBlockEntity() ? world.getBlockEntity(blockpos) : null; + BlockEntity blockEntity = state.method_31709() ? world.getBlockEntity(blockpos) : null; //hasBlockEntity() LootContext.Builder lootBuilder = (new LootContext.Builder((ServerWorld)eAccess.getWorld())) .random(eAccess.getWorld().random) diff --git a/src/main/java/carpet/helpers/XPcombine.java b/src/main/java/carpet/helpers/XPcombine.java index 0f27e5c6..00826d8d 100644 --- a/src/main/java/carpet/helpers/XPcombine.java +++ b/src/main/java/carpet/helpers/XPcombine.java @@ -28,7 +28,7 @@ public class XPcombine first == other || first.world.isClient || first.getServer().getTicks() == lastTickCombine || !first.isAlive() || !other.isAlive() || first.getExperienceAmount() > 15000 || other.getExperienceAmount() > 15000 - || first.pickupDelay == 32767 || other.pickupDelay == 32767 + //|| first.pickupDelay == 32767 || other.pickupDelay == 32767 || first.age == -32768 || other.age == -32768 || ((ExperienceOrbInterface)first).getCombineDelay() != 0 || ((ExperienceOrbInterface)other).getCombineDelay() != 0 ) @@ -37,10 +37,13 @@ public class XPcombine } int size = getTextureByXP(first.getExperienceAmount()); - ((ExperienceOrbInterface) first).setAmount(first.getExperienceAmount() + other.getExperienceAmount()); - ((ExperienceOrbInterface) first).setCombineDelay(Math.max(first.pickupDelay, other.pickupDelay)); + ((ExperienceOrbInterface) first).setAmount( + first.getExperienceAmount()*((ExperienceOrbInterface) first).getCount() + + other.getExperienceAmount()*((ExperienceOrbInterface) other).getCount()); + ((ExperienceOrbInterface) first).setCount(1); + //((ExperienceOrbInterface) first).setCombineDelay(Math.max(first.pickupDelay, other.pickupDelay)); first.age = Math.min(first.age, other.age); - other.remove(); + other.discard(); //discard ExperienceOrbEntity newOrb; @@ -51,7 +54,7 @@ public class XPcombine ((ExperienceOrbInterface)newOrb).setAmount(first.getExperienceAmount()); first.world.spawnEntity(newOrb); - first.remove(); + first.discard(); // discard } else { diff --git a/src/main/java/carpet/mixins/AbstractCauldronBlock_stackableSBoxesMixin.java b/src/main/java/carpet/mixins/AbstractCauldronBlock_stackableSBoxesMixin.java new file mode 100644 index 00000000..5b02fa77 --- /dev/null +++ b/src/main/java/carpet/mixins/AbstractCauldronBlock_stackableSBoxesMixin.java @@ -0,0 +1,37 @@ +package carpet.mixins; + +import carpet.CarpetSettings; +import net.minecraft.block.AbstractCauldronBlock; +import net.minecraft.block.BlockState; +import net.minecraft.block.ShulkerBoxBlock; +import net.minecraft.class_5620; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.BlockItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(AbstractCauldronBlock.class) +public class AbstractCauldronBlock_stackableSBoxesMixin +{ + @Redirect(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/class_5620;interact(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/util/ActionResult;")) + private ActionResult wrapInteractor(class_5620 class_5620, BlockState blockState, World world, BlockPos blockPos, PlayerEntity playerEntity, Hand hand, ItemStack itemStack) + { + int count = -1; + if (CarpetSettings.stackableShulkerBoxes && itemStack.getItem() instanceof BlockItem && ((BlockItem)itemStack.getItem()).getBlock() instanceof ShulkerBoxBlock) + count = itemStack.getCount(); + ActionResult result = class_5620.interact(blockState, world, blockPos, playerEntity, hand, itemStack); + if (count > 0 && result.isAccepted()) + { + ItemStack current = playerEntity.getStackInHand(hand); + if (current.getItem() instanceof BlockItem && ((BlockItem)itemStack.getItem()).getBlock() instanceof ShulkerBoxBlock) + current.setCount(count); + } + return result; + } +} diff --git a/src/main/java/carpet/mixins/ArmorStandEntity_scarpetMarkerMixin.java b/src/main/java/carpet/mixins/ArmorStandEntity_scarpetMarkerMixin.java index 5c6afd16..1547a91b 100644 --- a/src/main/java/carpet/mixins/ArmorStandEntity_scarpetMarkerMixin.java +++ b/src/main/java/carpet/mixins/ArmorStandEntity_scarpetMarkerMixin.java @@ -41,13 +41,13 @@ public abstract class ArmorStandEntity_scarpetMarkerMixin extends LivingEntity String hostName = StringUtils.removeStart(owner.get(),prefix); if (!hostName.isEmpty() && CarpetServer.scriptServer.getHostByName(hostName) == null) { - remove(); + discard(); //discard } } else { - remove(); + discard(); // discard } } } diff --git a/src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java b/src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java new file mode 100644 index 00000000..3c9c13e3 --- /dev/null +++ b/src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java @@ -0,0 +1,13 @@ +package carpet.mixins; + +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.util.math.BlockPos; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(BlockEntity.class) +public interface BlockEntity_movableBEMixin +{ + @Accessor + void setPos(BlockPos pos); +} diff --git a/src/main/java/carpet/mixins/BlockItem_creativeNoClipMixin.java b/src/main/java/carpet/mixins/BlockItem_creativeNoClipMixin.java index 48bf7e8b..ab5044a0 100644 --- a/src/main/java/carpet/mixins/BlockItem_creativeNoClipMixin.java +++ b/src/main/java/carpet/mixins/BlockItem_creativeNoClipMixin.java @@ -24,7 +24,7 @@ public class BlockItem_creativeNoClipMixin ItemPlacementContext contextOuter, BlockState stateOuter) { PlayerEntity player = contextOuter.getPlayer(); - if (CarpetSettings.creativeNoClip && player != null && player.isCreative() && player.abilities.flying) + if (CarpetSettings.creativeNoClip && player != null && player.isCreative() && player.method_31549().flying) { // copy from canPlace VoxelShape voxelShape = state.getCollisionShape(world, pos, context); diff --git a/src/main/java/carpet/mixins/CauldronBlock_stackableSBoxesMixin.java b/src/main/java/carpet/mixins/CauldronBlock_stackableSBoxesMixin.java index 783a035a..be348daf 100644 --- a/src/main/java/carpet/mixins/CauldronBlock_stackableSBoxesMixin.java +++ b/src/main/java/carpet/mixins/CauldronBlock_stackableSBoxesMixin.java @@ -19,7 +19,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(CauldronBlock.class) public class CauldronBlock_stackableSBoxesMixin -{ +{/* @Inject(method = "onUse", locals = LocalCapture.CAPTURE_FAILHARD, at = @At( value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;hasTag()Z", @@ -30,5 +30,5 @@ public class CauldronBlock_stackableSBoxesMixin { if (CarpetSettings.stackableShulkerBoxes) itemStack5.setCount(itemStack.getCount()); - } + }*/ } diff --git a/src/main/java/carpet/mixins/ChunkHolder_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/ChunkHolder_scarpetChunkCreationMixin.java index 7a1d8fc7..4d80f587 100644 --- a/src/main/java/carpet/mixins/ChunkHolder_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/ChunkHolder_scarpetChunkCreationMixin.java @@ -3,6 +3,7 @@ package carpet.mixins; import carpet.fakes.ChunkHolderInterface; import com.mojang.datafixers.util.Either; import net.minecraft.server.world.ChunkHolder; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.thread.ThreadExecutor; import net.minecraft.world.chunk.Chunk; @@ -24,11 +25,11 @@ public abstract class ChunkHolder_scarpetChunkCreationMixin implements ChunkHold @Shadow @Final private AtomicReferenceArray>> futuresByStatus; @Override - public CompletableFuture> setDefaultProtoChunk(ChunkPos chpos, ThreadExecutor executor) + public CompletableFuture> setDefaultProtoChunk(ChunkPos chpos, ThreadExecutor executor, ServerWorld world) { int i = ChunkStatus.EMPTY.getIndex(); CompletableFuture> completableFuture2 = CompletableFuture.supplyAsync( - () -> Either.left(new ProtoChunk(chpos, UpgradeData.NO_UPGRADE_DATA)), + () -> Either.left(new ProtoChunk(chpos, UpgradeData.NO_UPGRADE_DATA, world)), executor ); combineSavingFuture(completableFuture2); diff --git a/src/main/java/carpet/mixins/ClientPlayNetworkHandler_smoothClientAnimationsMixin.java b/src/main/java/carpet/mixins/ClientPlayNetworkHandler_smoothClientAnimationsMixin.java index 1a5f06e6..1c839d19 100644 --- a/src/main/java/carpet/mixins/ClientPlayNetworkHandler_smoothClientAnimationsMixin.java +++ b/src/main/java/carpet/mixins/ClientPlayNetworkHandler_smoothClientAnimationsMixin.java @@ -22,6 +22,7 @@ import java.util.Iterator; @Mixin(ClientPlayNetworkHandler.class) public class ClientPlayNetworkHandler_smoothClientAnimationsMixin { + /* @Shadow private ClientWorld world; // fix as suggested by G4me4u @Inject( method = "onChunkData", locals = LocalCapture.CAPTURE_FAILHARD, require = 0, at = @At( @@ -48,5 +49,5 @@ public class ClientPlayNetworkHandler_smoothClientAnimationsMixin } } } - } + }*/ } diff --git a/src/main/java/carpet/mixins/ContainerMixin.java b/src/main/java/carpet/mixins/ContainerMixin.java index f2beddee..96530b8c 100644 --- a/src/main/java/carpet/mixins/ContainerMixin.java +++ b/src/main/java/carpet/mixins/ContainerMixin.java @@ -7,6 +7,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.screen.ScreenHandler; +import net.minecraft.util.collection.DefaultedList; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -19,20 +20,21 @@ import java.util.List; @Mixin(ScreenHandler.class) public abstract class ContainerMixin { - @Shadow @Final public List slots; @Shadow public abstract ItemStack onSlotClick(int int_1, int int_2, SlotActionType slotActionType_1, PlayerEntity playerEntity_1); @Shadow public abstract void sendContentUpdates(); - @Inject( method = "onSlotClick", at = @At(value = "HEAD"), cancellable = true) + @Shadow @Final public DefaultedList slots; + + @Inject( method = "method_30010", at = @At(value = "HEAD"), cancellable = true) // on slot click private void onThrowClick( int slotId, int clickData, SlotActionType actionType, PlayerEntity playerEntity, CallbackInfoReturnable cir) { - if (actionType == SlotActionType.THROW && CarpetSettings.ctrlQCraftingFix && playerEntity.inventory.getCursorStack().isEmpty() && slotId >= 0) + if (actionType == SlotActionType.THROW && CarpetSettings.ctrlQCraftingFix && playerEntity.method_31548().getCursorStack().isEmpty() && slotId >= 0) { ItemStack itemStack_1 = ItemStack.EMPTY; Slot slot_4 = slots.get(slotId); - if (slot_4 != null && slot_4.hasStack() && slot_4.canTakeItems(playerEntity)) + if (/*slot_4 != null && */slot_4.hasStack() && slot_4.canTakeItems(playerEntity)) { if(slotId == 0 && clickData == 1) { diff --git a/src/main/java/carpet/mixins/Entity_scarpetEventsMixin.java b/src/main/java/carpet/mixins/Entity_scarpetEventsMixin.java index c68be88b..0070517a 100644 --- a/src/main/java/carpet/mixins/Entity_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/Entity_scarpetEventsMixin.java @@ -12,10 +12,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(Entity.class) public abstract class Entity_scarpetEventsMixin implements EntityInterface { - @Shadow public boolean removed; + //@Shadow public boolean removed; @Shadow protected int netherPortalTime; @Shadow private int netherPortalCooldown; + + @Shadow public abstract boolean isRemoved(); + private boolean permanentVehicle; private final EntityEventsGroup events = new EntityEventsGroup((Entity) (Object)this); @@ -72,7 +75,7 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface @Inject(method = "remove", at = @At("HEAD")) private void onRemove(CallbackInfo ci) { - if (!removed) events.onEvent(EntityEventsGroup.Event.ON_REMOVED); + if (!isRemoved()) events.onEvent(EntityEventsGroup.Event.ON_REMOVED); // ! isRemoved() } diff --git a/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java b/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java index c639b3cf..819d616d 100644 --- a/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java +++ b/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java @@ -16,6 +16,8 @@ public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface { @Shadow private int amount; + @Shadow private int field_27009; + public void setAmount(int amount) { this.amount = amount; } public int combineDelay = 50; @@ -45,6 +47,16 @@ public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface } } + @Override + public int getCount() { + return field_27009; + } + + @Override + public void setCount(int i) { + field_27009 = i; + } + @Inject(method = "onPlayerCollision", at = @At("HEAD")) void removeDelay(PlayerEntity playerEntity_1, CallbackInfo ci) { diff --git a/src/main/java/carpet/mixins/FallingBlockEntityMixin.java b/src/main/java/carpet/mixins/FallingBlockEntityMixin.java index 5cc0b912..82db5835 100644 --- a/src/main/java/carpet/mixins/FallingBlockEntityMixin.java +++ b/src/main/java/carpet/mixins/FallingBlockEntityMixin.java @@ -33,9 +33,9 @@ public abstract class FallingBlockEntityMixin extends Entity } @Override - public void remove() + public void remove(Entity.RemovalReason arg) // reason { - super.remove(); + super.remove(arg); if (LoggerRegistry.__fallingBlocks && logHelper != null) logHelper.onFinish(); } diff --git a/src/main/java/carpet/mixins/GuardianEntityMixin.java b/src/main/java/carpet/mixins/GuardianEntityMixin.java index 694ae931..af188bad 100644 --- a/src/main/java/carpet/mixins/GuardianEntityMixin.java +++ b/src/main/java/carpet/mixins/GuardianEntityMixin.java @@ -23,8 +23,8 @@ public abstract class GuardianEntityMixin extends HostileEntity @Override public void onStruckByLightning(ServerWorld serverWorld, LightningEntity lightningEntity) - { - if (!this.world.isClient && !this.removed && CarpetSettings.renewableSponges && !((Object)this instanceof ElderGuardianEntity)) + { // isRemoved() + if (!this.world.isClient && !this.isRemoved() && CarpetSettings.renewableSponges && !((Object)this instanceof ElderGuardianEntity)) { ElderGuardianEntity elderGuardian = new ElderGuardianEntity(EntityType.ELDER_GUARDIAN ,this.world); elderGuardian.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), this.yaw, this.pitch); @@ -38,7 +38,7 @@ public abstract class GuardianEntityMixin extends HostileEntity } this.world.spawnEntity(elderGuardian); - this.remove(); + this.discard(); // discard remove(); } else { diff --git a/src/main/java/carpet/mixins/HopperBlockEntityMixin.java b/src/main/java/carpet/mixins/HopperBlockEntityMixin.java index 265eef8a..15840d29 100644 --- a/src/main/java/carpet/mixins/HopperBlockEntityMixin.java +++ b/src/main/java/carpet/mixins/HopperBlockEntityMixin.java @@ -1,13 +1,16 @@ package carpet.mixins; import carpet.CarpetSettings; +import net.minecraft.block.BlockState; import net.minecraft.block.HopperBlock; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.HopperBlockEntity; import net.minecraft.block.entity.LootableContainerBlockEntity; +import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; import net.minecraft.util.DyeColor; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -17,41 +20,32 @@ import carpet.helpers.HopperCounter; import carpet.utils.WoolTool; @Mixin(HopperBlockEntity.class) -public abstract class HopperBlockEntityMixin extends LootableContainerBlockEntity { - - protected HopperBlockEntityMixin(BlockEntityType blockEntityType_1) { - super(blockEntityType_1); +public abstract class HopperBlockEntityMixin extends LootableContainerBlockEntity +{ + protected HopperBlockEntityMixin(BlockEntityType blockEntityType, BlockPos blockPos, BlockState blockState) { + super(blockEntityType, blockPos, blockState); } - @Shadow - public abstract double getHopperX(); - - @Shadow - public abstract double getHopperY(); - - @Shadow - public abstract double getHopperZ(); - @Shadow public abstract int size(); @Shadow public abstract void setStack(int slot, ItemStack stack); @Inject(method = "insert", at = @At("HEAD"), cancellable = true) - private void onInsert(CallbackInfoReturnable cir) + private static void onInsert(World world, BlockPos blockPos, BlockState blockState, Inventory inventory, CallbackInfoReturnable cir) { if (CarpetSettings.hopperCounters) { DyeColor wool_color = WoolTool.getWoolColorAtPosition( - getWorld(), - new BlockPos(getHopperX(), getHopperY(), getHopperZ()).offset(this.getCachedState().get(HopperBlock.FACING))); + world, + blockPos.offset(blockState.get(HopperBlock.FACING))); if (wool_color != null) { - for (int i = 0; i < size(); ++i) + for (int i = 0; i < inventory.size(); ++i) { - if (!this.getStack(i).isEmpty()) + if (!inventory.getStack(i).isEmpty()) { - ItemStack itemstack = this.getStack(i);//.copy(); - HopperCounter.COUNTERS.get(wool_color).add(this.getWorld().getServer(), itemstack); - this.setStack(i, ItemStack.EMPTY); + ItemStack itemstack = inventory.getStack(i);//.copy(); + HopperCounter.COUNTERS.get(wool_color).add(world.getServer(), itemstack); + inventory.setStack(i, ItemStack.EMPTY); } } cir.setReturnValue(true); diff --git a/src/main/java/carpet/mixins/ItemEntityMixin.java b/src/main/java/carpet/mixins/ItemEntityMixin.java index 5105a381..aa57be5c 100644 --- a/src/main/java/carpet/mixins/ItemEntityMixin.java +++ b/src/main/java/carpet/mixins/ItemEntityMixin.java @@ -97,7 +97,7 @@ public abstract class ItemEntityMixin extends Entity implements ItemEntityInterf otherStack.decrement(amount); if (otherStack.isEmpty()) { - other.remove(); + other.discard(); // discard remove(); } else { diff --git a/src/main/java/carpet/mixins/LivingEntity_creativeFlyMixin.java b/src/main/java/carpet/mixins/LivingEntity_creativeFlyMixin.java index c50a364c..6d3cf5c3 100644 --- a/src/main/java/carpet/mixins/LivingEntity_creativeFlyMixin.java +++ b/src/main/java/carpet/mixins/LivingEntity_creativeFlyMixin.java @@ -30,7 +30,7 @@ public abstract class LivingEntity_creativeFlyMixin extends Entity if (CarpetSettings.creativeFlyDrag != 0.09 && (Object)this instanceof PlayerEntity) { PlayerEntity self = (PlayerEntity)(Object)(this); - if (self.abilities.flying && ! onGround ) + if (self.method_31549().flying && ! onGround ) return (float)(1.0-CarpetSettings.creativeFlyDrag); } return original; @@ -43,7 +43,7 @@ public abstract class LivingEntity_creativeFlyMixin extends Entity if (CarpetSettings.creativeFlySpeed != 1.0D && (Object)this instanceof PlayerEntity) { PlayerEntity self = (PlayerEntity)(Object)(this); - if (self.abilities.flying && !onGround) + if (self.method_31549().flying && !onGround) cir.setReturnValue(flyingSpeed* (float)CarpetSettings.creativeFlySpeed); } } diff --git a/src/main/java/carpet/mixins/PistonBlockEntityRenderer_movableTEMixin.java b/src/main/java/carpet/mixins/PistonBlockEntityRenderer_movableTEMixin.java index 910cd16c..35470231 100644 --- a/src/main/java/carpet/mixins/PistonBlockEntityRenderer_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonBlockEntityRenderer_movableTEMixin.java @@ -4,6 +4,7 @@ import carpet.CarpetSettings; import carpet.fakes.PistonBlockEntityInterface; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.PistonBlockEntity; +import net.minecraft.class_5614; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.client.render.block.entity.BlockEntityRenderer; @@ -16,11 +17,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(PistonBlockEntityRenderer.class) -public abstract class PistonBlockEntityRenderer_movableTEMixin extends BlockEntityRenderer +public abstract class PistonBlockEntityRenderer_movableTEMixin implements BlockEntityRenderer { - public PistonBlockEntityRenderer_movableTEMixin(BlockEntityRenderDispatcher blockEntityRenderDispatcher_1) + BlockEntityRenderDispatcher dispatcher; + @Inject(method = "", at = @At("TAIL")) + private void onInitCM(class_5614.class_5615 arg, CallbackInfo ci) { - super(blockEntityRenderDispatcher_1); + dispatcher = arg.method_32139(); } @Inject(method = "render", at = @At(value = "INVOKE", @@ -41,14 +44,14 @@ public abstract class PistonBlockEntityRenderer_movableTEMixin extends BlockEnti BlockEntity carriedBlockEntity = ((PistonBlockEntityInterface) pistonBlockEntity_1).getCarriedBlockEntity(); if (carriedBlockEntity != null) { - carriedBlockEntity.setPos(pistonBlockEntity_1.getPos()); + // maybe ??? carriedBlockEntity.setPos(pistonBlockEntity_1.getPos()); //((BlockEntityRenderDispatcherInterface) BlockEntityRenderDispatcher.INSTANCE).renderBlockEntityOffset(carriedBlockEntity, float_1, int_1, BlockRenderLayer.field_20799, bufferBuilder_1, pistonBlockEntity_1.getRenderOffsetX(float_1), pistonBlockEntity_1.getRenderOffsetY(float_1), pistonBlockEntity_1.getRenderOffsetZ(float_1)); matrixStack_1.translate( pistonBlockEntity_1.getRenderOffsetX(partialTicks), pistonBlockEntity_1.getRenderOffsetY(partialTicks), pistonBlockEntity_1.getRenderOffsetZ(partialTicks) ); - BlockEntityRenderDispatcher.INSTANCE.render(carriedBlockEntity, partialTicks, matrixStack_1, layeredVertexConsumerStorage_1); + dispatcher.render(carriedBlockEntity, partialTicks, matrixStack_1, layeredVertexConsumerStorage_1); } } diff --git a/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java b/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java index ef16df54..9ecca0a3 100644 --- a/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java @@ -32,13 +32,12 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple private BlockEntity carriedBlockEntity; private boolean renderCarriedBlockEntity = false; private boolean renderSet = false; - - public PistonBlockEntity_movableTEMixin(BlockEntityType blockEntityType_1) - { - super(blockEntityType_1); + + public PistonBlockEntity_movableTEMixin(BlockEntityType blockEntityType, BlockPos blockPos, BlockState blockState) { + super(blockEntityType, blockPos, blockState); } - - + + /** * @author 2No2Name */ @@ -46,12 +45,23 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple { return carriedBlockEntity; } - + + @Override + public void method_31662(World world) { + super.method_31662(world); + if (carriedBlockEntity != null) carriedBlockEntity.method_31662(world); + } + public void setCarriedBlockEntity(BlockEntity blockEntity) { this.carriedBlockEntity = blockEntity; if (this.carriedBlockEntity != null) - this.carriedBlockEntity.setPos(this.pos); + { + ((BlockEntity_movableBEMixin)carriedBlockEntity).setPos(pos); + // this might be little dangerous since pos is final for a hashing reason? + if (world != null) carriedBlockEntity.method_31662(world); + } + // this.carriedBlockEntity.setPos(this.pos); } public boolean isRenderModeSet() @@ -73,14 +83,16 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple /** * @author 2No2Name */ - @Redirect(method = "tick", at = @At(value = "INVOKE", + @Redirect(method = "method_31707", at = @At(value = "INVOKE", // tick target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) - private boolean movableTEsetBlockState0(World world, BlockPos blockPos_1, BlockState blockAState_2, int int_1) + private static boolean movableTEsetBlockState0( + World world, BlockPos blockPos_1, BlockState blockAState_2, int int_1, + World world2, BlockPos blockPos, BlockState blockState, PistonBlockEntity pistonBlockEntity) { if (!CarpetSettings.movableBlockEntities) return world.setBlockState(blockPos_1, blockAState_2, int_1); else - return ((WorldInterface) (world)).setBlockStateWithBlockEntity(blockPos_1, blockAState_2, this.carriedBlockEntity, int_1); + return ((WorldInterface) (world)).setBlockStateWithBlockEntity(blockPos_1, blockAState_2, ((PistonBlockEntityInterface)pistonBlockEntity).getCarriedBlockEntity(), int_1); } @Redirect(method = "finish", at = @At(value = "INVOKE", @@ -116,14 +128,15 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple } @Inject(method = "fromTag", at = @At(value = "TAIL")) - private void onFromTag(BlockState state, CompoundTag compoundTag_1, CallbackInfo ci) + private void onFromTag(CompoundTag compoundTag_1, CallbackInfo ci) { if (CarpetSettings.movableBlockEntities && compoundTag_1.contains("carriedTileEntityCM", 10)) { if (this.pushedBlock.getBlock() instanceof BlockEntityProvider) - this.carriedBlockEntity = ((BlockEntityProvider) (this.pushedBlock.getBlock())).createBlockEntity(this.world); + this.carriedBlockEntity = ((BlockEntityProvider) (this.pushedBlock.getBlock())).createBlockEntity(pos, pushedBlock);// this.world); if (carriedBlockEntity != null) //Can actually be null, as BlockPistonMoving.createNewTileEntity(...) returns null - this.carriedBlockEntity.fromTag(state, compoundTag_1.getCompound("carriedTileEntityCM")); + this.carriedBlockEntity.fromTag(compoundTag_1.getCompound("carriedTileEntityCM")); + setCarriedBlockEntity(carriedBlockEntity); } } diff --git a/src/main/java/carpet/mixins/PistonBlockEntity_playerHandlingMixin.java b/src/main/java/carpet/mixins/PistonBlockEntity_playerHandlingMixin.java index e2b5f65b..86a20d8b 100644 --- a/src/main/java/carpet/mixins/PistonBlockEntity_playerHandlingMixin.java +++ b/src/main/java/carpet/mixins/PistonBlockEntity_playerHandlingMixin.java @@ -8,8 +8,10 @@ import net.minecraft.block.entity.PistonBlockEntity; import net.minecraft.block.piston.PistonBehavior; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -27,13 +29,13 @@ public abstract class PistonBlockEntity_playerHandlingMixin @Inject(method = "method_23672", at = @At("HEAD"), cancellable = true) private static void dontPushSpectators(Direction direction, Entity entity, double d, Direction direction2, CallbackInfo ci) { - if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).abilities.flying) ci.cancel(); + if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).method_31549().flying) ci.cancel(); } @Redirect(method = "pushEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setVelocity(DDD)V")) - private void ignoreAccel(Entity entity, double x, double y, double z) + private static void ignoreAccel(Entity entity, double x, double y, double z) { - if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).abilities.flying) return; + if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).method_31549().flying) return; entity.setVelocity(x,y,z); } @@ -41,15 +43,16 @@ public abstract class PistonBlockEntity_playerHandlingMixin value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPistonBehavior()Lnet/minecraft/block/piston/PistonBehavior;" )) - private PistonBehavior moveFakePlayers(Entity entity) + private static PistonBehavior moveFakePlayers(Entity entity, + World world, BlockPos blockPos, float ff, PistonBlockEntity pistonBlockEntity) { - if (entity instanceof EntityPlayerMPFake && pushedBlock.isOf(Blocks.SLIME_BLOCK)) + if (entity instanceof EntityPlayerMPFake && pistonBlockEntity.getPushedBlock().isOf(Blocks.SLIME_BLOCK)) { Vec3d vec3d = entity.getVelocity(); double e = vec3d.x; double f = vec3d.y; double g = vec3d.z; - Direction direction = getMovementDirection(); + Direction direction = pistonBlockEntity.getMovementDirection(); switch(direction.getAxis()) { case X: e = (double)direction.getOffsetX(); diff --git a/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java b/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java index 8d776a32..916e60a5 100644 --- a/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java @@ -51,16 +51,16 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock block != Blocks.SPAWNER; } - @Redirect(method = "isMovable", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;hasBlockEntity()Z")) // hasBLockENtity - private static boolean ifHasBlockEntity(Block block) + @Redirect(method = "isMovable", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;method_31709()Z")) // hasBLockENtity + private static boolean ifHasBlockEntity(BlockState blockState) { - if (!block.hasBlockEntity()) + if (!blockState.method_31709()) { return false; } else { - return !(CarpetSettings.movableBlockEntities && isPushableBlockEntity(block)); + return !(CarpetSettings.movableBlockEntities && isPushableBlockEntity(blockState.getBlock())); } } @@ -88,7 +88,7 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock for (int i = 0; i < list_1.size(); ++i) { BlockPos blockpos = list_1.get(i); - BlockEntity blockEntity = (list_2.get(i).getBlock().hasBlockEntity()) ? world_1.getBlockEntity(blockpos) : null; + BlockEntity blockEntity = (list_2.get(i).method_31709()) ? world_1.getBlockEntity(blockpos) : null; list1_BlockEntities.get().add(blockEntity); if (blockEntity != null) { @@ -102,34 +102,32 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock } @Inject(method = "move", at = @At(value = "INVOKE", shift = At.Shift.BEFORE, - target = "Lnet/minecraft/world/World;setBlockEntity(Lnet/minecraft/util/math/BlockPos;" + - "Lnet/minecraft/block/entity/BlockEntity;)V", ordinal = 0), + target = "Lnet/minecraft/world/World;addBlockEntity(Lnet/minecraft/block/entity/BlockEntity;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD) private void setBlockEntityWithCarried(World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1, CallbackInfoReturnable cir, BlockPos blockPos_2, PistonHandler pistonHandler_1, Map map_1, List list_1, List list_2, List list_3, BlockState[] blockStates_1, Direction direction_2, int int_2, - int int_3, BlockPos blockPos_4, BlockState blockState_1) + int int_3, BlockPos blockPos_4, BlockState blockState9, BlockState blockState4) { - BlockEntity blockEntityPiston = PistonExtensionBlock.createBlockEntityPiston((BlockState) list_2.get(int_3), + BlockEntity blockEntityPiston = PistonExtensionBlock.createBlockEntityPiston(blockPos_4, blockState4, (BlockState) list_2.get(int_3), direction_1, boolean_1, false); if (CarpetSettings.movableBlockEntities) ((PistonBlockEntityInterface) blockEntityPiston).setCarriedBlockEntity(list1_BlockEntities.get().get(int_3)); - world_1.setBlockEntity(blockPos_4, blockEntityPiston); + world_1.addBlockEntity(blockEntityPiston); + //world_1.setBlockEntity(blockPos_4, blockEntityPiston); } @Redirect(method = "move", at = @At(value = "INVOKE", - target = "Lnet/minecraft/world/World;setBlockEntity(Lnet/minecraft/util/math/BlockPos;" + - "Lnet/minecraft/block/entity/BlockEntity;)V", + target = "Lnet/minecraft/world/World;addBlockEntity(Lnet/minecraft/block/entity/BlockEntity;)V", ordinal = 0)) - private void dontDoAnything(World world, BlockPos blockPos_6, BlockEntity blockEntityPiston) + private void dontDoAnything(World world, BlockEntity blockEntity) { } @Redirect(method = "move", at = @At(value = "INVOKE", - target = "Lnet/minecraft/block/PistonExtensionBlock;createBlockEntityPiston(Lnet/minecraft/block/BlockState;" + - "Lnet/minecraft/util/math/Direction;ZZ)Lnet/minecraft/block/entity/BlockEntity;", + target = "Lnet/minecraft/block/PistonExtensionBlock;createBlockEntityPiston(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/Direction;ZZ)Lnet/minecraft/block/entity/BlockEntity;", ordinal = 0)) - private BlockEntity returnNull(BlockState blockState_1, Direction direction_1, boolean boolean_1, boolean boolean_2) + private BlockEntity returnNull(BlockPos blockPos, BlockState blockState, BlockState blockState2, Direction direction, boolean bl, boolean bl2) { return null; } diff --git a/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java b/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java index b262f9cc..261be608 100644 --- a/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java +++ b/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java @@ -39,21 +39,19 @@ public abstract class PistonHandler_customStickyMixin @Shadow @Final private World world; @Shadow @Final private Direction motionDirection; @Shadow protected abstract boolean tryMove(BlockPos blockPos_1, Direction direction_1); - @Shadow private static boolean isBlockSticky(Block block_1) { return false; } - @Shadow private static boolean isAdjacentBlockStuck(Block block, Block block2) {return false;} + @Shadow private static boolean isBlockSticky(BlockState block_1) { return false; } + @Shadow private static boolean isAdjacentBlockStuck(BlockState block, BlockState block2) {return false;} @Shadow protected abstract boolean canMoveAdjacentBlock(BlockPos pos); // collects information about sticking block when backtracking. private BlockPos currentPos; private BlockState currentState; - private BlockState previousState; @Redirect(method = "tryMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;", ordinal = 0)) private BlockState redirectGetBlockState_1_A(World world, BlockPos pos) { - return currentState = previousState = world.getBlockState(pos); + return currentState = world.getBlockState(pos); } @Redirect(method = "tryMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;", ordinal = 1)) private BlockState redirectGetBlockState_1_B(World world, BlockPos pos) { - previousState = currentState; currentPos = pos; return currentState = world.getBlockState(pos); } @@ -64,13 +62,13 @@ public abstract class PistonHandler_customStickyMixin */ @Redirect(method = "tryMove", at = @At( value = "INVOKE", - target = "Lnet/minecraft/block/piston/PistonHandler;isBlockSticky(Lnet/minecraft/block/Block;)Z", + target = "Lnet/minecraft/block/piston/PistonHandler;isBlockSticky(Lnet/minecraft/block/BlockState;)Z", ordinal = 0 ) ) - private boolean redirectIsStickyBlock(Block block_1) + private boolean redirectIsStickyBlock(BlockState blockState) { // applies to both MBE chests as well as sticky chains - return blockCanBePulled(currentState) || isBlockSticky(block_1); + return blockCanBePulled(blockState) || isBlockSticky(blockState); } /** @@ -107,17 +105,17 @@ public abstract class PistonHandler_customStickyMixin */ @Redirect(method = "tryMove", at = @At( value = "INVOKE", - target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)Z") + target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)Z") ) - private boolean isDraggingPreviousBlockBehind(Block previous, Block next) + private boolean isDraggingPreviousBlockBehind(BlockState previous, BlockState next) { if (CarpetSettings.doChainStone) { - if (previousState.getBlock() == Blocks.CHAIN && isChainOnAxis(previousState, motionDirection)) + if (previous.getBlock() == Blocks.CHAIN && isChainOnAxis(previous, motionDirection)) { - if ( (currentState.getBlock() == Blocks.CHAIN && isChainOnAxis(currentState, motionDirection)) + if ( (next.getBlock() == Blocks.CHAIN && isChainOnAxis(next, motionDirection)) || CarpetSettings.chainStoneStickToAll - || isEndRodOnAxis(currentState, motionDirection.getAxis()) + || isEndRodOnAxis(next, motionDirection.getAxis()) || Block.sideCoversSmallSquare(world, currentPos, motionDirection)) { return true; @@ -138,7 +136,7 @@ public abstract class PistonHandler_customStickyMixin target = "Ljava/util/List;get(I)Ljava/lang/Object;", shift = At.Shift.AFTER )) - private void stickToStickySide(BlockPos blockPos_1, Direction direction_1, CallbackInfoReturnable cir, BlockState blockState_1, Block block_1, int int_1, int int_2, int int_4, BlockPos blockPos_3, int int_5, int int_6) + private void stickToStickySide(BlockPos blockPos_1, Direction direction_1, CallbackInfoReturnable cir, BlockState blockState_1, int int_1, int int_2, int int_4, BlockPos blockPos_3, int int_5, int int_6) { if (CarpetSettings.movableBlockEntities) { @@ -208,13 +206,13 @@ public abstract class PistonHandler_customStickyMixin */ @Inject(method = "tryMove", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, at= @At( value = "INVOKE", - target = "Lnet/minecraft/block/piston/PistonHandler;isBlockSticky(Lnet/minecraft/block/Block;)Z", + target = "Lnet/minecraft/block/piston/PistonHandler;isBlockSticky(Lnet/minecraft/block/BlockState;)Z", ordinal = 1, shift = At.Shift.BEFORE ) ) private void redirectIsStickyBlock(BlockPos pos, Direction dir, CallbackInfoReturnable cir, - BlockState blockState, Block block, int i, int j, int l, BlockPos blockPos2, int m, int n, BlockPos blockPos3) + BlockState blockState, int i, int j, int l, BlockPos blockPos2, int m, int n, BlockPos blockPos3) { if (CarpetSettings.doChainStone) { @@ -232,7 +230,7 @@ public abstract class PistonHandler_customStickyMixin */ @Inject(method = "canMoveAdjacentBlock", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, at = @At( value = "INVOKE", - target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)Z", + target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)Z", shift = At.Shift.BEFORE )) private void otherSideStickyCases(BlockPos pos, CallbackInfoReturnable cir, @@ -268,9 +266,9 @@ public abstract class PistonHandler_customStickyMixin */ @Redirect(method = "canMoveAdjacentBlock", at = @At( value = "INVOKE", - target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)Z") + target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)Z") ) - private boolean isStuckSlimeStone(Block block, Block block2) + private boolean isStuckSlimeStone(BlockState block, BlockState block2) { return isBlockSticky(block2) && isAdjacentBlockStuck(block, block2); } diff --git a/src/main/java/carpet/mixins/PlayerEntity_creativeNoClipMixin.java b/src/main/java/carpet/mixins/PlayerEntity_creativeNoClipMixin.java index 0c63c4d4..d7301eee 100644 --- a/src/main/java/carpet/mixins/PlayerEntity_creativeNoClipMixin.java +++ b/src/main/java/carpet/mixins/PlayerEntity_creativeNoClipMixin.java @@ -28,7 +28,7 @@ public abstract class PlayerEntity_creativeNoClipMixin extends LivingEntity ) private boolean canClipTroughWorld(PlayerEntity playerEntity) { - return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.abilities.flying); + return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.method_31549().flying); } @@ -38,7 +38,7 @@ public abstract class PlayerEntity_creativeNoClipMixin extends LivingEntity ) private boolean collidesWithEntities(PlayerEntity playerEntity) { - return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.abilities.flying); + return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.method_31549().flying); } @Redirect(method = "updateSize", at = @At( @@ -47,6 +47,6 @@ public abstract class PlayerEntity_creativeNoClipMixin extends LivingEntity ) private boolean spectatorsDontPose(PlayerEntity playerEntity) { - return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.abilities.flying); + return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.method_31549().flying); } } diff --git a/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java b/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java index 1f8a099b..f2ad37fe 100644 --- a/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java @@ -257,7 +257,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin { if (PLAYER_SWITCHES_SLOT.isNeeded() && player.getServer() != null && player.getServer().isOnThread()) { - PLAYER_SWITCHES_SLOT.onSlotSwitch(player, player.inventory.selectedSlot, packet.getSelectedSlot()); + PLAYER_SWITCHES_SLOT.onSlotSwitch(player, player.method_31548().selectedSlot, packet.getSelectedSlot()); } } } diff --git a/src/main/java/carpet/mixins/ServerWorld_fakePlayersMixin.java b/src/main/java/carpet/mixins/ServerWorld_fakePlayersMixin.java index 352c1622..3e6f97bf 100644 --- a/src/main/java/carpet/mixins/ServerWorld_fakePlayersMixin.java +++ b/src/main/java/carpet/mixins/ServerWorld_fakePlayersMixin.java @@ -14,8 +14,9 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(ServerWorld.class) public abstract class ServerWorld_fakePlayersMixin { - @Shadow /*@Nonnull*/ public abstract MinecraftServer getServer(); + @Shadow /*@Nonnull*/ public abstract MinecraftServer getServer(); +/* @Shadow private boolean inEntityTick; @Redirect( method = "removePlayer", at = @At( @@ -24,7 +25,7 @@ public abstract class ServerWorld_fakePlayersMixin )) private void crashRemovePlayer(ServerWorld serverWorld, Entity entity_1, ServerPlayerEntity serverPlayerEntity_1) { - if ( !(inEntityTick && serverPlayerEntity_1 instanceof EntityPlayerMPFake) ) + if ( !(serverPlayerEntity_1 instanceof EntityPlayerMPFake) ) serverWorld.removeEntity(entity_1); else getServer().send(new ServerTask(getServer().getTicks(), () -> @@ -33,5 +34,5 @@ public abstract class ServerWorld_fakePlayersMixin serverPlayerEntity_1.onTeleportationDone(); })); - } + }*/ } diff --git a/src/main/java/carpet/mixins/ServerWorld_scarpetEventMixin.java b/src/main/java/carpet/mixins/ServerWorld_scarpetEventMixin.java index 5c11338a..7373895b 100644 --- a/src/main/java/carpet/mixins/ServerWorld_scarpetEventMixin.java +++ b/src/main/java/carpet/mixins/ServerWorld_scarpetEventMixin.java @@ -2,6 +2,8 @@ package carpet.mixins; import carpet.CarpetSettings; import carpet.script.CarpetEventServer; +import net.minecraft.class_5568; +import net.minecraft.class_5579; import net.minecraft.entity.Entity; import net.minecraft.entity.LightningEntity; import net.minecraft.server.world.ServerWorld; @@ -12,6 +14,7 @@ import net.minecraft.world.chunk.WorldChunk; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @@ -34,24 +37,25 @@ public class ServerWorld_scarpetEventMixin if (LIGHTNING.isNeeded()) LIGHTNING.onWorldEventFlag((ServerWorld) (Object)this, blockPos, bl2?1:0); } - @Inject(method = "loadEntityUnchecked", at = @At( + @Redirect(method = "addEntity", at = @At( value = "INVOKE", - target = "Lnet/minecraft/server/world/ServerChunkManager;loadEntity(Lnet/minecraft/entity/Entity;)V" + target = "Lnet/minecraft/class_5579;method_31818(Lnet/minecraft/class_5568;)Z" )) - private void onEntityAddedToWorld(Entity entity, CallbackInfo ci) + private boolean onEntityAddedToWorld(class_5579 class_5579, class_5568 arg) { - CarpetEventServer.Event event = ENTITY_LOAD.get(entity.getType()); - if (event != null) - { - if (event.isNeeded()) - { - event.onEntityAction(entity); + Entity entity = (Entity)arg; + boolean success = class_5579.method_31818(entity); + if (success) { + CarpetEventServer.Event event = ENTITY_LOAD.get(entity.getType()); + if (event != null) { + if (event.isNeeded()) { + event.onEntityAction(entity); + } + } else { + CarpetSettings.LOG.error("Failed to handle entity " + entity.getType().getTranslationKey()); } - } - else - { - CarpetSettings.LOG.error("Failed to handle entity "+entity.getType().getTranslationKey()); - } + }; + return success; } } diff --git a/src/main/java/carpet/mixins/SpawnHelperMixin.java b/src/main/java/carpet/mixins/SpawnHelperMixin.java index edfb9500..b4d5100d 100644 --- a/src/main/java/carpet/mixins/SpawnHelperMixin.java +++ b/src/main/java/carpet/mixins/SpawnHelperMixin.java @@ -117,8 +117,8 @@ public class SpawnHelperMixin BlockState state = world.getBlockState(blockpos); Block block = state.getBlock(); if ( - block.isIn(BlockTags.FENCES) || - block.isIn(BlockTags.WALLS) || + state.isIn(BlockTags.FENCES) || + state.isIn(BlockTags.WALLS) || ((block instanceof FenceGateBlock) && !state.get(FenceGateBlock.OPEN)) ) { diff --git a/src/main/java/carpet/mixins/ThreadedAnvilChunkStorage_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/ThreadedAnvilChunkStorage_scarpetChunkCreationMixin.java index 54211a59..34c616b0 100644 --- a/src/main/java/carpet/mixins/ThreadedAnvilChunkStorage_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/ThreadedAnvilChunkStorage_scarpetChunkCreationMixin.java @@ -335,8 +335,8 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem final long pos = cPos.toLong(); final ChunkHolder oldHolder = this.currentChunkHolders.remove(pos); - final ChunkHolder newHolder = new ChunkHolder(cPos, oldHolder.getLevel(), this.serverLightingProvider, this.chunkTaskPrioritySystem, (ChunkHolder.PlayersWatchingChunkProvider) this); - ((ChunkHolderInterface) newHolder).setDefaultProtoChunk(cPos, this.mainThreadExecutor); + final ChunkHolder newHolder = new ChunkHolder(cPos, oldHolder.getLevel(), world, this.serverLightingProvider, this.chunkTaskPrioritySystem, (ChunkHolder.PlayersWatchingChunkProvider) this); + ((ChunkHolderInterface) newHolder).setDefaultProtoChunk(cPos, this.mainThreadExecutor, world); this.currentChunkHolders.put(pos, newHolder); ((ChunkTicketManagerInterface) this.ticketManager).replaceHolder(oldHolder, newHolder); diff --git a/src/main/java/carpet/mixins/ThrownEntityMixin.java b/src/main/java/carpet/mixins/ThrownEntityMixin.java index 2ee48f38..f1eb5f35 100644 --- a/src/main/java/carpet/mixins/ThrownEntityMixin.java +++ b/src/main/java/carpet/mixins/ThrownEntityMixin.java @@ -33,9 +33,9 @@ public abstract class ThrownEntityMixin extends Entity } @Override - public void remove() + public void remove(Entity.RemovalReason arg) { - super.remove(); + super.remove(arg); if (LoggerRegistry.__projectiles && logHelper != null) logHelper.onFinish(); } diff --git a/src/main/java/carpet/mixins/TntEntityMixin.java b/src/main/java/carpet/mixins/TntEntityMixin.java index e9285e7e..3b95dd24 100644 --- a/src/main/java/carpet/mixins/TntEntityMixin.java +++ b/src/main/java/carpet/mixins/TntEntityMixin.java @@ -93,14 +93,14 @@ public abstract class TntEntityMixin extends Entity implements TntEntityInterfac if(!world.isClient && mergeBool && velocity.x == 0 && velocity.y == 0 && velocity.z == 0){ mergeBool = false; for(Entity entity : world.getOtherEntities(this, this.getBoundingBox())){ - if(entity instanceof TntEntity && !entity.removed){ + if(entity instanceof TntEntity && !entity.isRemoved()){ TntEntity entityTNTPrimed = (TntEntity)entity; Vec3d tntVelocity = entityTNTPrimed.getVelocity(); if(tntVelocity.x == 0 && tntVelocity.y == 0 && tntVelocity.z == 0 && this.getX() == entityTNTPrimed.getX() && this.getZ() == entityTNTPrimed.getZ() && this.getY() == entityTNTPrimed.getY() && this.fuseTimer == entityTNTPrimed.getFuseTimer()){ mergedTNT += ((TntEntityInterface) entityTNTPrimed).getMergedTNT(); - entityTNTPrimed.remove(); + entityTNTPrimed.discard(); // discard remove(); } } } diff --git a/src/main/java/carpet/mixins/WorldChunkBEList_tickMixin.java b/src/main/java/carpet/mixins/WorldChunkBEList_tickMixin.java new file mode 100644 index 00000000..b630be70 --- /dev/null +++ b/src/main/java/carpet/mixins/WorldChunkBEList_tickMixin.java @@ -0,0 +1,47 @@ +package carpet.mixins; + +import carpet.helpers.TickSpeed; +import carpet.utils.CarpetProfiler; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.class_5558; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(targets = "net.minecraft.world.chunk.WorldChunk$class_5563") +public class WorldChunkBEList_tickMixin +{ + @Shadow @Final private T field_27224; + CarpetProfiler.ProfilerToken entitySection; + + + @Inject(method = "method_31703", at = @At("HEAD")) + private void startTileEntitySection(CallbackInfo ci) + { + entitySection = CarpetProfiler.start_block_entity_section(field_27224.getWorld(), field_27224, CarpetProfiler.TYPE.TILEENTITY); + } + + @Redirect(method = "method_31703", at = @At( + value = "INVOKE", + target = "Lnet/minecraft/class_5558;tick(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/block/entity/BlockEntity;)V" + )) + private void checkProcessTEs(class_5558 class_5558, World world, BlockPos blockPos, BlockState blockState, T blockEntity) + { + //return class_5562.method_31704() || !TickSpeed.process_entities; // blockEntity can be NULL? happened once with fake player + if (TickSpeed.process_entities) class_5558.tick(world, blockPos, blockState, blockEntity); + } + + @Inject(method = "method_31703", at = @At("RETURN")) + private void endTileEntitySection(CallbackInfo ci) + { + CarpetProfiler.end_current_entity_section(entitySection); + } + +} diff --git a/src/main/java/carpet/mixins/WorldChunk_movableTEMixin.java b/src/main/java/carpet/mixins/WorldChunk_movableTEMixin.java index 5778f729..88454061 100644 --- a/src/main/java/carpet/mixins/WorldChunk_movableTEMixin.java +++ b/src/main/java/carpet/mixins/WorldChunk_movableTEMixin.java @@ -8,6 +8,7 @@ import net.minecraft.block.BlockState; import net.minecraft.block.PistonExtensionBlock; import net.minecraft.block.entity.BlockEntity; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkSectionPos; import net.minecraft.world.Heightmap; import net.minecraft.world.World; import net.minecraft.world.chunk.ChunkSection; @@ -40,10 +41,13 @@ public abstract class WorldChunk_movableTEMixin implements WorldChunkInterface @Shadow /* @Nullable */ public abstract BlockEntity getBlockEntity(BlockPos blockPos_1, WorldChunk.CreationType worldChunk$CreationType_1); - + + @Shadow protected abstract void method_31723(T blockEntity); + // Fix Failure: If a moving BlockEntity is placed while BlockEntities are ticking, this will not find it and then replace it with a new TileEntity! // blockEntity_2 = this.getBlockEntity(blockPos_1, WorldChunk.CreationType.CHECK); - @Redirect(method = "setBlockState", at = @At(value = "INVOKE", ordinal = 1, + // question is - with the changes in the BE handling this might not be a case anymore + @Redirect(method = "setBlockState", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/chunk/WorldChunk;getBlockEntity(Lnet/minecraft/util/math/BlockPos;" + "Lnet/minecraft/world/chunk/WorldChunk$CreationType;)" + "Lnet/minecraft/block/entity/BlockEntity;")) private BlockEntity ifGetBlockEntity(WorldChunk worldChunk, BlockPos blockPos_1, WorldChunk.CreationType worldChunk$CreationType_1) @@ -72,7 +76,8 @@ public abstract class WorldChunk_movableTEMixin implements WorldChunkInterface int x = blockPos_1.getX() & 15; int y = blockPos_1.getY(); int z = blockPos_1.getZ() & 15; - ChunkSection chunkSection = this.sections[y >> 4]; + int section = world.method_31602(y); + ChunkSection chunkSection = this.sections[section]; if (chunkSection == EMPTY_SECTION) { if (newBlockState.isAir()) @@ -80,8 +85,8 @@ public abstract class WorldChunk_movableTEMixin implements WorldChunkInterface return null; } - chunkSection = new ChunkSection(y >> 4 << 4); - this.sections[y >> 4] = chunkSection; + chunkSection = new ChunkSection(ChunkSectionPos.getSectionCoord(y)); + this.sections[section] = chunkSection; } boolean boolean_2 = chunkSection.isEmpty(); @@ -121,29 +126,31 @@ public abstract class WorldChunk_movableTEMixin implements WorldChunkInterface else { BlockEntity oldBlockEntity = null; - if (oldBlock instanceof BlockEntityProvider) + if (oldBlockState.method_31709()) // is BE Provider { oldBlockEntity = this.getBlockEntity(blockPos_1, WorldChunk.CreationType.CHECK); if (oldBlockEntity != null) { - oldBlockEntity.resetBlock(); + oldBlockEntity.method_31664(oldBlockState); + method_31723(oldBlockEntity); } } - - if (newBlock instanceof BlockEntityProvider) + + if (oldBlockState.method_31709()) // is BE Provider { if (newBlockEntity == null) { - newBlockEntity = ((BlockEntityProvider) newBlock).createBlockEntity(this.world); + newBlockEntity = ((BlockEntityProvider) newBlock).createBlockEntity(blockPos_1, newBlockState); } if (newBlockEntity != oldBlockEntity && newBlockEntity != null) { newBlockEntity.cancelRemoval(); - this.world.setBlockEntity(blockPos_1, newBlockEntity); - newBlockEntity.resetBlock(); + this.world.addBlockEntity(newBlockEntity); + newBlockEntity.method_31664(newBlockState); + method_31723(newBlockEntity); } } - + if (!this.world.isClient) { newBlockState.onBlockAdded(this.world, blockPos_1, oldBlockState, boolean_1); //This can call setblockstate! (e.g. hopper does) diff --git a/src/main/java/carpet/mixins/World_movableTEMixin.java b/src/main/java/carpet/mixins/World_movableTEMixin.java index a1a48117..d39fe37b 100644 --- a/src/main/java/carpet/mixins/World_movableTEMixin.java +++ b/src/main/java/carpet/mixins/World_movableTEMixin.java @@ -60,76 +60,63 @@ public abstract class World_movableTEMixin implements WorldInterface, WorldAcces */ public boolean setBlockStateWithBlockEntity(BlockPos blockPos_1, BlockState blockState_1, BlockEntity newBlockEntity, int int_1) { - if ((Object) this instanceof EmptyChunk) - return false; - - if (World.isHeightInvalid(blockPos_1)) - { - return false; - } - else if (!this.isClient && isDebugWorld()) + if (method_31606(blockPos_1) || !this.isClient && isDebugWorld()) return false; + WorldChunk worldChunk_1 = this.getWorldChunk(blockPos_1); + Block block_1 = blockState_1.getBlock(); + + BlockState blockState_2; + if (newBlockEntity != null && block_1 instanceof BlockEntityProvider) + blockState_2 = ((WorldChunkInterface) worldChunk_1).setBlockStateWithBlockEntity(blockPos_1, blockState_1, newBlockEntity, (int_1 & 64) != 0); + else + blockState_2 = worldChunk_1.setBlockState(blockPos_1, blockState_1, (int_1 & 64) != 0); + + if (blockState_2 == null) { return false; } else { - WorldChunk worldChunk_1 = this.getWorldChunk(blockPos_1); - Block block_1 = blockState_1.getBlock(); - - BlockState blockState_2; - if (newBlockEntity != null && block_1 instanceof BlockEntityProvider) - blockState_2 = ((WorldChunkInterface) worldChunk_1).setBlockStateWithBlockEntity(blockPos_1, blockState_1, newBlockEntity, (int_1 & 64) != 0); - else - blockState_2 = worldChunk_1.setBlockState(blockPos_1, blockState_1, (int_1 & 64) != 0); - - if (blockState_2 == null) + BlockState blockState_3 = this.getBlockState(blockPos_1); + + if (blockState_3 != blockState_2 && (blockState_3.getOpacity((BlockView) this, blockPos_1) != blockState_2.getOpacity((BlockView) this, blockPos_1) || blockState_3.getLuminance() != blockState_2.getLuminance() || blockState_3.hasSidedTransparency() || blockState_2.hasSidedTransparency())) { - return false; + Profiler profiler = getProfiler(); + profiler.push("queueCheckLight"); + this.getChunkManager().getLightingProvider().checkBlock(blockPos_1); + profiler.pop(); } - else + + if (blockState_3 == blockState_1) { - BlockState blockState_3 = this.getBlockState(blockPos_1); - - if (blockState_3 != blockState_2 && (blockState_3.getOpacity((BlockView) this, blockPos_1) != blockState_2.getOpacity((BlockView) this, blockPos_1) || blockState_3.getLuminance() != blockState_2.getLuminance() || blockState_3.hasSidedTransparency() || blockState_2.hasSidedTransparency())) + if (blockState_2 != blockState_3) { - Profiler profiler = getProfiler(); - profiler.push("queueCheckLight"); - this.getChunkManager().getLightingProvider().checkBlock(blockPos_1); - profiler.pop(); + this.scheduleBlockRerenderIfNeeded(blockPos_1, blockState_2, blockState_3); } - - if (blockState_3 == blockState_1) + + if ((int_1 & 2) != 0 && (!this.isClient || (int_1 & 4) == 0) && (this.isClient || worldChunk_1.getLevelType() != null && worldChunk_1.getLevelType().isAfter(ChunkHolder.LevelType.TICKING))) { - if (blockState_2 != blockState_3) - { - this.scheduleBlockRerenderIfNeeded(blockPos_1, blockState_2, blockState_3); - } - - if ((int_1 & 2) != 0 && (!this.isClient || (int_1 & 4) == 0) && (this.isClient || worldChunk_1.getLevelType() != null && worldChunk_1.getLevelType().isAfter(ChunkHolder.LevelType.TICKING))) - { - this.updateListeners(blockPos_1, blockState_2, blockState_1, int_1); - } - - if (!this.isClient && (int_1 & 1) != 0) - { - this.updateNeighborsAlways(blockPos_1, blockState_2.getBlock()); - if (blockState_1.hasComparatorOutput()) - { - updateComparators(blockPos_1, block_1); - } - } - - if ((int_1 & 16) == 0) - { - int int_2 = int_1 & -34; - blockState_2.prepare(this, blockPos_1, int_2); // prepare - blockState_1.updateNeighbors(this, blockPos_1, int_2); // updateNeighbours - blockState_1.prepare(this, blockPos_1, int_2); // prepare - } - this.onBlockChanged(blockPos_1, blockState_2, blockState_3); + this.updateListeners(blockPos_1, blockState_2, blockState_1, int_1); } - return true; + + if (!this.isClient && (int_1 & 1) != 0) + { + this.updateNeighborsAlways(blockPos_1, blockState_2.getBlock()); + if (blockState_1.hasComparatorOutput()) + { + updateComparators(blockPos_1, block_1); + } + } + + if ((int_1 & 16) == 0) + { + int int_2 = int_1 & -34; + blockState_2.prepare(this, blockPos_1, int_2); // prepare + blockState_1.updateNeighbors(this, blockPos_1, int_2); // updateNeighbours + blockState_1.prepare(this, blockPos_1, int_2); // prepare + } + this.onBlockChanged(blockPos_1, blockState_2, blockState_3); } + return true; } } } diff --git a/src/main/java/carpet/mixins/World_tickMixin.java b/src/main/java/carpet/mixins/World_tickMixin.java index 11b9a113..df2cdbec 100644 --- a/src/main/java/carpet/mixins/World_tickMixin.java +++ b/src/main/java/carpet/mixins/World_tickMixin.java @@ -43,39 +43,39 @@ public abstract class World_tickMixin implements WorldInterface private void endBlockEntities(CallbackInfo ci) { CarpetProfiler.end_current_section(currentSection); } - +/* @Inject(method = "tickBlockEntities", locals = LocalCapture.CAPTURE_FAILHARD, at = @At( value = "INVOKE", - target = "Lnet/minecraft/block/entity/BlockEntity;isRemoved()Z", + target = "Lnet/minecraft/class_5562;method_31704()Z", shift = At.Shift.BEFORE, ordinal = 0 )) - private void startTileEntitySection(CallbackInfo ci, Profiler profiler_1, Iterator i, BlockEntity blockEntity_2) + private void startTileEntitySection(CallbackInfo ci, Profiler profiler_1, Iterator i, class_5562 lv) { - entitySection = CarpetProfiler.start_block_entity_section((World)(Object)this, blockEntity_2, CarpetProfiler.TYPE.TILEENTITY); + entitySection = CarpetProfiler.start_block_entity_section((World)(Object)this, (BlockEntity) lv, CarpetProfiler.TYPE.TILEENTITY); } @Redirect(method = "tickBlockEntities", at = @At( value = "INVOKE", - target = "Lnet/minecraft/block/entity/BlockEntity;isRemoved()Z", + target = "Lnet/minecraft/class_5562;method_31704()Z", ordinal = 0 - )) - private boolean checkProcessTEs(BlockEntity blockEntity) + )) // isRemoved() + private boolean checkProcessTEs(class_5562 class_5562) { - return blockEntity.isRemoved() || !TickSpeed.process_entities; // blockEntity can be NULL? happened once with fake player + return class_5562.method_31704() || !TickSpeed.process_entities; // blockEntity can be NULL? happened once with fake player } @Inject(method = "tickBlockEntities", at = @At( value = "INVOKE", - target = "Lnet/minecraft/block/entity/BlockEntity;isRemoved()Z", - shift = At.Shift.BEFORE, - ordinal = 1 + target = "Lnet/minecraft/class_5562;method_31703()V", + shift = At.Shift.AFTER, + ordinal = 0 )) private void endTileEntitySection(CallbackInfo ci) { CarpetProfiler.end_current_entity_section(entitySection); } - +*/ @Inject(method = "tickEntity", at = @At("HEAD"), cancellable = true) private void startEntity(Consumer consumer_1, Entity e, CallbackInfo ci) { diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index de2ca657..51411ddf 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -46,7 +46,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity server.getPlayerManager().onPlayerConnect(new NetworkManagerFake(NetworkSide.SERVERBOUND), instance); instance.teleport(worldIn, d0, d1, d2, (float)yaw, (float)pitch); instance.setHealth(20.0F); - instance.removed = false; + instance.unsetRemoved(); instance.stepHeight = 0.6F; interactionManagerIn.setGameMode(gamemode); server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(instance, (byte) (instance.headYaw * 256 / 360)), dimensionId);//instance.dimension); @@ -102,7 +102,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity { this.networkHandler.syncWithPlayerPosition(); this.getServerWorld().getChunkManager().updateCameraPosition(this); - //if (netherPortalCooldown==10) onTeleportationDone(); <- causes hard crash but would need to be done to enable portals + onTeleportationDone(); //<- causes hard crash but would need to be done to enable portals // not as of 1.17 } super.tick(); this.playerTick(); diff --git a/src/main/java/carpet/script/CarpetScriptHost.java b/src/main/java/carpet/script/CarpetScriptHost.java index 15901d95..f50d29cb 100644 --- a/src/main/java/carpet/script/CarpetScriptHost.java +++ b/src/main/java/carpet/script/CarpetScriptHost.java @@ -438,7 +438,7 @@ public class CarpetScriptHost extends ScriptHost { for (Entity e : world.getEntitiesByType(EntityType.ARMOR_STAND, (as) -> as.getScoreboardTags().contains(markerName))) { - e.remove(); + e.discard(); } } if (this.saveTimeout > 0) diff --git a/src/main/java/carpet/script/api/Auxiliary.java b/src/main/java/carpet/script/api/Auxiliary.java index d05251f6..8b027387 100644 --- a/src/main/java/carpet/script/api/Auxiliary.java +++ b/src/main/java/carpet/script/api/Auxiliary.java @@ -369,7 +369,7 @@ public class Auxiliary { for (Entity e : cc.s.getWorld().getEntitiesByType(EntityType.ARMOR_STAND, (as) -> as.getScoreboardTags().contains(markerName))) { total ++; - e.remove(); + e.discard(); // discard // remove(); } int finalTotal = total; return (_cc, _tt) -> new NumericValue(finalTotal); diff --git a/src/main/java/carpet/script/api/Entities.java b/src/main/java/carpet/script/api/Entities.java index e666f950..33cf3b79 100644 --- a/src/main/java/carpet/script/api/Entities.java +++ b/src/main/java/carpet/script/api/Entities.java @@ -184,7 +184,7 @@ public class Entities { { String who = lv.get(0).evalValue(c).getString(); EntityValue.EntityClassDescriptor eDesc = EntityValue.getEntityDescriptor(who); - List entityList = ((CarpetContext)c).s.getWorld().getEntitiesByType(eDesc.directType, eDesc.filteringPredicate); + List entityList = ((CarpetContext)c).s.getWorld().getEntitiesByType(eDesc.directType, eDesc.filteringPredicate); Value retval = ListValue.wrap(entityList.stream().map(EntityValue::new).collect(Collectors.toList())); return (_c, _t ) -> retval; }); diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index d01f0d28..4f8cfc70 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -752,7 +752,7 @@ public class WorldAccess { destTag.putInt("x", targetPos.getX()); destTag.putInt("y", targetPos.getY()); destTag.putInt("z", targetPos.getZ()); - be.fromTag(finalSourceBlockState, destTag); + be.fromTag(destTag); be.markDirty(); } } diff --git a/src/main/java/carpet/script/utils/ShapesRenderer.java b/src/main/java/carpet/script/utils/ShapesRenderer.java index 371b840d..06d0a981 100644 --- a/src/main/java/carpet/script/utils/ShapesRenderer.java +++ b/src/main/java/carpet/script/utils/ShapesRenderer.java @@ -9,6 +9,7 @@ import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.Camera; import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.VertexFormat; import net.minecraft.client.util.math.AffineTransformation; import net.minecraft.client.world.ClientWorld; import net.minecraft.client.render.VertexFormats; @@ -441,7 +442,7 @@ public class ShapesRenderer // some raw shit public static void drawLine(Tessellator tessellator, BufferBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2, float red1, float grn1, float blu1, float alpha) { - builder.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR); // 3 + builder.begin(VertexFormat.class_5596.field_27377, VertexFormats.POSITION_COLOR); // 3 // GL LINES builder.vertex(x1, y1, z1).color(red1, grn1, blu1, alpha).next(); builder.vertex(x2, y2, z2).color(red1, grn1, blu1, alpha).next(); tessellator.draw(); @@ -454,7 +455,7 @@ public class ShapesRenderer boolean xthick, boolean ythick, boolean zthick, float red1, float grn1, float blu1, float alpha, float red2, float grn2, float blu2) { - builder.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR); // 3 + builder.begin(VertexFormat.class_5596.field_27377, VertexFormats.POSITION_COLOR); // 3 /lines if (xthick) { builder.vertex(x1, y1, z1).color(red1, grn2, blu2, alpha).next(); @@ -507,7 +508,7 @@ public class ShapesRenderer boolean xthick, boolean ythick, boolean zthick, float red1, float grn1, float blu1, float alpha) { - builder.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27382, VertexFormats.POSITION_COLOR); // QUADS if (xthick && ythick) { @@ -582,8 +583,8 @@ public class ShapesRenderer for (int dh = 0; dh < hsteps; dh++) { float hh = dh*hstep; - builder.begin(GL11.GL_LINE_LOOP, VertexFormats.POSITION_COLOR); - for (int i = 0; i <= num_steps360; i++) + builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); // line loop to line strip + for (int i = 0; i <= num_steps360+1; i++) { float theta = step * i; float x = r * MathHelper.cos(theta); @@ -598,7 +599,7 @@ public class ShapesRenderer { for (int i = 0; i <= num_steps180; i++) { - builder.begin(GL11.GL_LINE_LOOP, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); // line loop to line strip float theta = step * i; float x = r * MathHelper.cos(theta); @@ -608,12 +609,13 @@ public class ShapesRenderer builder.vertex(cx + x, cy + 0, cz - z).color(red, grn, blu, alpha).next(); builder.vertex(cx + x, cy + h, cz - z).color(red, grn, blu, alpha).next(); builder.vertex(cx - x, cy + h, cz + z).color(red, grn, blu, alpha).next(); + builder.vertex(cx - x, cy + 0, cz + z).color(red, grn, blu, alpha).next(); tessellator.draw(); } } else { - builder.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27377, VertexFormats.POSITION_COLOR); //lines for (int i = 0; i <= num_steps180; i++) { float theta = step * i; @@ -631,7 +633,7 @@ public class ShapesRenderer for (int dh = 0; dh < hsteps; dh++) { float hh = dh * hstep; - builder.begin(GL11.GL_LINE_LOOP, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); // line loop to line strip for (int i = 0; i <= num_steps360; i++) { float theta = step * i; @@ -647,7 +649,7 @@ public class ShapesRenderer { for (int i = 0; i <= num_steps180; i++) { - builder.begin(GL11.GL_LINE_LOOP, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); // line loop to line strip float theta = step * i; float y = r * MathHelper.cos(theta); @@ -662,7 +664,7 @@ public class ShapesRenderer } else { - builder.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27377, VertexFormats.POSITION_COLOR); //lines for (int i = 0; i <= num_steps180; i++) { float theta = step * i; @@ -679,7 +681,7 @@ public class ShapesRenderer for (int dh = 0; dh < hsteps; dh++) { float hh = dh * hstep; - builder.begin(GL11.GL_LINE_LOOP, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); // line loop to line strip for (int i = 0; i <= num_steps360; i++) { float theta = step * i; @@ -694,7 +696,7 @@ public class ShapesRenderer { for (int i = 0; i <= num_steps180; i++) { - builder.begin(GL11.GL_LINE_LOOP, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); // line loop to line strip float theta = step * i; float x = r * MathHelper.cos(theta); @@ -709,7 +711,7 @@ public class ShapesRenderer } else { - builder.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27377, VertexFormats.POSITION_COLOR); //lines for (int i = 0; i <= num_steps180; i++) { float theta = step * i; @@ -736,7 +738,7 @@ public class ShapesRenderer if (axis == Direction.Axis.Y) { - builder.begin(GL11.GL_TRIANGLE_FAN, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27381, VertexFormats.POSITION_COLOR); //triangle fan builder.vertex(cx, cy, cz).color(red, grn, blu, alpha).next(); for (int i = 0; i <= num_steps360; i++) { @@ -748,7 +750,7 @@ public class ShapesRenderer tessellator.draw(); if (!isFlat) { - builder.begin(GL11.GL_TRIANGLE_FAN, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27381, VertexFormats.POSITION_COLOR); //trifan builder.vertex(cx, cy+h, cz).color(red, grn, blu, alpha).next(); for (int i = 0; i <= num_steps360; i++) { @@ -759,14 +761,20 @@ public class ShapesRenderer } tessellator.draw(); - builder.begin(GL11.GL_QUAD_STRIP, VertexFormats.POSITION_COLOR); - for (int i = 0; i <= num_steps360; i++) + builder.begin(VertexFormat.class_5596.field_27382, VertexFormats.POSITION_COLOR); // quad strip to quads + float xp = r * 1; + float zp = r * 0; + for (int i = 1; i <= num_steps360; i++) { float theta = step * i; float x = r * MathHelper.cos(theta); float z = r * MathHelper.sin(theta); - builder.vertex(cx + x, cy + 0, cz + z).color(red, grn, blu, alpha).next(); + builder.vertex(cx + xp, cy + 0, cz + zp).color(red, grn, blu, alpha).next(); + builder.vertex(cx + xp, cy + h, cz + zp).color(red, grn, blu, alpha).next(); builder.vertex(cx + x, cy + h, cz + z).color(red, grn, blu, alpha).next(); + builder.vertex(cx + x, cy + 0, cz + z).color(red, grn, blu, alpha).next(); + xp = x; + zp = z; } tessellator.draw(); } @@ -774,7 +782,7 @@ public class ShapesRenderer } else if (axis == Direction.Axis.X) { - builder.begin(GL11.GL_TRIANGLE_FAN, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27381, VertexFormats.POSITION_COLOR); //trifan builder.vertex(cx, cy, cz).color(red, grn, blu, alpha).next(); for (int i = 0; i <= num_steps360; i++) { @@ -786,7 +794,7 @@ public class ShapesRenderer tessellator.draw(); if (!isFlat) { - builder.begin(GL11.GL_TRIANGLE_FAN, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27381, VertexFormats.POSITION_COLOR); //trifan builder.vertex(cx+h, cy, cz).color(red, grn, blu, alpha).next(); for (int i = 0; i <= num_steps360; i++) { @@ -797,21 +805,27 @@ public class ShapesRenderer } tessellator.draw(); - builder.begin(GL11.GL_QUAD_STRIP, VertexFormats.POSITION_COLOR); - for (int i = 0; i <= num_steps360; i++) + builder.begin(VertexFormat.class_5596.field_27382, VertexFormats.POSITION_COLOR); // quad strip to quads + float yp = r * 1; + float zp = r * 0; + for (int i = 1; i <= num_steps360; i++) { float theta = step * i; float y = r * MathHelper.cos(theta); float z = r * MathHelper.sin(theta); - builder.vertex(cx + 0, cy + y, cz + z).color(red, grn, blu, alpha).next(); + builder.vertex(cx + 0, cy + yp, cz + zp).color(red, grn, blu, alpha).next(); + builder.vertex(cx + h, cy + yp, cz + zp).color(red, grn, blu, alpha).next(); builder.vertex(cx + h, cy + y, cz + z).color(red, grn, blu, alpha).next(); + builder.vertex(cx + 0, cy + y, cz + z).color(red, grn, blu, alpha).next(); + yp = y; + zp = z; } tessellator.draw(); } } else if (axis == Direction.Axis.Z) { - builder.begin(GL11.GL_TRIANGLE_FAN, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27381, VertexFormats.POSITION_COLOR); //trifan builder.vertex(cx, cy, cz).color(red, grn, blu, alpha).next(); for (int i = 0; i <= num_steps360; i++) { @@ -823,7 +837,7 @@ public class ShapesRenderer tessellator.draw(); if (!isFlat) { - builder.begin(GL11.GL_TRIANGLE_FAN, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27381, VertexFormats.POSITION_COLOR); //trifan builder.vertex(cx, cy, cz+h).color(red, grn, blu, alpha).next(); for (int i = 0; i <= num_steps360; i++) { @@ -834,14 +848,20 @@ public class ShapesRenderer } tessellator.draw(); - builder.begin(GL11.GL_QUAD_STRIP, VertexFormats.POSITION_COLOR); - for (int i = 0; i <= num_steps360; i++) + builder.begin(VertexFormat.class_5596.field_27382, VertexFormats.POSITION_COLOR); // quad strip to quads + float xp = r; + float yp = 0; + for (int i = 1; i <= num_steps360; i++) { float theta = step * i; float x = r * MathHelper.cos(theta); float y = r * MathHelper.sin(theta); - builder.vertex(cx + x, cy + y, cz + 0).color(red, grn, blu, alpha).next(); + builder.vertex(cx + xp, cy + yp, cz + 0).color(red, grn, blu, alpha).next(); + builder.vertex(cx + xp, cy + yp, cz + h).color(red, grn, blu, alpha).next(); builder.vertex(cx + x, cy + y, cz + h).color(red, grn, blu, alpha).next(); + builder.vertex(cx + x, cy + y, cz + 0).color(red, grn, blu, alpha).next(); + xp = x; + yp = y; } tessellator.draw(); } @@ -855,10 +875,10 @@ public class ShapesRenderer { float step = (float)Math.PI / (subd/2); int num_steps180 = (int)(Math.PI / step)+1; - int num_steps360 = (int)(2*Math.PI / step); + int num_steps360 = (int)(2*Math.PI / step)+1; for (int i = 0; i <= num_steps360; i++) { - builder.begin(GL11.GL_LINE_STRIP, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); //linestrip float theta = step * i ; for (int j = 0; j <= num_steps180; j++) { @@ -872,7 +892,7 @@ public class ShapesRenderer } for (int j = 0; j <= num_steps180; j++) { - builder.begin(GL11.GL_LINE_LOOP, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); // line loop to line strip float phi = step * j ; for (int i = 0; i <= num_steps360; i++) @@ -901,7 +921,12 @@ public class ShapesRenderer { float theta = i * step; float thetaprime = theta+step; - builder.begin(GL11.GL_QUAD_STRIP, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.class_5596.field_27382, VertexFormats.POSITION_COLOR); // quad strip to quads + float xb = 0; + float zb = 0; + float xbp = 0; + float zbp = 0; + float yp = r; for (int j = 0; j <= num_steps180; j++) { float phi = j * step; @@ -910,8 +935,15 @@ public class ShapesRenderer float y = r * MathHelper.cos(phi); float xp = r * MathHelper.sin(phi) * MathHelper.cos(thetaprime); float zp = r * MathHelper.sin(phi) * MathHelper.sin(thetaprime); - builder.vertex(x + cx, y + cy, z + cz).color(red, grn, blu, alpha).next(); + builder.vertex(xb + cx, yp + cy, zb + cz).color(red, grn, blu, alpha).next(); + builder.vertex(xbp + cx, yp + cy, zbp + cz).color(red, grn, blu, alpha).next(); builder.vertex(xp + cx, y + cy, zp + cz).color(red, grn, blu, alpha).next(); + builder.vertex(x + cx, y + cy, z + cz).color(red, grn, blu, alpha).next(); + xb = x; + zb = z; + xbp = xp; + zbp = zp; + yp = y; } tessellator.draw(); } diff --git a/src/main/java/carpet/script/utils/WorldTools.java b/src/main/java/carpet/script/utils/WorldTools.java index c32d94fc..9fd952b4 100644 --- a/src/main/java/carpet/script/utils/WorldTools.java +++ b/src/main/java/carpet/script/utils/WorldTools.java @@ -142,7 +142,7 @@ public class WorldTools List nearbyPlayers = world.getPlayers(p -> pos.getSquaredDistance(p.getX(), pos.getY(), p.getZ(), true) < vvd); if (!nearbyPlayers.isEmpty()) { - ChunkDataS2CPacket packet = new ChunkDataS2CPacket(worldChunk, 65535); + ChunkDataS2CPacket packet = new ChunkDataS2CPacket(worldChunk); ChunkPos chpos = new ChunkPos(pos); nearbyPlayers.forEach(p -> p.networkHandler.sendPacket(packet)); } diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 49978474..7c703596 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -346,7 +346,7 @@ public class EntityValue extends Value private static final Map> featureAccessors = new HashMap>() {{ //put("test", (e, a) -> a == null ? Value.NULL : new StringValue(a.getString())); - put("removed", (entity, arg) -> new NumericValue(entity.removed)); + put("removed", (entity, arg) -> new NumericValue(entity.isRemoved())); put("uuid",(e, a) -> new StringValue(e.getUuidAsString())); put("id",(e, a) -> new NumericValue(e.getEntityId())); put("pos", (e, a) -> ListValue.of(new NumericValue(e.getX()), new NumericValue(e.getY()), new NumericValue(e.getZ()))); @@ -620,7 +620,7 @@ public class EntityValue extends Value put("selected_slot", (e, a) -> { if (e instanceof PlayerEntity) - return new NumericValue(((PlayerEntity) e).inventory.selectedSlot); + return new NumericValue(((PlayerEntity) e).method_31548().selectedSlot); //getInventory return Value.NULL; }); @@ -796,7 +796,7 @@ public class EntityValue extends Value } private static final Map> featureModifiers = new HashMap>() {{ - put("remove", (entity, value) -> entity.remove()); + put("remove", (entity, value) -> entity.discard()); // using discard here - will see other options if valid put("age", (e, v) -> e.age = Math.abs((int)NumericValue.asNumber(v).getLong()) ); put("health", (e, v) -> { float health = (float) NumericValue.asNumber(v).getDouble(); diff --git a/src/main/java/carpet/script/value/NBTSerializableValue.java b/src/main/java/carpet/script/value/NBTSerializableValue.java index 7d41eec1..de8c9ea8 100644 --- a/src/main/java/carpet/script/value/NBTSerializableValue.java +++ b/src/main/java/carpet/script/value/NBTSerializableValue.java @@ -145,7 +145,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa Block block = blockState.getBlock(); if (block instanceof InventoryProvider) { inventory = ((InventoryProvider)block).getInventory(blockState, world, blockPos); - } else if (block.hasBlockEntity()) { + } else if (blockState.method_31709()) { //hasBlockEntity() BlockEntity blockEntity = BlockValue.getBlockEntity(world, blockPos); if (blockEntity instanceof Inventory) { inventory = (Inventory)blockEntity; @@ -181,7 +181,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa if (v1 instanceof EntityValue) { Entity e = ((EntityValue) v1).getEntity(); - if (e instanceof PlayerEntity) inv = ((PlayerEntity) e).inventory; + if (e instanceof PlayerEntity) inv = ((PlayerEntity) e).method_31548(); else if (e instanceof Inventory) inv = (Inventory) e; else if (e instanceof VillagerEntity) inv = ((VillagerEntity) e).getInventory(); @@ -231,7 +231,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa return new InventoryLocator( player, player.getBlockPos(), - isEnder ? player.getEnderChestInventory() : player.inventory, + isEnder ? player.getEnderChestInventory() : player.method_31548(), offset + 1, isEnder ); diff --git a/src/main/java/carpet/utils/BlockInfo.java b/src/main/java/carpet/utils/BlockInfo.java index 85ad6cb4..1315eb8f 100644 --- a/src/main/java/carpet/utils/BlockInfo.java +++ b/src/main/java/carpet/utils/BlockInfo.java @@ -4,9 +4,10 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Material; import net.minecraft.block.MaterialColor; +import net.minecraft.class_5532; // TargetFinder import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.ai.TargetFinder; +//import net.minecraft.entity.ai.TargetFinder; import net.minecraft.entity.ai.goal.WanderAroundGoal; import net.minecraft.entity.ai.pathing.NavigationType; import net.minecraft.entity.mob.PathAwareEntity; @@ -231,7 +232,7 @@ public class BlockInfo for (int i=0; i<1000; i++) { - Vec3d vec = TargetFinder.findTarget(creature, 10, 7); + Vec3d vec = class_5532.method_31510(creature, 10, 7); // TargetFinder.findTarget(creature, 10, 7); if (vec == null) { continue; @@ -251,7 +252,7 @@ public class BlockInfo } total_ticks += 3*i; } - creature.remove(); + creature.discard(); // discarded // remove(Entity.RemovalReason.field_26999); // 2nd option - DISCARDED long total_time = (total_ticks)/1000/20; return Messenger.s(String.format(" - Wander chance above: %.1f%%\n - Average standby above: %s", (100.0F*success)/1000, diff --git a/src/main/java/carpet/utils/MobAI.java b/src/main/java/carpet/utils/MobAI.java index c332755c..1f59e4b4 100644 --- a/src/main/java/carpet/utils/MobAI.java +++ b/src/main/java/carpet/utils/MobAI.java @@ -39,7 +39,7 @@ public class MobAI return currentTrackers.contains(type); } - public static void clearTracking(EntityType etype) + public static void clearTracking(EntityType etype) { aiTrackers.remove(etype); for(ServerWorld world : CarpetServer.minecraft_server.getWorlds() ) diff --git a/src/main/java/carpet/utils/SpawnReporter.java b/src/main/java/carpet/utils/SpawnReporter.java index 6e21bcb2..ae3ab5ab 100644 --- a/src/main/java/carpet/utils/SpawnReporter.java +++ b/src/main/java/carpet/utils/SpawnReporter.java @@ -398,23 +398,23 @@ public class SpawnReporter { if (entity.hasVehicle()) { - entity.getVehicle().remove(); + entity.getVehicle().discard(); } if (entity.hasPassengers()) { for (Entity e: entity.getPassengerList()) { - e.remove(); + e.discard(); } } if (entity instanceof OcelotEntity) { for (Entity e: entity.getEntityWorld().getOtherEntities(entity, entity.getBoundingBox())) { - e.remove(); + e.discard(); } } - entity.remove(); + entity.discard(); } // yeeted from SpawnHelper - temporary fix diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index edd05eeb..caaf6a82 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -28,6 +28,7 @@ "MinecraftServer_tickspeedMixin", "World_tickMixin", "ServerWorld_tickMixin", + "WorldChunkBEList_tickMixin", "ServerChunkManager_tickMixin", "ThreadedAnvilChunkStorage_tickMixin", "ChunkTicketManager_tickMixin", @@ -122,6 +123,7 @@ "ContainerMixin", "ClientConnectionMixin", "CauldronBlock_stackableSBoxesMixin", + "AbstractCauldronBlock_stackableSBoxesMixin", "ItemEntityMixin", "TntBlockMixin", "ExplosionMixin", @@ -175,6 +177,7 @@ "Ingredient_scarpetMixin", "BlockStateArgument_scarpetMixin", + "BlockEntity_movableBEMixin", "PistonBlock_movableTEMixin", "PistonBlockEntity_movableTEMixin", "World_movableTEMixin", diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a025852d..8ed269fb 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -31,7 +31,7 @@ "accessWidener" : "carpet.accesswidener", "depends": { - "minecraft": "1.16.x", + "minecraft": "1.17.x", "fabricloader": ">=0.7.1" }, "suggests": {