From 2cdea92da7080d6992573feb6ae88de05ac76615 Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 6 Nov 2020 00:06:53 -0400 Subject: [PATCH 001/115] 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": { From d48896ad8bc5b5e07bd3903e85526b8a658800b9 Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 6 Nov 2020 23:10:43 -0400 Subject: [PATCH 002/115] mappings. More colors and materials --- gradle.properties | 2 +- .../java/carpet/helpers/BlockRotator.java | 2 +- .../helpers/EntityPlayerActionPack.java | 4 +- .../carpet/helpers/OptimizedExplosion.java | 4 +- ...actCauldronBlock_stackableSBoxesMixin.java | 8 +- .../mixins/BlockItem_creativeNoClipMixin.java | 2 +- .../java/carpet/mixins/ContainerMixin.java | 2 +- .../java/carpet/mixins/CoralBlockMixin.java | 6 +- .../mixins/LivingEntity_creativeFlyMixin.java | 4 +- ...tonBlockEntityRenderer_movableTEMixin.java | 6 +- .../PistonBlockEntity_movableTEMixin.java | 10 +- ...PistonBlockEntity_playerHandlingMixin.java | 4 +- .../mixins/PistonBlock_movableTEMixin.java | 6 +- .../PlayerEntity_creativeNoClipMixin.java | 6 +- ...PlayNetworkHandler_scarpetEventsMixin.java | 2 +- .../mixins/ServerWorld_scarpetEventMixin.java | 4 +- .../mixins/WorldChunkBEList_tickMixin.java | 21 ++- .../mixins/WorldChunk_movableTEMixin.java | 16 +- .../carpet/mixins/World_movableTEMixin.java | 2 +- .../java/carpet/script/api/WorldAccess.java | 2 +- .../carpet/script/utils/ShapesRenderer.java | 48 +++--- .../java/carpet/script/value/EntityValue.java | 2 +- .../script/value/NBTSerializableValue.java | 6 +- src/main/java/carpet/utils/BlockInfo.java | 151 ++++++++++-------- src/main/java/carpet/utils/WoolTool.java | 8 +- 25 files changed, 174 insertions(+), 154 deletions(-) diff --git a/gradle.properties b/gradle.properties index b957a95b..fe229047 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=20w45a - yarn_mappings=20w45a+build.6 + yarn_mappings=20w45a+build.20 loader_version=0.10.6+build.214 # Mod Properties diff --git a/src/main/java/carpet/helpers/BlockRotator.java b/src/main/java/carpet/helpers/BlockRotator.java index 49af4a69..e0b27d3f 100644 --- a/src/main/java/carpet/helpers/BlockRotator.java +++ b/src/main/java/carpet/helpers/BlockRotator.java @@ -49,7 +49,7 @@ public class BlockRotator { public static boolean flipBlockWithCactus(BlockState state, World world, PlayerEntity player, Hand hand, BlockHitResult hit) { //getAbilities() - if (!player.method_31549().allowModifyWorld || !CarpetSettings.flippinCactus || !player_holds_cactus_mainhand(player)) + if (!player.getAbilities().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 696ac319..67e94916 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.method_31548(); // getInventory; + PlayerInventory inv = player.getInventory(); // 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.method_31548(); // getInventory; + PlayerInventory inv = player.getInventory(); // 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 be910afb..82a1d07a 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.method_31549().flying)) { //getAbilities + && (!player.isCreative() || !player.getAbilities().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 = state.method_31709() ? world.getBlockEntity(blockpos) : null; //hasBlockEntity() + BlockEntity blockEntity = state.hasBlockEntity() ? 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/mixins/AbstractCauldronBlock_stackableSBoxesMixin.java b/src/main/java/carpet/mixins/AbstractCauldronBlock_stackableSBoxesMixin.java index 5b02fa77..003d8773 100644 --- a/src/main/java/carpet/mixins/AbstractCauldronBlock_stackableSBoxesMixin.java +++ b/src/main/java/carpet/mixins/AbstractCauldronBlock_stackableSBoxesMixin.java @@ -4,7 +4,7 @@ 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.block.cauldron.CauldronBehavior; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; @@ -19,13 +19,13 @@ 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) + @Redirect(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/cauldron/CauldronBehavior;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(CauldronBehavior cauldronBehavior, 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); + ActionResult result = cauldronBehavior.interact(blockState, world, blockPos, playerEntity, hand, itemStack); if (count > 0 && result.isAccepted()) { ItemStack current = playerEntity.getStackInHand(hand); diff --git a/src/main/java/carpet/mixins/BlockItem_creativeNoClipMixin.java b/src/main/java/carpet/mixins/BlockItem_creativeNoClipMixin.java index ab5044a0..329a72ff 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.method_31549().flying) + if (CarpetSettings.creativeNoClip && player != null && player.isCreative() && player.getAbilities().flying) { // copy from canPlace VoxelShape voxelShape = state.getCollisionShape(world, pos, context); diff --git a/src/main/java/carpet/mixins/ContainerMixin.java b/src/main/java/carpet/mixins/ContainerMixin.java index 96530b8c..485128ad 100644 --- a/src/main/java/carpet/mixins/ContainerMixin.java +++ b/src/main/java/carpet/mixins/ContainerMixin.java @@ -30,7 +30,7 @@ public abstract class ContainerMixin @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.method_31548().getCursorStack().isEmpty() && slotId >= 0) + if (actionType == SlotActionType.THROW && CarpetSettings.ctrlQCraftingFix && playerEntity.getInventory().getCursorStack().isEmpty() && slotId >= 0) { ItemStack itemStack_1 = ItemStack.EMPTY; Slot slot_4 = slots.get(slotId); diff --git a/src/main/java/carpet/mixins/CoralBlockMixin.java b/src/main/java/carpet/mixins/CoralBlockMixin.java index ea6db8e0..9e241b41 100644 --- a/src/main/java/carpet/mixins/CoralBlockMixin.java +++ b/src/main/java/carpet/mixins/CoralBlockMixin.java @@ -8,7 +8,7 @@ import net.minecraft.block.Blocks; import net.minecraft.block.CoralBlock; import net.minecraft.block.CoralParentBlock; import net.minecraft.block.Fertilizable; -import net.minecraft.block.MaterialColor; +import net.minecraft.block.MapColor; import net.minecraft.server.world.ServerWorld; import net.minecraft.tag.BlockTags; import net.minecraft.tag.FluidTags; @@ -49,12 +49,12 @@ public abstract class CoralBlockMixin implements Fertilizable else coral = new CoralMushroomFeature(DefaultFeatureConfig.CODEC); - MaterialColor color = blockUnder.getTopMaterialColor(worldIn, pos); + MapColor color = blockUnder.getMapColor(worldIn, pos); BlockState proper_block = blockUnder; for (Block block: BlockTags.CORAL_BLOCKS.values()) { proper_block = block.getDefaultState(); - if (proper_block.getTopMaterialColor(worldIn,pos) == color) + if (proper_block.getMapColor(worldIn,pos) == color) { break; } diff --git a/src/main/java/carpet/mixins/LivingEntity_creativeFlyMixin.java b/src/main/java/carpet/mixins/LivingEntity_creativeFlyMixin.java index 6d3cf5c3..7de5e55c 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.method_31549().flying && ! onGround ) + if (self.getAbilities().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.method_31549().flying && !onGround) + if (self.getAbilities().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 35470231..62fcc876 100644 --- a/src/main/java/carpet/mixins/PistonBlockEntityRenderer_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonBlockEntityRenderer_movableTEMixin.java @@ -4,10 +4,10 @@ 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; +import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; import net.minecraft.client.render.block.entity.PistonBlockEntityRenderer; import net.minecraft.client.util.math.MatrixStack; import org.spongepowered.asm.mixin.Mixin; @@ -21,9 +21,9 @@ public abstract class PistonBlockEntityRenderer_movableTEMixin implements BlockE { BlockEntityRenderDispatcher dispatcher; @Inject(method = "", at = @At("TAIL")) - private void onInitCM(class_5614.class_5615 arg, CallbackInfo ci) + private void onInitCM(BlockEntityRendererFactory.Arguments arguments, CallbackInfo ci) { - dispatcher = arg.method_32139(); + dispatcher = arguments.getRenderDispatcher(); } @Inject(method = "render", at = @At(value = "INVOKE", diff --git a/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java b/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java index 9ecca0a3..093be7c3 100644 --- a/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java @@ -47,9 +47,9 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple } @Override - public void method_31662(World world) { - super.method_31662(world); - if (carriedBlockEntity != null) carriedBlockEntity.method_31662(world); + public void setWorld(World world) { + super.setWorld(world); + if (carriedBlockEntity != null) carriedBlockEntity.setWorld(world); } public void setCarriedBlockEntity(BlockEntity blockEntity) @@ -59,7 +59,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple { ((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); + if (world != null) carriedBlockEntity.setWorld(world); } // this.carriedBlockEntity.setPos(this.pos); } @@ -83,7 +83,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple /** * @author 2No2Name */ - @Redirect(method = "method_31707", at = @At(value = "INVOKE", // tick + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z")) private static boolean movableTEsetBlockState0( World world, BlockPos blockPos_1, BlockState blockAState_2, int int_1, diff --git a/src/main/java/carpet/mixins/PistonBlockEntity_playerHandlingMixin.java b/src/main/java/carpet/mixins/PistonBlockEntity_playerHandlingMixin.java index 86a20d8b..4f5ac386 100644 --- a/src/main/java/carpet/mixins/PistonBlockEntity_playerHandlingMixin.java +++ b/src/main/java/carpet/mixins/PistonBlockEntity_playerHandlingMixin.java @@ -29,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).method_31549().flying) ci.cancel(); + if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).getAbilities().flying) ci.cancel(); } @Redirect(method = "pushEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setVelocity(DDD)V")) private static void ignoreAccel(Entity entity, double x, double y, double z) { - if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).method_31549().flying) return; + if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).getAbilities().flying) return; entity.setVelocity(x,y,z); } diff --git a/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java b/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java index 916e60a5..e8def5d4 100644 --- a/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java @@ -51,10 +51,10 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock block != Blocks.SPAWNER; } - @Redirect(method = "isMovable", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;method_31709()Z")) // hasBLockENtity + @Redirect(method = "isMovable", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;hasBlockEntity()Z")) private static boolean ifHasBlockEntity(BlockState blockState) { - if (!blockState.method_31709()) + if (!blockState.hasBlockEntity()) { return false; } @@ -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).method_31709()) ? world_1.getBlockEntity(blockpos) : null; + BlockEntity blockEntity = (list_2.get(i).hasBlockEntity()) ? world_1.getBlockEntity(blockpos) : null; list1_BlockEntities.get().add(blockEntity); if (blockEntity != null) { diff --git a/src/main/java/carpet/mixins/PlayerEntity_creativeNoClipMixin.java b/src/main/java/carpet/mixins/PlayerEntity_creativeNoClipMixin.java index d7301eee..adba18ba 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.method_31549().flying); + return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.getAbilities().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.method_31549().flying); + return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.getAbilities().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.method_31549().flying); + return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.getAbilities().flying); } } diff --git a/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java b/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java index f2ad37fe..6c806a99 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.method_31548().selectedSlot, packet.getSelectedSlot()); + PLAYER_SWITCHES_SLOT.onSlotSwitch(player, player.getInventory().selectedSlot, packet.getSelectedSlot()); } } } diff --git a/src/main/java/carpet/mixins/ServerWorld_scarpetEventMixin.java b/src/main/java/carpet/mixins/ServerWorld_scarpetEventMixin.java index 7373895b..8ca7259a 100644 --- a/src/main/java/carpet/mixins/ServerWorld_scarpetEventMixin.java +++ b/src/main/java/carpet/mixins/ServerWorld_scarpetEventMixin.java @@ -39,12 +39,12 @@ public class ServerWorld_scarpetEventMixin @Redirect(method = "addEntity", at = @At( value = "INVOKE", - target = "Lnet/minecraft/class_5579;method_31818(Lnet/minecraft/class_5568;)Z" + target = "Lnet/minecraft/class_5579;addEntity(Lnet/minecraft/class_5568;)Z" )) private boolean onEntityAddedToWorld(class_5579 class_5579, class_5568 arg) { Entity entity = (Entity)arg; - boolean success = class_5579.method_31818(entity); + boolean success = class_5579.addEntity(entity); if (success) { CarpetEventServer.Event event = ENTITY_LOAD.get(entity.getType()); if (event != null) { diff --git a/src/main/java/carpet/mixins/WorldChunkBEList_tickMixin.java b/src/main/java/carpet/mixins/WorldChunkBEList_tickMixin.java index b630be70..b6136a8c 100644 --- a/src/main/java/carpet/mixins/WorldChunkBEList_tickMixin.java +++ b/src/main/java/carpet/mixins/WorldChunkBEList_tickMixin.java @@ -4,7 +4,7 @@ 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.block.entity.BlockEntityTicker; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Final; @@ -15,30 +15,29 @@ 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") +@Mixin(targets = "net.minecraft.world.chunk.WorldChunk$DirectBlockEntityTickInvoker") public class WorldChunkBEList_tickMixin { - @Shadow @Final private T field_27224; + @Shadow @Final private T blockEntity; CarpetProfiler.ProfilerToken entitySection; - @Inject(method = "method_31703", at = @At("HEAD")) + @Inject(method = "tick()V", at = @At("HEAD")) private void startTileEntitySection(CallbackInfo ci) { - entitySection = CarpetProfiler.start_block_entity_section(field_27224.getWorld(), field_27224, CarpetProfiler.TYPE.TILEENTITY); + entitySection = CarpetProfiler.start_block_entity_section(blockEntity.getWorld(), blockEntity, CarpetProfiler.TYPE.TILEENTITY); } - @Redirect(method = "method_31703", at = @At( + @Redirect(method = "tick()V", 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" + target = "Lnet/minecraft/block/entity/BlockEntityTicker;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) + private void checkProcessTEs(BlockEntityTicker blockEntityTicker, World world, BlockPos pos, BlockState state, 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); + if (TickSpeed.process_entities) blockEntityTicker.tick(world, pos, state, blockEntity); } - @Inject(method = "method_31703", at = @At("RETURN")) + @Inject(method = "tick()V", 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 88454061..fc1c0160 100644 --- a/src/main/java/carpet/mixins/WorldChunk_movableTEMixin.java +++ b/src/main/java/carpet/mixins/WorldChunk_movableTEMixin.java @@ -42,7 +42,7 @@ public abstract class WorldChunk_movableTEMixin implements WorldChunkInterface /* @Nullable */ public abstract BlockEntity getBlockEntity(BlockPos blockPos_1, WorldChunk.CreationType worldChunk$CreationType_1); - @Shadow protected abstract void method_31723(T blockEntity); + @Shadow protected abstract void updateTicker(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); @@ -76,7 +76,7 @@ public abstract class WorldChunk_movableTEMixin implements WorldChunkInterface int x = blockPos_1.getX() & 15; int y = blockPos_1.getY(); int z = blockPos_1.getZ() & 15; - int section = world.method_31602(y); + int section = world.getSectionIndex(y); ChunkSection chunkSection = this.sections[section]; if (chunkSection == EMPTY_SECTION) { @@ -126,17 +126,17 @@ public abstract class WorldChunk_movableTEMixin implements WorldChunkInterface else { BlockEntity oldBlockEntity = null; - if (oldBlockState.method_31709()) // is BE Provider + if (oldBlockState.hasBlockEntity()) { oldBlockEntity = this.getBlockEntity(blockPos_1, WorldChunk.CreationType.CHECK); if (oldBlockEntity != null) { - oldBlockEntity.method_31664(oldBlockState); - method_31723(oldBlockEntity); + oldBlockEntity.setCachedState(oldBlockState); + updateTicker(oldBlockEntity); } } - if (oldBlockState.method_31709()) // is BE Provider + if (oldBlockState.hasBlockEntity()) { if (newBlockEntity == null) { @@ -146,8 +146,8 @@ public abstract class WorldChunk_movableTEMixin implements WorldChunkInterface { newBlockEntity.cancelRemoval(); this.world.addBlockEntity(newBlockEntity); - newBlockEntity.method_31664(newBlockState); - method_31723(newBlockEntity); + newBlockEntity.setCachedState(newBlockState); + updateTicker(newBlockEntity); } } diff --git a/src/main/java/carpet/mixins/World_movableTEMixin.java b/src/main/java/carpet/mixins/World_movableTEMixin.java index d39fe37b..818676c0 100644 --- a/src/main/java/carpet/mixins/World_movableTEMixin.java +++ b/src/main/java/carpet/mixins/World_movableTEMixin.java @@ -60,7 +60,7 @@ public abstract class World_movableTEMixin implements WorldInterface, WorldAcces */ public boolean setBlockStateWithBlockEntity(BlockPos blockPos_1, BlockState blockState_1, BlockEntity newBlockEntity, int int_1) { - if (method_31606(blockPos_1) || !this.isClient && isDebugWorld()) return false; + if (isOutOfHeightLimit(blockPos_1) || !this.isClient && isDebugWorld()) return false; WorldChunk worldChunk_1 = this.getWorldChunk(blockPos_1); Block block_1 = blockState_1.getBlock(); diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index 4f8cfc70..d9cd3406 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -956,7 +956,7 @@ public class WorldAccess { expression.addLazyFunction("map_colour", -1, (c, t, lv) -> stateStringQuery(c, "map_colour", lv, (s, p) -> - BlockInfo.mapColourName.get(s.getTopMaterialColor(((CarpetContext)c).s.getWorld(), p)))); + BlockInfo.mapColourName.get(s.getMapColor(((CarpetContext)c).s.getWorld(), p)))); expression.addLazyFunction("property", -1, (c, t, lv) -> { diff --git a/src/main/java/carpet/script/utils/ShapesRenderer.java b/src/main/java/carpet/script/utils/ShapesRenderer.java index 06d0a981..7a8f24bc 100644 --- a/src/main/java/carpet/script/utils/ShapesRenderer.java +++ b/src/main/java/carpet/script/utils/ShapesRenderer.java @@ -442,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(VertexFormat.class_5596.field_27377, VertexFormats.POSITION_COLOR); // 3 // GL LINES + builder.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR); builder.vertex(x1, y1, z1).color(red1, grn1, blu1, alpha).next(); builder.vertex(x2, y2, z2).color(red1, grn1, blu1, alpha).next(); tessellator.draw(); @@ -455,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(VertexFormat.class_5596.field_27377, VertexFormats.POSITION_COLOR); // 3 /lines + builder.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR); if (xthick) { builder.vertex(x1, y1, z1).color(red1, grn2, blu2, alpha).next(); @@ -508,7 +508,7 @@ public class ShapesRenderer boolean xthick, boolean ythick, boolean zthick, float red1, float grn1, float blu1, float alpha) { - builder.begin(VertexFormat.class_5596.field_27382, VertexFormats.POSITION_COLOR); // QUADS + builder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); if (xthick && ythick) { @@ -583,7 +583,7 @@ public class ShapesRenderer for (int dh = 0; dh < hsteps; dh++) { float hh = dh*hstep; - builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); // line loop to line strip + builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip for (int i = 0; i <= num_steps360+1; i++) { float theta = step * i; @@ -599,7 +599,7 @@ public class ShapesRenderer { for (int i = 0; i <= num_steps180; i++) { - builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); // line loop to line strip + builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip float theta = step * i; float x = r * MathHelper.cos(theta); @@ -615,7 +615,7 @@ public class ShapesRenderer } else { - builder.begin(VertexFormat.class_5596.field_27377, VertexFormats.POSITION_COLOR); //lines + builder.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR); for (int i = 0; i <= num_steps180; i++) { float theta = step * i; @@ -633,7 +633,7 @@ public class ShapesRenderer for (int dh = 0; dh < hsteps; dh++) { float hh = dh * hstep; - builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); // line loop to line strip + builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip for (int i = 0; i <= num_steps360; i++) { float theta = step * i; @@ -649,7 +649,7 @@ public class ShapesRenderer { for (int i = 0; i <= num_steps180; i++) { - builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); // line loop to line strip + builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip float theta = step * i; float y = r * MathHelper.cos(theta); @@ -664,7 +664,7 @@ public class ShapesRenderer } else { - builder.begin(VertexFormat.class_5596.field_27377, VertexFormats.POSITION_COLOR); //lines + builder.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR); for (int i = 0; i <= num_steps180; i++) { float theta = step * i; @@ -681,7 +681,7 @@ public class ShapesRenderer for (int dh = 0; dh < hsteps; dh++) { float hh = dh * hstep; - builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); // line loop to line strip + builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip for (int i = 0; i <= num_steps360; i++) { float theta = step * i; @@ -696,7 +696,7 @@ public class ShapesRenderer { for (int i = 0; i <= num_steps180; i++) { - builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); // line loop to line strip + builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip float theta = step * i; float x = r * MathHelper.cos(theta); @@ -711,7 +711,7 @@ public class ShapesRenderer } else { - builder.begin(VertexFormat.class_5596.field_27377, VertexFormats.POSITION_COLOR); //lines + builder.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR); for (int i = 0; i <= num_steps180; i++) { float theta = step * i; @@ -738,7 +738,7 @@ public class ShapesRenderer if (axis == Direction.Axis.Y) { - builder.begin(VertexFormat.class_5596.field_27381, VertexFormats.POSITION_COLOR); //triangle fan + builder.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR); builder.vertex(cx, cy, cz).color(red, grn, blu, alpha).next(); for (int i = 0; i <= num_steps360; i++) { @@ -750,7 +750,7 @@ public class ShapesRenderer tessellator.draw(); if (!isFlat) { - builder.begin(VertexFormat.class_5596.field_27381, VertexFormats.POSITION_COLOR); //trifan + builder.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR); builder.vertex(cx, cy+h, cz).color(red, grn, blu, alpha).next(); for (int i = 0; i <= num_steps360; i++) { @@ -761,7 +761,7 @@ public class ShapesRenderer } tessellator.draw(); - builder.begin(VertexFormat.class_5596.field_27382, VertexFormats.POSITION_COLOR); // quad strip to quads + builder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); // quad strip to quads float xp = r * 1; float zp = r * 0; for (int i = 1; i <= num_steps360; i++) @@ -782,7 +782,7 @@ public class ShapesRenderer } else if (axis == Direction.Axis.X) { - builder.begin(VertexFormat.class_5596.field_27381, VertexFormats.POSITION_COLOR); //trifan + builder.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR); builder.vertex(cx, cy, cz).color(red, grn, blu, alpha).next(); for (int i = 0; i <= num_steps360; i++) { @@ -794,7 +794,7 @@ public class ShapesRenderer tessellator.draw(); if (!isFlat) { - builder.begin(VertexFormat.class_5596.field_27381, VertexFormats.POSITION_COLOR); //trifan + builder.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR); builder.vertex(cx+h, cy, cz).color(red, grn, blu, alpha).next(); for (int i = 0; i <= num_steps360; i++) { @@ -805,7 +805,7 @@ public class ShapesRenderer } tessellator.draw(); - builder.begin(VertexFormat.class_5596.field_27382, VertexFormats.POSITION_COLOR); // quad strip to quads + builder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); // quad strip to quads float yp = r * 1; float zp = r * 0; for (int i = 1; i <= num_steps360; i++) @@ -825,7 +825,7 @@ public class ShapesRenderer } else if (axis == Direction.Axis.Z) { - builder.begin(VertexFormat.class_5596.field_27381, VertexFormats.POSITION_COLOR); //trifan + builder.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR); builder.vertex(cx, cy, cz).color(red, grn, blu, alpha).next(); for (int i = 0; i <= num_steps360; i++) { @@ -837,7 +837,7 @@ public class ShapesRenderer tessellator.draw(); if (!isFlat) { - builder.begin(VertexFormat.class_5596.field_27381, VertexFormats.POSITION_COLOR); //trifan + builder.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR); builder.vertex(cx, cy, cz+h).color(red, grn, blu, alpha).next(); for (int i = 0; i <= num_steps360; i++) { @@ -848,7 +848,7 @@ public class ShapesRenderer } tessellator.draw(); - builder.begin(VertexFormat.class_5596.field_27382, VertexFormats.POSITION_COLOR); // quad strip to quads + builder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); // quad strip to quads float xp = r; float yp = 0; for (int i = 1; i <= num_steps360; i++) @@ -878,7 +878,7 @@ public class ShapesRenderer int num_steps360 = (int)(2*Math.PI / step)+1; for (int i = 0; i <= num_steps360; i++) { - builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); //linestrip + builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); float theta = step * i ; for (int j = 0; j <= num_steps180; j++) { @@ -892,7 +892,7 @@ public class ShapesRenderer } for (int j = 0; j <= num_steps180; j++) { - builder.begin(VertexFormat.class_5596.field_27378, VertexFormats.POSITION_COLOR); // line loop to line strip + builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip float phi = step * j ; for (int i = 0; i <= num_steps360; i++) @@ -921,7 +921,7 @@ public class ShapesRenderer { float theta = i * step; float thetaprime = theta+step; - builder.begin(VertexFormat.class_5596.field_27382, VertexFormats.POSITION_COLOR); // quad strip to quads + builder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); // quad strip to quads float xb = 0; float zb = 0; float xbp = 0; diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 7c703596..19740819 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -620,7 +620,7 @@ public class EntityValue extends Value put("selected_slot", (e, a) -> { if (e instanceof PlayerEntity) - return new NumericValue(((PlayerEntity) e).method_31548().selectedSlot); //getInventory + return new NumericValue(((PlayerEntity) e).getInventory().selectedSlot); //getInventory return Value.NULL; }); diff --git a/src/main/java/carpet/script/value/NBTSerializableValue.java b/src/main/java/carpet/script/value/NBTSerializableValue.java index de8c9ea8..a7e6d3a7 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 (blockState.method_31709()) { //hasBlockEntity() + } else if (blockState.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).method_31548(); + if (e instanceof PlayerEntity) inv = ((PlayerEntity) e).getInventory(); 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.method_31548(), + isEnder ? player.getEnderChestInventory() : player.getInventory(), offset + 1, isEnder ); diff --git a/src/main/java/carpet/utils/BlockInfo.java b/src/main/java/carpet/utils/BlockInfo.java index 1315eb8f..2a420ba0 100644 --- a/src/main/java/carpet/utils/BlockInfo.java +++ b/src/main/java/carpet/utils/BlockInfo.java @@ -3,7 +3,7 @@ package carpet.utils; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; +import net.minecraft.block.MapColor; import net.minecraft.class_5532; // TargetFinder import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnReason; @@ -68,61 +68,81 @@ public class BlockInfo put(BlockSoundGroup.BONE, "bone"); put(BlockSoundGroup.NETHERITE, "netherite"); put(BlockSoundGroup.ANCIENT_DEBRIS, "ancient_debris"); + put(BlockSoundGroup.LODESTONE, "lodestone"); + put(BlockSoundGroup.CHAIN, "chain"); + put(BlockSoundGroup.NETHER_GOLD_ORE, "nether_gold_ore"); + put(BlockSoundGroup.GILDED_BLACKSTONE, "gilded_blackstone"); + put(BlockSoundGroup.field_27196, "candle"); + put(BlockSoundGroup.field_27197, "amethyst"); + put(BlockSoundGroup.field_27198, "amethyst_cluster"); + put(BlockSoundGroup.field_27199, "small_amethyst_bud"); + put(BlockSoundGroup.field_27200, "large_amethyst_bud"); + put(BlockSoundGroup.field_27201, "medium_amethyst_bud"); + put(BlockSoundGroup.field_27202, "tuff"); + put(BlockSoundGroup.field_27203, "calcite"); + put(BlockSoundGroup.field_27204, "copper"); }}; - public static final Map mapColourName = new HashMap() {{ - put(MaterialColor.CLEAR , "air" ); - put(MaterialColor.GRASS , "grass" ); - put(MaterialColor.SAND , "sand" ); - put(MaterialColor.WEB , "wool" ); - put(MaterialColor.LAVA , "tnt" ); - put(MaterialColor.ICE , "ice" ); - put(MaterialColor.IRON , "iron" ); - put(MaterialColor.FOLIAGE , "foliage" ); - put(MaterialColor.WHITE , "snow" ); - put(MaterialColor.CLAY , "clay" ); - put(MaterialColor.DIRT , "dirt" ); - put(MaterialColor.STONE , "stone" ); - put(MaterialColor.WATER , "water" ); - put(MaterialColor.WOOD , "wood" ); - put(MaterialColor.QUARTZ , "quartz" ); - put(MaterialColor.ORANGE , "adobe" ); - put(MaterialColor.MAGENTA , "magenta" ); - put(MaterialColor.LIGHT_BLUE, "light_blue"); - put(MaterialColor.YELLOW , "yellow" ); - put(MaterialColor.LIME , "lime" ); - put(MaterialColor.PINK , "pink" ); - put(MaterialColor.GRAY , "gray" ); - put(MaterialColor.LIGHT_GRAY, "light_gray"); - put(MaterialColor.CYAN , "cyan" ); - put(MaterialColor.PURPLE , "purple" ); - put(MaterialColor.BLUE , "blue" ); - put(MaterialColor.BROWN , "brown" ); - put(MaterialColor.GREEN , "green" ); - put(MaterialColor.RED , "red" ); - put(MaterialColor.BLACK , "black" ); - put(MaterialColor.GOLD , "gold" ); - put(MaterialColor.DIAMOND , "diamond" ); - put(MaterialColor.LAPIS , "lapis" ); - put(MaterialColor.EMERALD , "emerald" ); - put(MaterialColor.SPRUCE , "obsidian" ); - put(MaterialColor.NETHER , "netherrack"); //TODO fix these - put(MaterialColor.WHITE_TERRACOTTA , "white_terracotta" ); - put(MaterialColor.ORANGE_TERRACOTTA , "orange_terracotta" ); - put(MaterialColor.MAGENTA_TERRACOTTA , "magenta_terracotta" ); - put(MaterialColor.LIGHT_BLUE_TERRACOTTA, "light_blue_terracotta" ); - put(MaterialColor.YELLOW_TERRACOTTA , "yellow_terracotta" ); - put(MaterialColor.LIME_TERRACOTTA , "lime_terracotta" ); - put(MaterialColor.PINK_TERRACOTTA , "pink_terracotta" ); - put(MaterialColor.GRAY_TERRACOTTA , "gray_terracotta" ); - put(MaterialColor.LIGHT_GRAY_TERRACOTTA, "light_gray_terracotta" ); - put(MaterialColor.CYAN_TERRACOTTA , "cyan_terracotta" ); - put(MaterialColor.PURPLE_TERRACOTTA , "purple_terracotta" ); - put(MaterialColor.BLUE_TERRACOTTA , "blue_terracotta" ); - put(MaterialColor.BROWN_TERRACOTTA , "brown_terracotta" ); - put(MaterialColor.GREEN_TERRACOTTA , "green_terracotta" ); - put(MaterialColor.RED_TERRACOTTA , "red_terracotta" ); - put(MaterialColor.BLACK_TERRACOTTA , "black_terracotta" ); + public static final Map mapColourName = new HashMap() {{ + put(MapColor.CLEAR , "air" ); + put(MapColor.GRASS , "grass" ); + put(MapColor.SAND , "sand" ); + put(MapColor.WEB , "wool" ); + put(MapColor.LAVA , "tnt" ); + put(MapColor.ICE , "ice" ); + put(MapColor.IRON , "iron" ); + put(MapColor.FOLIAGE , "foliage" ); + put(MapColor.WHITE , "snow" ); + put(MapColor.CLAY , "clay" ); + put(MapColor.DIRT , "dirt" ); + put(MapColor.STONE , "stone" ); + put(MapColor.WATER , "water" ); + put(MapColor.WOOD , "wood" ); + put(MapColor.QUARTZ , "quartz" ); + put(MapColor.ORANGE , "adobe" ); + put(MapColor.MAGENTA , "magenta" ); + put(MapColor.LIGHT_BLUE, "light_blue"); + put(MapColor.YELLOW , "yellow" ); + put(MapColor.LIME , "lime" ); + put(MapColor.PINK , "pink" ); + put(MapColor.GRAY , "gray" ); + put(MapColor.LIGHT_GRAY, "light_gray"); + put(MapColor.CYAN , "cyan" ); + put(MapColor.PURPLE , "purple" ); + put(MapColor.BLUE , "blue" ); + put(MapColor.BROWN , "brown" ); + put(MapColor.GREEN , "green" ); + put(MapColor.RED , "red" ); + put(MapColor.BLACK , "black" ); + put(MapColor.GOLD , "gold" ); + put(MapColor.DIAMOND , "diamond" ); + put(MapColor.LAPIS , "lapis" ); + put(MapColor.EMERALD , "emerald" ); + put(MapColor.SPRUCE , "obsidian" ); + put(MapColor.NETHER , "netherrack"); //TODO fix these + put(MapColor.WHITE_TERRACOTTA , "white_terracotta" ); + put(MapColor.ORANGE_TERRACOTTA , "orange_terracotta" ); + put(MapColor.MAGENTA_TERRACOTTA , "magenta_terracotta" ); + put(MapColor.LIGHT_BLUE_TERRACOTTA, "light_blue_terracotta" ); + put(MapColor.YELLOW_TERRACOTTA , "yellow_terracotta" ); + put(MapColor.LIME_TERRACOTTA , "lime_terracotta" ); + put(MapColor.PINK_TERRACOTTA , "pink_terracotta" ); + put(MapColor.GRAY_TERRACOTTA , "gray_terracotta" ); + put(MapColor.LIGHT_GRAY_TERRACOTTA, "light_gray_terracotta" ); + put(MapColor.CYAN_TERRACOTTA , "cyan_terracotta" ); + put(MapColor.PURPLE_TERRACOTTA , "purple_terracotta" ); + put(MapColor.BLUE_TERRACOTTA , "blue_terracotta" ); + put(MapColor.BROWN_TERRACOTTA , "brown_terracotta" ); + put(MapColor.GREEN_TERRACOTTA , "green_terracotta" ); + put(MapColor.RED_TERRACOTTA , "red_terracotta" ); + put(MapColor.BLACK_TERRACOTTA , "black_terracotta" ); + put(MapColor.CRIMSON_NYLIUM , "crimson_nylium" ); + put(MapColor.CRIMSON_STEM , "crimson_stem" ); + put(MapColor.CRIMSON_HYPHAE , "crimson_hyphae" ); + put(MapColor.WARPED_NYLIUM , "warped_nylium" ); + put(MapColor.WARPED_STEM , "warped_stem" ); + put(MapColor.WARPED_HYPHAE , "warped_hyphae" ); + put(MapColor.WARPED_WART , "warped_wart" ); }}; public static final Map materialName = new HashMap() {{ @@ -133,20 +153,20 @@ public class BlockInfo put(Material.PLANT , "plant" ); put(Material.UNDERWATER_PLANT, "water_plant" ); put(Material.REPLACEABLE_PLANT, "vegetation" ); - put(Material.REPLACEABLE_UNDERWATER_PLANT , "sea_grass" ); + put(Material.REPLACEABLE_UNDERWATER_PLANT, "sea_grass" ); put(Material.WATER , "water" ); put(Material.BUBBLE_COLUMN , "bubble_column"); put(Material.LAVA , "lava" ); - put(Material.SNOW_LAYER , "snow_layer" ); + put(Material.SNOW_LAYER , "snow_layer" ); put(Material.FIRE , "fire" ); - put(Material.SUPPORTED , "decoration" ); + put(Material.SUPPORTED , "decoration" ); put(Material.COBWEB , "cobweb" ); put(Material.REDSTONE_LAMP , "redstone_lamp"); - put(Material.ORGANIC_PRODUCT , "clay" ); - put(Material.SOIL , "dirt" ); - put(Material.SOLID_ORGANIC , "grass" ); - put(Material.DENSE_ICE , "packed_ice" ); - put(Material.AGGREGATE , "sand" ); + put(Material.ORGANIC_PRODUCT, "clay" ); + put(Material.SOIL , "dirt" ); + put(Material.SOLID_ORGANIC , "grass" ); + put(Material.DENSE_ICE , "packed_ice" ); + put(Material.AGGREGATE , "sand" ); put(Material.SPONGE , "sponge" ); put(Material.SHULKER_BOX , "shulker" ); put(Material.WOOD , "wood" ); @@ -162,13 +182,14 @@ public class BlockInfo put(Material.STONE , "stone" ); put(Material.METAL , "metal" ); put(Material.SNOW_BLOCK , "snow" ); - put(Material.REPAIR_STATION , "anvil" ); + put(Material.REPAIR_STATION , "anvil" ); put(Material.BARRIER , "barrier" ); put(Material.PISTON , "piston" ); put(Material.UNUSED_PLANT , "coral" ); - put(Material.GOURD , "gourd" ); + put(Material.GOURD , "gourd" ); put(Material.EGG , "dragon_egg" ); put(Material.CAKE , "cake" ); + put(Material.AMETHYST , "amethyst" ); }}; public static List blockInfo(BlockPos pos, ServerWorld world) @@ -186,7 +207,7 @@ public class BlockInfo lst.add(Messenger.s("=====================================")); lst.add(Messenger.s(String.format("Block info for %s%s (id %d%s):",Registry.BLOCK.getId(block),metastring, Registry.BLOCK.getRawId(block), metastring ))); lst.add(Messenger.s(String.format(" - Material: %s", materialName.get(material)))); - lst.add(Messenger.s(String.format(" - Map colour: %s", mapColourName.get(state.getTopMaterialColor(world, pos))))); + lst.add(Messenger.s(String.format(" - Map colour: %s", mapColourName.get(state.getMapColor(world, pos))))); lst.add(Messenger.s(String.format(" - Sound type: %s", soundName.get(block.getSoundGroup(state))))); lst.add(Messenger.s("")); lst.add(Messenger.s(String.format(" - Full block: %s", state.isFullCube(world, pos)))); // isFullCube() ))); diff --git a/src/main/java/carpet/utils/WoolTool.java b/src/main/java/carpet/utils/WoolTool.java index 832d4b3b..d6b51d48 100644 --- a/src/main/java/carpet/utils/WoolTool.java +++ b/src/main/java/carpet/utils/WoolTool.java @@ -3,7 +3,7 @@ package carpet.utils; import carpet.CarpetSettings; import carpet.helpers.HopperCounter; import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; +import net.minecraft.block.MapColor; import net.minecraft.block.BlockState; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.entity.player.PlayerEntity; @@ -20,12 +20,12 @@ import java.util.List; public class WoolTool { - private static final HashMap Material2Dye = new HashMap<>(); + private static final HashMap Material2Dye = new HashMap<>(); static { for (DyeColor color: DyeColor.values()) { - Material2Dye.put(color.getMaterialColor(),color); + Material2Dye.put(color.getMapColor(),color); } } @@ -98,6 +98,6 @@ public class WoolTool BlockState state = worldIn.getBlockState(pos); if (state.getMaterial() != Material.WOOL || !state.isSolidBlock(worldIn, pos)) //isSimpleFullBlock return null; - return Material2Dye.get(state.getTopMaterialColor(worldIn, pos)); + return Material2Dye.get(state.getMapColor(worldIn, pos)); } } From 059f1a15f88c8920904a086c65508ae1c375c26f Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 6 Nov 2020 23:20:43 -0400 Subject: [PATCH 003/115] 1.16 and 1.17 materials, sounds and colors --- docs/scarpet/api/BlocksAndWorldAccess.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/scarpet/api/BlocksAndWorldAccess.md b/docs/scarpet/api/BlocksAndWorldAccess.md index 0aa6031d..3d1ff567 100644 --- a/docs/scarpet/api/BlocksAndWorldAccess.md +++ b/docs/scarpet/api/BlocksAndWorldAccess.md @@ -384,7 +384,14 @@ Boolean function, true if the block at position blocks movement. Returns the name of sound type made by the block at position. One of: `'wood'`, `'gravel'`, `'grass'`, `'stone'`, `'metal'`, `'glass'`, `'wool'`, `'sand'`, `'snow'`, -`'ladder'`, `'anvil'`, `'slime'`, `'sea_grass'`, `'coral'` +`'ladder'`, `'anvil'`, `'slime'`, `'sea_grass'`, `'coral'`, `'bamboo'`', `'shoots'`', `'scaffolding'`', `'berry'`', `'crop'`', +`'stem'`', `'wart'`', +`'lantern'`', `'fungi_stem'`', `'nylium'`', `'fungus'`', `'roots'`', `'shroomlight'`', `'weeping_vines'`', `'soul_sand'`', + `'soul_soil'`', `'basalt'`', +`'wart'`', `'netherrack'`', `'nether_bricks'`', `'nether_sprouts'`', `'nether_ore'`', `'bone'`', `'netherite'`', `'ancient_debris'`', +`'lodestone'`', `'chain'`', `'nether_gold_ore'`', `'gilded_blackstone'`', +`'candle'`', `'amethyst'`', `'amethyst_cluster'`', `'small_amethyst_bud'`', `'large_amethyst_bud'`', `'medium_amethyst_bud'`', +`'tuff'`', `'calcite'`', `'copper'`' ### `material(pos)` @@ -394,7 +401,7 @@ Returns the name of material of the block at position. very useful to target a g `'bubble_column'`, `'lava'`, `'snow_layer'`, `'fire'`, `'redstone_bits'`, `'cobweb'`, `'redstone_lamp'`, `'clay'`, `'dirt'`, `'grass'`, `'packed_ice'`, `'sand'`, `'sponge'`, `'wood'`, `'wool'`, `'tnt'`, `'leaves'`, `'glass'`, `'ice'`, `'cactus'`, `'stone'`, `'iron'`, `'snow'`, `'anvil'`, `'barrier'`, `'piston'`, `'coral'`, `'gourd'`, -`'dragon_egg'`, `'cake'` +`'dragon_egg'`, `'cake'`, `'amethyst'` ### `map_colour(pos)` @@ -406,7 +413,8 @@ Returns the map colour of a block at position. One of: '`, `'diamond'`, `'lapis'`, `'emerald'`, `'obsidian'`, `'netherrack'`, `'white_terracotta'`, `'orange_terracotta'`, `'magenta_terracotta'`, `'light_blue_terracotta'`, `'yellow_terracotta'`, `'lime_terracotta'`, `'pink_terracotta'`, `'gray_terracotta'`, `'light_gray_terracotta'`, `'cyan_terracotta'`, `'purple_terracotta'`, `'blue_terracotta'`, -`'brown_terracotta'`, `'green_terracotta'`, `'red_terracotta'`, `'black_terracotta'` +`'brown_terracotta'`, `'green_terracotta'`, `'red_terracotta'`, `'black_terracotta'`, +`'crimson_nylium'`, `'crimson_stem'`, `'crimson_hyphae'`, `'warped_nylium'`, `'warped_stem'`, `'warped_hyphae'`, `'warped_wart'` ### `loaded(pos)` From b04757585000dd4e5f1fc6e617041accc19fbfca Mon Sep 17 00:00:00 2001 From: gnembon Date: Mon, 9 Nov 2020 03:09:28 -0400 Subject: [PATCH 004/115] mapping fixes --- src/main/java/carpet/script/value/ValueConversions.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/carpet/script/value/ValueConversions.java b/src/main/java/carpet/script/value/ValueConversions.java index 91f6c77e..9d03a33e 100644 --- a/src/main/java/carpet/script/value/ValueConversions.java +++ b/src/main/java/carpet/script/value/ValueConversions.java @@ -2,7 +2,7 @@ package carpet.script.value; import carpet.script.exception.InternalExpressionException; import carpet.utils.BlockInfo; -import net.minecraft.block.MaterialColor; +import net.minecraft.block.MapColor; import net.minecraft.entity.Entity; import net.minecraft.entity.ai.brain.LookTarget; import net.minecraft.entity.ai.brain.WalkTarget; @@ -64,7 +64,7 @@ public class ValueConversions return of(world.getRegistryKey().getValue()); } - public static Value of(MaterialColor color) {return ListValue.of(StringValue.of(BlockInfo.mapColourName.get(color)), ofRGB(color.color));} + public static Value of(MapColor color) {return ListValue.of(StringValue.of(BlockInfo.mapColourName.get(color)), ofRGB(color.color));} public static Value of(NumberRange range) { return ListValue.of(NumericValue.of(range.getMin()), NumericValue.of(range.getMax()));} From 735bc58772fa515f955bae9932b125d3dac139cb Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 11 Nov 2020 02:12:29 -0400 Subject: [PATCH 005/115] fix update --- src/main/java/carpet/mixins/WorldChunk_fillUpdatesMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/mixins/WorldChunk_fillUpdatesMixin.java b/src/main/java/carpet/mixins/WorldChunk_fillUpdatesMixin.java index cab107b8..cde6b27e 100644 --- a/src/main/java/carpet/mixins/WorldChunk_fillUpdatesMixin.java +++ b/src/main/java/carpet/mixins/WorldChunk_fillUpdatesMixin.java @@ -31,7 +31,7 @@ public class WorldChunk_fillUpdatesMixin { if (CarpetSettings.impendingFillSkipUpdates) // doing due dilligence from AbstractBlock onStateReplaced { - if (blockState.getBlock().hasBlockEntity() && !blockState.isOf(state.getBlock())) + if (blockState.hasBlockEntity() && !blockState.isOf(state.getBlock())) { world.removeBlockEntity(pos); } From 21700e8d7e4c5382a6b736692daeee1f9912a0ae Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 11 Nov 2020 16:18:27 -0400 Subject: [PATCH 006/115] 20w46a --- gradle.properties | 4 ++-- ...stonBlockEntityRenderer_movableTEMixin.java | 2 +- .../java/carpet/mixins/TntEntityMixin.java | 10 +++++----- src/main/java/carpet/utils/BlockInfo.java | 18 +++++++++--------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/gradle.properties b/gradle.properties index f0a78e37..5b122dc7 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=20w45a - yarn_mappings=20w45a+build.20 + minecraft_version=20w46a + yarn_mappings=20w46a+build.2 loader_version=0.10.6+build.214 # Mod Properties diff --git a/src/main/java/carpet/mixins/PistonBlockEntityRenderer_movableTEMixin.java b/src/main/java/carpet/mixins/PistonBlockEntityRenderer_movableTEMixin.java index 62fcc876..d41652b0 100644 --- a/src/main/java/carpet/mixins/PistonBlockEntityRenderer_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonBlockEntityRenderer_movableTEMixin.java @@ -21,7 +21,7 @@ public abstract class PistonBlockEntityRenderer_movableTEMixin implements BlockE { BlockEntityRenderDispatcher dispatcher; @Inject(method = "", at = @At("TAIL")) - private void onInitCM(BlockEntityRendererFactory.Arguments arguments, CallbackInfo ci) + private void onInitCM(BlockEntityRendererFactory.Context arguments, CallbackInfo ci) { dispatcher = arguments.getRenderDispatcher(); } diff --git a/src/main/java/carpet/mixins/TntEntityMixin.java b/src/main/java/carpet/mixins/TntEntityMixin.java index 3b95dd24..52849252 100644 --- a/src/main/java/carpet/mixins/TntEntityMixin.java +++ b/src/main/java/carpet/mixins/TntEntityMixin.java @@ -20,7 +20,9 @@ import carpet.logging.logHelpers.TNTLogHelper; @Mixin(TntEntity.class) public abstract class TntEntityMixin extends Entity implements TntEntityInterface { - @Shadow private int fuseTimer; + //@Shadow private int fuseTimer; + + @Shadow public abstract int getFuse(); private TNTLogHelper logHelper; private boolean mergeBool = false; @@ -98,7 +100,7 @@ public abstract class TntEntityMixin extends Entity implements TntEntityInterfac 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()){ + && getFuse() == entityTNTPrimed.getFuse()){ mergedTNT += ((TntEntityInterface) entityTNTPrimed).getMergedTNT(); entityTNTPrimed.discard(); // discard remove(); } @@ -108,9 +110,7 @@ public abstract class TntEntityMixin extends Entity implements TntEntityInterfac } } - @Inject(method = "tick", at = @At(value = "FIELD", - target = "Lnet/minecraft/entity/TntEntity;fuseTimer:I", - ordinal = 0)) + @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/TntEntity;setFuse(I)V")) private void setMergeable(CallbackInfo ci) { // Merge code, merge only tnt that have had a chance to move CARPET-XCOM diff --git a/src/main/java/carpet/utils/BlockInfo.java b/src/main/java/carpet/utils/BlockInfo.java index 2a420ba0..6705c82d 100644 --- a/src/main/java/carpet/utils/BlockInfo.java +++ b/src/main/java/carpet/utils/BlockInfo.java @@ -72,15 +72,15 @@ public class BlockInfo put(BlockSoundGroup.CHAIN, "chain"); put(BlockSoundGroup.NETHER_GOLD_ORE, "nether_gold_ore"); put(BlockSoundGroup.GILDED_BLACKSTONE, "gilded_blackstone"); - put(BlockSoundGroup.field_27196, "candle"); - put(BlockSoundGroup.field_27197, "amethyst"); - put(BlockSoundGroup.field_27198, "amethyst_cluster"); - put(BlockSoundGroup.field_27199, "small_amethyst_bud"); - put(BlockSoundGroup.field_27200, "large_amethyst_bud"); - put(BlockSoundGroup.field_27201, "medium_amethyst_bud"); - put(BlockSoundGroup.field_27202, "tuff"); - put(BlockSoundGroup.field_27203, "calcite"); - put(BlockSoundGroup.field_27204, "copper"); + put(BlockSoundGroup.CANDLE, "candle"); + put(BlockSoundGroup.AMETHYST_BLOCK, "amethyst"); + put(BlockSoundGroup.AMETHYST_CLUSTER, "amethyst_cluster"); + put(BlockSoundGroup.SMALL_AMETHYST_BUD, "small_amethyst_bud"); + put(BlockSoundGroup.LARGE_AMETHYST_BUD, "large_amethyst_bud"); + put(BlockSoundGroup.MEDIUM_AMETHYST_BUD, "medium_amethyst_bud"); + put(BlockSoundGroup.TUFF, "tuff"); + put(BlockSoundGroup.CALCITE, "calcite"); + put(BlockSoundGroup.COPPER, "copper"); }}; public static final Map mapColourName = new HashMap() {{ From 6c8defae913cc1b0666cf69aafd9435db6149a73 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 15 Nov 2020 01:55:40 -0400 Subject: [PATCH 007/115] fixes to entity selection in scripts and xp no cooldown --- gradle.properties | 4 +- .../mixins/ExperienceOrbEntityMixin.java | 12 ++++ .../script/command/CommandArgument.java | 4 +- .../java/carpet/script/value/EntityValue.java | 61 ++++++++++++------- 4 files changed, 54 insertions(+), 27 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5b122dc7..1cfbcf0f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,8 +5,8 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=20w46a - yarn_mappings=20w46a+build.2 - loader_version=0.10.6+build.214 + yarn_mappings=20w46a+build.11 + loader_version=0.10.7 # Mod Properties mod_version = 1.4.17+v201111 diff --git a/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java b/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java index 819d616d..80c453b2 100644 --- a/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java +++ b/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java @@ -9,6 +9,7 @@ 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(ExperienceOrbEntity.class) @@ -64,4 +65,15 @@ public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface playerEntity_1.experiencePickUpDelay = 0; } + @Redirect(method = "onPlayerCollision", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;addExperience(I)V")) + void addXP(PlayerEntity playerEntity, int experience) + { + playerEntity.addExperience(experience); + if (CarpetSettings.xpNoCooldown) while(field_27009 > 1) + { + field_27009 --; + playerEntity.addExperience(experience); + } + } + } diff --git a/src/main/java/carpet/script/command/CommandArgument.java b/src/main/java/carpet/script/command/CommandArgument.java index 82bd5c69..347c8017 100644 --- a/src/main/java/carpet/script/command/CommandArgument.java +++ b/src/main/java/carpet/script/command/CommandArgument.java @@ -191,13 +191,13 @@ public abstract class CommandArgument (c, p) -> ValueConversions.of( IdentifierArgumentType.getAdvancementArgument(c, p).getId()), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getMinecraftServer().getAdvancementLoader().getAdvancements().stream().map(Advancement::getId), builder) ), new VanillaUnconfigurableArgument("lootcondition", IdentifierArgumentType::identifier, - (c, p) -> ValueConversions.of( Registry.LOOT_CONDITION_TYPE.getId(IdentifierArgumentType.method_23727(c, p).getType())), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getMinecraftServer().getPredicateManager().getIds(), builder) + (c, p) -> ValueConversions.of( Registry.LOOT_CONDITION_TYPE.getId(IdentifierArgumentType.getPredicateArgument(c, p).getType())), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getMinecraftServer().getPredicateManager().getIds(), builder) ), new VanillaUnconfigurableArgument("loottable", IdentifierArgumentType::identifier, (c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getMinecraftServer().getLootManager().getTableIds(), builder) ), new VanillaUnconfigurableArgument("attribute", IdentifierArgumentType::identifier, - (c, p) -> ValueConversions.of( Registry.ATTRIBUTE.getId(IdentifierArgumentType.method_27575(c, p))), (ctx, builder) -> CommandSource.suggestIdentifiers(Registry.ATTRIBUTE.getIds(), builder) + (c, p) -> ValueConversions.of( Registry.ATTRIBUTE.getId(IdentifierArgumentType.getAttributeArgument(c, p))), (ctx, builder) -> CommandSource.suggestIdentifiers(Registry.ATTRIBUTE.getIds(), builder) ), new VanillaUnconfigurableArgument("boss", IdentifierArgumentType::identifier, (c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), BossBarCommand.SUGGESTION_PROVIDER diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index b469f77d..9b003d7e 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -17,6 +17,7 @@ import carpet.script.exception.InternalExpressionException; import com.google.common.collect.Sets; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; +import net.minecraft.class_5575; import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.ai.brain.Brain; import net.minecraft.entity.ai.brain.Memory; @@ -210,7 +211,7 @@ public class EntityValue extends Value public static class EntityClassDescriptor { - public EntityType directType; + public class_5575 directType; // interface of EntityType public Predicate filteringPredicate; public List> typeList; public Value listValue; @@ -221,11 +222,25 @@ public class EntityValue extends Value typeList = types; listValue = (types==null)?Value.NULL:ListValue.wrap(types.stream().map(et -> StringValue.of(nameFromRegistryId(Registry.ENTITY_TYPE.getId(et)))).collect(Collectors.toList())); } + + EntityClassDescriptor( class_5575 type, Predicate predicate, List> types) + { + directType = type; + filteringPredicate = predicate; + typeList = types; + listValue = (types==null)?Value.NULL:ListValue.wrap(types.stream().map(et -> StringValue.of(nameFromRegistryId(Registry.ENTITY_TYPE.getId(et)))).collect(Collectors.toList())); + } + EntityClassDescriptor(EntityType type, Predicate predicate, Stream> types) { this(type, predicate, types.collect(Collectors.toList())); } + EntityClassDescriptor(class_5575 type, Predicate predicate, Stream> types) + { + this(type, predicate, types.collect(Collectors.toList())); + } + public final static Map byName = new HashMap() {{ List> allTypes = Registry.ENTITY_TYPE.stream().collect(Collectors.toList()); // nonliving types @@ -279,49 +294,49 @@ public class EntityValue extends Value ).collect(Collectors.toSet()); - put("*", new EntityClassDescriptor(null, e -> true, allTypes) ); - put("valid", new EntityClassDescriptor(null, EntityPredicates.VALID_ENTITY, allTypes)); - put("!valid", new EntityClassDescriptor(null, e -> !e.isAlive(), allTypes)); + put("*", new EntityClassDescriptor(class_5575.method_31795(Entity.class), e -> true, allTypes) ); + put("valid", new EntityClassDescriptor(class_5575.method_31795(Entity.class), EntityPredicates.VALID_ENTITY, allTypes)); + put("!valid", new EntityClassDescriptor(class_5575.method_31795(Entity.class), e -> !e.isAlive(), allTypes)); - put("living", new EntityClassDescriptor(null, (e) -> (e instanceof LivingEntity && e.isAlive()), allTypes.stream().filter(living::contains))); - put("!living", new EntityClassDescriptor(null, (e) -> (!(e instanceof LivingEntity) && e.isAlive()), allTypes.stream().filter(et -> !living.contains(et)))); + put("living", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), EntityPredicates.VALID_ENTITY, allTypes.stream().filter(living::contains))); + put("!living", new EntityClassDescriptor(class_5575.method_31795(Entity.class), (e) -> (!(e instanceof LivingEntity) && e.isAlive()), allTypes.stream().filter(et -> !living.contains(et)))); - put("projectile", new EntityClassDescriptor(null, (e) -> (e instanceof ProjectileEntity && e.isAlive()), allTypes.stream().filter(projectiles::contains))); - put("!projectile", new EntityClassDescriptor(null, (e) -> (!(e instanceof ProjectileEntity) && e.isAlive()), allTypes.stream().filter(et -> !projectiles.contains(et) && !living.contains(et)))); + put("projectile", new EntityClassDescriptor(class_5575.method_31795(ProjectileEntity.class), EntityPredicates.VALID_ENTITY, allTypes.stream().filter(projectiles::contains))); + put("!projectile", new EntityClassDescriptor(class_5575.method_31795(Entity.class), (e) -> (!(e instanceof ProjectileEntity) && e.isAlive()), allTypes.stream().filter(et -> !projectiles.contains(et) && !living.contains(et)))); - put("minecarts", new EntityClassDescriptor(null, (e) -> (e instanceof AbstractMinecartEntity && e.isAlive()), allTypes.stream().filter(minecarts::contains))); - put("!minecarts", new EntityClassDescriptor(null, (e) -> (!(e instanceof AbstractMinecartEntity) && e.isAlive()), allTypes.stream().filter(et -> !minecarts.contains(et) && !living.contains(et)))); + put("minecarts", new EntityClassDescriptor(class_5575.method_31795(AbstractMinecartEntity.class), EntityPredicates.VALID_ENTITY, allTypes.stream().filter(minecarts::contains))); + put("!minecarts", new EntityClassDescriptor(class_5575.method_31795(Entity.class), (e) -> (!(e instanceof AbstractMinecartEntity) && e.isAlive()), allTypes.stream().filter(et -> !minecarts.contains(et) && !living.contains(et)))); // combat groups - put("arthropod", new EntityClassDescriptor(null, e -> ((e instanceof LivingEntity) && ((LivingEntity) e).getGroup() == EntityGroup.ARTHROPOD && e.isAlive()), allTypes.stream().filter(arthropods::contains))); - put("!arthropod", new EntityClassDescriptor(null, e -> ((e instanceof LivingEntity) && ((LivingEntity) e).getGroup() != EntityGroup.ARTHROPOD && e.isAlive()), allTypes.stream().filter(et -> !arthropods.contains(et) && living.contains(et)))); + put("arthropod", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() == EntityGroup.ARTHROPOD && e.isAlive()), allTypes.stream().filter(arthropods::contains))); + put("!arthropod", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() != EntityGroup.ARTHROPOD && e.isAlive()), allTypes.stream().filter(et -> !arthropods.contains(et) && living.contains(et)))); - put("undead", new EntityClassDescriptor(null, e -> ((e instanceof LivingEntity) && ((LivingEntity) e).getGroup() == EntityGroup.UNDEAD && e.isAlive()), allTypes.stream().filter(undeads::contains))); - put("!undead", new EntityClassDescriptor(null, e -> ((e instanceof LivingEntity) && ((LivingEntity) e).getGroup() != EntityGroup.UNDEAD && e.isAlive()), allTypes.stream().filter(et -> !undeads.contains(et) && living.contains(et)))); + put("undead", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() == EntityGroup.UNDEAD && e.isAlive()), allTypes.stream().filter(undeads::contains))); + put("!undead", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() != EntityGroup.UNDEAD && e.isAlive()), allTypes.stream().filter(et -> !undeads.contains(et) && living.contains(et)))); - put("aquatic", new EntityClassDescriptor(null, e -> ((e instanceof LivingEntity) && ((LivingEntity) e).getGroup() == EntityGroup.AQUATIC && e.isAlive()), allTypes.stream().filter(aquatique::contains))); - put("!aquatic", new EntityClassDescriptor(null, e -> ((e instanceof LivingEntity) && ((LivingEntity) e).getGroup() != EntityGroup.AQUATIC && e.isAlive()), allTypes.stream().filter(et -> !aquatique.contains(et) && living.contains(et)))); + put("aquatic", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() == EntityGroup.AQUATIC && e.isAlive()), allTypes.stream().filter(aquatique::contains))); + put("!aquatic", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() != EntityGroup.AQUATIC && e.isAlive()), allTypes.stream().filter(et -> !aquatique.contains(et) && living.contains(et)))); - put("illager", new EntityClassDescriptor(null, e -> ((e instanceof LivingEntity) && ((LivingEntity) e).getGroup() == EntityGroup.ILLAGER && e.isAlive()), allTypes.stream().filter(illagers::contains))); - put("!illager", new EntityClassDescriptor(null, e -> ((e instanceof LivingEntity) && ((LivingEntity) e).getGroup() != EntityGroup.ILLAGER && e.isAlive()), allTypes.stream().filter(et -> !illagers.contains(et) && living.contains(et)))); + put("illager", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() == EntityGroup.ILLAGER && e.isAlive()), allTypes.stream().filter(illagers::contains))); + put("!illager", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() != EntityGroup.ILLAGER && e.isAlive()), allTypes.stream().filter(et -> !illagers.contains(et) && living.contains(et)))); - put("regular", new EntityClassDescriptor(null, e -> ((e instanceof LivingEntity) && ((LivingEntity) e).getGroup() == EntityGroup.DEFAULT && e.isAlive()), allTypes.stream().filter(regular::contains))); - put("!regular", new EntityClassDescriptor(null, e -> ((e instanceof LivingEntity) && ((LivingEntity) e).getGroup() != EntityGroup.DEFAULT && e.isAlive()), allTypes.stream().filter(et -> !regular.contains(et) && living.contains(et)))); + put("regular", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() == EntityGroup.DEFAULT && e.isAlive()), allTypes.stream().filter(regular::contains))); + put("!regular", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() != EntityGroup.DEFAULT && e.isAlive()), allTypes.stream().filter(et -> !regular.contains(et) && living.contains(et)))); for (Identifier typeId : Registry.ENTITY_TYPE.getIds()) { EntityType type = Registry.ENTITY_TYPE.get(typeId); String mobType = ValueConversions.simplify(typeId); put( mobType, new EntityClassDescriptor(type, EntityPredicates.VALID_ENTITY, Stream.of(type))); - put("!"+mobType, new EntityClassDescriptor(null, (e) -> e.getType() != type && e.isAlive(), allTypes.stream().filter(et -> et != type))); + put("!"+mobType, new EntityClassDescriptor(class_5575.method_31795(Entity.class), (e) -> e.getType() != type && e.isAlive(), allTypes.stream().filter(et -> et != type))); } for (SpawnGroup catId : SpawnGroup.values()) { String catStr = catId.getName(); - put( catStr, new EntityClassDescriptor(null, e -> ((e.getType().getSpawnGroup() == catId) && e.isAlive()), allTypes.stream().filter(et -> et.getSpawnGroup() == catId))); - put("!"+catStr, new EntityClassDescriptor(null, e -> ((e.getType().getSpawnGroup() != catId) && e.isAlive()), allTypes.stream().filter(et -> et.getSpawnGroup() != catId))); + put( catStr, new EntityClassDescriptor(class_5575.method_31795(Entity.class), e -> ((e.getType().getSpawnGroup() == catId) && e.isAlive()), allTypes.stream().filter(et -> et.getSpawnGroup() == catId))); + put("!"+catStr, new EntityClassDescriptor(class_5575.method_31795(Entity.class), e -> ((e.getType().getSpawnGroup() != catId) && e.isAlive()), allTypes.stream().filter(et -> et.getSpawnGroup() != catId))); } }}; } From ecca8d44f1ac79396c34ea6ddc68fa84db208d64 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 15 Nov 2020 23:10:12 -0400 Subject: [PATCH 008/115] temp fix --- src/main/java/carpet/CarpetSettings.java | 4 +++ .../mixins/ExperienceOrbEntityMixin.java | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 7bf32edf..b513fbea 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -155,6 +155,10 @@ public class CarpetSettings @Rule( desc = "Players absorb XP instantly, without delay", category = CREATIVE ) public static boolean xpNoCooldown = false; + @Rule( desc = "xpfix", category = SURVIVAL ) + public static boolean xpfix = false; + + @Rule( desc = "XP orbs combine with other into bigger orbs", category = FEATURE ) public static boolean combineXPOrbs = false; diff --git a/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java b/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java index 80c453b2..3e3df2d8 100644 --- a/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java +++ b/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java @@ -3,14 +3,19 @@ package carpet.mixins; import carpet.CarpetSettings; import carpet.fakes.ExperienceOrbInterface; import carpet.helpers.XPcombine; +import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.ExperienceOrbEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; 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; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.Map; @Mixin(ExperienceOrbEntity.class) public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface @@ -19,6 +24,10 @@ public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface @Shadow private int field_27009; + @Shadow protected abstract int getMendingRepairCost(int repairAmount); + + @Shadow protected abstract int getMendingRepairAmount(int experienceAmount); + public void setAmount(int amount) { this.amount = amount; } public int combineDelay = 50; @@ -76,4 +85,21 @@ public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface } } + // temporary until gets fixed game-side + @Inject(method = "onPlayerCollision", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, at = @At( + value = "INVOKE", + target = "Lnet/minecraft/entity/ExperienceOrbEntity;getMendingRepairAmount(I)I" + )) + void cancelApplication(PlayerEntity player, CallbackInfo ci, Map.Entry entry, ItemStack itemStack) + { + if (CarpetSettings.xpfix && field_27009 > 1) + { + int i = Math.min(getMendingRepairAmount(this.amount), itemStack.getDamage()); + field_27009--; + itemStack.setDamage(itemStack.getDamage() - i); + // cancel effects of mending application + ci.cancel(); + } + } + } From a5dd6ed1c29951d152242d9af5ad7c3a6b8d23c3 Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 17 Nov 2020 08:41:16 -0400 Subject: [PATCH 009/115] mappings --- gradle.properties | 4 ++-- src/main/java/carpet/script/api/Scoreboards.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index 1cfbcf0f..d7e4e95d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,8 +5,8 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=20w46a - yarn_mappings=20w46a+build.11 - loader_version=0.10.7 + yarn_mappings=20w46a+build.15 + loader_version=0.10.8 # Mod Properties mod_version = 1.4.17+v201111 diff --git a/src/main/java/carpet/script/api/Scoreboards.java b/src/main/java/carpet/script/api/Scoreboards.java index 748d1124..009df20e 100644 --- a/src/main/java/carpet/script/api/Scoreboards.java +++ b/src/main/java/carpet/script/api/Scoreboards.java @@ -113,7 +113,7 @@ public class Scoreboards { else { String critetionName = lv.get(1).evalValue(c).getString(); - criterion = ScoreboardCriterion.createStatCriterion(critetionName).orElse(null); + criterion = ScoreboardCriterion.getOrCreateStatCriterion(critetionName).orElse(null); if (criterion==null) { throw new InternalExpressionException("Unknown scoreboard criterion: "+critetionName); @@ -124,7 +124,7 @@ public class Scoreboards { if (objective != null) return LazyValue.FALSE; - scoreboard.addObjective(objectiveName, criterion, new LiteralText(objectiveName), criterion.getCriterionType()); + scoreboard.addObjective(objectiveName, criterion, new LiteralText(objectiveName), criterion.getDefaultRenderType()); return LazyValue.TRUE; }); From 23c730686ca22a2b1c51d0d0dca9271925914b42 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 18 Nov 2020 16:28:13 -0400 Subject: [PATCH 010/115] added xpstack to 1.17 --- src/main/resources/assets/carpet/scripts/ai_tracker.sc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/carpet/scripts/ai_tracker.sc b/src/main/resources/assets/carpet/scripts/ai_tracker.sc index 4e7e9fd0..737aacf9 100644 --- a/src/main/resources/assets/carpet/scripts/ai_tracker.sc +++ b/src/main/resources/assets/carpet/scripts/ai_tracker.sc @@ -49,7 +49,7 @@ villager_buddy_detection() -> __toggle('villager_buddy_detection', null); item_pickup() -> __toggle('item_pickup', null); portal_cooldown() -> __toggle('portal_cooldown', null); health() -> __toggle('health', null); -//xpstack() -> __toggle('xpstack', null); //1.17 feature +xpstack() -> __toggle('xpstack', null); //1.17 feature toggle_boxes() -> ( From 54d9c2a8eee675eeb9e22ea71ca906445a104f17 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sat, 21 Nov 2020 06:33:35 -0400 Subject: [PATCH 011/115] compacting --- src/main/resources/assets/carpet/scripts/ai_tracker.sc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/resources/assets/carpet/scripts/ai_tracker.sc b/src/main/resources/assets/carpet/scripts/ai_tracker.sc index 737aacf9..c1985ecb 100644 --- a/src/main/resources/assets/carpet/scripts/ai_tracker.sc +++ b/src/main/resources/assets/carpet/scripts/ai_tracker.sc @@ -371,10 +371,7 @@ global_functions = { _(arg) -> _(orb) -> ( tag = query(orb, 'nbt'); ct = tag:'Count'; - [[], [], if (ct > 1, [ - //['value', 'size:', tag:'Value'], - ['stack', ct] - ],[]) ] + [[], [], if (ct > 1, [['stack', ct]],[]) ] ), , null From 5cd6c3965e709063dc25f4c0046a513f8db2390d Mon Sep 17 00:00:00 2001 From: gnembon Date: Sat, 21 Nov 2020 06:40:22 -0400 Subject: [PATCH 012/115] mappings --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index d7e4e95d..4b5ae75c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=20w46a - yarn_mappings=20w46a+build.15 + yarn_mappings=20w46a+build.20 loader_version=0.10.8 # Mod Properties From 3aee1a7f7fdd3ee69139d37e5da2eef0b48a10f9 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 25 Nov 2020 19:21:56 -0400 Subject: [PATCH 013/115] 20w48a --- gradle.properties | 4 ++-- .../carpet/mixins/ServerPlayerEntityMixin.java | 1 - .../java/carpet/patches/EntityPlayerMPFake.java | 14 ++++++-------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/gradle.properties b/gradle.properties index ccf0db54..c28a4a43 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=20w46a - yarn_mappings=20w46a+build.20 + minecraft_version=20w48a + yarn_mappings=20w48a+build.1 loader_version=0.10.8 # Mod Properties diff --git a/src/main/java/carpet/mixins/ServerPlayerEntityMixin.java b/src/main/java/carpet/mixins/ServerPlayerEntityMixin.java index 88fe4345..f29428da 100644 --- a/src/main/java/carpet/mixins/ServerPlayerEntityMixin.java +++ b/src/main/java/carpet/mixins/ServerPlayerEntityMixin.java @@ -26,7 +26,6 @@ public abstract class ServerPlayerEntityMixin implements ServerPlayerEntityInter MinecraftServer minecraftServer_1, ServerWorld serverWorld_1, GameProfile gameProfile_1, - ServerPlayerInteractionManager serverPlayerInteractionManager_1, CallbackInfo ci) { this.actionPack = new EntityPlayerActionPack((ServerPlayerEntity) (Object) this); diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index 7c74c024..82c29d17 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -32,7 +32,6 @@ public class EntityPlayerMPFake extends ServerPlayerEntity { //prolly half of that crap is not necessary, but it works ServerWorld worldIn = server.getWorld(dimensionId); - ServerPlayerInteractionManager interactionManagerIn = new ServerPlayerInteractionManager(worldIn); GameProfile gameprofile = server.getUserCache().findByName(username); if (gameprofile == null) { @@ -42,14 +41,14 @@ public class EntityPlayerMPFake extends ServerPlayerEntity { gameprofile = SkullBlockEntity.loadProperties(gameprofile); } - EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, gameprofile, interactionManagerIn, false); + EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, gameprofile, false); instance.fixStartingPosition = () -> instance.refreshPositionAndAngles(d0, d1, d2, (float) yaw, (float) pitch); server.getPlayerManager().onPlayerConnect(new NetworkManagerFake(NetworkSide.SERVERBOUND), instance); instance.teleport(worldIn, d0, d1, d2, (float)yaw, (float)pitch); instance.setHealth(20.0F); instance.unsetRemoved(); instance.stepHeight = 0.6F; - interactionManagerIn.setGameMode(gamemode); + instance.interactionManager.setGameMode(gamemode); server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(instance, (byte) (instance.headYaw * 256 / 360)), dimensionId);//instance.dimension); server.getPlayerManager().sendToDimension(new EntityPositionS2CPacket(instance), dimensionId);//instance.dimension); instance.getServerWorld().getChunkManager().updateCameraPosition(instance); @@ -62,14 +61,13 @@ public class EntityPlayerMPFake extends ServerPlayerEntity player.getServer().getPlayerManager().remove(player); player.networkHandler.disconnect(new TranslatableText("multiplayer.disconnect.duplicate_login")); ServerWorld worldIn = player.getServerWorld();//.getWorld(player.dimension); - ServerPlayerInteractionManager interactionManagerIn = new ServerPlayerInteractionManager(worldIn); GameProfile gameprofile = player.getGameProfile(); - EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, interactionManagerIn, true); + EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, true); server.getPlayerManager().onPlayerConnect(new NetworkManagerFake(NetworkSide.SERVERBOUND), playerShadow); playerShadow.setHealth(player.getHealth()); playerShadow.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.yaw, player.pitch); - interactionManagerIn.setGameMode(player.interactionManager.getGameMode()); + playerShadow.interactionManager.setGameMode(player.interactionManager.getGameMode()); ((ServerPlayerEntityInterface) playerShadow).getActionPack().copyFrom(((ServerPlayerEntityInterface) player).getActionPack()); playerShadow.stepHeight = 0.6F; playerShadow.dataTracker.set(PLAYER_MODEL_PARTS, player.getDataTracker().get(PLAYER_MODEL_PARTS)); @@ -81,9 +79,9 @@ public class EntityPlayerMPFake extends ServerPlayerEntity return playerShadow; } - private EntityPlayerMPFake(MinecraftServer server, ServerWorld worldIn, GameProfile profile, ServerPlayerInteractionManager interactionManagerIn, boolean shadow) + private EntityPlayerMPFake(MinecraftServer server, ServerWorld worldIn, GameProfile profile, boolean shadow) { - super(server, worldIn, profile, interactionManagerIn); + super(server, worldIn, profile); isAShadow = shadow; } From 42b7af97f504a4f4aaf016aa80d25925ecbbb787 Mon Sep 17 00:00:00 2001 From: gnembon Date: Thu, 26 Nov 2020 03:06:03 -0400 Subject: [PATCH 014/115] udpate --- src/main/java/carpet/script/value/NBTSerializableValue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/script/value/NBTSerializableValue.java b/src/main/java/carpet/script/value/NBTSerializableValue.java index f6be3d11..9471b7f3 100644 --- a/src/main/java/carpet/script/value/NBTSerializableValue.java +++ b/src/main/java/carpet/script/value/NBTSerializableValue.java @@ -210,7 +210,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa return new InventoryLocator( player, player.getBlockPos(), - isEnder ? player.getEnderChestInventory() : player.inventory, + isEnder ? player.getEnderChestInventory() : player.getInventory(), offset + 1, isEnder ); From 685c156f1c801d649bf39c2f9dba535582ffdbce Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 29 Nov 2020 02:31:13 -0400 Subject: [PATCH 015/115] fixed diagonal light propagations. --- .../mixins/SkyLightStorage_scarpetChunkCreationMixin.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/carpet/mixins/SkyLightStorage_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/SkyLightStorage_scarpetChunkCreationMixin.java index bf6bdc07..e3c5788c 100644 --- a/src/main/java/carpet/mixins/SkyLightStorage_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/SkyLightStorage_scarpetChunkCreationMixin.java @@ -94,8 +94,9 @@ public abstract class SkyLightStorage_scarpetChunkCreationMixin extends LightSto final long dst = BlockPos.add(pos, ox + t * dx, dy, oz + t * dz); long src = BlockPos.offset(dst, dir); - if (neighborLightArray == null) - src = BlockPos.asLong(BlockPos.unpackLongX(src), ChunkSectionPos.getBlockCoord(ChunkSectionPos.unpackY(neighborCeilingSectionPos)), BlockPos.unpackLongZ(src)); + // fixed due to https://bugs.mojang.com/browse/MC-196542 so keeping the direction + //if (neighborLightArray == null) + // src = BlockPos.asLong(BlockPos.unpackLongX(src), ChunkSectionPos.getBlockCoord(ChunkSectionPos.unpackY(neighborCeilingSectionPos)), BlockPos.unpackLongZ(src)); final int srcLevel = neighborCeilingLightArray != null ? ((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborCeilingLightArray, src) From f95838d6311eca0b675eb0140e5c8c4743b6b6dc Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 29 Nov 2020 02:50:17 -0400 Subject: [PATCH 016/115] optimizations --- ...ightStorage_scarpetChunkCreationMixin.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/carpet/mixins/SkyLightStorage_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/SkyLightStorage_scarpetChunkCreationMixin.java index e3c5788c..cf4d0543 100644 --- a/src/main/java/carpet/mixins/SkyLightStorage_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/SkyLightStorage_scarpetChunkCreationMixin.java @@ -88,19 +88,26 @@ public abstract class SkyLightStorage_scarpetChunkCreationMixin extends LightSto final int dx = Math.abs(dir.getOffsetZ()); final int dz = Math.abs(dir.getOffsetX()); + int emptyLightLevel = (neighborCeilingLightArray == null) + ? (this.isSectionEnabled(ChunkSectionPos.withZeroY(neighborCeilingSectionPos)) ? 0 : 15) + : 0; + int neighbourY = (neighborLightArray == null) + ? ChunkSectionPos.getBlockCoord(ChunkSectionPos.unpackY(neighborCeilingSectionPos)) + : 0; + for (int t = 0; t < 16; ++t) for (int dy = 0; dy < 16; ++dy) { final long dst = BlockPos.add(pos, ox + t * dx, dy, oz + t * dz); long src = BlockPos.offset(dst, dir); - // fixed due to https://bugs.mojang.com/browse/MC-196542 so keeping the direction - //if (neighborLightArray == null) - // src = BlockPos.asLong(BlockPos.unpackLongX(src), ChunkSectionPos.getBlockCoord(ChunkSectionPos.unpackY(neighborCeilingSectionPos)), BlockPos.unpackLongZ(src)); + long adj_src = (neighborLightArray != null) + ? src + : BlockPos.asLong(BlockPos.unpackLongX(src), neighbourY, BlockPos.unpackLongZ(src)); - final int srcLevel = neighborCeilingLightArray != null ? - ((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborCeilingLightArray, src) - : this.isSectionEnabled(ChunkSectionPos.withZeroY(neighborCeilingSectionPos)) ? 0 : 15; + final int srcLevel = neighborCeilingLightArray != null + ? ((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborCeilingLightArray, adj_src) + : emptyLightLevel; levelPropagator.cmInvokeUpdateLevel(src, dst, levelPropagator.cmCallGetPropagatedLevel(src, dst, srcLevel), true); } From 62ee3a17c953022698fc8d5ddb9c4a8adf8d5023 Mon Sep 17 00:00:00 2001 From: gnembon Date: Mon, 30 Nov 2020 09:38:43 -0400 Subject: [PATCH 017/115] mappings --- gradle.properties | 2 +- .../carpet/mixins/ExperienceOrbEntityMixin.java | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gradle.properties b/gradle.properties index c28a4a43..6a6f35ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=20w48a - yarn_mappings=20w48a+build.1 + yarn_mappings=20w48a+build.7 loader_version=0.10.8 # Mod Properties diff --git a/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java b/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java index 3e3df2d8..e07d3d49 100644 --- a/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java +++ b/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java @@ -22,7 +22,7 @@ public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface { @Shadow private int amount; - @Shadow private int field_27009; + @Shadow private int pickingCount; @Shadow protected abstract int getMendingRepairCost(int repairAmount); @@ -59,12 +59,12 @@ public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface @Override public int getCount() { - return field_27009; + return pickingCount; } @Override public void setCount(int i) { - field_27009 = i; + pickingCount = i; } @Inject(method = "onPlayerCollision", at = @At("HEAD")) @@ -78,9 +78,9 @@ public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface void addXP(PlayerEntity playerEntity, int experience) { playerEntity.addExperience(experience); - if (CarpetSettings.xpNoCooldown) while(field_27009 > 1) + if (CarpetSettings.xpNoCooldown) while(pickingCount > 1) { - field_27009 --; + pickingCount --; playerEntity.addExperience(experience); } } @@ -92,10 +92,10 @@ public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface )) void cancelApplication(PlayerEntity player, CallbackInfo ci, Map.Entry entry, ItemStack itemStack) { - if (CarpetSettings.xpfix && field_27009 > 1) + if (CarpetSettings.xpfix && pickingCount > 1) { int i = Math.min(getMendingRepairAmount(this.amount), itemStack.getDamage()); - field_27009--; + pickingCount--; itemStack.setDamage(itemStack.getDamage() - i); // cancel effects of mending application ci.cancel(); From 5422493c330c370e9d6b5894d048ca2e12610e9d Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 2 Dec 2020 19:22:56 -0400 Subject: [PATCH 018/115] 20w49a --- gradle.properties | 4 ++-- .../java/carpet/helpers/EntityPlayerActionPack.java | 12 ++++++------ src/main/java/carpet/helpers/InventoryHelper.java | 4 ++-- .../carpet/mixins/BiomeArray_getBiomeArrayMixin.java | 8 ++++++-- .../StructureBlockBlockEntity_fillUpdatesMixin.java | 6 +++--- src/main/java/carpet/patches/EntityPlayerMPFake.java | 4 ++-- src/main/java/carpet/script/value/BlockValue.java | 2 +- src/main/java/carpet/script/value/EntityValue.java | 2 +- .../carpet/script/value/NBTSerializableValue.java | 2 +- 9 files changed, 24 insertions(+), 20 deletions(-) diff --git a/gradle.properties b/gradle.properties index 2400dd21..946fe691 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=20w48a - yarn_mappings=20w48a+build.7 + minecraft_version=20w49a + yarn_mappings=20w49a+build.1 loader_version=0.10.8 # Mod Properties diff --git a/src/main/java/carpet/helpers/EntityPlayerActionPack.java b/src/main/java/carpet/helpers/EntityPlayerActionPack.java index 3fa489a7..af934aba 100644 --- a/src/main/java/carpet/helpers/EntityPlayerActionPack.java +++ b/src/main/java/carpet/helpers/EntityPlayerActionPack.java @@ -305,7 +305,7 @@ public class EntityPlayerActionPack BlockHitResult blockHit = (BlockHitResult) hit; BlockPos pos = blockHit.getBlockPos(); Direction side = blockHit.getSide(); - if (pos.getY() < player.server.getWorldHeight() - (side == Direction.UP ? 1 : 0) && world.canPlayerModifyAt(player, pos)) + if (pos.getY() < player.getServerWorld().getTopHeightLimit() - (side == Direction.UP ? 1 : 0) && world.canPlayerModifyAt(player, pos)) { ActionResult result = player.interactionManager.interactBlock(player, world, player.getStackInHand(hand), hand, blockHit); if (result.isAccepted()) @@ -393,7 +393,7 @@ public class EntityPlayerActionPack boolean blockBroken = false; if (player.interactionManager.getGameMode().isCreative()) { - player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.server.getWorldHeight()); + player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getServerWorld().getTopHeightLimit()); ap.blockHitDelay = 5; blockBroken = true; } @@ -401,9 +401,9 @@ public class EntityPlayerActionPack { if (ap.currentBlock != null) { - player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, side, player.server.getWorldHeight()); + player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, side, player.getServerWorld().getTopHeightLimit()); } - player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.server.getWorldHeight()); + player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getServerWorld().getTopHeightLimit()); boolean notAir = !state.isAir(); if (notAir && ap.curBlockDamageMP == 0) { @@ -426,7 +426,7 @@ public class EntityPlayerActionPack ap.curBlockDamageMP += state.calcBlockBreakingDelta(player, player.world, pos); if (ap.curBlockDamageMP >= 1) { - player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, side, player.server.getWorldHeight()); + player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, side, player.getServerWorld().getTopHeightLimit()); ap.currentBlock = null; ap.blockHitDelay = 5; blockBroken = true; @@ -448,7 +448,7 @@ public class EntityPlayerActionPack EntityPlayerActionPack ap = ((ServerPlayerEntityInterface) player).getActionPack(); if (ap.currentBlock == null) return; player.world.setBlockBreakingInfo(-1, ap.currentBlock, -1); - player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.server.getWorldHeight()); + player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.getServerWorld().getTopHeightLimit()); ap.currentBlock = null; } }, diff --git a/src/main/java/carpet/helpers/InventoryHelper.java b/src/main/java/carpet/helpers/InventoryHelper.java index acc3c0f2..073408e7 100644 --- a/src/main/java/carpet/helpers/InventoryHelper.java +++ b/src/main/java/carpet/helpers/InventoryHelper.java @@ -35,12 +35,12 @@ public class InventoryHelper changed = true; } - if (bet.isEmpty()) + if (bet.method_33133()) // isEmpty { tag.remove("BlockEntityTag"); changed = true; } - if (tag.isEmpty()) + if (tag.method_33133()) { stack.setTag(null); changed = true; diff --git a/src/main/java/carpet/mixins/BiomeArray_getBiomeArrayMixin.java b/src/main/java/carpet/mixins/BiomeArray_getBiomeArrayMixin.java index 5f431cb3..9dac8e3d 100644 --- a/src/main/java/carpet/mixins/BiomeArray_getBiomeArrayMixin.java +++ b/src/main/java/carpet/mixins/BiomeArray_getBiomeArrayMixin.java @@ -18,15 +18,19 @@ public class BiomeArray_getBiomeArrayMixin implements BiomeArrayInterface @Shadow @Final public static int HORIZONTAL_BIT_MASK; - @Shadow @Final public static int VERTICAL_BIT_MASK; + //@Shadow @Final public static int VERTICAL_BIT_MASK; @Shadow @Final private Biome[] data; + @Shadow @Final private int field_28126; + + @Shadow @Final private int field_28127; + @Override public void setBiomeAtIndex(BlockPos pos, World world, Biome what) { int int_4 = (pos.getX() >> 2) & HORIZONTAL_BIT_MASK; - int int_5 = MathHelper.clamp((pos.getY() >> 2), 0, VERTICAL_BIT_MASK); + int int_5 = MathHelper.clamp((pos.getY() >> 2)-field_28126, 0, field_28127); int int_6 = (pos.getZ() >> 2) & HORIZONTAL_BIT_MASK; data[(int_5 << (HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT)) | (int_6 << HORIZONTAL_SECTION_COUNT) | int_4] = what; } diff --git a/src/main/java/carpet/mixins/StructureBlockBlockEntity_fillUpdatesMixin.java b/src/main/java/carpet/mixins/StructureBlockBlockEntity_fillUpdatesMixin.java index 541cdbc8..1bf98277 100644 --- a/src/main/java/carpet/mixins/StructureBlockBlockEntity_fillUpdatesMixin.java +++ b/src/main/java/carpet/mixins/StructureBlockBlockEntity_fillUpdatesMixin.java @@ -17,15 +17,15 @@ public abstract class StructureBlockBlockEntity_fillUpdatesMixin { @Redirect(method = "place", at = @At( value = "INVOKE", - target = "Lnet/minecraft/structure/Structure;place(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;)V" + target = "Lnet/minecraft/structure/Structure;place(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;I)Z" )) - private void onStructurePlacen(Structure structure, ServerWorldAccess serverWorldAccess, BlockPos pos, StructurePlacementData placementData, Random random) + private boolean onStructurePlacen(Structure structure, ServerWorldAccess serverWorldAccess, BlockPos pos, BlockPos blockPos, StructurePlacementData placementData, Random random, int i) { if(!CarpetSettings.fillUpdates) CarpetSettings.impendingFillSkipUpdates = true; try { - structure.place(serverWorldAccess, pos, placementData, random); + return structure.place(serverWorldAccess, pos, blockPos, placementData, random, i); // serverWorldAccess, pos, placementData, random); } finally { diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index 911a4234..4db233f6 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -48,7 +48,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity instance.setHealth(20.0F); instance.unsetRemoved(); instance.stepHeight = 0.6F; - instance.interactionManager.setGameMode(gamemode); + instance.interactionManager.changeGameMode(gamemode); server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(instance, (byte) (instance.headYaw * 256 / 360)), dimensionId);//instance.dimension); server.getPlayerManager().sendToDimension(new EntityPositionS2CPacket(instance), dimensionId);//instance.dimension); instance.getServerWorld().getChunkManager().updateCameraPosition(instance); @@ -67,7 +67,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity playerShadow.setHealth(player.getHealth()); playerShadow.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.yaw, player.pitch); - playerShadow.interactionManager.setGameMode(player.interactionManager.getGameMode()); + playerShadow.interactionManager.changeGameMode(player.interactionManager.getGameMode()); ((ServerPlayerEntityInterface) playerShadow).getActionPack().copyFrom(((ServerPlayerEntityInterface) player).getActionPack()); playerShadow.stepHeight = 0.6F; playerShadow.dataTracker.set(PLAYER_MODEL_PARTS, player.getDataTracker().get(PLAYER_MODEL_PARTS)); diff --git a/src/main/java/carpet/script/value/BlockValue.java b/src/main/java/carpet/script/value/BlockValue.java index e883f27f..1556fb36 100644 --- a/src/main/java/carpet/script/value/BlockValue.java +++ b/src/main/java/carpet/script/value/BlockValue.java @@ -108,7 +108,7 @@ public class BlockValue extends Value { if (data != null) { - if (data.isEmpty()) + if (data.method_33133()) return null; return data; } diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 2c513c8f..0d8c3dbc 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -1295,7 +1295,7 @@ public class EntityValue extends Value GameMode toSet = v instanceof NumericValue ? GameMode.byId(((NumericValue) v).getInt(), null) : GameMode.byName(v.getString().toLowerCase(Locale.ROOT), null); - if (toSet != null) ((ServerPlayerEntity) e).setGameMode(toSet); + if (toSet != null) ((ServerPlayerEntity) e).changeGameMode(toSet); }); put("jumping",(e,v)->{ diff --git a/src/main/java/carpet/script/value/NBTSerializableValue.java b/src/main/java/carpet/script/value/NBTSerializableValue.java index f8bc58e3..48fa8b71 100644 --- a/src/main/java/carpet/script/value/NBTSerializableValue.java +++ b/src/main/java/carpet/script/value/NBTSerializableValue.java @@ -392,7 +392,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa { Tag tag = getTag(); if (tag instanceof CompoundTag) - return !((CompoundTag) tag).isEmpty(); + return !((CompoundTag) tag).method_33133(); if (tag instanceof AbstractListTag) return ((AbstractListTag) tag).isEmpty(); if (tag instanceof AbstractNumberTag) From 56313ae74fe6b2b9c4cee51eaf07e923742c5863 Mon Sep 17 00:00:00 2001 From: gnembon Date: Thu, 3 Dec 2020 22:02:01 -0400 Subject: [PATCH 019/115] using more standard approach to what mojang is using. JIT should inline that anyways. not broken, but closes / fixes #604 --- .../java/carpet/mixins/BiomeArray_getBiomeArrayMixin.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/carpet/mixins/BiomeArray_getBiomeArrayMixin.java b/src/main/java/carpet/mixins/BiomeArray_getBiomeArrayMixin.java index 9dac8e3d..f0acfa6b 100644 --- a/src/main/java/carpet/mixins/BiomeArray_getBiomeArrayMixin.java +++ b/src/main/java/carpet/mixins/BiomeArray_getBiomeArrayMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.fakes.BiomeArrayInterface; +import net.minecraft.class_5742; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; @@ -29,9 +30,9 @@ public class BiomeArray_getBiomeArrayMixin implements BiomeArrayInterface @Override public void setBiomeAtIndex(BlockPos pos, World world, Biome what) { - int int_4 = (pos.getX() >> 2) & HORIZONTAL_BIT_MASK; - int int_5 = MathHelper.clamp((pos.getY() >> 2)-field_28126, 0, field_28127); - int int_6 = (pos.getZ() >> 2) & HORIZONTAL_BIT_MASK; + int int_4 = class_5742.method_33100(pos.getX()) & HORIZONTAL_BIT_MASK; + int int_5 = MathHelper.clamp(class_5742.method_33100(pos.getY())-field_28126, 0, field_28127); + int int_6 = class_5742.method_33100(pos.getZ()) & HORIZONTAL_BIT_MASK; data[(int_5 << (HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT)) | (int_6 << HORIZONTAL_SECTION_COUNT) | int_4] = what; } } From d58039936890aec40dac3ed449eafc18b9e55012 Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 4 Dec 2020 00:40:02 -0400 Subject: [PATCH 020/115] fix --- src/main/java/carpet/helpers/EntityPlayerActionPack.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/helpers/EntityPlayerActionPack.java b/src/main/java/carpet/helpers/EntityPlayerActionPack.java index e1616b54..7c242e09 100644 --- a/src/main/java/carpet/helpers/EntityPlayerActionPack.java +++ b/src/main/java/carpet/helpers/EntityPlayerActionPack.java @@ -279,7 +279,7 @@ public class EntityPlayerActionPack public void setSlot(int slot) { - player.inventory.selectedSlot = slot-1; + player.getInventory().selectedSlot = slot-1; player.networkHandler.sendPacket(new HeldItemChangeS2CPacket(slot-1)); } From 7ecef187d4cf3bfd884067244586a1498c694d37 Mon Sep 17 00:00:00 2001 From: gnembon Date: Mon, 7 Dec 2020 01:22:12 -0400 Subject: [PATCH 021/115] fix --- src/main/java/carpet/script/api/Inventories.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/script/api/Inventories.java b/src/main/java/carpet/script/api/Inventories.java index fb4983ae..40dfa2e3 100644 --- a/src/main/java/carpet/script/api/Inventories.java +++ b/src/main/java/carpet/script/api/Inventories.java @@ -97,7 +97,7 @@ public class Inventories { String tag = lv.get(1).evalValue(c).getString(); net.minecraft.tag.Tag itemTag = tagManager.getItems().getTag(new Identifier(tag)); if (itemTag == null) return LazyValue.NULL; - return item.isIn(itemTag)?LazyValue.TRUE:LazyValue.FALSE; + return itemTag.contains(item)?LazyValue.TRUE:LazyValue.FALSE; }); expression.addLazyFunction("recipe_data", -1, (c, t, lv) -> From 00ad9eccc744c6ec143a8e183a25258bab2dc72e Mon Sep 17 00:00:00 2001 From: gnembon Date: Mon, 14 Dec 2020 02:51:01 -0400 Subject: [PATCH 022/115] mappings --- gradle.properties | 2 +- src/main/java/carpet/helpers/InventoryHelper.java | 4 ++-- src/main/java/carpet/mixins/ContainerMixin.java | 2 +- src/main/java/carpet/script/value/BlockValue.java | 2 +- src/main/java/carpet/script/value/NBTSerializableValue.java | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index 946fe691..e90ca8d1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=20w49a - yarn_mappings=20w49a+build.1 + yarn_mappings=20w49a+build.8 loader_version=0.10.8 # Mod Properties diff --git a/src/main/java/carpet/helpers/InventoryHelper.java b/src/main/java/carpet/helpers/InventoryHelper.java index 073408e7..acc3c0f2 100644 --- a/src/main/java/carpet/helpers/InventoryHelper.java +++ b/src/main/java/carpet/helpers/InventoryHelper.java @@ -35,12 +35,12 @@ public class InventoryHelper changed = true; } - if (bet.method_33133()) // isEmpty + if (bet.isEmpty()) { tag.remove("BlockEntityTag"); changed = true; } - if (tag.method_33133()) + if (tag.isEmpty()) { stack.setTag(null); changed = true; diff --git a/src/main/java/carpet/mixins/ContainerMixin.java b/src/main/java/carpet/mixins/ContainerMixin.java index 485128ad..0b3125c0 100644 --- a/src/main/java/carpet/mixins/ContainerMixin.java +++ b/src/main/java/carpet/mixins/ContainerMixin.java @@ -27,7 +27,7 @@ public abstract class ContainerMixin @Shadow @Final public DefaultedList slots; - @Inject( method = "method_30010", at = @At(value = "HEAD"), cancellable = true) // on slot click + @Inject( method = "removeStack", at = @At(value = "HEAD"), cancellable = true) private void onThrowClick( int slotId, int clickData, SlotActionType actionType, PlayerEntity playerEntity, CallbackInfoReturnable cir) { if (actionType == SlotActionType.THROW && CarpetSettings.ctrlQCraftingFix && playerEntity.getInventory().getCursorStack().isEmpty() && slotId >= 0) diff --git a/src/main/java/carpet/script/value/BlockValue.java b/src/main/java/carpet/script/value/BlockValue.java index 1556fb36..e883f27f 100644 --- a/src/main/java/carpet/script/value/BlockValue.java +++ b/src/main/java/carpet/script/value/BlockValue.java @@ -108,7 +108,7 @@ public class BlockValue extends Value { if (data != null) { - if (data.method_33133()) + if (data.isEmpty()) return null; return data; } diff --git a/src/main/java/carpet/script/value/NBTSerializableValue.java b/src/main/java/carpet/script/value/NBTSerializableValue.java index 2f6e41bd..4b9dce80 100644 --- a/src/main/java/carpet/script/value/NBTSerializableValue.java +++ b/src/main/java/carpet/script/value/NBTSerializableValue.java @@ -392,7 +392,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa { Tag tag = getTag(); if (tag instanceof CompoundTag) - return !((CompoundTag) tag).method_33133(); + return !((CompoundTag) tag).isEmpty(); if (tag instanceof AbstractListTag) return ((AbstractListTag) tag).isEmpty(); if (tag instanceof AbstractNumberTag) From 32d0ba96944e00495e68a67750c8f0a49e694f9b Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 16 Dec 2020 19:06:09 -0400 Subject: [PATCH 023/115] 20w51a --- gradle.properties | 4 ++-- src/main/java/carpet/CarpetSettings.java | 4 ++-- .../carpet/mixins/ServerWorld_onePlayerSleepingMixin.java | 4 ++-- src/main/java/carpet/script/api/Inventories.java | 8 ++++---- src/main/java/carpet/script/api/WorldAccess.java | 8 ++++---- src/main/java/carpet/script/utils/WorldTools.java | 2 +- src/main/java/carpet/script/value/EntityValue.java | 6 +++--- src/main/java/carpet/script/value/ValueConversions.java | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gradle.properties b/gradle.properties index 27470602..ed329661 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=20w49a - yarn_mappings=20w49a+build.8 + minecraft_version=20w51a + yarn_mappings=20w51a+build.1 loader_version=0.10.8 # Mod Properties diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index fc374572..2e608ef1 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -538,8 +538,8 @@ public class CarpetSettings public static boolean waterFlow = true; */ - @Rule(desc = "One player is required on the server to cause night to pass", category = SURVIVAL) - public static boolean onePlayerSleeping = false; + //@Rule(desc = "One player is required on the server to cause night to pass", category = SURVIVAL) + //public static boolean onePlayerSleeping = false; @Rule( desc = "Sets a different motd message on client trying to connect to the server", diff --git a/src/main/java/carpet/mixins/ServerWorld_onePlayerSleepingMixin.java b/src/main/java/carpet/mixins/ServerWorld_onePlayerSleepingMixin.java index 32f8a630..6d2d6fab 100644 --- a/src/main/java/carpet/mixins/ServerWorld_onePlayerSleepingMixin.java +++ b/src/main/java/carpet/mixins/ServerWorld_onePlayerSleepingMixin.java @@ -17,7 +17,7 @@ import java.util.stream.Stream; @Mixin(ServerWorld.class) public class ServerWorld_onePlayerSleepingMixin -{ +{/* removed due to 1.17 changes @Shadow @Final private List players; @Shadow private boolean allPlayersSleeping; @@ -49,5 +49,5 @@ public class ServerWorld_onePlayerSleepingMixin return stream.anyMatch((p) -> !p.isSpectator() && p.isSleepingLongEnough()); return stream.noneMatch(predicate); } - +*/ } diff --git a/src/main/java/carpet/script/api/Inventories.java b/src/main/java/carpet/script/api/Inventories.java index 40dfa2e3..0548101f 100644 --- a/src/main/java/carpet/script/api/Inventories.java +++ b/src/main/java/carpet/script/api/Inventories.java @@ -73,7 +73,7 @@ public class Inventories { CarpetContext cc = (CarpetContext)c; TagManager tagManager = cc.s.getMinecraftServer().getTagManager(); String tag = lv.get(0).evalValue(c).getString(); - net.minecraft.tag.Tag itemTag = tagManager.getItems().getTag(new Identifier(tag)); + net.minecraft.tag.Tag itemTag = tagManager.method_33164(Registry.ITEM_KEY).getTag(new Identifier(tag)); if (itemTag == null) return LazyValue.NULL; Value ret = ListValue.wrap(itemTag.values().stream().map(b -> ValueConversions.of(Registry.ITEM.getId(b))).collect(Collectors.toList())); return (_c, _t) -> ret; @@ -85,17 +85,17 @@ public class Inventories { TagManager tagManager = cc.s.getMinecraftServer().getTagManager(); if (lv.size() == 0) { - Value ret = ListValue.wrap(tagManager.getItems().getTagIds().stream().map(ValueConversions::of).collect(Collectors.toList())); + Value ret = ListValue.wrap(tagManager.method_33164(Registry.ITEM_KEY).getTagIds().stream().map(ValueConversions::of).collect(Collectors.toList())); return (_c, _t) -> ret; } Item item = NBTSerializableValue.parseItem(lv.get(0).evalValue(c).getString()).getItem(); if (lv.size() == 1) { - Value ret = ListValue.wrap(tagManager.getItems().getTagsFor(item).stream().map(ValueConversions::of).collect(Collectors.toList())); + Value ret = ListValue.wrap(tagManager.method_33164(Registry.ITEM_KEY).getTagsFor(item).stream().map(ValueConversions::of).collect(Collectors.toList())); return (_c, _t) -> ret; } String tag = lv.get(1).evalValue(c).getString(); - net.minecraft.tag.Tag itemTag = tagManager.getItems().getTag(new Identifier(tag)); + net.minecraft.tag.Tag itemTag = tagManager.method_33164(Registry.ITEM_KEY).getTag(new Identifier(tag)); if (itemTag == null) return LazyValue.NULL; return itemTag.contains(item)?LazyValue.TRUE:LazyValue.FALSE; }); diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index ac558afb..c72b47b0 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -1109,7 +1109,7 @@ public class WorldAccess { CarpetContext cc = (CarpetContext)c; TagManager tagManager = cc.s.getMinecraftServer().getTagManager(); String tag = lv.get(0).evalValue(c).getString(); - net.minecraft.tag.Tag blockTag = tagManager.getBlocks().getTag(new Identifier(tag)); + net.minecraft.tag.Tag blockTag = tagManager.method_33164(Registry.BLOCK_KEY).getTag(new Identifier(tag)); if (blockTag == null) return LazyValue.NULL; Value ret = ListValue.wrap(blockTag.values().stream().map(b -> ValueConversions.of(Registry.BLOCK.getId(b))).collect(Collectors.toList())); return (_c, _t) -> ret; @@ -1121,17 +1121,17 @@ public class WorldAccess { TagManager tagManager = cc.s.getMinecraftServer().getTagManager(); if (lv.size() == 0) { - Value ret = ListValue.wrap(tagManager.getBlocks().getTagIds().stream().map(ValueConversions::of).collect(Collectors.toList())); + Value ret = ListValue.wrap(tagManager.method_33164(Registry.BLOCK_KEY).getTagIds().stream().map(ValueConversions::of).collect(Collectors.toList())); return (_c, _t) -> ret; } BlockArgument blockLocator = BlockArgument.findIn(cc, lv, 0, true); if (blockLocator.offset == lv.size()) { - Value ret = ListValue.wrap(tagManager.getBlocks().getTagsFor(blockLocator.block.getBlockState().getBlock()).stream().map(ValueConversions::of).collect(Collectors.toList())); + Value ret = ListValue.wrap(tagManager.method_33164(Registry.BLOCK_KEY).getTagsFor(blockLocator.block.getBlockState().getBlock()).stream().map(ValueConversions::of).collect(Collectors.toList())); return (_c, _t) -> ret; } String tag = lv.get(blockLocator.offset).evalValue(c).getString(); - net.minecraft.tag.Tag blockTag = tagManager.getBlocks().getTag(new Identifier(tag)); + net.minecraft.tag.Tag blockTag = tagManager.method_33164(Registry.BLOCK_KEY).getTag(new Identifier(tag)); if (blockTag == null) return LazyValue.NULL; return blockLocator.block.getBlockState().isIn(blockTag)?LazyValue.TRUE:LazyValue.FALSE; }); diff --git a/src/main/java/carpet/script/utils/WorldTools.java b/src/main/java/carpet/script/utils/WorldTools.java index 9fd952b4..1993c9a4 100644 --- a/src/main/java/carpet/script/utils/WorldTools.java +++ b/src/main/java/carpet/script/utils/WorldTools.java @@ -97,7 +97,7 @@ public class WorldTools ChunkGenerator chunkGenerator2; DimensionType dimensionType2; if (dimensionOptions == null) { - dimensionType2 = (DimensionType)server.getRegistryManager().getDimensionTypes().getOrThrow(DimensionType.OVERWORLD_REGISTRY_KEY); + dimensionType2 = (DimensionType)server.getRegistryManager().method_33309(Registry.DIMENSION_TYPE_KEY).getOrThrow(DimensionType.OVERWORLD_REGISTRY_KEY); chunkGenerator2 = GeneratorOptions.createOverworldGenerator(server.getRegistryManager().get(Registry.BIOME_KEY), server.getRegistryManager().get(Registry.NOISE_SETTINGS_WORLDGEN), (new Random()).nextLong()); } else { dimensionType2 = dimensionOptions.getDimensionType(); diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 7796ba70..d8961fc3 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -235,7 +235,7 @@ public class EntityValue extends Value positive = false; who = who.substring(1); } - net.minecraft.tag.Tag> eTag = server.getTagManager().getEntityTypes().getTag(new Identifier(who)); + net.minecraft.tag.Tag> eTag = server.getTagManager().method_33164(Registry.ENTITY_TYPE_KEY).getTag(new Identifier(who)); if (eTag == null) throw new InternalExpressionException(who+" is not a valid entity descriptor"); if (positive) { @@ -438,13 +438,13 @@ public class EntityValue extends Value put("tags", (e, a) -> ListValue.wrap(e.getScoreboardTags().stream().map(StringValue::new).collect(Collectors.toList()))); put("scoreboard_tags", (e, a) -> ListValue.wrap(e.getScoreboardTags().stream().map(StringValue::new).collect(Collectors.toList()))); - put("entity_tags", (e, a) -> ListValue.wrap(e.getServer().getTagManager().getEntityTypes().getTagsFor(e.getType()).stream().map(ValueConversions::of).collect(Collectors.toList()))); + put("entity_tags", (e, a) -> ListValue.wrap(e.getServer().getTagManager().method_33164(Registry.ENTITY_TYPE_KEY).getTagsFor(e.getType()).stream().map(ValueConversions::of).collect(Collectors.toList()))); // deprecated put("has_tag", (e, a) -> new NumericValue(e.getScoreboardTags().contains(a.getString()))); put("has_scoreboard_tag", (e, a) -> new NumericValue(e.getScoreboardTags().contains(a.getString()))); put("has_entity_tag", (e, a) -> { - net.minecraft.tag.Tag> tag = e.getServer().getTagManager().getEntityTypes().getTag(new Identifier(a.getString())); + net.minecraft.tag.Tag> tag = e.getServer().getTagManager().method_33164(Registry.ENTITY_TYPE_KEY).getTag(new Identifier(a.getString())); if (tag == null) return Value.NULL; return new NumericValue(e.getType().isIn(tag)); }); diff --git a/src/main/java/carpet/script/value/ValueConversions.java b/src/main/java/carpet/script/value/ValueConversions.java index adb26099..8699dc54 100644 --- a/src/main/java/carpet/script/value/ValueConversions.java +++ b/src/main/java/carpet/script/value/ValueConversions.java @@ -389,7 +389,7 @@ public class ValueConversions BlockPredicateInterface predicateData = (BlockPredicateInterface) blockPredicate; return ListValue.of( predicateData.getCMBlockState()==null?Value.NULL:of(Registry.BLOCK.getId(predicateData.getCMBlockState().getBlock())), - predicateData.getCMBlockTag()==null?Value.NULL:of(tagManager.getBlocks().getTagId(predicateData.getCMBlockTag())), + predicateData.getCMBlockTag()==null?Value.NULL:of(tagManager.method_33164(Registry.BLOCK_KEY).getUncheckedTagId(predicateData.getCMBlockTag())), MapValue.wrap(predicateData.getCMProperties()), predicateData.getCMDataTag() == null?Value.NULL:new NBTSerializableValue(predicateData.getCMDataTag()) ); From b14cf288a18755977ed265604011733be76bc258 Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 15 Jan 2021 04:51:06 -0400 Subject: [PATCH 024/115] mappings --- gradle.properties | 2 +- .../helpers/EntityPlayerActionPack.java | 4 +- .../java/carpet/helpers/ParticleDisplay.java | 4 +- .../MinecraftServer_tickspeedMixin.java | 4 +- ...tonBlockEntityRenderer_movableTEMixin.java | 2 +- ...InteractionManager_scarpetEventsMixin.java | 2 +- .../mixins/ServerWorld_scarpetMixin.java | 14 ++-- .../java/carpet/script/api/Inventories.java | 8 +- .../java/carpet/script/api/WorldAccess.java | 12 +-- .../script/command/CommandArgument.java | 34 ++++---- .../carpet/script/utils/ShapeDispatcher.java | 8 +- .../java/carpet/script/utils/WorldTools.java | 2 +- .../java/carpet/script/value/EntityValue.java | 10 +-- .../carpet/script/value/ValueConversions.java | 2 +- src/main/java/carpet/utils/BlockInfo.java | 84 +++++++++---------- 15 files changed, 97 insertions(+), 95 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5b9a9640..fb8b49ee 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=20w51a - yarn_mappings=20w51a+build.1 + yarn_mappings=20w51a+build.30 loader_version=0.11.0 # Mod Properties diff --git a/src/main/java/carpet/helpers/EntityPlayerActionPack.java b/src/main/java/carpet/helpers/EntityPlayerActionPack.java index 7c242e09..87cb6eab 100644 --- a/src/main/java/carpet/helpers/EntityPlayerActionPack.java +++ b/src/main/java/carpet/helpers/EntityPlayerActionPack.java @@ -10,7 +10,7 @@ import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.entity.vehicle.MinecartEntity; import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.s2c.play.HeldItemChangeS2CPacket; +import net.minecraft.network.packet.s2c.play.UpdateSelectedSlotS2CPacket; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; import net.minecraft.server.world.ServerWorld; @@ -280,7 +280,7 @@ public class EntityPlayerActionPack public void setSlot(int slot) { player.getInventory().selectedSlot = slot-1; - player.networkHandler.sendPacket(new HeldItemChangeS2CPacket(slot-1)); + player.networkHandler.sendPacket(new UpdateSelectedSlotS2CPacket(slot-1)); } public enum ActionType diff --git a/src/main/java/carpet/helpers/ParticleDisplay.java b/src/main/java/carpet/helpers/ParticleDisplay.java index ff82f24b..a86d2973 100644 --- a/src/main/java/carpet/helpers/ParticleDisplay.java +++ b/src/main/java/carpet/helpers/ParticleDisplay.java @@ -2,7 +2,7 @@ package carpet.helpers; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import net.minecraft.command.argument.ParticleArgumentType; +import net.minecraft.command.argument.ParticleEffectArgumentType; import net.minecraft.particle.ParticleEffect; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; @@ -19,7 +19,7 @@ public class ParticleDisplay { try { - return ParticleArgumentType.readParameters(new StringReader(name)); + return ParticleEffectArgumentType.readParameters(new StringReader(name)); } catch (CommandSyntaxException e) { diff --git a/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java b/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java index 03bb1f38..0cad4711 100644 --- a/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java +++ b/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java @@ -40,7 +40,7 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec @Shadow protected abstract boolean shouldKeepTicking(); - @Shadow private long field_19248; + @Shadow private long nextTickTimestamp; @Shadow protected abstract void method_16208(); @@ -127,7 +127,7 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec while(this.runEveryTask()) {Thread.yield();} } this.waitingForNextTick = true; - this.field_19248 = Math.max(Util.getMeasuringTimeMs() + /*50L*/ msThisTick, this.timeReference); + this.nextTickTimestamp = Math.max(Util.getMeasuringTimeMs() + /*50L*/ msThisTick, this.timeReference); // run all tasks (this will not do a lot when warping), but that's fine since we already run them this.method_16208(); this.profiler.pop(); diff --git a/src/main/java/carpet/mixins/PistonBlockEntityRenderer_movableTEMixin.java b/src/main/java/carpet/mixins/PistonBlockEntityRenderer_movableTEMixin.java index d41652b0..801e9693 100644 --- a/src/main/java/carpet/mixins/PistonBlockEntityRenderer_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonBlockEntityRenderer_movableTEMixin.java @@ -27,7 +27,7 @@ public abstract class PistonBlockEntityRenderer_movableTEMixin implements BlockE } @Inject(method = "render", at = @At(value = "INVOKE", - target = "Lnet/minecraft/client/render/block/entity/PistonBlockEntityRenderer;method_3575(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;ZI)V", ordinal = 3)) + target = "Lnet/minecraft/client/render/block/entity/PistonBlockEntityRenderer;renderModel(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;ZI)V", ordinal = 3)) private void updateRenderBool(PistonBlockEntity pistonBlockEntity_1, float float_1, MatrixStack matrixStack_1, VertexConsumerProvider layeredVertexConsumerStorage_1, int int_1, int int_2, CallbackInfo ci) //private void updateRenderBool(PistonBlockEntity pistonBlockEntity_1, double double_1, double double_2, double double_3, float float_1, class_4587 class_4587_1, class_4597 class_4597_1, int int_1, CallbackInfo ci) { diff --git a/src/main/java/carpet/mixins/ServerPlayerInteractionManager_scarpetEventsMixin.java b/src/main/java/carpet/mixins/ServerPlayerInteractionManager_scarpetEventsMixin.java index 559fbc91..d7ce33b2 100644 --- a/src/main/java/carpet/mixins/ServerPlayerInteractionManager_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/ServerPlayerInteractionManager_scarpetEventsMixin.java @@ -75,6 +75,6 @@ public class ServerPlayerInteractionManager_scarpetEventsMixin implements Server public void setBlockBreakingProgress(int progress) { blockBreakingProgress = MathHelper.clamp(progress, -1, 10); - world.setBlockBreakingInfo(-1*this.player.getEntityId(), miningPos, blockBreakingProgress); + world.setBlockBreakingInfo(-1*this.player.getId(), miningPos, blockBreakingProgress); } } diff --git a/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java b/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java index 99598274..8cad062d 100644 --- a/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java +++ b/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java @@ -3,16 +3,17 @@ package carpet.mixins; import carpet.CarpetSettings; import carpet.fakes.ServerWorldInterface; import carpet.script.CarpetEventServer; -import net.minecraft.class_5568; -import net.minecraft.class_5579; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLike; import net.minecraft.entity.LightningEntity; +import net.minecraft.server.world.ServerEntityManager; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.profiler.Profiler; import net.minecraft.world.chunk.WorldChunk; import net.minecraft.world.level.ServerWorldProperties; +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; @@ -42,12 +43,12 @@ public class ServerWorld_scarpetMixin implements ServerWorldInterface @Redirect(method = "addEntity", at = @At( value = "INVOKE", - target = "Lnet/minecraft/class_5579;addEntity(Lnet/minecraft/class_5568;)Z" + target = "Lnet/minecraft/server/world/ServerEntityManager;addEntity(Lnet/minecraft/entity/EntityLike;)Z" )) - private boolean onEntityAddedToWorld(class_5579 class_5579, class_5568 arg) + private boolean onEntityAddedToWorld(ServerEntityManager serverEntityManager, EntityLike entityLike) { - Entity entity = (Entity)arg; - boolean success = class_5579.addEntity(entity); + Entity entity = (Entity)entityLike; + boolean success = serverEntityManager.addEntity(entity); if (success) { CarpetEventServer.Event event = ENTITY_LOAD.get(entity.getType()); if (event != null) { @@ -61,6 +62,7 @@ public class ServerWorld_scarpetMixin implements ServerWorldInterface return success; } + @Final @Shadow private ServerWorldProperties worldProperties; public ServerWorldProperties getWorldPropertiesCM(){ diff --git a/src/main/java/carpet/script/api/Inventories.java b/src/main/java/carpet/script/api/Inventories.java index 0548101f..6cdb86ec 100644 --- a/src/main/java/carpet/script/api/Inventories.java +++ b/src/main/java/carpet/script/api/Inventories.java @@ -73,7 +73,7 @@ public class Inventories { CarpetContext cc = (CarpetContext)c; TagManager tagManager = cc.s.getMinecraftServer().getTagManager(); String tag = lv.get(0).evalValue(c).getString(); - net.minecraft.tag.Tag itemTag = tagManager.method_33164(Registry.ITEM_KEY).getTag(new Identifier(tag)); + net.minecraft.tag.Tag itemTag = tagManager.getOrCreateTagGroup(Registry.ITEM_KEY).getTag(new Identifier(tag)); if (itemTag == null) return LazyValue.NULL; Value ret = ListValue.wrap(itemTag.values().stream().map(b -> ValueConversions.of(Registry.ITEM.getId(b))).collect(Collectors.toList())); return (_c, _t) -> ret; @@ -85,17 +85,17 @@ public class Inventories { TagManager tagManager = cc.s.getMinecraftServer().getTagManager(); if (lv.size() == 0) { - Value ret = ListValue.wrap(tagManager.method_33164(Registry.ITEM_KEY).getTagIds().stream().map(ValueConversions::of).collect(Collectors.toList())); + Value ret = ListValue.wrap(tagManager.getOrCreateTagGroup(Registry.ITEM_KEY).getTagIds().stream().map(ValueConversions::of).collect(Collectors.toList())); return (_c, _t) -> ret; } Item item = NBTSerializableValue.parseItem(lv.get(0).evalValue(c).getString()).getItem(); if (lv.size() == 1) { - Value ret = ListValue.wrap(tagManager.method_33164(Registry.ITEM_KEY).getTagsFor(item).stream().map(ValueConversions::of).collect(Collectors.toList())); + Value ret = ListValue.wrap(tagManager.getOrCreateTagGroup(Registry.ITEM_KEY).getTagsFor(item).stream().map(ValueConversions::of).collect(Collectors.toList())); return (_c, _t) -> ret; } String tag = lv.get(1).evalValue(c).getString(); - net.minecraft.tag.Tag itemTag = tagManager.method_33164(Registry.ITEM_KEY).getTag(new Identifier(tag)); + net.minecraft.tag.Tag itemTag = tagManager.getOrCreateTagGroup(Registry.ITEM_KEY).getTag(new Identifier(tag)); if (itemTag == null) return LazyValue.NULL; return itemTag.contains(item)?LazyValue.TRUE:LazyValue.FALSE; }); diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index c72b47b0..0e7b019c 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -245,7 +245,7 @@ public class WorldAccess { return true; } else { ItemStack itemStack_1 = player.getMainHandStack(); - boolean boolean_2 = player.isUsingEffectiveTool(blockState_1); + boolean boolean_2 = player.canHarvest(blockState_1); itemStack_1.postMine(player.world, blockState_1, blockPos_1, player); if (boolean_1 && boolean_2) { ItemStack itemStack_2 = itemStack_1.isEmpty() ? ItemStack.EMPTY : itemStack_1.copy(); @@ -905,7 +905,7 @@ public class WorldAccess { boolean dropLoot = true; if (playerBreak) { - boolean isUsingEffectiveTool = !state.isToolRequired() || tool.isEffectiveOn(state); + boolean isUsingEffectiveTool = !state.isToolRequired() || tool.isSuitableFor(state); //postMine() durability from item classes float hardness = state.getHardness(world, where); int damageAmount = 0; @@ -1109,7 +1109,7 @@ public class WorldAccess { CarpetContext cc = (CarpetContext)c; TagManager tagManager = cc.s.getMinecraftServer().getTagManager(); String tag = lv.get(0).evalValue(c).getString(); - net.minecraft.tag.Tag blockTag = tagManager.method_33164(Registry.BLOCK_KEY).getTag(new Identifier(tag)); + net.minecraft.tag.Tag blockTag = tagManager.getOrCreateTagGroup(Registry.BLOCK_KEY).getTag(new Identifier(tag)); if (blockTag == null) return LazyValue.NULL; Value ret = ListValue.wrap(blockTag.values().stream().map(b -> ValueConversions.of(Registry.BLOCK.getId(b))).collect(Collectors.toList())); return (_c, _t) -> ret; @@ -1121,17 +1121,17 @@ public class WorldAccess { TagManager tagManager = cc.s.getMinecraftServer().getTagManager(); if (lv.size() == 0) { - Value ret = ListValue.wrap(tagManager.method_33164(Registry.BLOCK_KEY).getTagIds().stream().map(ValueConversions::of).collect(Collectors.toList())); + Value ret = ListValue.wrap(tagManager.getOrCreateTagGroup(Registry.BLOCK_KEY).getTagIds().stream().map(ValueConversions::of).collect(Collectors.toList())); return (_c, _t) -> ret; } BlockArgument blockLocator = BlockArgument.findIn(cc, lv, 0, true); if (blockLocator.offset == lv.size()) { - Value ret = ListValue.wrap(tagManager.method_33164(Registry.BLOCK_KEY).getTagsFor(blockLocator.block.getBlockState().getBlock()).stream().map(ValueConversions::of).collect(Collectors.toList())); + Value ret = ListValue.wrap(tagManager.getOrCreateTagGroup(Registry.BLOCK_KEY).getTagsFor(blockLocator.block.getBlockState().getBlock()).stream().map(ValueConversions::of).collect(Collectors.toList())); return (_c, _t) -> ret; } String tag = lv.get(blockLocator.offset).evalValue(c).getString(); - net.minecraft.tag.Tag blockTag = tagManager.method_33164(Registry.BLOCK_KEY).getTag(new Identifier(tag)); + net.minecraft.tag.Tag blockTag = tagManager.getOrCreateTagGroup(Registry.BLOCK_KEY).getTag(new Identifier(tag)); if (blockTag == null) return LazyValue.NULL; return blockLocator.block.getBlockState().isIn(blockTag)?LazyValue.TRUE:LazyValue.FALSE; }); diff --git a/src/main/java/carpet/script/command/CommandArgument.java b/src/main/java/carpet/script/command/CommandArgument.java index cae45ed2..01163359 100644 --- a/src/main/java/carpet/script/command/CommandArgument.java +++ b/src/main/java/carpet/script/command/CommandArgument.java @@ -47,18 +47,18 @@ import net.minecraft.command.argument.EntityArgumentType; import net.minecraft.command.argument.EntitySummonArgumentType; import net.minecraft.command.argument.GameProfileArgumentType; import net.minecraft.command.argument.IdentifierArgumentType; -import net.minecraft.command.argument.ItemEnchantmentArgumentType; +import net.minecraft.command.argument.EnchantmentArgumentType; import net.minecraft.command.argument.ItemSlotArgumentType; import net.minecraft.command.argument.ItemStackArgumentType; import net.minecraft.command.argument.MessageArgumentType; -import net.minecraft.command.argument.MobEffectArgumentType; +import net.minecraft.command.argument.StatusEffectArgumentType; import net.minecraft.command.argument.NbtCompoundTagArgumentType; import net.minecraft.command.argument.NbtPathArgumentType; import net.minecraft.command.argument.NbtTagArgumentType; import net.minecraft.command.argument.NumberRangeArgumentType; -import net.minecraft.command.argument.ObjectiveArgumentType; -import net.minecraft.command.argument.ObjectiveCriteriaArgumentType; -import net.minecraft.command.argument.ParticleArgumentType; +import net.minecraft.command.argument.ScoreboardObjectiveArgumentType; +import net.minecraft.command.argument.ScoreboardCriterionArgumentType; +import net.minecraft.command.argument.ParticleEffectArgumentType; import net.minecraft.command.argument.RotationArgumentType; import net.minecraft.command.argument.ScoreHolderArgumentType; import net.minecraft.command.argument.ScoreboardSlotArgumentType; @@ -152,17 +152,17 @@ public abstract class CommandArgument new VanillaUnconfigurableArgument("entitytype", EntitySummonArgumentType::entitySummon, (c, p) -> ValueConversions.of(EntitySummonArgumentType.getEntitySummon(c, p)), SuggestionProviders.SUMMONABLE_ENTITIES ), - new VanillaUnconfigurableArgument("floatrange", NumberRangeArgumentType::method_30918, + new VanillaUnconfigurableArgument("floatrange", NumberRangeArgumentType::floatRange, (c, p) -> ValueConversions.of(c.getArgument(p, NumberRange.FloatRange.class)), true ), // function?? new PlayerProfileArgument(), - new VanillaUnconfigurableArgument("intrange", NumberRangeArgumentType::numberRange, + new VanillaUnconfigurableArgument("intrange", NumberRangeArgumentType::intRange, (c, p) -> ValueConversions.of(NumberRangeArgumentType.IntRangeArgumentType.getRangeArgument(c, p)), true ), - new VanillaUnconfigurableArgument("enchantment", ItemEnchantmentArgumentType::itemEnchantment, - (c, p) -> ValueConversions.of(Registry.ENCHANTMENT.getId(ItemEnchantmentArgumentType.getEnchantment(c, p))), false + new VanillaUnconfigurableArgument("enchantment", EnchantmentArgumentType::enchantment, + (c, p) -> ValueConversions.of(Registry.ENCHANTMENT.getId(EnchantmentArgumentType.getEnchantment(c, p))), false ), // item_predicate ?? //same as item but accepts tags, not sure right now new SlotArgument(), @@ -172,22 +172,22 @@ public abstract class CommandArgument new VanillaUnconfigurableArgument("message", MessageArgumentType::message, (c, p) -> new FormattedTextValue(MessageArgumentType.getMessage(c, p)), true ), - new VanillaUnconfigurableArgument("effect", MobEffectArgumentType::mobEffect, - (c, p) -> ValueConversions.of(Registry.STATUS_EFFECT.getId(MobEffectArgumentType.getMobEffect(c, p))),false + new VanillaUnconfigurableArgument("effect", StatusEffectArgumentType::statusEffect, + (c, p) -> ValueConversions.of(Registry.STATUS_EFFECT.getId(StatusEffectArgumentType.getStatusEffect(c, p))),false ), new TagArgument(), // for nbt_compound_tag and nbt_tag new VanillaUnconfigurableArgument("path", NbtPathArgumentType::nbtPath, (c, p) -> StringValue.of(NbtPathArgumentType.getNbtPath(c, p).toString()), true ), - new VanillaUnconfigurableArgument("objective", ObjectiveArgumentType::objective, - (c, p) -> ValueConversions.of(ObjectiveArgumentType.getObjective(c, p)), false + new VanillaUnconfigurableArgument("objective", ScoreboardObjectiveArgumentType::scoreboardObjective, + (c, p) -> ValueConversions.of(ScoreboardObjectiveArgumentType.getObjective(c, p)), false ), - new VanillaUnconfigurableArgument("criterion", ObjectiveCriteriaArgumentType::objectiveCriteria, - (c, p) -> StringValue.of(ObjectiveCriteriaArgumentType.getCriteria(c, p).getName()), false + new VanillaUnconfigurableArgument("criterion", ScoreboardCriterionArgumentType::scoreboardCriterion, + (c, p) -> StringValue.of(ScoreboardCriterionArgumentType.getCriterion(c, p).getName()), false ), // operation // not sure if we need it, you have scarpet for that - new VanillaUnconfigurableArgument("particle", ParticleArgumentType::particle, - (c, p) -> ValueConversions.of(ParticleArgumentType.getParticle(c, p)), false + new VanillaUnconfigurableArgument("particle", ParticleEffectArgumentType::particleEffect, + (c, p) -> ValueConversions.of(ParticleEffectArgumentType.getParticle(c, p)), false ), // resource / identifier section diff --git a/src/main/java/carpet/script/utils/ShapeDispatcher.java b/src/main/java/carpet/script/utils/ShapeDispatcher.java index 761b8420..871d55aa 100644 --- a/src/main/java/carpet/script/utils/ShapeDispatcher.java +++ b/src/main/java/carpet/script/utils/ShapeDispatcher.java @@ -18,7 +18,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import net.minecraft.command.argument.ParticleArgumentType; +import net.minecraft.command.argument.ParticleEffectArgumentType; import net.minecraft.entity.Entity; import net.minecraft.nbt.ByteTag; import net.minecraft.nbt.CompoundTag; @@ -152,7 +152,7 @@ public class ShapeDispatcher return particle; try { - particle = ParticleArgumentType.readParameters(new StringReader(name)); + particle = ParticleEffectArgumentType.readParameters(new StringReader(name)); } catch (CommandSyntaxException e) { @@ -1225,11 +1225,11 @@ public class ShapeDispatcher @Override public Value validate(Map options, CarpetContext cc, Value value) { - if (value instanceof EntityValue) return new NumericValue(((EntityValue) value).getEntity().getEntityId()); + if (value instanceof EntityValue) return new NumericValue(((EntityValue) value).getEntity().getId()); ServerPlayerEntity player = EntityValue.getPlayerByValue(cc.s.getMinecraftServer(), value); if (player == null) throw new InternalExpressionException(id+" parameter needs to represent an entity or player"); - return new NumericValue(player.getEntityId()); + return new NumericValue(player.getId()); } public Value decode(Tag tag) { return new NumericValue(((IntTag)tag).getInt()); } diff --git a/src/main/java/carpet/script/utils/WorldTools.java b/src/main/java/carpet/script/utils/WorldTools.java index 1993c9a4..ca3c3354 100644 --- a/src/main/java/carpet/script/utils/WorldTools.java +++ b/src/main/java/carpet/script/utils/WorldTools.java @@ -97,7 +97,7 @@ public class WorldTools ChunkGenerator chunkGenerator2; DimensionType dimensionType2; if (dimensionOptions == null) { - dimensionType2 = (DimensionType)server.getRegistryManager().method_33309(Registry.DIMENSION_TYPE_KEY).getOrThrow(DimensionType.OVERWORLD_REGISTRY_KEY); + dimensionType2 = server.getRegistryManager().getMutable(Registry.DIMENSION_TYPE_KEY).getOrThrow(DimensionType.OVERWORLD_REGISTRY_KEY); chunkGenerator2 = GeneratorOptions.createOverworldGenerator(server.getRegistryManager().get(Registry.BIOME_KEY), server.getRegistryManager().get(Registry.NOISE_SETTINGS_WORLDGEN), (new Random()).nextLong()); } else { dimensionType2 = dimensionOptions.getDimensionType(); diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 3c958902..7ef07900 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -191,7 +191,7 @@ public class EntityValue extends Value { if (v instanceof EntityValue) { - return getEntity().getEntityId()==((EntityValue) v).getEntity().getEntityId(); + return getEntity().getId()==((EntityValue) v).getEntity().getId(); } return super.equals((Value)v); } @@ -241,7 +241,7 @@ public class EntityValue extends Value positive = false; who = who.substring(1); } - net.minecraft.tag.Tag> eTag = server.getTagManager().method_33164(Registry.ENTITY_TYPE_KEY).getTag(new Identifier(who)); + net.minecraft.tag.Tag> eTag = server.getTagManager().getOrCreateTagGroup(Registry.ENTITY_TYPE_KEY).getTag(new Identifier(who)); if (eTag == null) throw new InternalExpressionException(who+" is not a valid entity descriptor"); if (positive) { @@ -415,7 +415,7 @@ public class EntityValue extends Value //put("test", (e, a) -> a == null ? Value.NULL : new StringValue(a.getString())); 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("id",(e, a) -> new NumericValue(e.getId())); put("pos", (e, a) -> ListValue.of(new NumericValue(e.getX()), new NumericValue(e.getY()), new NumericValue(e.getZ()))); put("location", (e, a) -> ListValue.of(new NumericValue(e.getX()), new NumericValue(e.getY()), new NumericValue(e.getZ()), new NumericValue(e.yaw), new NumericValue(e.pitch))); put("x", (e, a) -> new NumericValue(e.getX())); @@ -444,13 +444,13 @@ public class EntityValue extends Value put("tags", (e, a) -> ListValue.wrap(e.getScoreboardTags().stream().map(StringValue::new).collect(Collectors.toList()))); put("scoreboard_tags", (e, a) -> ListValue.wrap(e.getScoreboardTags().stream().map(StringValue::new).collect(Collectors.toList()))); - put("entity_tags", (e, a) -> ListValue.wrap(e.getServer().getTagManager().method_33164(Registry.ENTITY_TYPE_KEY).getTagsFor(e.getType()).stream().map(ValueConversions::of).collect(Collectors.toList()))); + put("entity_tags", (e, a) -> ListValue.wrap(e.getServer().getTagManager().getOrCreateTagGroup(Registry.ENTITY_TYPE_KEY).getTagsFor(e.getType()).stream().map(ValueConversions::of).collect(Collectors.toList()))); // deprecated put("has_tag", (e, a) -> new NumericValue(e.getScoreboardTags().contains(a.getString()))); put("has_scoreboard_tag", (e, a) -> new NumericValue(e.getScoreboardTags().contains(a.getString()))); put("has_entity_tag", (e, a) -> { - net.minecraft.tag.Tag> tag = e.getServer().getTagManager().method_33164(Registry.ENTITY_TYPE_KEY).getTag(new Identifier(a.getString())); + net.minecraft.tag.Tag> tag = e.getServer().getTagManager().getOrCreateTagGroup(Registry.ENTITY_TYPE_KEY).getTag(new Identifier(a.getString())); if (tag == null) return Value.NULL; return new NumericValue(e.getType().isIn(tag)); }); diff --git a/src/main/java/carpet/script/value/ValueConversions.java b/src/main/java/carpet/script/value/ValueConversions.java index 8699dc54..1874238d 100644 --- a/src/main/java/carpet/script/value/ValueConversions.java +++ b/src/main/java/carpet/script/value/ValueConversions.java @@ -389,7 +389,7 @@ public class ValueConversions BlockPredicateInterface predicateData = (BlockPredicateInterface) blockPredicate; return ListValue.of( predicateData.getCMBlockState()==null?Value.NULL:of(Registry.BLOCK.getId(predicateData.getCMBlockState().getBlock())), - predicateData.getCMBlockTag()==null?Value.NULL:of(tagManager.method_33164(Registry.BLOCK_KEY).getUncheckedTagId(predicateData.getCMBlockTag())), + predicateData.getCMBlockTag()==null?Value.NULL:of(tagManager.getOrCreateTagGroup(Registry.BLOCK_KEY).getUncheckedTagId(predicateData.getCMBlockTag())), MapValue.wrap(predicateData.getCMProperties()), predicateData.getCMDataTag() == null?Value.NULL:new NBTSerializableValue(predicateData.getCMDataTag()) ); diff --git a/src/main/java/carpet/utils/BlockInfo.java b/src/main/java/carpet/utils/BlockInfo.java index 6705c82d..2136d1a4 100644 --- a/src/main/java/carpet/utils/BlockInfo.java +++ b/src/main/java/carpet/utils/BlockInfo.java @@ -85,20 +85,20 @@ public class BlockInfo public static final Map mapColourName = new HashMap() {{ put(MapColor.CLEAR , "air" ); - put(MapColor.GRASS , "grass" ); - put(MapColor.SAND , "sand" ); - put(MapColor.WEB , "wool" ); - put(MapColor.LAVA , "tnt" ); - put(MapColor.ICE , "ice" ); - put(MapColor.IRON , "iron" ); - put(MapColor.FOLIAGE , "foliage" ); + put(MapColor.PALE_GREEN , "grass" ); + put(MapColor.PALE_YELLOW , "sand" ); + put(MapColor.WHITE_GRAY , "wool" ); + put(MapColor.BRIGHT_RED , "tnt" ); + put(MapColor.PALE_PURPLE , "ice" ); + put(MapColor.IRON_GRAY , "iron" ); + put(MapColor.DARK_GREEN , "foliage" ); put(MapColor.WHITE , "snow" ); - put(MapColor.CLAY , "clay" ); - put(MapColor.DIRT , "dirt" ); - put(MapColor.STONE , "stone" ); - put(MapColor.WATER , "water" ); - put(MapColor.WOOD , "wood" ); - put(MapColor.QUARTZ , "quartz" ); + put(MapColor.LIGHT_BLUE_GRAY , "clay" ); + put(MapColor.DIRT_BROWN , "dirt" ); + put(MapColor.STONE_GRAY , "stone" ); + put(MapColor.WATER_BLUE , "water" ); + put(MapColor.OAK_TAN , "wood" ); + put(MapColor.OFF_WHITE , "quartz" ); put(MapColor.ORANGE , "adobe" ); put(MapColor.MAGENTA , "magenta" ); put(MapColor.LIGHT_BLUE, "light_blue"); @@ -115,34 +115,34 @@ public class BlockInfo put(MapColor.RED , "red" ); put(MapColor.BLACK , "black" ); put(MapColor.GOLD , "gold" ); - put(MapColor.DIAMOND , "diamond" ); - put(MapColor.LAPIS , "lapis" ); - put(MapColor.EMERALD , "emerald" ); - put(MapColor.SPRUCE , "obsidian" ); - put(MapColor.NETHER , "netherrack"); //TODO fix these - put(MapColor.WHITE_TERRACOTTA , "white_terracotta" ); - put(MapColor.ORANGE_TERRACOTTA , "orange_terracotta" ); - put(MapColor.MAGENTA_TERRACOTTA , "magenta_terracotta" ); - put(MapColor.LIGHT_BLUE_TERRACOTTA, "light_blue_terracotta" ); - put(MapColor.YELLOW_TERRACOTTA , "yellow_terracotta" ); - put(MapColor.LIME_TERRACOTTA , "lime_terracotta" ); - put(MapColor.PINK_TERRACOTTA , "pink_terracotta" ); - put(MapColor.GRAY_TERRACOTTA , "gray_terracotta" ); - put(MapColor.LIGHT_GRAY_TERRACOTTA, "light_gray_terracotta" ); - put(MapColor.CYAN_TERRACOTTA , "cyan_terracotta" ); - put(MapColor.PURPLE_TERRACOTTA , "purple_terracotta" ); - put(MapColor.BLUE_TERRACOTTA , "blue_terracotta" ); - put(MapColor.BROWN_TERRACOTTA , "brown_terracotta" ); - put(MapColor.GREEN_TERRACOTTA , "green_terracotta" ); - put(MapColor.RED_TERRACOTTA , "red_terracotta" ); - put(MapColor.BLACK_TERRACOTTA , "black_terracotta" ); - put(MapColor.CRIMSON_NYLIUM , "crimson_nylium" ); - put(MapColor.CRIMSON_STEM , "crimson_stem" ); - put(MapColor.CRIMSON_HYPHAE , "crimson_hyphae" ); - put(MapColor.WARPED_NYLIUM , "warped_nylium" ); - put(MapColor.WARPED_STEM , "warped_stem" ); - put(MapColor.WARPED_HYPHAE , "warped_hyphae" ); - put(MapColor.WARPED_WART , "warped_wart" ); + put(MapColor.DIAMOND_BLUE , "diamond" ); + put(MapColor.LAPIS_BLUE , "lapis" ); + put(MapColor.EMERALD_GREEN , "emerald" ); + put(MapColor.SPRUCE_BROWN , "obsidian" ); + put(MapColor.DARK_RED , "netherrack"); //TODO fix these + put(MapColor.TERRACOTTA_WHITE , "white_terracotta" ); + put(MapColor.TERRACOTTA_ORANGE , "orange_terracotta" ); + put(MapColor.TERRACOTTA_MAGENTA , "magenta_terracotta" ); + put(MapColor.TERRACOTTA_LIGHT_BLUE, "light_blue_terracotta" ); + put(MapColor.TERRACOTTA_YELLOW , "yellow_terracotta" ); + put(MapColor.TERRACOTTA_LIME , "lime_terracotta" ); + put(MapColor.TERRACOTTA_PINK , "pink_terracotta" ); + put(MapColor.TERRACOTTA_GRAY , "gray_terracotta" ); + put(MapColor.TERRACOTTA_LIGHT_GRAY, "light_gray_terracotta" ); + put(MapColor.TERRACOTTA_CYAN , "cyan_terracotta" ); + put(MapColor.TERRACOTTA_PURPLE , "purple_terracotta" ); + put(MapColor.TERRACOTTA_BLUE , "blue_terracotta" ); + put(MapColor.TERRACOTTA_BROWN , "brown_terracotta" ); + put(MapColor.TERRACOTTA_GREEN , "green_terracotta" ); + put(MapColor.TERRACOTTA_RED , "red_terracotta" ); + put(MapColor.TERRACOTTA_BLACK , "black_terracotta" ); + put(MapColor.DULL_RED , "crimson_nylium" ); + put(MapColor.DULL_PINK , "crimson_stem" ); + put(MapColor.DARK_CRIMSON , "crimson_hyphae" ); + put(MapColor.TEAL , "warped_nylium" ); + put(MapColor.DARK_AQUA , "warped_stem" ); + put(MapColor.DARK_DULL_PINK , "warped_hyphae" ); + put(MapColor.BRIGHT_TEAL , "warped_wart" ); }}; public static final Map materialName = new HashMap() {{ @@ -159,7 +159,7 @@ public class BlockInfo put(Material.LAVA , "lava" ); put(Material.SNOW_LAYER , "snow_layer" ); put(Material.FIRE , "fire" ); - put(Material.SUPPORTED , "decoration" ); + put(Material.DECORATION , "decoration" ); put(Material.COBWEB , "cobweb" ); put(Material.REDSTONE_LAMP , "redstone_lamp"); put(Material.ORGANIC_PRODUCT, "clay" ); From 6305fcab65073f404fec3caa946c258b9b8a2a7f Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 20 Jan 2021 19:13:44 -0400 Subject: [PATCH 025/115] 21w03a --- src/main/java/carpet/mixins/SummonCommandMixin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/carpet/mixins/SummonCommandMixin.java b/src/main/java/carpet/mixins/SummonCommandMixin.java index 4f936254..8825c743 100644 --- a/src/main/java/carpet/mixins/SummonCommandMixin.java +++ b/src/main/java/carpet/mixins/SummonCommandMixin.java @@ -31,10 +31,10 @@ public class SummonCommandMixin LocalDifficulty localDifficulty_1 = world.getLocalDifficulty(at); boolean boolean_2 = world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING) && world.random.nextDouble() < (double)localDifficulty_1.getLocalDifficulty() * 0.01D; if (boolean_2) { - SkeletonHorseEntity skeletonHorseEntity_1 = (SkeletonHorseEntity) EntityType.SKELETON_HORSE.create(world); + SkeletonHorseEntity skeletonHorseEntity_1 = EntityType.SKELETON_HORSE.create(world); skeletonHorseEntity_1.setTrapped(true); skeletonHorseEntity_1.setBreedingAge(0); - skeletonHorseEntity_1.resetPosition(entity.getX(), entity.getY(), entity.getZ()); + skeletonHorseEntity_1.setPosition(entity.getX(), entity.getY(), entity.getZ()); world.spawnEntity(skeletonHorseEntity_1); } } From 50eae09c17b3f9853a2b9239424a60241349140f Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 3 Feb 2021 20:15:45 -0400 Subject: [PATCH 026/115] 21w05a --- gradle.properties | 6 +++--- .../java/carpet/fakes/StructureFeatureInterface.java | 3 ++- src/main/java/carpet/helpers/FeatureGenerator.java | 6 ++++-- src/main/java/carpet/mixins/CarpetBlockMixin.java | 7 ++++--- src/main/java/carpet/mixins/StructureFeatureMixin.java | 9 +++++---- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/gradle.properties b/gradle.properties index e0aa382d..1206cf86 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=21w03a - yarn_mappings=21w03a+build.1 + minecraft_version=21w05a + yarn_mappings=21w05a+build.1 loader_version=0.11.1 - fabric_version=0.29.4+1.16 + fabric_version=0.30.0+1.17 # Mod Properties mod_version = 1.4.24 diff --git a/src/main/java/carpet/fakes/StructureFeatureInterface.java b/src/main/java/carpet/fakes/StructureFeatureInterface.java index d74f087c..b54d3364 100644 --- a/src/main/java/carpet/fakes/StructureFeatureInterface.java +++ b/src/main/java/carpet/fakes/StructureFeatureInterface.java @@ -3,6 +3,7 @@ package carpet.fakes; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.HeightLimitView; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.source.BiomeSource; import net.minecraft.world.gen.ChunkRandom; @@ -12,5 +13,5 @@ import net.minecraft.world.gen.feature.FeatureConfig; public interface StructureFeatureInterface { boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly,Biome biome, FeatureConfig config); - boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, C featureConfig); + boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView); } diff --git a/src/main/java/carpet/helpers/FeatureGenerator.java b/src/main/java/carpet/helpers/FeatureGenerator.java index aa497e30..40bda4b9 100644 --- a/src/main/java/carpet/helpers/FeatureGenerator.java +++ b/src/main/java/carpet/helpers/FeatureGenerator.java @@ -156,12 +156,14 @@ public class FeatureGenerator ConfiguredStructureFeature configuredFeature = biome.getGenerationSettings().method_30978(structure.configure(null)); if (configuredFeature == null || configuredFeature.config == null) return null; ChunkPos chunkPos2 = structure.getStartChunk(params, seed, chunkRandom, chunkPos.x, chunkPos.z); //find some chunk I guess - if (chunkPos.x == chunkPos2.x && chunkPos.z == chunkPos2.z && ((StructureFeatureInterface)structure).shouldStartPublicAt(generator, generator.getBiomeSource(), seed, chunkRandom, chunkPos.x, chunkPos.z, biome, chunkPos, configuredFeature.config)) // should start at + // using here world for heightview, rather than chunk since we - unlike vanilla, want to avoid creating any chunks even on the + // structure starts level - lets see where would that take us. + if (chunkPos.x == chunkPos2.x && chunkPos.z == chunkPos2.z && ((StructureFeatureInterface)structure).shouldStartPublicAt(generator, generator.getBiomeSource(), seed, chunkRandom, chunkPos.x, chunkPos.z, biome, chunkPos, configuredFeature.config, world)) // should start at { if (!computeBox) return StructureStart.DEFAULT; StructureManager manager = world.getStructureManager(); StructureStart structureStart3 = structure.getStructureStartFactory().create((StructureFeature) configuredFeature.feature, chunkPos.x, chunkPos.z, BlockBox.empty(), 0, seed); - structureStart3.init(world.getRegistryManager(), generator, manager, chunkPos.x, chunkPos.z, biome, (T) configuredFeature.config); + structureStart3.init(world.getRegistryManager(), generator, manager, chunkPos.x, chunkPos.z, biome, (T) configuredFeature.config, world); if (!structureStart3.hasChildren()) return null; return structureStart3; } diff --git a/src/main/java/carpet/mixins/CarpetBlockMixin.java b/src/main/java/carpet/mixins/CarpetBlockMixin.java index 922538dd..f5eafed6 100644 --- a/src/main/java/carpet/mixins/CarpetBlockMixin.java +++ b/src/main/java/carpet/mixins/CarpetBlockMixin.java @@ -4,11 +4,12 @@ import carpet.utils.WoolTool; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.CarpetBlock; +import net.minecraft.class_5815; import net.minecraft.item.ItemPlacementContext; import net.minecraft.server.world.ServerWorld; import org.spongepowered.asm.mixin.Mixin; -@Mixin(CarpetBlock.class) +@Mixin(class_5815.class) // WoolCarpetBlock public abstract class CarpetBlockMixin extends Block { @@ -21,8 +22,8 @@ public abstract class CarpetBlockMixin extends Block { BlockState state = super.getPlacementState(context); if (context.getPlayer() != null && !context.getWorld().isClient) - { - WoolTool.carpetPlacedAction(((CarpetBlock)(Object)this).getColor(), context.getPlayer(), context.getBlockPos(), (ServerWorld) context.getWorld()); + { // getColor() + WoolTool.carpetPlacedAction(((class_5815)(Object)this).method_33635(), context.getPlayer(), context.getBlockPos(), (ServerWorld) context.getWorld()); } return state; } diff --git a/src/main/java/carpet/mixins/StructureFeatureMixin.java b/src/main/java/carpet/mixins/StructureFeatureMixin.java index 2bbf8667..e9f7c9d9 100644 --- a/src/main/java/carpet/mixins/StructureFeatureMixin.java +++ b/src/main/java/carpet/mixins/StructureFeatureMixin.java @@ -7,6 +7,7 @@ import net.minecraft.structure.StructureStart; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.BlockBox; +import net.minecraft.world.HeightLimitView; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.source.BiomeSource; import net.minecraft.world.chunk.Chunk; @@ -28,7 +29,7 @@ public abstract class StructureFeatureMixin implements @Shadow public abstract StructureFeature.StructureStartFactory getStructureStartFactory(); - @Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, C featureConfig); + @Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, C config, HeightLimitView heightLimitView); @Override public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly, Biome biome, FeatureConfig config) @@ -107,7 +108,7 @@ public abstract class StructureFeatureMixin implements StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos.x, chunkpos.z, BlockBox.empty(),0,worldIn.getSeed()); if (config == null) config = new DefaultFeatureConfig(); - structurestart1.init(worldIn.getRegistryManager(), generator, worldIn.getStructureManager() , chunkpos.x, chunkpos.z, biome_1, config); + structurestart1.init(worldIn.getRegistryManager(), generator, worldIn.getStructureManager() , chunkpos.x, chunkpos.z, biome_1, config, ichunk); structurestart = structurestart1.hasChildren() ? structurestart1 : StructureStart.DEFAULT; if (structurestart.hasChildren()) @@ -120,8 +121,8 @@ public abstract class StructureFeatureMixin implements } @Override - public boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, C featureConfig) + public boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView) { - return shouldStartAt(chunkGenerator, biomeSource, l, chunkRandom, i, j, biome, chunkPos, featureConfig); + return shouldStartAt(chunkGenerator, biomeSource, l, chunkRandom, i, j, biome, chunkPos, featureConfig, heightLimitView); } } From 257aca4254ab0d189e87922e2dab5b767cb24e28 Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 9 Feb 2021 00:16:07 -0400 Subject: [PATCH 027/115] mappings --- gradle.properties | 6 +++--- .../java/carpet/helpers/EntityPlayerActionPack.java | 12 ++++++------ src/main/java/carpet/mixins/CarpetBlockMixin.java | 7 +++---- src/main/java/carpet/mixins/ContainerMixin.java | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/gradle.properties b/gradle.properties index 192cf593..ed7ae03f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=21w05a - yarn_mappings=21w05a+build.1 + minecraft_version=21w05b + yarn_mappings=21w05b+build.14 loader_version=0.11.1 - fabric_version=0.30.0+1.17 + fabric_version=0.30.1+1.17 # Mod Properties mod_version = 1.4.25 diff --git a/src/main/java/carpet/helpers/EntityPlayerActionPack.java b/src/main/java/carpet/helpers/EntityPlayerActionPack.java index 87cb6eab..971d6647 100644 --- a/src/main/java/carpet/helpers/EntityPlayerActionPack.java +++ b/src/main/java/carpet/helpers/EntityPlayerActionPack.java @@ -312,7 +312,7 @@ public class EntityPlayerActionPack BlockHitResult blockHit = (BlockHitResult) hit; BlockPos pos = blockHit.getBlockPos(); Direction side = blockHit.getSide(); - if (pos.getY() < player.getServerWorld().getTopHeightLimit() - (side == Direction.UP ? 1 : 0) && world.canPlayerModifyAt(player, pos)) + if (pos.getY() < player.getServerWorld().getTopY() - (side == Direction.UP ? 1 : 0) && world.canPlayerModifyAt(player, pos)) { ActionResult result = player.interactionManager.interactBlock(player, world, player.getStackInHand(hand), hand, blockHit); if (result.isAccepted()) @@ -400,7 +400,7 @@ public class EntityPlayerActionPack boolean blockBroken = false; if (player.interactionManager.getGameMode().isCreative()) { - player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getServerWorld().getTopHeightLimit()); + player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getServerWorld().getTopY()); ap.blockHitDelay = 5; blockBroken = true; } @@ -408,9 +408,9 @@ public class EntityPlayerActionPack { if (ap.currentBlock != null) { - player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, side, player.getServerWorld().getTopHeightLimit()); + player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, side, player.getServerWorld().getTopY()); } - player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getServerWorld().getTopHeightLimit()); + player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getServerWorld().getTopY()); boolean notAir = !state.isAir(); if (notAir && ap.curBlockDamageMP == 0) { @@ -433,7 +433,7 @@ public class EntityPlayerActionPack ap.curBlockDamageMP += state.calcBlockBreakingDelta(player, player.world, pos); if (ap.curBlockDamageMP >= 1) { - player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, side, player.getServerWorld().getTopHeightLimit()); + player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, side, player.getServerWorld().getTopY()); ap.currentBlock = null; ap.blockHitDelay = 5; blockBroken = true; @@ -455,7 +455,7 @@ public class EntityPlayerActionPack EntityPlayerActionPack ap = ((ServerPlayerEntityInterface) player).getActionPack(); if (ap.currentBlock == null) return; player.world.setBlockBreakingInfo(-1, ap.currentBlock, -1); - player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.getServerWorld().getTopHeightLimit()); + player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.getServerWorld().getTopY()); ap.currentBlock = null; } }, diff --git a/src/main/java/carpet/mixins/CarpetBlockMixin.java b/src/main/java/carpet/mixins/CarpetBlockMixin.java index f5eafed6..32b4b481 100644 --- a/src/main/java/carpet/mixins/CarpetBlockMixin.java +++ b/src/main/java/carpet/mixins/CarpetBlockMixin.java @@ -3,13 +3,12 @@ package carpet.mixins; import carpet.utils.WoolTool; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.block.CarpetBlock; -import net.minecraft.class_5815; +import net.minecraft.block.DyedCarpetBlock; import net.minecraft.item.ItemPlacementContext; import net.minecraft.server.world.ServerWorld; import org.spongepowered.asm.mixin.Mixin; -@Mixin(class_5815.class) // WoolCarpetBlock +@Mixin(DyedCarpetBlock.class) // WoolCarpetBlock public abstract class CarpetBlockMixin extends Block { @@ -23,7 +22,7 @@ public abstract class CarpetBlockMixin extends Block BlockState state = super.getPlacementState(context); if (context.getPlayer() != null && !context.getWorld().isClient) { // getColor() - WoolTool.carpetPlacedAction(((class_5815)(Object)this).method_33635(), context.getPlayer(), context.getBlockPos(), (ServerWorld) context.getWorld()); + WoolTool.carpetPlacedAction(((DyedCarpetBlock)(Object)this).getDyeColor(), context.getPlayer(), context.getBlockPos(), (ServerWorld) context.getWorld()); } return state; } diff --git a/src/main/java/carpet/mixins/ContainerMixin.java b/src/main/java/carpet/mixins/ContainerMixin.java index 0b3125c0..83d71954 100644 --- a/src/main/java/carpet/mixins/ContainerMixin.java +++ b/src/main/java/carpet/mixins/ContainerMixin.java @@ -27,7 +27,7 @@ public abstract class ContainerMixin @Shadow @Final public DefaultedList slots; - @Inject( method = "removeStack", at = @At(value = "HEAD"), cancellable = true) + @Inject( method = "internalOnSlotClick", at = @At(value = "HEAD"), cancellable = true) private void onThrowClick( int slotId, int clickData, SlotActionType actionType, PlayerEntity playerEntity, CallbackInfoReturnable cir) { if (actionType == SlotActionType.THROW && CarpetSettings.ctrlQCraftingFix && playerEntity.getInventory().getCursorStack().isEmpty() && slotId >= 0) From ef4dc62f1fea1e3d056702887ee68907a56c6ef0 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 10 Feb 2021 23:29:42 -0400 Subject: [PATCH 028/115] 21w06a --- gradle.properties | 6 +++--- .../mixins/ChunkHolder_scarpetChunkCreationMixin.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index ed7ae03f..566c7f95 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=21w05b - yarn_mappings=21w05b+build.14 + minecraft_version=21w06a + yarn_mappings=21w06a+build.1 loader_version=0.11.1 - fabric_version=0.30.1+1.17 + fabric_version=0.30.2+1.17 # Mod Properties mod_version = 1.4.25 diff --git a/src/main/java/carpet/mixins/ChunkHolder_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/ChunkHolder_scarpetChunkCreationMixin.java index 4d80f587..39cbca4f 100644 --- a/src/main/java/carpet/mixins/ChunkHolder_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/ChunkHolder_scarpetChunkCreationMixin.java @@ -20,7 +20,7 @@ import java.util.concurrent.atomic.AtomicReferenceArray; @Mixin(ChunkHolder.class) public abstract class ChunkHolder_scarpetChunkCreationMixin implements ChunkHolderInterface { - @Shadow protected abstract void combineSavingFuture(CompletableFuture> newChunkFuture); + @Shadow protected abstract void combineSavingFuture(CompletableFuture> newChunkFuture, String type); @Shadow @Final private AtomicReferenceArray>> futuresByStatus; @@ -32,7 +32,7 @@ public abstract class ChunkHolder_scarpetChunkCreationMixin implements ChunkHold () -> Either.left(new ProtoChunk(chpos, UpgradeData.NO_UPGRADE_DATA, world)), executor ); - combineSavingFuture(completableFuture2); + combineSavingFuture(completableFuture2, "unfull"); // possible debug data futuresByStatus.set(i, completableFuture2); return completableFuture2; } From 695d66da50b70170617b43aaf68b118ddbc051b7 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 17 Feb 2021 13:18:57 -0400 Subject: [PATCH 029/115] mapping --- gradle.properties | 2 +- .../mixins/BiomeArray_getBiomeArrayMixin.java | 8 +-- .../mixins/ServerWorld_scarpetMixin.java | 4 +- .../carpet/script/utils/ShapesRenderer.java | 2 +- .../java/carpet/script/value/EntityValue.java | 52 +++++++++---------- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/gradle.properties b/gradle.properties index 4e184925..62202819 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=21w06a - yarn_mappings=21w06a+build.1 + yarn_mappings=21w06a+build.21 loader_version=0.11.1 fabric_version=0.30.2+1.17 diff --git a/src/main/java/carpet/mixins/BiomeArray_getBiomeArrayMixin.java b/src/main/java/carpet/mixins/BiomeArray_getBiomeArrayMixin.java index f0acfa6b..3c757a7f 100644 --- a/src/main/java/carpet/mixins/BiomeArray_getBiomeArrayMixin.java +++ b/src/main/java/carpet/mixins/BiomeArray_getBiomeArrayMixin.java @@ -1,12 +1,12 @@ package carpet.mixins; import carpet.fakes.BiomeArrayInterface; -import net.minecraft.class_5742; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.source.BiomeArray; +import net.minecraft.world.biome.source.BiomeCoords; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -30,9 +30,9 @@ public class BiomeArray_getBiomeArrayMixin implements BiomeArrayInterface @Override public void setBiomeAtIndex(BlockPos pos, World world, Biome what) { - int int_4 = class_5742.method_33100(pos.getX()) & HORIZONTAL_BIT_MASK; - int int_5 = MathHelper.clamp(class_5742.method_33100(pos.getY())-field_28126, 0, field_28127); - int int_6 = class_5742.method_33100(pos.getZ()) & HORIZONTAL_BIT_MASK; + int int_4 = BiomeCoords.fromBlock(pos.getX()) & HORIZONTAL_BIT_MASK; + int int_5 = MathHelper.clamp(BiomeCoords.fromBlock(pos.getY())-field_28126, 0, field_28127); + int int_6 = BiomeCoords.fromBlock(pos.getZ()) & HORIZONTAL_BIT_MASK; data[(int_5 << (HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT)) | (int_6 << HORIZONTAL_SECTION_COUNT) | int_4] = what; } } diff --git a/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java b/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java index 8cad062d..7959d320 100644 --- a/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java +++ b/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java @@ -4,7 +4,7 @@ import carpet.CarpetSettings; import carpet.fakes.ServerWorldInterface; import carpet.script.CarpetEventServer; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLike; +import net.minecraft.world.entity.EntityLike; import net.minecraft.entity.LightningEntity; import net.minecraft.server.world.ServerEntityManager; import net.minecraft.server.world.ServerWorld; @@ -43,7 +43,7 @@ public class ServerWorld_scarpetMixin implements ServerWorldInterface @Redirect(method = "addEntity", at = @At( value = "INVOKE", - target = "Lnet/minecraft/server/world/ServerEntityManager;addEntity(Lnet/minecraft/entity/EntityLike;)Z" + target = "Lnet/minecraft/server/world/ServerEntityManager;addEntity(Lnet/minecraft/world/entity/EntityLike;)Z" )) private boolean onEntityAddedToWorld(ServerEntityManager serverEntityManager, EntityLike entityLike) { diff --git a/src/main/java/carpet/script/utils/ShapesRenderer.java b/src/main/java/carpet/script/utils/ShapesRenderer.java index 03bc54aa..d3889ea1 100644 --- a/src/main/java/carpet/script/utils/ShapesRenderer.java +++ b/src/main/java/carpet/script/utils/ShapesRenderer.java @@ -10,7 +10,7 @@ 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.util.math.AffineTransformation; import net.minecraft.client.world.ClientWorld; import net.minecraft.client.render.VertexFormats; import net.minecraft.nbt.CompoundTag; diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 7ef07900..6460480a 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -19,7 +19,6 @@ import carpet.script.exception.InternalExpressionException; import com.google.common.collect.Sets; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import net.minecraft.class_5575; import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.ai.brain.Brain; import net.minecraft.entity.ai.brain.Memory; @@ -58,6 +57,7 @@ import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.text.LiteralText; import net.minecraft.util.Identifier; +import net.minecraft.util.TypeFilter; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.hit.HitResult; @@ -259,7 +259,7 @@ public class EntityValue extends Value public static class EntityClassDescriptor { - public class_5575 directType; // interface of EntityType + public TypeFilter directType; // interface of EntityType public Predicate filteringPredicate; public List> typeList; public Value listValue; @@ -271,7 +271,7 @@ public class EntityValue extends Value listValue = (types==null)?Value.NULL:ListValue.wrap(types.stream().map(et -> StringValue.of(nameFromRegistryId(Registry.ENTITY_TYPE.getId(et)))).collect(Collectors.toList())); } - EntityClassDescriptor( class_5575 type, Predicate predicate, List> types) + EntityClassDescriptor( TypeFilter type, Predicate predicate, List> types) { directType = type; filteringPredicate = predicate; @@ -284,7 +284,7 @@ public class EntityValue extends Value this(type, predicate, types.collect(Collectors.toList())); } - EntityClassDescriptor(class_5575 type, Predicate predicate, Stream> types) + EntityClassDescriptor(TypeFilter type, Predicate predicate, Stream> types) { this(type, predicate, types.collect(Collectors.toList())); } @@ -342,49 +342,49 @@ public class EntityValue extends Value ).collect(Collectors.toSet()); - put("*", new EntityClassDescriptor(class_5575.method_31795(Entity.class), e -> true, allTypes) ); - put("valid", new EntityClassDescriptor(class_5575.method_31795(Entity.class), EntityPredicates.VALID_ENTITY, allTypes)); - put("!valid", new EntityClassDescriptor(class_5575.method_31795(Entity.class), e -> !e.isAlive(), allTypes)); + put("*", new EntityClassDescriptor(TypeFilter.instanceOf(Entity.class), e -> true, allTypes) ); + put("valid", new EntityClassDescriptor(TypeFilter.instanceOf(Entity.class), EntityPredicates.VALID_ENTITY, allTypes)); + put("!valid", new EntityClassDescriptor(TypeFilter.instanceOf(Entity.class), e -> !e.isAlive(), allTypes)); - put("living", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), EntityPredicates.VALID_ENTITY, allTypes.stream().filter(living::contains))); - put("!living", new EntityClassDescriptor(class_5575.method_31795(Entity.class), (e) -> (!(e instanceof LivingEntity) && e.isAlive()), allTypes.stream().filter(et -> !living.contains(et)))); + put("living", new EntityClassDescriptor(TypeFilter.instanceOf(LivingEntity.class), EntityPredicates.VALID_ENTITY, allTypes.stream().filter(living::contains))); + put("!living", new EntityClassDescriptor(TypeFilter.instanceOf(Entity.class), (e) -> (!(e instanceof LivingEntity) && e.isAlive()), allTypes.stream().filter(et -> !living.contains(et)))); - put("projectile", new EntityClassDescriptor(class_5575.method_31795(ProjectileEntity.class), EntityPredicates.VALID_ENTITY, allTypes.stream().filter(projectiles::contains))); - put("!projectile", new EntityClassDescriptor(class_5575.method_31795(Entity.class), (e) -> (!(e instanceof ProjectileEntity) && e.isAlive()), allTypes.stream().filter(et -> !projectiles.contains(et) && !living.contains(et)))); + put("projectile", new EntityClassDescriptor(TypeFilter.instanceOf(ProjectileEntity.class), EntityPredicates.VALID_ENTITY, allTypes.stream().filter(projectiles::contains))); + put("!projectile", new EntityClassDescriptor(TypeFilter.instanceOf(Entity.class), (e) -> (!(e instanceof ProjectileEntity) && e.isAlive()), allTypes.stream().filter(et -> !projectiles.contains(et) && !living.contains(et)))); - put("minecarts", new EntityClassDescriptor(class_5575.method_31795(AbstractMinecartEntity.class), EntityPredicates.VALID_ENTITY, allTypes.stream().filter(minecarts::contains))); - put("!minecarts", new EntityClassDescriptor(class_5575.method_31795(Entity.class), (e) -> (!(e instanceof AbstractMinecartEntity) && e.isAlive()), allTypes.stream().filter(et -> !minecarts.contains(et) && !living.contains(et)))); + put("minecarts", new EntityClassDescriptor(TypeFilter.instanceOf(AbstractMinecartEntity.class), EntityPredicates.VALID_ENTITY, allTypes.stream().filter(minecarts::contains))); + put("!minecarts", new EntityClassDescriptor(TypeFilter.instanceOf(Entity.class), (e) -> (!(e instanceof AbstractMinecartEntity) && e.isAlive()), allTypes.stream().filter(et -> !minecarts.contains(et) && !living.contains(et)))); // combat groups - put("arthropod", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() == EntityGroup.ARTHROPOD && e.isAlive()), allTypes.stream().filter(arthropods::contains))); - put("!arthropod", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() != EntityGroup.ARTHROPOD && e.isAlive()), allTypes.stream().filter(et -> !arthropods.contains(et) && living.contains(et)))); + put("arthropod", new EntityClassDescriptor(TypeFilter.instanceOf(LivingEntity.class), e -> (((LivingEntity) e).getGroup() == EntityGroup.ARTHROPOD && e.isAlive()), allTypes.stream().filter(arthropods::contains))); + put("!arthropod", new EntityClassDescriptor(TypeFilter.instanceOf(LivingEntity.class), e -> (((LivingEntity) e).getGroup() != EntityGroup.ARTHROPOD && e.isAlive()), allTypes.stream().filter(et -> !arthropods.contains(et) && living.contains(et)))); - put("undead", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() == EntityGroup.UNDEAD && e.isAlive()), allTypes.stream().filter(undeads::contains))); - put("!undead", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() != EntityGroup.UNDEAD && e.isAlive()), allTypes.stream().filter(et -> !undeads.contains(et) && living.contains(et)))); + put("undead", new EntityClassDescriptor(TypeFilter.instanceOf(LivingEntity.class), e -> (((LivingEntity) e).getGroup() == EntityGroup.UNDEAD && e.isAlive()), allTypes.stream().filter(undeads::contains))); + put("!undead", new EntityClassDescriptor(TypeFilter.instanceOf(LivingEntity.class), e -> (((LivingEntity) e).getGroup() != EntityGroup.UNDEAD && e.isAlive()), allTypes.stream().filter(et -> !undeads.contains(et) && living.contains(et)))); - put("aquatic", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() == EntityGroup.AQUATIC && e.isAlive()), allTypes.stream().filter(aquatique::contains))); - put("!aquatic", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() != EntityGroup.AQUATIC && e.isAlive()), allTypes.stream().filter(et -> !aquatique.contains(et) && living.contains(et)))); + put("aquatic", new EntityClassDescriptor(TypeFilter.instanceOf(LivingEntity.class), e -> (((LivingEntity) e).getGroup() == EntityGroup.AQUATIC && e.isAlive()), allTypes.stream().filter(aquatique::contains))); + put("!aquatic", new EntityClassDescriptor(TypeFilter.instanceOf(LivingEntity.class), e -> (((LivingEntity) e).getGroup() != EntityGroup.AQUATIC && e.isAlive()), allTypes.stream().filter(et -> !aquatique.contains(et) && living.contains(et)))); - put("illager", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() == EntityGroup.ILLAGER && e.isAlive()), allTypes.stream().filter(illagers::contains))); - put("!illager", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() != EntityGroup.ILLAGER && e.isAlive()), allTypes.stream().filter(et -> !illagers.contains(et) && living.contains(et)))); + put("illager", new EntityClassDescriptor(TypeFilter.instanceOf(LivingEntity.class), e -> (((LivingEntity) e).getGroup() == EntityGroup.ILLAGER && e.isAlive()), allTypes.stream().filter(illagers::contains))); + put("!illager", new EntityClassDescriptor(TypeFilter.instanceOf(LivingEntity.class), e -> (((LivingEntity) e).getGroup() != EntityGroup.ILLAGER && e.isAlive()), allTypes.stream().filter(et -> !illagers.contains(et) && living.contains(et)))); - put("regular", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() == EntityGroup.DEFAULT && e.isAlive()), allTypes.stream().filter(regular::contains))); - put("!regular", new EntityClassDescriptor(class_5575.method_31795(LivingEntity.class), e -> (((LivingEntity) e).getGroup() != EntityGroup.DEFAULT && e.isAlive()), allTypes.stream().filter(et -> !regular.contains(et) && living.contains(et)))); + put("regular", new EntityClassDescriptor(TypeFilter.instanceOf(LivingEntity.class), e -> (((LivingEntity) e).getGroup() == EntityGroup.DEFAULT && e.isAlive()), allTypes.stream().filter(regular::contains))); + put("!regular", new EntityClassDescriptor(TypeFilter.instanceOf(LivingEntity.class), e -> (((LivingEntity) e).getGroup() != EntityGroup.DEFAULT && e.isAlive()), allTypes.stream().filter(et -> !regular.contains(et) && living.contains(et)))); for (Identifier typeId : Registry.ENTITY_TYPE.getIds()) { EntityType type = Registry.ENTITY_TYPE.get(typeId); String mobType = ValueConversions.simplify(typeId); put( mobType, new EntityClassDescriptor(type, EntityPredicates.VALID_ENTITY, Stream.of(type))); - put("!"+mobType, new EntityClassDescriptor(class_5575.method_31795(Entity.class), (e) -> e.getType() != type && e.isAlive(), allTypes.stream().filter(et -> et != type))); + put("!"+mobType, new EntityClassDescriptor(TypeFilter.instanceOf(Entity.class), (e) -> e.getType() != type && e.isAlive(), allTypes.stream().filter(et -> et != type))); } for (SpawnGroup catId : SpawnGroup.values()) { String catStr = catId.getName(); - put( catStr, new EntityClassDescriptor(class_5575.method_31795(Entity.class), e -> ((e.getType().getSpawnGroup() == catId) && e.isAlive()), allTypes.stream().filter(et -> et.getSpawnGroup() == catId))); - put("!"+catStr, new EntityClassDescriptor(class_5575.method_31795(Entity.class), e -> ((e.getType().getSpawnGroup() != catId) && e.isAlive()), allTypes.stream().filter(et -> et.getSpawnGroup() != catId))); + put( catStr, new EntityClassDescriptor(TypeFilter.instanceOf(Entity.class), e -> ((e.getType().getSpawnGroup() == catId) && e.isAlive()), allTypes.stream().filter(et -> et.getSpawnGroup() == catId))); + put("!"+catStr, new EntityClassDescriptor(TypeFilter.instanceOf(Entity.class), e -> ((e.getType().getSpawnGroup() != catId) && e.isAlive()), allTypes.stream().filter(et -> et.getSpawnGroup() != catId))); } }}; } From 6d320866e6b2acb744f6841c29998bde7c6a0dac Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 17 Feb 2021 20:17:01 -0400 Subject: [PATCH 030/115] 21w07a --- gradle.properties | 6 +++--- .../mixins/ArmorStandEntity_scarpetMarkerMixin.java | 2 +- .../mixins/PistonBlockEntity_movableTEMixin.java | 8 ++++---- .../StructureBlockBlockEntity_limitsMixin.java | 8 +++++--- src/main/java/carpet/script/api/WorldAccess.java | 2 +- src/main/java/carpet/script/value/BlockValue.java | 2 +- src/main/java/carpet/script/value/EntityValue.java | 12 ++++++------ 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/gradle.properties b/gradle.properties index 62202819..8ef29394 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=21w06a - yarn_mappings=21w06a+build.21 + minecraft_version=21w07a + yarn_mappings=21w07a+build.1 loader_version=0.11.1 - fabric_version=0.30.2+1.17 + fabric_version=0.30.5+1.17 # Mod Properties mod_version = 1.4.26 diff --git a/src/main/java/carpet/mixins/ArmorStandEntity_scarpetMarkerMixin.java b/src/main/java/carpet/mixins/ArmorStandEntity_scarpetMarkerMixin.java index 193532a6..5bb4b7c2 100644 --- a/src/main/java/carpet/mixins/ArmorStandEntity_scarpetMarkerMixin.java +++ b/src/main/java/carpet/mixins/ArmorStandEntity_scarpetMarkerMixin.java @@ -26,7 +26,7 @@ public abstract class ArmorStandEntity_scarpetMarkerMixin extends LivingEntity * Remove all markers that do not belong to any script host and not part of the global one when loaded * @param ci */ - @Inject(method = "readCustomDataFromTag", at = @At("HEAD")) + @Inject(method = "readCustomDataFromNbt", at = @At("HEAD")) private void checkScarpetMarkerUnloaded(CallbackInfo ci) { if (!world.isClient) diff --git a/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java b/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java index 093be7c3..009e134a 100644 --- a/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java @@ -127,7 +127,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple } } - @Inject(method = "fromTag", at = @At(value = "TAIL")) + @Inject(method = "readNbt", at = @At(value = "TAIL")) private void onFromTag(CompoundTag compoundTag_1, CallbackInfo ci) { if (CarpetSettings.movableBlockEntities && compoundTag_1.contains("carriedTileEntityCM", 10)) @@ -135,18 +135,18 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple if (this.pushedBlock.getBlock() instanceof BlockEntityProvider) 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(compoundTag_1.getCompound("carriedTileEntityCM")); + this.carriedBlockEntity.readNbt(compoundTag_1.getCompound("carriedTileEntityCM")); setCarriedBlockEntity(carriedBlockEntity); } } - @Inject(method = "toTag", at = @At(value = "RETURN", shift = At.Shift.BEFORE)) + @Inject(method = "writeNbt", at = @At(value = "RETURN", shift = At.Shift.BEFORE)) private void onToTag(CompoundTag compoundTag_1, CallbackInfoReturnable cir) { if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null) { //Leave name "carriedTileEntityCM" instead of "carriedBlockEntityCM" for upgrade compatibility with 1.13.2 movable TE - compoundTag_1.put("carriedTileEntityCM", this.carriedBlockEntity.toTag(new CompoundTag())); + compoundTag_1.put("carriedTileEntityCM", this.carriedBlockEntity.writeNbt(new CompoundTag())); } } } diff --git a/src/main/java/carpet/mixins/StructureBlockBlockEntity_limitsMixin.java b/src/main/java/carpet/mixins/StructureBlockBlockEntity_limitsMixin.java index c676ae56..7060b579 100644 --- a/src/main/java/carpet/mixins/StructureBlockBlockEntity_limitsMixin.java +++ b/src/main/java/carpet/mixins/StructureBlockBlockEntity_limitsMixin.java @@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant; public abstract class StructureBlockBlockEntity_limitsMixin { @ModifyConstant( - method = "fromTag", + method = "readNbt", constant = @Constant(intValue = 48) ) private int positiveLimit(int original) { @@ -23,7 +23,7 @@ public abstract class StructureBlockBlockEntity_limitsMixin } @ModifyConstant( - method = "fromTag", + method = "readNbt", constant = @Constant(intValue = -48) ) private int negativeLimit(int original) { @@ -41,7 +41,7 @@ public abstract class StructureBlockBlockEntity_limitsMixin private Block ignoredBlock(Block original) { return CarpetSettings.structureBlockIgnoredBlock; } - +/* @Environment(EnvType.CLIENT) @ModifyConstant( method = "getSquaredRenderDistance", @@ -50,4 +50,6 @@ public abstract class StructureBlockBlockEntity_limitsMixin private double outlineRenderDistanceLimit(double original) { return CarpetSettings.structureBlockOutlineDistance; } + + */ } diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index 0e7b019c..95ba3673 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -836,7 +836,7 @@ public class WorldAccess { destTag.putInt("x", targetPos.getX()); destTag.putInt("y", targetPos.getY()); destTag.putInt("z", targetPos.getZ()); - be.fromTag(destTag); + be.readNbt(destTag); be.markDirty(); success = true; } diff --git a/src/main/java/carpet/script/value/BlockValue.java b/src/main/java/carpet/script/value/BlockValue.java index e883f27f..c2825f26 100644 --- a/src/main/java/carpet/script/value/BlockValue.java +++ b/src/main/java/carpet/script/value/BlockValue.java @@ -121,7 +121,7 @@ public class BlockValue extends Value data = tag; return null; } - data = be.toTag(tag); + data = be.writeNbt(tag); return data; } return null; diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 6460480a..4d60505c 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -841,7 +841,7 @@ public class EntityValue extends Value }); put("nbt",(e, a) -> { - CompoundTag nbttagcompound = e.toTag((new CompoundTag())); + CompoundTag nbttagcompound = e.writeNbt((new CompoundTag())); if (a==null) return new NBTSerializableValue(nbttagcompound); return new NBTSerializableValue(nbttagcompound).get(a); @@ -884,7 +884,7 @@ public class EntityValue extends Value EnumSet set = EnumSet.noneOf(PlayerPositionLookS2CPacket.Flag.class); set.add(PlayerPositionLookS2CPacket.Flag.X_ROT); set.add(PlayerPositionLookS2CPacket.Flag.Y_ROT); - ((ServerPlayerEntity)e).networkHandler.teleportRequest(x, y, z, yaw, pitch, set ); + ((ServerPlayerEntity)e).networkHandler.requestTeleport(x, y, z, yaw, pitch, set ); } else { @@ -1458,7 +1458,7 @@ public class EntityValue extends Value Value tagValue = NBTSerializableValue.fromValue(v); if (tagValue instanceof NBTSerializableValue) { - e.fromTag(((NBTSerializableValue) tagValue).getCompoundTag()); + e.readNbt(((NBTSerializableValue) tagValue).getCompoundTag()); e.setUuid(uUID); } } @@ -1470,9 +1470,9 @@ public class EntityValue extends Value Value tagValue = NBTSerializableValue.fromValue(v); if (tagValue instanceof NBTSerializableValue) { - CompoundTag nbttagcompound = e.toTag((new CompoundTag())); + CompoundTag nbttagcompound = e.writeNbt((new CompoundTag())); nbttagcompound.copyFrom(((NBTSerializableValue) tagValue).getCompoundTag()); - e.fromTag(nbttagcompound); + e.readNbt(nbttagcompound); e.setUuid(uUID); } } @@ -1497,7 +1497,7 @@ public class EntityValue extends Value { if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); CompoundTag tag = new CompoundTag(); - tag.put("Data", getEntity().toTag( new CompoundTag())); + tag.put("Data", getEntity().writeNbt( new CompoundTag())); tag.put("Name", StringTag.of(Registry.ENTITY_TYPE.getId(getEntity().getType()).toString())); return tag; } From d537faae984c981c7b76fb6352c276c7e44588fa Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 17 Feb 2021 23:36:11 -0400 Subject: [PATCH 031/115] restored structureBlockOutlineDistance --- src/main/java/carpet/CarpetSettings.java | 2 +- ...ructureBlockBlockEntityRenderer_mixin.java | 21 +++++++++++++++++++ src/main/resources/carpet.mixins.json | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/main/java/carpet/mixins/StructureBlockBlockEntityRenderer_mixin.java diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 9f92ee1c..caaef34f 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -859,5 +859,5 @@ public class CarpetSettings strict = false, validate = Validator.NONNEGATIVE_NUMBER.class ) - public static double structureBlockOutlineDistance = 96d; + public static int structureBlockOutlineDistance = 96; } diff --git a/src/main/java/carpet/mixins/StructureBlockBlockEntityRenderer_mixin.java b/src/main/java/carpet/mixins/StructureBlockBlockEntityRenderer_mixin.java new file mode 100644 index 00000000..25f25786 --- /dev/null +++ b/src/main/java/carpet/mixins/StructureBlockBlockEntityRenderer_mixin.java @@ -0,0 +1,21 @@ +package carpet.mixins; + +import carpet.CarpetSettings; +import net.minecraft.block.entity.StructureBlockBlockEntity; +import net.minecraft.client.render.block.entity.BlockEntityRenderer; +import net.minecraft.client.render.block.entity.StructureBlockBlockEntityRenderer; +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.callback.CallbackInfoReturnable; + +@Mixin(StructureBlockBlockEntityRenderer.class) +public abstract class StructureBlockBlockEntityRenderer_mixin implements BlockEntityRenderer +{ + @Inject(method = "method_33893", at = @At("HEAD"), cancellable = true) + void newLimit(CallbackInfoReturnable cir) + { + if (CarpetSettings.structureBlockOutlineDistance != 96) + cir.setReturnValue(CarpetSettings.structureBlockOutlineDistance); + } +} diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index d4edc11c..21c9a8e8 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -206,6 +206,7 @@ "InGameHudMixin", "PlayerListHudMixin", "PistonBlockEntityRenderer_movableTEMixin", + "StructureBlockBlockEntityRenderer_mixin", "ClientPlayerEntity_clientCommandMixin", "WorldRenderer_fogOffMixin", "WorldRenderer_creativeNoClipMixin", From 2cf403057c9eecadc5229a94bc3fdb9db662e46b Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 24 Feb 2021 18:25:16 -0400 Subject: [PATCH 032/115] 21w08a - rework on handling /log packets - rework on player attack and interaction with entities - rework display_title (need recheck) - rework packets for structure blocks --- gradle.properties | 8 ++-- .../fakes/StructureFeatureInterface.java | 2 +- .../java/carpet/helpers/FeatureGenerator.java | 6 +-- .../java/carpet/logging/HUDController.java | 20 +++++--- .../PlayerEntity_scarpetEventsMixin.java | 23 +++++++++ ...PlayNetworkHandler_scarpetEventsMixin.java | 8 ++-- .../carpet/mixins/StructureFeatureMixin.java | 10 ++-- .../UpdateStructureBlockC2SPacketMixin.java | 2 +- .../carpet/patches/EntityPlayerMPFake.java | 2 +- .../java/carpet/script/api/Auxiliary.java | 48 ++++++++++++++----- .../java/carpet/script/api/WorldAccess.java | 2 +- src/main/java/carpet/utils/BlockInfo.java | 5 +- 12 files changed, 95 insertions(+), 41 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5acaab5a..4502d343 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=21w07a - yarn_mappings=21w07a+build.1 - loader_version=0.11.1 - fabric_version=0.30.5+1.17 + minecraft_version=21w08a + yarn_mappings=21w08a+build.1 + loader_version=0.11.2 + fabric_version=0.31.1+1.17 # Mod Properties mod_version = 1.4.27 diff --git a/src/main/java/carpet/fakes/StructureFeatureInterface.java b/src/main/java/carpet/fakes/StructureFeatureInterface.java index b54d3364..75d34585 100644 --- a/src/main/java/carpet/fakes/StructureFeatureInterface.java +++ b/src/main/java/carpet/fakes/StructureFeatureInterface.java @@ -13,5 +13,5 @@ import net.minecraft.world.gen.feature.FeatureConfig; public interface StructureFeatureInterface { boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly,Biome biome, FeatureConfig config); - boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView); + boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, ChunkPos chpos, Biome biome, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView); } diff --git a/src/main/java/carpet/helpers/FeatureGenerator.java b/src/main/java/carpet/helpers/FeatureGenerator.java index 40bda4b9..5096e62c 100644 --- a/src/main/java/carpet/helpers/FeatureGenerator.java +++ b/src/main/java/carpet/helpers/FeatureGenerator.java @@ -158,12 +158,12 @@ public class FeatureGenerator ChunkPos chunkPos2 = structure.getStartChunk(params, seed, chunkRandom, chunkPos.x, chunkPos.z); //find some chunk I guess // using here world for heightview, rather than chunk since we - unlike vanilla, want to avoid creating any chunks even on the // structure starts level - lets see where would that take us. - if (chunkPos.x == chunkPos2.x && chunkPos.z == chunkPos2.z && ((StructureFeatureInterface)structure).shouldStartPublicAt(generator, generator.getBiomeSource(), seed, chunkRandom, chunkPos.x, chunkPos.z, biome, chunkPos, configuredFeature.config, world)) // should start at + if (chunkPos.x == chunkPos2.x && chunkPos.z == chunkPos2.z && ((StructureFeatureInterface)structure).shouldStartPublicAt(generator, generator.getBiomeSource(), seed, chunkRandom, chunkPos, biome, chunkPos, configuredFeature.config, world)) // should start at { if (!computeBox) return StructureStart.DEFAULT; StructureManager manager = world.getStructureManager(); - StructureStart structureStart3 = structure.getStructureStartFactory().create((StructureFeature) configuredFeature.feature, chunkPos.x, chunkPos.z, BlockBox.empty(), 0, seed); - structureStart3.init(world.getRegistryManager(), generator, manager, chunkPos.x, chunkPos.z, biome, (T) configuredFeature.config, world); + StructureStart structureStart3 = structure.getStructureStartFactory().create((StructureFeature) configuredFeature.feature, chunkPos, BlockBox.empty(), 0, seed); + structureStart3.init(world.getRegistryManager(), generator, manager, chunkPos, biome, (T) configuredFeature.config, world); if (!structureStart3.hasChildren()) return null; return structureStart3; } diff --git a/src/main/java/carpet/logging/HUDController.java b/src/main/java/carpet/logging/HUDController.java index 88b3a3ee..4919cf9f 100644 --- a/src/main/java/carpet/logging/HUDController.java +++ b/src/main/java/carpet/logging/HUDController.java @@ -6,7 +6,9 @@ import carpet.logging.logHelpers.PacketCounter; import carpet.mixins.PlayerListHeaderS2CPacketMixin; import carpet.utils.Messenger; import carpet.utils.SpawnReporter; +import io.netty.buffer.Unpooled; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.network.PacketByteBuf; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.network.packet.s2c.play.PlayerListHeaderS2CPacket; import net.minecraft.server.MinecraftServer; @@ -53,9 +55,10 @@ public class HUDController } public static void clear_player(PlayerEntity player) { - PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket(); - ((PlayerListHeaderS2CPacketMixin)packet).setHeader(new LiteralText("")); - ((PlayerListHeaderS2CPacketMixin)packet).setFooter(new LiteralText("")); + PacketByteBuf packetData = new PacketByteBuf(Unpooled.buffer()).writeText(new LiteralText("")).writeText(new LiteralText("")); + PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket(packetData); + //((PlayerListHeaderS2CPacketMixin)packet).setHeader(new LiteralText("")); + //((PlayerListHeaderS2CPacketMixin)packet).setFooter(new LiteralText("")); ((ServerPlayerEntity)player).networkHandler.sendPacket(packet); } @@ -99,9 +102,14 @@ public class HUDController for (PlayerEntity player: player_huds.keySet()) { - PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket(); - ((PlayerListHeaderS2CPacketMixin)packet).setHeader(new LiteralText("")); - ((PlayerListHeaderS2CPacketMixin)packet).setFooter(Messenger.c(player_huds.get(player).toArray(new Object[0]))); + PacketByteBuf packetData = new PacketByteBuf(Unpooled.buffer()). + writeText(new LiteralText("")). + writeText(Messenger.c(player_huds.get(player).toArray(new Object[0]))); + PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket(packetData); + + //PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket(); + //((PlayerListHeaderS2CPacketMixin)packet).setHeader(new LiteralText("")); + //((PlayerListHeaderS2CPacketMixin)packet).setFooter(Messenger.c(player_huds.get(player).toArray(new Object[0]))); ((ServerPlayerEntity)player).networkHandler.sendPacket(packet); } } diff --git a/src/main/java/carpet/mixins/PlayerEntity_scarpetEventsMixin.java b/src/main/java/carpet/mixins/PlayerEntity_scarpetEventsMixin.java index e997f533..3f98fb79 100644 --- a/src/main/java/carpet/mixins/PlayerEntity_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/PlayerEntity_scarpetEventsMixin.java @@ -8,14 +8,19 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; import net.minecraft.world.World; 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.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import static carpet.script.CarpetEventServer.Event.PLAYER_ATTACKS_ENTITY; import static carpet.script.CarpetEventServer.Event.PLAYER_DEALS_DAMAGE; +import static carpet.script.CarpetEventServer.Event.PLAYER_INTERACTS_WITH_ENTITY; import static carpet.script.CarpetEventServer.Event.PLAYER_TAKES_DAMAGE; import static carpet.script.CarpetEventServer.Event.PLAYER_COLLIDES_WITH_ENTITY; @@ -53,4 +58,22 @@ public abstract class PlayerEntity_scarpetEventsMixin extends LivingEntity PLAYER_COLLIDES_WITH_ENTITY.onEntityHandAction((ServerPlayerEntity)(Object)this, entity, null); } } + + @Inject(method = "interact", at = @At("HEAD")) + private void doInteract(Entity entity, Hand hand, CallbackInfoReturnable cir) + { + if (!world.isClient && PLAYER_INTERACTS_WITH_ENTITY.isNeeded()) + { + PLAYER_INTERACTS_WITH_ENTITY.onEntityHandAction((ServerPlayerEntity) (Object)this, entity, hand); + } + } + + @Inject(method = "attack", at = @At("HEAD")) + private void onAttack(Entity target, CallbackInfo ci) + { + if (!world.isClient && PLAYER_ATTACKS_ENTITY.isNeeded() && target.isAttackable()) + { + PLAYER_ATTACKS_ENTITY.onEntityHandAction((ServerPlayerEntity) (Object)this, target, null); + } + } } diff --git a/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java b/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java index cc752361..7ef22620 100644 --- a/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java @@ -225,16 +225,16 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin PLAYER_DEPLOYS_ELYTRA.onPlayerEvent(player); } - @Inject(method = "onPlayerInteractEntity", at = @At( + /*@Inject(method = "onPlayerInteractEntity", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;interact(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;" )) private void onEntityInteract(PlayerInteractEntityC2SPacket playerInteractEntityC2SPacket_1, CallbackInfo ci) { PLAYER_INTERACTS_WITH_ENTITY.onEntityHandAction(player, playerInteractEntityC2SPacket_1.getEntity(player.getServerWorld()), playerInteractEntityC2SPacket_1.getHand()); - } + }*/ - @Inject(method = "onPlayerInteractEntity", at = @At( + /*@Inject(method = "onPlayerInteractEntity", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;attack(Lnet/minecraft/entity/Entity;)V" )) @@ -242,7 +242,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin { //todo add hit and hand in the future PLAYER_ATTACKS_ENTITY.onEntityHandAction(player, playerInteractEntityC2SPacket_1.getEntity(player.getServerWorld()), null); - } + }*/ @Inject(method = "onButtonClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;updateLastActionTime()V")) private void onItemBeingPickedFromInventory(ButtonClickC2SPacket packet, CallbackInfo ci) diff --git a/src/main/java/carpet/mixins/StructureFeatureMixin.java b/src/main/java/carpet/mixins/StructureFeatureMixin.java index e9f7c9d9..62a8d2f0 100644 --- a/src/main/java/carpet/mixins/StructureFeatureMixin.java +++ b/src/main/java/carpet/mixins/StructureFeatureMixin.java @@ -29,7 +29,7 @@ public abstract class StructureFeatureMixin implements @Shadow public abstract StructureFeature.StructureStartFactory getStructureStartFactory(); - @Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, C config, HeightLimitView heightLimitView); + @Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, ChunkPos chunkPos, Biome biome, ChunkPos chunkPos2, C featureConfig, HeightLimitView heightLimitView); @Override public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly, Biome biome, FeatureConfig config) @@ -105,10 +105,10 @@ public abstract class StructureFeatureMixin implements if (biome == null) biome_1 = generator.getBiomeSource().getBiomeForNoiseGen((chunkpos.getStartX() + 9) >> 2, 0, (chunkpos.getStartZ() + 9) >> 2 ); - StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos.x, chunkpos.z, BlockBox.empty(),0,worldIn.getSeed()); + StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos, BlockBox.empty(),0,worldIn.getSeed()); if (config == null) config = new DefaultFeatureConfig(); - structurestart1.init(worldIn.getRegistryManager(), generator, worldIn.getStructureManager() , chunkpos.x, chunkpos.z, biome_1, config, ichunk); + structurestart1.init(worldIn.getRegistryManager(), generator, worldIn.getStructureManager() , chunkpos, biome_1, config, ichunk); structurestart = structurestart1.hasChildren() ? structurestart1 : StructureStart.DEFAULT; if (structurestart.hasChildren()) @@ -121,8 +121,8 @@ public abstract class StructureFeatureMixin implements } @Override - public boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView) + public boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, ChunkPos chpos, Biome biome, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView) { - return shouldStartAt(chunkGenerator, biomeSource, l, chunkRandom, i, j, biome, chunkPos, featureConfig, heightLimitView); + return shouldStartAt(chunkGenerator, biomeSource, l, chunkRandom, chpos, biome, chunkPos, featureConfig, heightLimitView); } } diff --git a/src/main/java/carpet/mixins/UpdateStructureBlockC2SPacketMixin.java b/src/main/java/carpet/mixins/UpdateStructureBlockC2SPacketMixin.java index 78509307..8cc3d3ba 100644 --- a/src/main/java/carpet/mixins/UpdateStructureBlockC2SPacketMixin.java +++ b/src/main/java/carpet/mixins/UpdateStructureBlockC2SPacketMixin.java @@ -21,7 +21,7 @@ public class UpdateStructureBlockC2SPacketMixin { private BlockPos size; @Inject( - method = "read", + method = "(Lnet/minecraft/network/PacketByteBuf;)V", at = @At("TAIL") ) private void structureBlockLimitsRead(PacketByteBuf buf, CallbackInfo ci) { diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index 39808ad4..895eca83 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -75,7 +75,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(playerShadow, (byte) (player.headYaw * 256 / 360)), playerShadow.world.getRegistryKey()); - server.getPlayerManager().sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, playerShadow)); + server.getPlayerManager().sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.class_5893.field_29136, playerShadow)); player.getServerWorld().getChunkManager().updateCameraPosition(playerShadow); return playerShadow; } diff --git a/src/main/java/carpet/script/api/Auxiliary.java b/src/main/java/carpet/script/api/Auxiliary.java index 4672a0ae..fb2f5160 100644 --- a/src/main/java/carpet/script/api/Auxiliary.java +++ b/src/main/java/carpet/script/api/Auxiliary.java @@ -36,6 +36,11 @@ import carpet.script.value.Value; import carpet.script.value.ValueConversions; import carpet.utils.Messenger; import net.minecraft.block.BlockState; +import net.minecraft.class_5888; +import net.minecraft.class_5894; +import net.minecraft.class_5903; +import net.minecraft.class_5904; +import net.minecraft.class_5905; import net.minecraft.command.DataCommandStorage; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -47,9 +52,10 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtHelper; import net.minecraft.nbt.StringTag; import net.minecraft.nbt.Tag; +import net.minecraft.network.Packet; import net.minecraft.network.packet.s2c.play.PlaySoundIdS2CPacket; -import net.minecraft.network.packet.s2c.play.TitleS2CPacket; -import net.minecraft.network.packet.s2c.play.TitleS2CPacket.Action; +//import net.minecraft.network.packet.s2c.play.TitleS2CPacket; +//import net.minecraft.network.packet.s2c.play.TitleS2CPacket.Action; import net.minecraft.particle.ParticleEffect; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; @@ -85,6 +91,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -497,6 +504,7 @@ public class Auxiliary { return (_c, _t) -> finalRes; // pass through for variables }); expression.addLazyFunction("display_title", -1, (c, t, lv) -> { + if (lv.size() < 2) throw new InternalExpressionException("'display_title' needs at least a target, type and message, and optionally times"); Value pVal = lv.get(0).evalValue(c); if (!(pVal instanceof ListValue)) pVal = ListValue.of(pVal); @@ -507,26 +515,40 @@ public class Auxiliary { if (player == null) throw new InternalExpressionException("'display_title' requires a valid online player or a list of players as first argument. "+v.getString()+" is not a player."); return player; }); - TitleS2CPacket.Action action; + Function> packetGetter; + //TitleS2CPacket.Action action; switch (lv.get(1).evalValue(c).getString().toLowerCase(Locale.ROOT)) { case "title": - action = Action.TITLE; + packetGetter = (x) -> new class_5904(x); + //action = Action.TITLE; + if (lv.size() < 3) + throw new InternalExpressionException("Third argument of 'display_title' must be present except for 'clear' type"); + break; case "subtitle": - action = Action.SUBTITLE; + packetGetter = (x) -> new class_5903(x); + if (lv.size() < 3) + throw new InternalExpressionException("Third argument of 'display_title' must be present except for 'clear' type"); + + //action = Action.SUBTITLE; break; case "actionbar": - action = Action.ACTIONBAR; + packetGetter = (x) -> new class_5894(x); + if (lv.size() < 3) + throw new InternalExpressionException("Third argument of 'display_title' must be present except for 'clear' type"); + + //action = Action.ACTIONBAR; break; case "clear": - action = Action.CLEAR; + packetGetter = (x) -> new class_5888(true); // resetting default fade + //action = Action.CLEAR; break; default: throw new InternalExpressionException("'display_title' requires 'title', 'subtitle', 'actionbar' or 'clear' as second argument"); } - if (action != Action.CLEAR && lv.size() < 3) - throw new InternalExpressionException("Third argument of 'display_title' must be present except for 'clear' type"); + //if (action != Action.CLEAR && lv.size() < 3) + // throw new InternalExpressionException("Third argument of 'display_title' must be present except for 'clear' type"); Text title = null; if (lv.size() > 2) { @@ -536,17 +558,19 @@ public class Auxiliary { else title = new LiteralText(pVal.getString()); } - TitleS2CPacket timesPacket; + class_5905 timesPacket; // TimesPacket if (lv.size() > 3) { int in = NumericValue.asNumber(lv.get(3).evalValue(c),"fade in for display_title" ).getInt(); int stay = NumericValue.asNumber(lv.get(4).evalValue(c),"stay for display_title" ).getInt(); int out = NumericValue.asNumber(lv.get(5).evalValue(c),"fade out for display_title" ).getInt(); - timesPacket = new TitleS2CPacket(Action.TIMES, null, in, stay, out); + timesPacket = new class_5905(in, stay, out); + //timesPacket = new TitleS2CPacket(Action.TIMES, null, in, stay, out); } else timesPacket = null; - TitleS2CPacket packet = new TitleS2CPacket(action, title); + Packet packet = packetGetter.apply(title); + //TitleS2CPacket packet = new TitleS2CPacket(action, title); AtomicInteger total = new AtomicInteger(0); targets.forEach(p -> { if (timesPacket != null) p.networkHandler.sendPacket(timesPacket); diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index 95ba3673..e190bb3a 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -1356,7 +1356,7 @@ public class WorldAccess { return; } StructureStart start = structures.get(structure); - ChunkPos structureChunkPos = new ChunkPos(start.getChunkX(), start.getChunkZ()); + ChunkPos structureChunkPos = start.method_34000(); // new ChunkPos(start.getChunkX(), start.getChunkZ()); BlockBox box = start.getBoundingBox(); for (int chx = box.minX / 16; chx <= box.maxX / 16; chx++) { diff --git a/src/main/java/carpet/utils/BlockInfo.java b/src/main/java/carpet/utils/BlockInfo.java index 2136d1a4..a3aa1886 100644 --- a/src/main/java/carpet/utils/BlockInfo.java +++ b/src/main/java/carpet/utils/BlockInfo.java @@ -4,10 +4,9 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Material; import net.minecraft.block.MapColor; -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.NoPenaltyTargeting; import net.minecraft.entity.ai.goal.WanderAroundGoal; import net.minecraft.entity.ai.pathing.NavigationType; import net.minecraft.entity.mob.PathAwareEntity; @@ -253,7 +252,7 @@ public class BlockInfo for (int i=0; i<1000; i++) { - Vec3d vec = class_5532.method_31510(creature, 10, 7); // TargetFinder.findTarget(creature, 10, 7); + Vec3d vec = NoPenaltyTargeting.find(creature, 10, 7); // TargetFinder.findTarget(creature, 10, 7); if (vec == null) { continue; From 9fb43b6095af5fc98c324f4a9a2b0a2a79ed8dad Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 2 Mar 2021 08:52:32 -0400 Subject: [PATCH 033/115] mappings --- src/main/java/carpet/commands/PlayerCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/commands/PlayerCommand.java b/src/main/java/carpet/commands/PlayerCommand.java index d38c56a3..f5677e94 100644 --- a/src/main/java/carpet/commands/PlayerCommand.java +++ b/src/main/java/carpet/commands/PlayerCommand.java @@ -274,7 +274,7 @@ public class PlayerCommand } MinecraftServer server = source.getMinecraftServer(); - if (!World.isInBuildLimit(new BlockPos(pos.x, pos.y, pos.z))) + if (!World.isValid(new BlockPos(pos.x, pos.y, pos.z))) { Messenger.m(context.getSource(), "rb Player "+playerName+" cannot be placed outside of the world"); return 0; From 3f16c45a69b5163fb78d3c856db770a30253df4e Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 2 Mar 2021 09:08:16 -0400 Subject: [PATCH 034/115] mappings --- gradle.properties | 6 ++--- .../mixins/ServerChunkManagerMixin.java | 2 +- .../java/carpet/mixins/SpawnHelperMixin.java | 2 +- .../carpet/patches/EntityPlayerMPFake.java | 2 +- .../java/carpet/script/api/Auxiliary.java | 22 +++++++++---------- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/gradle.properties b/gradle.properties index 95ff9731..e1435648 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=21w08a - yarn_mappings=21w08a+build.1 + minecraft_version=21w08b + yarn_mappings=21w08b+build.17 loader_version=0.11.2 - fabric_version=0.31.1+1.17 + fabric_version=0.31.2+1.17 # Mod Properties mod_version = 1.4.28 diff --git a/src/main/java/carpet/mixins/ServerChunkManagerMixin.java b/src/main/java/carpet/mixins/ServerChunkManagerMixin.java index c8bfcd21..3f2edb09 100644 --- a/src/main/java/carpet/mixins/ServerChunkManagerMixin.java +++ b/src/main/java/carpet/mixins/ServerChunkManagerMixin.java @@ -77,7 +77,7 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter int spawnTries = SpawnReporter.spawn_tries.get(cat); if (!SpawnReporter.local_spawns.containsKey(cat)) { - if (!cat.isAnimal() || boolean_3) + if (!cat.isRare() || boolean_3) // isAnimal { // fill mobcaps for that category so spawn got cancelled SpawnReporter.spawn_ticks_full.put(key, diff --git a/src/main/java/carpet/mixins/SpawnHelperMixin.java b/src/main/java/carpet/mixins/SpawnHelperMixin.java index b4d5100d..61347721 100644 --- a/src/main/java/carpet/mixins/SpawnHelperMixin.java +++ b/src/main/java/carpet/mixins/SpawnHelperMixin.java @@ -279,7 +279,7 @@ public class SpawnHelperMixin for(int var8 = 0; var8 < var7; ++var8) { SpawnGroup entityCategory = var6[var8]; - if ((spawnAnimals || !entityCategory.isPeaceful()) && (spawnMonsters || entityCategory.isPeaceful()) && (shouldSpawnAnimals || !entityCategory.isAnimal()) ) + if ((spawnAnimals || !entityCategory.isPeaceful()) && (spawnMonsters || entityCategory.isPeaceful()) && (shouldSpawnAnimals || !entityCategory.isRare()) ) { RegistryKey dim = world.getRegistryKey(); // getDimensionType; int newCap = (int) ((double)entityCategory.getCapacity()*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4)))); diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index 895eca83..c682d437 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -75,7 +75,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(playerShadow, (byte) (player.headYaw * 256 / 360)), playerShadow.world.getRegistryKey()); - server.getPlayerManager().sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.class_5893.field_29136, playerShadow)); + server.getPlayerManager().sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.class_5893.ADD_PLAYER, playerShadow)); player.getServerWorld().getChunkManager().updateCameraPosition(playerShadow); return playerShadow; } diff --git a/src/main/java/carpet/script/api/Auxiliary.java b/src/main/java/carpet/script/api/Auxiliary.java index fb2f5160..2fcfee47 100644 --- a/src/main/java/carpet/script/api/Auxiliary.java +++ b/src/main/java/carpet/script/api/Auxiliary.java @@ -36,11 +36,6 @@ import carpet.script.value.Value; import carpet.script.value.ValueConversions; import carpet.utils.Messenger; import net.minecraft.block.BlockState; -import net.minecraft.class_5888; -import net.minecraft.class_5894; -import net.minecraft.class_5903; -import net.minecraft.class_5904; -import net.minecraft.class_5905; import net.minecraft.command.DataCommandStorage; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -53,9 +48,14 @@ import net.minecraft.nbt.NbtHelper; import net.minecraft.nbt.StringTag; import net.minecraft.nbt.Tag; import net.minecraft.network.Packet; +import net.minecraft.network.packet.s2c.play.ClearTitleS2CPacket; +import net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket; import net.minecraft.network.packet.s2c.play.PlaySoundIdS2CPacket; //import net.minecraft.network.packet.s2c.play.TitleS2CPacket; //import net.minecraft.network.packet.s2c.play.TitleS2CPacket.Action; +import net.minecraft.network.packet.s2c.play.SubtitleS2CPacket; +import net.minecraft.network.packet.s2c.play.TitleFadeS2CPacket; +import net.minecraft.network.packet.s2c.play.TitleS2CPacket; import net.minecraft.particle.ParticleEffect; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; @@ -520,28 +520,28 @@ public class Auxiliary { switch (lv.get(1).evalValue(c).getString().toLowerCase(Locale.ROOT)) { case "title": - packetGetter = (x) -> new class_5904(x); + packetGetter = TitleS2CPacket::new; //action = Action.TITLE; if (lv.size() < 3) throw new InternalExpressionException("Third argument of 'display_title' must be present except for 'clear' type"); break; case "subtitle": - packetGetter = (x) -> new class_5903(x); + packetGetter = SubtitleS2CPacket::new; if (lv.size() < 3) throw new InternalExpressionException("Third argument of 'display_title' must be present except for 'clear' type"); //action = Action.SUBTITLE; break; case "actionbar": - packetGetter = (x) -> new class_5894(x); + packetGetter = OverlayMessageS2CPacket::new; if (lv.size() < 3) throw new InternalExpressionException("Third argument of 'display_title' must be present except for 'clear' type"); //action = Action.ACTIONBAR; break; case "clear": - packetGetter = (x) -> new class_5888(true); // resetting default fade + packetGetter = (x) -> new ClearTitleS2CPacket(true); // resetting default fade //action = Action.CLEAR; break; default: @@ -558,13 +558,13 @@ public class Auxiliary { else title = new LiteralText(pVal.getString()); } - class_5905 timesPacket; // TimesPacket + TitleFadeS2CPacket timesPacket; // TimesPacket if (lv.size() > 3) { int in = NumericValue.asNumber(lv.get(3).evalValue(c),"fade in for display_title" ).getInt(); int stay = NumericValue.asNumber(lv.get(4).evalValue(c),"stay for display_title" ).getInt(); int out = NumericValue.asNumber(lv.get(5).evalValue(c),"fade out for display_title" ).getInt(); - timesPacket = new class_5905(in, stay, out); + timesPacket = new TitleFadeS2CPacket(in, stay, out); //timesPacket = new TitleS2CPacket(Action.TIMES, null, in, stay, out); } else timesPacket = null; From 170fd9d7624f4bd55df4a696bd682ff7902bd533 Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 9 Mar 2021 20:06:29 -0400 Subject: [PATCH 035/115] mappings --- gradle.properties | 4 ++-- src/main/java/carpet/helpers/FeatureGenerator.java | 2 +- src/main/java/carpet/mixins/CoralFeatureMixin.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index e1435648..569fff79 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,9 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=21w08b - yarn_mappings=21w08b+build.17 + yarn_mappings=21w08b+build.22 loader_version=0.11.2 - fabric_version=0.31.2+1.17 + fabric_version=0.32.0+1.17 # Mod Properties mod_version = 1.4.28 diff --git a/src/main/java/carpet/helpers/FeatureGenerator.java b/src/main/java/carpet/helpers/FeatureGenerator.java index 5096e62c..401e9e7b 100644 --- a/src/main/java/carpet/helpers/FeatureGenerator.java +++ b/src/main/java/carpet/helpers/FeatureGenerator.java @@ -24,7 +24,7 @@ import net.minecraft.world.biome.source.BiomeAccess; import net.minecraft.world.gen.ChunkRandom; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.StructureConfig; -import net.minecraft.world.gen.tree.BeehiveTreeDecorator; +import net.minecraft.world.gen.treedecorator.BeehiveTreeDecorator; import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredFeatures; import net.minecraft.world.gen.feature.ConfiguredStructureFeature; diff --git a/src/main/java/carpet/mixins/CoralFeatureMixin.java b/src/main/java/carpet/mixins/CoralFeatureMixin.java index 2271bffd..41b88df0 100644 --- a/src/main/java/carpet/mixins/CoralFeatureMixin.java +++ b/src/main/java/carpet/mixins/CoralFeatureMixin.java @@ -15,11 +15,11 @@ import java.util.Random; public abstract class CoralFeatureMixin implements CoralFeatureInterface { - @Shadow protected abstract boolean spawnCoral(WorldAccess var1, Random var2, BlockPos var3, BlockState var4); + @Shadow protected abstract boolean generateCoral(WorldAccess var1, Random var2, BlockPos var3, BlockState var4); @Override public boolean growSpecific(World worldIn, Random random, BlockPos pos, BlockState blockUnder) { - return spawnCoral(worldIn, random, pos, blockUnder); + return generateCoral(worldIn, random, pos, blockUnder); } } From 42f78a596a916bb4ed84849b6816c7cd0312662b Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 10 Mar 2021 23:13:59 -0400 Subject: [PATCH 036/115] 20w10a - broken scarpet shapes --- gradle.properties | 6 +-- .../java/carpet/commands/ScriptCommand.java | 4 +- .../java/carpet/helpers/FeatureGenerator.java | 2 +- .../java/carpet/mixins/ContainerMixin.java | 15 ++++--- .../PlayerManager_scarpetEventsMixin.java | 6 ++- ...PlayNetworkHandler_scarpetEventsMixin.java | 2 +- .../ServerPlayerEntity_scarpetEventMixin.java | 2 +- ...StructureBlockBlockEntity_limitsMixin.java | 2 +- .../TradeOutputSlot_scarpetEventMixin.java | 3 +- .../UpdateStructureBlockC2SPacketMixin.java | 5 ++- .../WorldRenderer_scarpetRenderMixin.java | 16 ++++--- .../carpet/patches/EntityPlayerMPFake.java | 2 +- .../carpet/script/bundled/FileModule.java | 4 +- .../carpet/script/utils/ShapesRenderer.java | 45 +++++++++++-------- .../java/carpet/script/utils/WorldTools.java | 4 ++ .../java/carpet/utils/FabricAPIHooks.java | 8 ++-- 16 files changed, 78 insertions(+), 48 deletions(-) diff --git a/gradle.properties b/gradle.properties index 569fff79..1aa00f0a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=21w08b - yarn_mappings=21w08b+build.22 + minecraft_version=21w10a + yarn_mappings=21w10a+build.1 loader_version=0.11.2 - fabric_version=0.32.0+1.17 + fabric_version=0.32.1+1.17 # Mod Properties mod_version = 1.4.28 diff --git a/src/main/java/carpet/commands/ScriptCommand.java b/src/main/java/carpet/commands/ScriptCommand.java index 75030545..4d841f01 100644 --- a/src/main/java/carpet/commands/ScriptCommand.java +++ b/src/main/java/carpet/commands/ScriptCommand.java @@ -468,7 +468,7 @@ public class ScriptCommand { ServerCommandSource source = context.getSource(); CarpetScriptHost host = getHost(context); - BlockBox area = new BlockBox(a, b); + BlockBox area = BlockBox.method_34390(a, b); CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin); int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ(); if (int_1 > CarpetSettings.fillLimit) @@ -517,7 +517,7 @@ public class ScriptCommand { ServerCommandSource source = context.getSource(); CarpetScriptHost host = getHost(context); - BlockBox area = new BlockBox(a, b); + BlockBox area = BlockBox.method_34390(a, b); // create CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin); int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ(); if (int_1 > CarpetSettings.fillLimit) diff --git a/src/main/java/carpet/helpers/FeatureGenerator.java b/src/main/java/carpet/helpers/FeatureGenerator.java index 401e9e7b..c2fd2be0 100644 --- a/src/main/java/carpet/helpers/FeatureGenerator.java +++ b/src/main/java/carpet/helpers/FeatureGenerator.java @@ -113,7 +113,7 @@ public class FeatureGenerator private static Thing simpleTree(TreeFeatureConfig config) { - config.ignoreFluidCheck(); + //config.ignoreFluidCheck(); return simplePlop(Feature.TREE.configure(config)); } diff --git a/src/main/java/carpet/mixins/ContainerMixin.java b/src/main/java/carpet/mixins/ContainerMixin.java index 83d71954..01905693 100644 --- a/src/main/java/carpet/mixins/ContainerMixin.java +++ b/src/main/java/carpet/mixins/ContainerMixin.java @@ -13,6 +13,7 @@ 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.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.List; @@ -21,16 +22,20 @@ import java.util.List; public abstract class ContainerMixin { - @Shadow public abstract ItemStack onSlotClick(int int_1, int int_2, SlotActionType slotActionType_1, PlayerEntity playerEntity_1); + @Shadow public abstract void onSlotClick(int int_1, int int_2, SlotActionType slotActionType_1, PlayerEntity playerEntity_1); @Shadow public abstract void sendContentUpdates(); @Shadow @Final public DefaultedList slots; + @Shadow protected abstract void endQuickCraft(); + + @Shadow public abstract ItemStack method_34255(); + @Inject( method = "internalOnSlotClick", at = @At(value = "HEAD"), cancellable = true) - private void onThrowClick( int slotId, int clickData, SlotActionType actionType, PlayerEntity playerEntity, CallbackInfoReturnable cir) + private void onThrowClick(int slotId, int clickData, SlotActionType actionType, PlayerEntity playerEntity, CallbackInfo ci) { - if (actionType == SlotActionType.THROW && CarpetSettings.ctrlQCraftingFix && playerEntity.getInventory().getCursorStack().isEmpty() && slotId >= 0) + if (actionType == SlotActionType.THROW && CarpetSettings.ctrlQCraftingFix && this.method_34255().isEmpty() /* playerEntity.getInventory().getCursorStack().isEmpty()*/ && slotId >= 0) { ItemStack itemStack_1 = ItemStack.EMPTY; Slot slot_4 = slots.get(slotId); @@ -44,8 +49,8 @@ public abstract class ContainerMixin this.onSlotClick(slotId, 0, SlotActionType.THROW, playerEntity); } this.sendContentUpdates(); - cir.setReturnValue(itemStack_1); - cir.cancel(); + this.endQuickCraft(); + ci.cancel(); } } } diff --git a/src/main/java/carpet/mixins/PlayerManager_scarpetEventsMixin.java b/src/main/java/carpet/mixins/PlayerManager_scarpetEventsMixin.java index 0d2d1c96..9da0d4e9 100644 --- a/src/main/java/carpet/mixins/PlayerManager_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/PlayerManager_scarpetEventsMixin.java @@ -19,7 +19,11 @@ public class PlayerManager_scarpetEventsMixin PLAYER_RESPAWNS.onPlayerEvent(player); } - @Inject(method = "respawnPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;onSpawn()V")) + @Inject(method = "respawnPlayer", at = @At( + value = "INVOKE", + //target = "Lnet/minecraft/server/network/ServerPlayerEntity;onSpawn()V" + target = "Lnet/minecraft/server/network/ServerPlayerEntity;method_34225()V" + )) private void invalidatePreviousInstance(ServerPlayerEntity player, boolean alive, CallbackInfoReturnable cir) { ((ServerPlayerEntityInterface)player).invalidateEntityObjectReference(); diff --git a/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java b/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java index 7ef22620..c1f91226 100644 --- a/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java @@ -51,7 +51,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin { @Shadow public ServerPlayerEntity player; - @Inject(method = "onPlayerInput", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;method_14218(FFZZ)V")) + @Inject(method = "onPlayerInput", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;updateInput(FFZZ)V")) private void checkMoves(PlayerInputC2SPacket p, CallbackInfo ci) { if (PLAYER_RIDES.isNeeded() && (p.getSideways() != 0.0F || p.getForward() != 0.0F || p.isJumping() || p.isSneaking())) diff --git a/src/main/java/carpet/mixins/ServerPlayerEntity_scarpetEventMixin.java b/src/main/java/carpet/mixins/ServerPlayerEntity_scarpetEventMixin.java index 511d56dc..b1b375f9 100644 --- a/src/main/java/carpet/mixins/ServerPlayerEntity_scarpetEventMixin.java +++ b/src/main/java/carpet/mixins/ServerPlayerEntity_scarpetEventMixin.java @@ -80,7 +80,7 @@ public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity } } - @Redirect(method = "method_14218", at = @At( + @Redirect(method = "updateInput", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;setSneaking(Z)V" )) diff --git a/src/main/java/carpet/mixins/StructureBlockBlockEntity_limitsMixin.java b/src/main/java/carpet/mixins/StructureBlockBlockEntity_limitsMixin.java index 7060b579..8ff19855 100644 --- a/src/main/java/carpet/mixins/StructureBlockBlockEntity_limitsMixin.java +++ b/src/main/java/carpet/mixins/StructureBlockBlockEntity_limitsMixin.java @@ -34,7 +34,7 @@ public abstract class StructureBlockBlockEntity_limitsMixin method = "saveStructure(Z)Z", at = @At( value = "INVOKE", - target = "Lnet/minecraft/structure/Structure;saveFromWorld(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;ZLnet/minecraft/block/Block;)V" + target = "Lnet/minecraft/structure/Structure;saveFromWorld(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Vec3i;ZLnet/minecraft/block/Block;)V" ), index = 4 ) diff --git a/src/main/java/carpet/mixins/TradeOutputSlot_scarpetEventMixin.java b/src/main/java/carpet/mixins/TradeOutputSlot_scarpetEventMixin.java index 053e799b..a1f5fd18 100644 --- a/src/main/java/carpet/mixins/TradeOutputSlot_scarpetEventMixin.java +++ b/src/main/java/carpet/mixins/TradeOutputSlot_scarpetEventMixin.java @@ -11,6 +11,7 @@ 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.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @@ -25,7 +26,7 @@ public abstract class TradeOutputSlot_scarpetEventMixin { @Inject(method = "onTakeItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/village/Merchant;trade(Lnet/minecraft/village/TradeOffer;)V") ) - private void onTrade(PlayerEntity player, ItemStack stack, CallbackInfoReturnable cir) { + private void onTrade(PlayerEntity player, ItemStack stack, CallbackInfo ci) { if(PLAYER_TRADES.isNeeded() && !this.merchant.getMerchantWorld().isClient()) { PLAYER_TRADES.onTrade((ServerPlayerEntity) player, merchant, merchantInventory.getTradeOffer()); diff --git a/src/main/java/carpet/mixins/UpdateStructureBlockC2SPacketMixin.java b/src/main/java/carpet/mixins/UpdateStructureBlockC2SPacketMixin.java index 8cc3d3ba..4be905f1 100644 --- a/src/main/java/carpet/mixins/UpdateStructureBlockC2SPacketMixin.java +++ b/src/main/java/carpet/mixins/UpdateStructureBlockC2SPacketMixin.java @@ -7,6 +7,7 @@ import net.minecraft.network.PacketByteBuf; import net.minecraft.network.packet.c2s.play.UpdateStructureBlockC2SPacket; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3i; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -18,7 +19,7 @@ public class UpdateStructureBlockC2SPacketMixin { @Shadow private BlockPos offset; @Shadow - private BlockPos size; + private Vec3i size; @Inject( method = "(Lnet/minecraft/network/PacketByteBuf;)V", @@ -28,7 +29,7 @@ public class UpdateStructureBlockC2SPacketMixin { if (buf.readableBytes() == 6*4) { // This will throw an exception if carpet is not installed on client offset = new BlockPos(MathHelper.clamp(buf.readInt(), -CarpetSettings.structureBlockLimit, CarpetSettings.structureBlockLimit), MathHelper.clamp(buf.readInt(), -CarpetSettings.structureBlockLimit, CarpetSettings.structureBlockLimit), MathHelper.clamp(buf.readInt(), -CarpetSettings.structureBlockLimit, CarpetSettings.structureBlockLimit)); - size = new BlockPos(MathHelper.clamp(buf.readInt(), 0, CarpetSettings.structureBlockLimit), MathHelper.clamp(buf.readInt(), 0, CarpetSettings.structureBlockLimit), MathHelper.clamp(buf.readInt(), 0, CarpetSettings.structureBlockLimit)); + size = new Vec3i(MathHelper.clamp(buf.readInt(), 0, CarpetSettings.structureBlockLimit), MathHelper.clamp(buf.readInt(), 0, CarpetSettings.structureBlockLimit), MathHelper.clamp(buf.readInt(), 0, CarpetSettings.structureBlockLimit)); } } diff --git a/src/main/java/carpet/mixins/WorldRenderer_scarpetRenderMixin.java b/src/main/java/carpet/mixins/WorldRenderer_scarpetRenderMixin.java index ea412ab0..8f28b5cd 100644 --- a/src/main/java/carpet/mixins/WorldRenderer_scarpetRenderMixin.java +++ b/src/main/java/carpet/mixins/WorldRenderer_scarpetRenderMixin.java @@ -40,9 +40,11 @@ public class WorldRenderer_scarpetRenderMixin // in normal circumstances we want to render shapes at the very end so it appears correctly behind stuff. if (!FabricAPIHooks.WORLD_RENDER_EVENTS && CarpetClient.shapes != null && transparencyShader == null) { - RenderSystem.pushMatrix(); - CarpetClient.shapes.render(camera, tickDelta); - RenderSystem.popMatrix(); + matrices.push(); + //RenderSystem.pushMatrix(); ?? + CarpetClient.shapes.render(matrices, camera, tickDelta); + //RenderSystem.popMatrix(); ?? + matrices.pop(); } } @@ -56,9 +58,11 @@ public class WorldRenderer_scarpetRenderMixin // with fabulous graphics - stuff doesn't work this way for some reason - need to render with chunk lines. if (!FabricAPIHooks.WORLD_RENDER_EVENTS && CarpetClient.shapes != null && transparencyShader != null) { - RenderSystem.pushMatrix(); - CarpetClient.shapes.render(camera, tickDelta); - RenderSystem.popMatrix(); + matrices.push(); + //RenderSystem.pushMatrix(); + CarpetClient.shapes.render(matrices, camera, tickDelta); + //RenderSystem.popMatrix(); + matrices.pop(); } } } diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index c682d437..39808ad4 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -75,7 +75,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(playerShadow, (byte) (player.headYaw * 256 / 360)), playerShadow.world.getRegistryKey()); - server.getPlayerManager().sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.class_5893.ADD_PLAYER, playerShadow)); + server.getPlayerManager().sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, playerShadow)); player.getServerWorld().getChunkManager().updateCameraPosition(playerShadow); return playerShadow; } diff --git a/src/main/java/carpet/script/bundled/FileModule.java b/src/main/java/carpet/script/bundled/FileModule.java index 4684b0fa..263db1e1 100644 --- a/src/main/java/carpet/script/bundled/FileModule.java +++ b/src/main/java/carpet/script/bundled/FileModule.java @@ -2,7 +2,7 @@ package carpet.script.bundled; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtIo; -import net.minecraft.nbt.PositionTracker; +import net.minecraft.nbt.NbtTagSizeTracker; import net.minecraft.nbt.Tag; import net.minecraft.nbt.TagReaders; @@ -97,7 +97,7 @@ public class FileModule extends Module else { dataInput_1.readUTF(); - return TagReaders.of(byte_1).read(dataInput_1, 0, PositionTracker.DEFAULT); + return TagReaders.of(byte_1).read(dataInput_1, 0, NbtTagSizeTracker.EMPTY); } } catch (IOException ignored) diff --git a/src/main/java/carpet/script/utils/ShapesRenderer.java b/src/main/java/carpet/script/utils/ShapesRenderer.java index d3889ea1..2af4ff84 100644 --- a/src/main/java/carpet/script/utils/ShapesRenderer.java +++ b/src/main/java/carpet/script/utils/ShapesRenderer.java @@ -10,6 +10,7 @@ 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.MatrixStack; import net.minecraft.util.math.AffineTransformation; import net.minecraft.client.world.ClientWorld; import net.minecraft.client.render.VertexFormats; @@ -48,7 +49,7 @@ public class ShapesRenderer shapes = new HashMap<>(); } - public void render(Camera camera, float partialTick) + public void render(MatrixStack matrices, Camera camera, float partialTick) { //Camera camera = this.client.gameRenderer.getCamera(); ClientWorld iWorld = this.client.world; @@ -62,11 +63,11 @@ public class ShapesRenderer RenderSystem.defaultBlendFunc(); //RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO); //RenderSystem.shadeModel(7425); - RenderSystem.shadeModel(GL11.GL_FLAT); - RenderSystem.enableAlphaTest(); - RenderSystem.alphaFunc(GL11.GL_GREATER, 0.003f); + //////////RenderSystem.shadeModel(GL11.GL_FLAT); + //////////RenderSystem.enableAlphaTest(); + //////////RenderSystem.alphaFunc(GL11.GL_GREATER, 0.003f); RenderSystem.disableCull(); - RenderSystem.disableLighting(); + //////////RenderSystem.disableLighting(); RenderSystem.depthMask(false); // causes water to vanish //RenderSystem.depthMask(true); @@ -100,7 +101,7 @@ public class ShapesRenderer s -> { if ( !s.lastCall() && s.shouldRender(dimensionType)) - s.renderLines(tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick); + s.renderLines(matrices, tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick); } ); //texts @@ -109,7 +110,7 @@ public class ShapesRenderer s -> { if ( s.lastCall() && s.shouldRender(dimensionType)) - s.renderLines(tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick); + s.renderLines(matrices, tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick); } ); @@ -120,7 +121,7 @@ public class ShapesRenderer RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.enableTexture(); - RenderSystem.shadeModel(7424); + //////////////RenderSystem.shadeModel(7424); } public void addShapes(ListTag tag) @@ -184,7 +185,7 @@ public class ShapesRenderer protected MinecraftClient client; long expiryTick; double renderEpsilon = 0; - public abstract void renderLines(Tessellator tessellator, BufferBuilder builder, double cx, double cy, double cz, float partialTick ); + public abstract void renderLines(MatrixStack matrices, Tessellator tessellator, BufferBuilder builder, double cx, double cy, double cz, float partialTick ); public void renderFaces(Tessellator tessellator, BufferBuilder builder, double cx, double cy, double cz, float partialTick ) {} protected RenderedShape(MinecraftClient client, T shape) { @@ -230,8 +231,9 @@ public class ShapesRenderer } @Override - public void renderLines(Tessellator tessellator, BufferBuilder builder, double cx, double cy, double cz, float partialTick) + public void renderLines(MatrixStack matrices, Tessellator tessellator, BufferBuilder builder, double cx, double cy, double cz, float partialTick) { + /* if (shape.a == 0.0) return; Vec3d v1 = shape.relativiseRender(client.world, shape.pos, partialTick); Camera camera1 = client.gameRenderer.getCamera(); @@ -243,13 +245,17 @@ public class ShapesRenderer RenderSystem.disableCull(); else RenderSystem.enableCull(); - RenderSystem.pushMatrix(); - RenderSystem.translatef((float)(v1.x - d), (float)(v1.y - e), (float)(v1.z - f)); - RenderSystem.normal3f(0.0F, 1.0F, 0.0F); + //RenderSystem.pushMatrix(); + matrices.push(); + //RenderSystem.translatef((float)(v1.x - d), (float)(v1.y - e), (float)(v1.z - f)); + matrices.translate(v1.x - d,v1.y - e,v1.z - f); + //RenderSystem.normal3f(0.0F, 1.0F, 0.0F); + //matrices. if (shape.facing == null) { - RenderSystem.multMatrix(new Matrix4f(camera1.getRotation())); + matrices.multiply(camera1.getRotation()); + //RenderSystem.multMatrix(new Matrix4f(camera1.getRotation())); } else { @@ -258,6 +264,7 @@ public class ShapesRenderer case NORTH: break; case SOUTH: + matrices. RenderSystem.rotatef(180.0f, 0.0f, 1.0f, 0.0f); break; case EAST: @@ -301,6 +308,8 @@ public class ShapesRenderer //RenderSystem.depthFunc(515); //RenderSystem.enableAlphaTest(); //RenderSystem.alphaFunc(GL11.GL_GREATER, 0.003f); + + */ } @Override @@ -333,7 +342,7 @@ public class ShapesRenderer } @Override - public void renderLines(Tessellator tessellator, BufferBuilder bufferBuilder, double cx, double cy, double cz, float partialTick) + public void renderLines(MatrixStack matrices, Tessellator tessellator, BufferBuilder bufferBuilder, double cx, double cy, double cz, float partialTick) { if (shape.a == 0.0) return; Vec3d v1 = shape.relativiseRender(client.world, shape.from, partialTick); @@ -370,7 +379,7 @@ public class ShapesRenderer super(client, (ShapeDispatcher.Line)shape); } @Override - public void renderLines(Tessellator tessellator, BufferBuilder bufferBuilder, double cx, double cy, double cz, float partialTick) + public void renderLines(MatrixStack matrices, Tessellator tessellator, BufferBuilder bufferBuilder, double cx, double cy, double cz, float partialTick) { Vec3d v1 = shape.relativiseRender(client.world, shape.from, partialTick); Vec3d v2 = shape.relativiseRender(client.world, shape.to, partialTick); @@ -390,7 +399,7 @@ public class ShapesRenderer super(client, (ShapeDispatcher.Sphere)shape); } @Override - public void renderLines(Tessellator tessellator, BufferBuilder bufferBuilder, double cx, double cy, double cz, float partialTick) + public void renderLines(MatrixStack matrices, Tessellator tessellator, BufferBuilder bufferBuilder, double cx, double cy, double cz, float partialTick) { if (shape.a == 0.0) return; Vec3d vc = shape.relativiseRender(client.world, shape.center, partialTick); @@ -420,7 +429,7 @@ public class ShapesRenderer super(client, (ShapeDispatcher.Cylinder)shape); } @Override - public void renderLines(Tessellator tessellator, BufferBuilder bufferBuilder, double cx, double cy, double cz, float partialTick) + public void renderLines(MatrixStack matrices, Tessellator tessellator, BufferBuilder bufferBuilder, double cx, double cy, double cz, float partialTick) { if (shape.a == 0.0) return; Vec3d vc = shape.relativiseRender(client.world, shape.center, partialTick); diff --git a/src/main/java/carpet/script/utils/WorldTools.java b/src/main/java/carpet/script/utils/WorldTools.java index 4ae4559b..1fcd553d 100644 --- a/src/main/java/carpet/script/utils/WorldTools.java +++ b/src/main/java/carpet/script/utils/WorldTools.java @@ -2,6 +2,8 @@ package carpet.script.utils; import carpet.fakes.MinecraftServerInterface; import com.google.common.collect.ImmutableList; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.network.packet.s2c.play.ChunkDataS2CPacket; import net.minecraft.server.MinecraftServer; import net.minecraft.server.WorldGenerationProgressListener; @@ -154,6 +156,8 @@ public class WorldTools { @Override public void start(ChunkPos spawnPos) { } @Override public void setChunkStatus(ChunkPos pos, ChunkStatus status) { } + @Environment(EnvType.CLIENT) + @Override public void start() { } @Override public void stop() { } } diff --git a/src/main/java/carpet/utils/FabricAPIHooks.java b/src/main/java/carpet/utils/FabricAPIHooks.java index b9c49bd5..c0274419 100644 --- a/src/main/java/carpet/utils/FabricAPIHooks.java +++ b/src/main/java/carpet/utils/FabricAPIHooks.java @@ -19,9 +19,11 @@ public class FabricAPIHooks { if (WORLD_RENDER_EVENTS) { WorldRenderEvents.BEFORE_DEBUG_RENDER.register(context -> { if (CarpetClient.shapes != null) { - RenderSystem.pushMatrix(); - CarpetClient.shapes.render(context.camera(), context.tickDelta()); - RenderSystem.popMatrix(); + context.matrixStack().push(); + //RenderSystem.pushMatrix(); + CarpetClient.shapes.render(context.matrixStack(), context.camera(), context.tickDelta()); + //RenderSystem.popMatrix(); + context.matrixStack().pop(); } }); } From e19ae0ef0fc90560898d1cde41158bfea2d0712d Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 14 Mar 2021 03:20:51 -0300 Subject: [PATCH 037/115] name --- src/main/java/carpet/script/api/Scoreboards.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/script/api/Scoreboards.java b/src/main/java/carpet/script/api/Scoreboards.java index d43dede8..fb6192c5 100644 --- a/src/main/java/carpet/script/api/Scoreboards.java +++ b/src/main/java/carpet/script/api/Scoreboards.java @@ -183,7 +183,7 @@ public class Scoreboards { switch (property) { case "criterion": if(modify) { - ScoreboardCriterion criterion = ScoreboardCriterion.createStatCriterion(setValue.getString()).orElse(null); + ScoreboardCriterion criterion = ScoreboardCriterion.getOrCreateStatCriterion(setValue.getString()).orElse(null); if (criterion==null) throw new InternalExpressionException("Unknown scoreboard criterion: "+ setValue.getString()); if(objective.getCriterion().equals(criterion) || lv.size() == 1) return LazyValue.FALSE; ((Scoreboard_scarpetMixin)scoreboard).getObjectivesByCriterion().get(objective.getCriterion()).remove(objective); From 1bd6dcbf1271f89f56041b38d567b482cc408603 Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 16 Mar 2021 15:31:58 -0300 Subject: [PATCH 038/115] rework on shapes. Labels are showing up, but lines don't. --- gradle.properties | 6 +- .../java/carpet/commands/ScriptCommand.java | 4 +- ...PistonBlockEntity_playerHandlingMixin.java | 2 +- .../WorldRenderer_scarpetRenderMixin.java | 32 ++---- .../carpet/script/utils/ShapesRenderer.java | 105 ++++++++++++------ .../java/carpet/utils/FabricAPIHooks.java | 3 +- 6 files changed, 89 insertions(+), 63 deletions(-) diff --git a/gradle.properties b/gradle.properties index e7d9094a..b87c4d41 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,9 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=21w10a - yarn_mappings=21w10a+build.1 - loader_version=0.11.2 - fabric_version=0.32.1+1.17 + yarn_mappings=21w10a+build.15 + loader_version=0.11.3 + fabric_version=0.32.2+1.17 # Mod Properties mod_version = 1.4.29 diff --git a/src/main/java/carpet/commands/ScriptCommand.java b/src/main/java/carpet/commands/ScriptCommand.java index 4d841f01..ceda769d 100644 --- a/src/main/java/carpet/commands/ScriptCommand.java +++ b/src/main/java/carpet/commands/ScriptCommand.java @@ -468,7 +468,7 @@ public class ScriptCommand { ServerCommandSource source = context.getSource(); CarpetScriptHost host = getHost(context); - BlockBox area = BlockBox.method_34390(a, b); + BlockBox area = BlockBox.create(a, b); CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin); int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ(); if (int_1 > CarpetSettings.fillLimit) @@ -517,7 +517,7 @@ public class ScriptCommand { ServerCommandSource source = context.getSource(); CarpetScriptHost host = getHost(context); - BlockBox area = BlockBox.method_34390(a, b); // create + BlockBox area = BlockBox.create(a, b); CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin); int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ(); if (int_1 > CarpetSettings.fillLimit) diff --git a/src/main/java/carpet/mixins/PistonBlockEntity_playerHandlingMixin.java b/src/main/java/carpet/mixins/PistonBlockEntity_playerHandlingMixin.java index 4f5ac386..bf08598f 100644 --- a/src/main/java/carpet/mixins/PistonBlockEntity_playerHandlingMixin.java +++ b/src/main/java/carpet/mixins/PistonBlockEntity_playerHandlingMixin.java @@ -26,7 +26,7 @@ public abstract class PistonBlockEntity_playerHandlingMixin @Shadow public abstract Direction getMovementDirection(); - @Inject(method = "method_23672", at = @At("HEAD"), cancellable = true) + @Inject(method = "moveEntity", 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).getAbilities().flying) ci.cancel(); diff --git a/src/main/java/carpet/mixins/WorldRenderer_scarpetRenderMixin.java b/src/main/java/carpet/mixins/WorldRenderer_scarpetRenderMixin.java index 8f28b5cd..7ae262c0 100644 --- a/src/main/java/carpet/mixins/WorldRenderer_scarpetRenderMixin.java +++ b/src/main/java/carpet/mixins/WorldRenderer_scarpetRenderMixin.java @@ -22,8 +22,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(WorldRenderer.class) public class WorldRenderer_scarpetRenderMixin { - @Shadow private /*@Nullable*/ ShaderEffect transparencyShader; - @Inject(method = "", at = @At("RETURN")) private void addRenderers(MinecraftClient client, BufferBuilderStorage bufferBuilders, CallbackInfo ci) { @@ -32,37 +30,23 @@ public class WorldRenderer_scarpetRenderMixin @Inject(method = "render", at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/render/Camera;)V", - shift = At.Shift.AFTER + target = "Lnet/minecraft/client/render/BufferBuilderStorage;getEffectVertexConsumers()Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;", shift = At.Shift.BEFORE + //target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.AFTER + //target = "Lnet/minecraft/client/render/BackgroundRenderer;method_23792()V", shift = At.Shift.AFTER + //target = "Lnet/minecraft/client/render/BufferBuilderStorage;getEntityVertexConsumers()Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;", shift = At.Shift.AFTER + //target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.AFTER // before return )) private void renderScarpetThings(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, CallbackInfo ci) { // in normal circumstances we want to render shapes at the very end so it appears correctly behind stuff. - if (!FabricAPIHooks.WORLD_RENDER_EVENTS && CarpetClient.shapes != null && transparencyShader == null) + // we might actually not need to play with render hooks here. + if (!FabricAPIHooks.WORLD_RENDER_EVENTS && CarpetClient.shapes != null ) { matrices.push(); - //RenderSystem.pushMatrix(); ?? CarpetClient.shapes.render(matrices, camera, tickDelta); - //RenderSystem.popMatrix(); ?? matrices.pop(); - } - } + RenderSystem.applyModelViewMatrix(); - @Inject(method = "render", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/render/debug/DebugRenderer;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;DDD)V", - shift = At.Shift.AFTER - )) - private void renderScarpetThingsFabulously(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, CallbackInfo ci) - { - // with fabulous graphics - stuff doesn't work this way for some reason - need to render with chunk lines. - if (!FabricAPIHooks.WORLD_RENDER_EVENTS && CarpetClient.shapes != null && transparencyShader != null) - { - matrices.push(); - //RenderSystem.pushMatrix(); - CarpetClient.shapes.render(matrices, camera, tickDelta); - //RenderSystem.popMatrix(); - matrices.pop(); } } } diff --git a/src/main/java/carpet/script/utils/ShapesRenderer.java b/src/main/java/carpet/script/utils/ShapesRenderer.java index 2af4ff84..019018fb 100644 --- a/src/main/java/carpet/script/utils/ShapesRenderer.java +++ b/src/main/java/carpet/script/utils/ShapesRenderer.java @@ -10,19 +10,20 @@ 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.render.debug.DebugRenderer; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.math.AffineTransformation; import net.minecraft.client.world.ClientWorld; import net.minecraft.client.render.VertexFormats; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; +import net.minecraft.util.math.Box; import net.minecraft.util.math.Direction; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Matrix4f; import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.Vec3f; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; -import org.lwjgl.opengl.GL11; import java.util.HashMap; import java.util.Map; @@ -31,6 +32,7 @@ import java.util.function.BiFunction; public class ShapesRenderer { private final Map, Long2ObjectOpenHashMap>> shapes; + private final Map, Long2ObjectOpenHashMap>> labels; private MinecraftClient client; private Map>> renderedShapes @@ -47,6 +49,7 @@ public class ShapesRenderer { this.client = minecraftClient; shapes = new HashMap<>(); + labels = new HashMap<>(); } public void render(MatrixStack matrices, Camera camera, float partialTick) @@ -54,18 +57,22 @@ public class ShapesRenderer //Camera camera = this.client.gameRenderer.getCamera(); ClientWorld iWorld = this.client.world; RegistryKey dimensionType = iWorld.getRegistryKey(); - if (shapes.get(dimensionType) == null || shapes.get(dimensionType).isEmpty()) return; + if ((shapes.get(dimensionType) == null || shapes.get(dimensionType).isEmpty()) && + (labels.get(dimensionType) == null || labels.get(dimensionType).isEmpty())) return; long currentTime = client.world.getTime(); RenderSystem.disableTexture(); RenderSystem.enableDepthTest(); RenderSystem.depthFunc(515); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); + //RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO); //RenderSystem.shadeModel(7425); //////////RenderSystem.shadeModel(GL11.GL_FLAT); //////////RenderSystem.enableAlphaTest(); + //GL11.glEnable(GL11.GL_ALPHA_TEST); //////////RenderSystem.alphaFunc(GL11.GL_GREATER, 0.003f); + //GL11.glAlphaFunc(GL11.GL_GREATER, 0.003f); RenderSystem.disableCull(); //////////RenderSystem.disableLighting(); RenderSystem.depthMask(false); @@ -83,16 +90,19 @@ public class ShapesRenderer double cameraY = camera.getPos().y; double cameraZ = camera.getPos().z; - synchronized (shapes) - { + if (shapes.size() != 0) { synchronized (shapes) { shapes.get(dimensionType).long2ObjectEntrySet().removeIf( entry -> entry.getValue().isExpired(currentTime) ); + matrices.push(); + matrices.method_34425(matrices.peek().getModel()); + RenderSystem.applyModelViewMatrix(); + shapes.get(dimensionType).values().forEach( s -> { - if ( !s.lastCall() && s.shouldRender(dimensionType)) + if (s.shouldRender(dimensionType)) s.renderFaces(tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick); } ); @@ -100,21 +110,29 @@ public class ShapesRenderer shapes.get(dimensionType).values().forEach( s -> { - if ( !s.lastCall() && s.shouldRender(dimensionType)) + if (s.shouldRender(dimensionType)) s.renderLines(matrices, tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick); } ); + matrices.pop(); + RenderSystem.applyModelViewMatrix(); + }} + if (labels.size() != 0) { synchronized (labels) + { + labels.get(dimensionType).long2ObjectEntrySet().removeIf( + entry -> entry.getValue().isExpired(currentTime) + ); //texts // maybe we can move it laster to lines and makes sure we don't overpass and don't have blinky transparency problems - shapes.get(dimensionType).values().forEach( + labels.get(dimensionType).values().forEach( s -> { - if ( s.lastCall() && s.shouldRender(dimensionType)) + if (s.shouldRender(dimensionType)) s.renderLines(matrices, tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick); } ); - } + }} RenderSystem.enableCull(); RenderSystem.depthMask(true); RenderSystem.lineWidth(1.0F); @@ -147,16 +165,18 @@ public class ShapesRenderer RenderedShape rshape = shapeFactory.apply(client, shape); RegistryKey dim = shape.shapeDimension; long key = rshape.key(); - synchronized (shapes) + Map, Long2ObjectOpenHashMap>> container = + rshape.stageDeux()?labels:shapes; + synchronized (container) { - RenderedShape existing = shapes.computeIfAbsent(dim, d -> new Long2ObjectOpenHashMap<>()).get(key); + RenderedShape existing = container.computeIfAbsent(dim, d -> new Long2ObjectOpenHashMap<>()).get(key); if (existing != null) { // promoting previous shape existing.promoteWith(rshape); } else { - shapes.get(dim).put(key, rshape); + container.get(dim).put(key, rshape); } } } @@ -167,6 +187,10 @@ public class ShapesRenderer { shapes.values().forEach(Long2ObjectOpenHashMap::clear); } + synchronized (labels) + { + labels.values().forEach(Long2ObjectOpenHashMap::clear); + } } public void renewShapes() @@ -177,6 +201,12 @@ public class ShapesRenderer shape.expiryTick++; })); } + synchronized (labels) + { + labels.values().forEach(el -> el.values().forEach(shape -> { + shape.expiryTick++; + })); + } } public abstract static class RenderedShape @@ -211,7 +241,7 @@ public class ShapesRenderer if (client.world.getEntityById(shape.followEntity) == null) return false; return true; } - public boolean lastCall() + public boolean stageDeux() { return false; } @@ -233,7 +263,6 @@ public class ShapesRenderer @Override public void renderLines(MatrixStack matrices, Tessellator tessellator, BufferBuilder builder, double cx, double cy, double cz, float partialTick) { - /* if (shape.a == 0.0) return; Vec3d v1 = shape.relativiseRender(client.world, shape.pos, partialTick); Camera camera1 = client.gameRenderer.getCamera(); @@ -250,11 +279,12 @@ public class ShapesRenderer //RenderSystem.translatef((float)(v1.x - d), (float)(v1.y - e), (float)(v1.z - f)); matrices.translate(v1.x - d,v1.y - e,v1.z - f); //RenderSystem.normal3f(0.0F, 1.0F, 0.0F); - //matrices. + // not needed if (shape.facing == null) { - matrices.multiply(camera1.getRotation()); + matrices.method_34425(new Matrix4f(camera1.getRotation())); + // or better matrices.multiply(camera1.getRotation()); //RenderSystem.multMatrix(new Matrix4f(camera1.getRotation())); } else @@ -264,31 +294,40 @@ public class ShapesRenderer case NORTH: break; case SOUTH: - matrices. - RenderSystem.rotatef(180.0f, 0.0f, 1.0f, 0.0f); + matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180)); + //RenderSystem.rotatef(180.0f, 0.0f, 1.0f, 0.0f); break; case EAST: - RenderSystem.rotatef(270.0f, 0.0f, 1.0f, 0.0f); + matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(270)); + //RenderSystem.rotatef(270.0f, 0.0f, 1.0f, 0.0f); break; case WEST: - RenderSystem.rotatef(90.0f, 0.0f, 1.0f, 0.0f); + matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90)); + //RenderSystem.rotatef(90.0f, 0.0f, 1.0f, 0.0f); break; case UP: - RenderSystem.rotatef(90.0f, 1.0f, 0.0f, 0.0f); + matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90)); + //RenderSystem.rotatef(90.0f, 1.0f, 0.0f, 0.0f); break; case DOWN: - RenderSystem.rotatef(-90.0f, 1.0f, 0.0f, 0.0f); + matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(-90)); + //RenderSystem.rotatef(-90.0f, 1.0f, 0.0f, 0.0f); break; } } - RenderSystem.scalef(shape.size* 0.0025f, -shape.size*0.0025f, shape.size*0.0025f); + matrices.scale(shape.size* 0.0025f, -shape.size*0.0025f, shape.size*0.0025f); + //RenderSystem.scalef(shape.size* 0.0025f, -shape.size*0.0025f, shape.size*0.0025f); if (shape.tilt!=0.0f) { - RenderSystem.rotatef(shape.tilt, 0.0f, 0.0f, 1.0f); + matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(shape.tilt)); + //RenderSystem.rotatef(shape.tilt, 0.0f, 0.0f, 1.0f); } - RenderSystem.translatef(-10*shape.indent, -10*shape.height-9, (float) (-10*renderEpsilon)-10*shape.raise); + matrices.translate(-10*shape.indent, -10*shape.height-9, (-10*renderEpsilon)-10*shape.raise); + //RenderSystem.translatef(-10*shape.indent, -10*shape.height-9, (float) (-10*renderEpsilon)-10*shape.raise); //if (visibleThroughWalls) RenderSystem.disableDepthTest(); - RenderSystem.scalef(-1.0F, 1.0F, 1.0F); + //RenderSystem.scalef(-1.0F, 1.0F, 1.0F); + matrices.scale(-1, 1, 1); + //RenderSystem.applyModelViewMatrix(); // passed matrix directly to textRenderer.draw float text_x = 0; if (shape.align == 0) @@ -300,20 +339,23 @@ public class ShapesRenderer text_x = (float)(-textRenderer.getWidth(shape.value.getString())); } VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer()); - textRenderer.draw(shape.value, text_x, 0.0F, shape.textcolor, false, AffineTransformation.identity().getMatrix(), immediate, false, shape.textbck, 15728880); + textRenderer.draw(shape.value, text_x, 0.0F, shape.textcolor, false, matrices.peek().getModel(), /*AffineTransformation.identity().getMatrix(),*/ immediate, false, shape.textbck, 15728880); + //textRenderer.draw(shape.value, text_x, 0.0F, shape.textcolor, false, AffineTransformation.identity().getMatrix(), immediate, false, shape.textbck, 15728880); immediate.draw(); - RenderSystem.popMatrix(); + matrices.pop(); + RenderSystem.applyModelViewMatrix(); + //RenderSystem.popMatrix(); RenderSystem.enableCull(); //RenderSystem.enableDepthTest(); //RenderSystem.depthFunc(515); //RenderSystem.enableAlphaTest(); //RenderSystem.alphaFunc(GL11.GL_GREATER, 0.003f); - */ + } @Override - public boolean lastCall() + public boolean stageDeux() { return true; } @@ -348,6 +390,7 @@ public class ShapesRenderer Vec3d v1 = shape.relativiseRender(client.world, shape.from, partialTick); Vec3d v2 = shape.relativiseRender(client.world, shape.to, partialTick); RenderSystem.lineWidth(shape.lineWidth); + //DebugRenderer.drawBox(new Box(v1.x, v1.y, v1.z, v2.x, v2.y, v2.z), 0.5f, 0.5f, 0.5f, 0.5f);//shape.r, shape.g, shape.b, shape.a); drawBoxWireGLLines(tessellator, bufferBuilder, (float)(v1.x-cx-renderEpsilon), (float)(v1.y-cy-renderEpsilon), (float)(v1.z-cz-renderEpsilon), (float)(v2.x-cx+renderEpsilon), (float)(v2.y-cy+renderEpsilon), (float)(v2.z-cz+renderEpsilon), diff --git a/src/main/java/carpet/utils/FabricAPIHooks.java b/src/main/java/carpet/utils/FabricAPIHooks.java index c0274419..38c23c25 100644 --- a/src/main/java/carpet/utils/FabricAPIHooks.java +++ b/src/main/java/carpet/utils/FabricAPIHooks.java @@ -20,10 +20,9 @@ public class FabricAPIHooks { WorldRenderEvents.BEFORE_DEBUG_RENDER.register(context -> { if (CarpetClient.shapes != null) { context.matrixStack().push(); - //RenderSystem.pushMatrix(); CarpetClient.shapes.render(context.matrixStack(), context.camera(), context.tickDelta()); - //RenderSystem.popMatrix(); context.matrixStack().pop(); + RenderSystem.applyModelViewMatrix(); } }); } From 0b93101248a9336d4961fb54daac29f30a9cbb06 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 17 Mar 2021 10:42:31 -0300 Subject: [PATCH 039/115] mapping --- gradle.properties | 2 +- src/main/java/carpet/mixins/ContainerMixin.java | 4 ++-- src/main/java/carpet/script/api/Scoreboards.java | 4 ++-- src/main/java/carpet/script/argument/FileArgument.java | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index b87c4d41..55b918a5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=21w10a - yarn_mappings=21w10a+build.15 + yarn_mappings=21w10a+build.23 loader_version=0.11.3 fabric_version=0.32.2+1.17 diff --git a/src/main/java/carpet/mixins/ContainerMixin.java b/src/main/java/carpet/mixins/ContainerMixin.java index 01905693..96e650fa 100644 --- a/src/main/java/carpet/mixins/ContainerMixin.java +++ b/src/main/java/carpet/mixins/ContainerMixin.java @@ -30,12 +30,12 @@ public abstract class ContainerMixin @Shadow protected abstract void endQuickCraft(); - @Shadow public abstract ItemStack method_34255(); + @Shadow public abstract ItemStack getCursorStack(); @Inject( method = "internalOnSlotClick", at = @At(value = "HEAD"), cancellable = true) private void onThrowClick(int slotId, int clickData, SlotActionType actionType, PlayerEntity playerEntity, CallbackInfo ci) { - if (actionType == SlotActionType.THROW && CarpetSettings.ctrlQCraftingFix && this.method_34255().isEmpty() /* playerEntity.getInventory().getCursorStack().isEmpty()*/ && slotId >= 0) + if (actionType == SlotActionType.THROW && CarpetSettings.ctrlQCraftingFix && this.getCursorStack().isEmpty() && slotId >= 0) { ItemStack itemStack_1 = ItemStack.EMPTY; Slot slot_4 = slots.get(slotId); diff --git a/src/main/java/carpet/script/api/Scoreboards.java b/src/main/java/carpet/script/api/Scoreboards.java index fb6192c5..82136acb 100644 --- a/src/main/java/carpet/script/api/Scoreboards.java +++ b/src/main/java/carpet/script/api/Scoreboards.java @@ -594,12 +594,12 @@ public class Scoreboards { return LazyValue.FALSE; case "style": if(propertyValue == null) { - return (_c, _t) -> StringValue.of(bossBar.getOverlay().getName()); + return (_c, _t) -> StringValue.of(bossBar.getStyle().getName()); } BossBar.Style style = BossBar.Style.byName(propertyValue.getString()); if(style == null) throw new InternalExpressionException("'" + propertyValue.getString() + "' is not a valid value for property " + property); - bossBar.setOverlay(style); + bossBar.setStyle(style); return LazyValue.TRUE; case "value": if(propertyValue == null) return (_c, _t) -> NumericValue.of(bossBar.getValue()); diff --git a/src/main/java/carpet/script/argument/FileArgument.java b/src/main/java/carpet/script/argument/FileArgument.java index f3ad42fe..c3800fa0 100644 --- a/src/main/java/carpet/script/argument/FileArgument.java +++ b/src/main/java/carpet/script/argument/FileArgument.java @@ -11,7 +11,7 @@ import com.google.gson.JsonParser; import com.google.gson.stream.JsonReader; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtIo; -import net.minecraft.nbt.PositionTracker; +import net.minecraft.nbt.NbtTagSizeTracker; import net.minecraft.nbt.Tag; import net.minecraft.nbt.TagReaders; import net.minecraft.util.WorldSavePath; @@ -233,7 +233,7 @@ public class FileArgument else { dataInput_1.readUTF(); - return TagReaders.of(byte_1).read(dataInput_1, 0, PositionTracker.DEFAULT); + return TagReaders.of(byte_1).read(dataInput_1, 0, NbtTagSizeTracker.EMPTY); } } catch (IOException ignored) From 7d135187b106b2b730adf6c1086f8ffc905f4f6b Mon Sep 17 00:00:00 2001 From: gnembon Date: Thu, 18 Mar 2021 00:37:05 -0300 Subject: [PATCH 040/115] fixed shapes for 1.17 rendringo --- gradle.properties | 4 +- .../WorldRenderer_scarpetRenderMixin.java | 15 +- .../carpet/script/utils/ShapesRenderer.java | 155 ++++++------------ .../java/carpet/utils/FabricAPIHooks.java | 5 +- 4 files changed, 57 insertions(+), 122 deletions(-) diff --git a/gradle.properties b/gradle.properties index 55b918a5..f7d913be 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=21w10a - yarn_mappings=21w10a+build.23 + minecraft_version=21w11a + yarn_mappings=21w11a+build.2 loader_version=0.11.3 fabric_version=0.32.2+1.17 diff --git a/src/main/java/carpet/mixins/WorldRenderer_scarpetRenderMixin.java b/src/main/java/carpet/mixins/WorldRenderer_scarpetRenderMixin.java index 7ae262c0..7cb983a1 100644 --- a/src/main/java/carpet/mixins/WorldRenderer_scarpetRenderMixin.java +++ b/src/main/java/carpet/mixins/WorldRenderer_scarpetRenderMixin.java @@ -2,10 +2,7 @@ package carpet.mixins; import carpet.network.CarpetClient; import carpet.script.utils.ShapesRenderer; -import carpet.utils.FabricAPIHooks; -import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gl.ShaderEffect; import net.minecraft.client.render.BufferBuilderStorage; import net.minecraft.client.render.Camera; import net.minecraft.client.render.GameRenderer; @@ -14,7 +11,6 @@ import net.minecraft.client.render.WorldRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.Matrix4f; 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.callback.CallbackInfo; @@ -30,7 +26,9 @@ public class WorldRenderer_scarpetRenderMixin @Inject(method = "render", at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/render/BufferBuilderStorage;getEffectVertexConsumers()Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;", shift = At.Shift.BEFORE + target = "Lnet/minecraft/client/render/TexturedRenderLayers;getEntityTranslucentCull()Lnet/minecraft/client/render/RenderLayer;", shift = At.Shift.BEFORE + //target = "Lnet/minecraft/client/render/RenderLayer;getWaterMask()Lnet/minecraft/client/render/RenderLayer;", shift = At.Shift.AFTER + //target = "Lnet/minecraft/client/render/BufferBuilderStorage;getEffectVertexConsumers()Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;", shift = At.Shift.BEFORE //target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.AFTER //target = "Lnet/minecraft/client/render/BackgroundRenderer;method_23792()V", shift = At.Shift.AFTER //target = "Lnet/minecraft/client/render/BufferBuilderStorage;getEntityVertexConsumers()Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;", shift = At.Shift.AFTER @@ -40,13 +38,10 @@ public class WorldRenderer_scarpetRenderMixin { // in normal circumstances we want to render shapes at the very end so it appears correctly behind stuff. // we might actually not need to play with render hooks here. - if (!FabricAPIHooks.WORLD_RENDER_EVENTS && CarpetClient.shapes != null ) + //if (!FabricAPIHooks.WORLD_RENDER_EVENTS && CarpetClient.shapes != null ) + if (CarpetClient.shapes != null) { - matrices.push(); CarpetClient.shapes.render(matrices, camera, tickDelta); - matrices.pop(); - RenderSystem.applyModelViewMatrix(); - } } } diff --git a/src/main/java/carpet/script/utils/ShapesRenderer.java b/src/main/java/carpet/script/utils/ShapesRenderer.java index 019018fb..6795f497 100644 --- a/src/main/java/carpet/script/utils/ShapesRenderer.java +++ b/src/main/java/carpet/script/utils/ShapesRenderer.java @@ -7,19 +7,17 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.Camera; +import net.minecraft.client.render.GameRenderer; import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.VertexFormat; -import net.minecraft.client.render.debug.DebugRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.world.ClientWorld; import net.minecraft.client.render.VertexFormats; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; -import net.minecraft.util.math.Box; import net.minecraft.util.math.Direction; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Matrix4f; import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3f; import net.minecraft.util.registry.RegistryKey; @@ -62,25 +60,19 @@ public class ShapesRenderer long currentTime = client.world.getTime(); RenderSystem.disableTexture(); RenderSystem.enableDepthTest(); + RenderSystem.setShader(GameRenderer::method_34540); RenderSystem.depthFunc(515); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); - + // too bright //RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO); - //RenderSystem.shadeModel(7425); - //////////RenderSystem.shadeModel(GL11.GL_FLAT); - //////////RenderSystem.enableAlphaTest(); - //GL11.glEnable(GL11.GL_ALPHA_TEST); - //////////RenderSystem.alphaFunc(GL11.GL_GREATER, 0.003f); - //GL11.glAlphaFunc(GL11.GL_GREATER, 0.003f); + // meh + //RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); + RenderSystem.disableCull(); - //////////RenderSystem.disableLighting(); RenderSystem.depthMask(false); - // causes water to vanish - //RenderSystem.depthMask(true); //RenderSystem.polygonOffset(-3f, -3f); //RenderSystem.enablePolygonOffset(); - //Entity entity = this.client.gameRenderer.getCamera().getFocusedEntity(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuffer(); @@ -94,52 +86,40 @@ public class ShapesRenderer shapes.get(dimensionType).long2ObjectEntrySet().removeIf( entry -> entry.getValue().isExpired(currentTime) ); - - matrices.push(); - matrices.method_34425(matrices.peek().getModel()); + MatrixStack matrixStack = RenderSystem.getModelViewStack(); + matrixStack.push(); + matrixStack.method_34425(matrices.peek().getModel()); RenderSystem.applyModelViewMatrix(); - shapes.get(dimensionType).values().forEach( - s -> - { - if (s.shouldRender(dimensionType)) - s.renderFaces(tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick); - } - ); - //lines - shapes.get(dimensionType).values().forEach( - - s -> { - if (s.shouldRender(dimensionType)) - s.renderLines(matrices, tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick); - } - ); - matrices.pop(); + // lines + RenderSystem.lineWidth(0.5F); + shapes.get(dimensionType).values().forEach( s -> { + if (s.shouldRender(dimensionType)) s.renderLines(matrices, tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick); + }); + // faces + RenderSystem.lineWidth(0.1F); + shapes.get(dimensionType).values().forEach(s -> { + if (s.shouldRender(dimensionType)) s.renderFaces(tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick); + }); + RenderSystem.lineWidth(1.0F); + matrixStack.pop(); RenderSystem.applyModelViewMatrix(); + }} if (labels.size() != 0) { synchronized (labels) { labels.get(dimensionType).long2ObjectEntrySet().removeIf( entry -> entry.getValue().isExpired(currentTime) ); - //texts - // maybe we can move it laster to lines and makes sure we don't overpass and don't have blinky transparency problems - labels.get(dimensionType).values().forEach( - s -> - { - if (s.shouldRender(dimensionType)) - s.renderLines(matrices, tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick); - } - ); - + labels.get(dimensionType).values().forEach(s -> { + if (s.shouldRender(dimensionType)) s.renderLines(matrices, tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick); + }); }} RenderSystem.enableCull(); RenderSystem.depthMask(true); - RenderSystem.lineWidth(1.0F); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.enableTexture(); - //////////////RenderSystem.shadeModel(7424); } public void addShapes(ListTag tag) @@ -197,15 +177,11 @@ public class ShapesRenderer { synchronized (shapes) { - shapes.values().forEach(el -> el.values().forEach(shape -> { - shape.expiryTick++; - })); + shapes.values().forEach(el -> el.values().forEach(shape -> shape.expiryTick++)); } synchronized (labels) { - labels.values().forEach(el -> el.values().forEach(shape -> { - shape.expiryTick++; - })); + labels.values().forEach(el -> el.values().forEach(shape -> shape.expiryTick++)); } } @@ -238,8 +214,7 @@ public class ShapesRenderer if (shape.followEntity <=0 ) return true; if (client.world == null) return false; if (client.world.getRegistryKey() != dim) return false; - if (client.world.getEntityById(shape.followEntity) == null) return false; - return true; + return client.world.getEntityById(shape.followEntity) != null; } public boolean stageDeux() { @@ -267,25 +242,16 @@ public class ShapesRenderer Vec3d v1 = shape.relativiseRender(client.world, shape.pos, partialTick); Camera camera1 = client.gameRenderer.getCamera(); TextRenderer textRenderer = client.textRenderer; - double d = camera1.getPos().x; - double e = camera1.getPos().y; - double f = camera1.getPos().z; if (shape.doublesided) RenderSystem.disableCull(); else RenderSystem.enableCull(); - //RenderSystem.pushMatrix(); matrices.push(); - //RenderSystem.translatef((float)(v1.x - d), (float)(v1.y - e), (float)(v1.z - f)); - matrices.translate(v1.x - d,v1.y - e,v1.z - f); - //RenderSystem.normal3f(0.0F, 1.0F, 0.0F); - // not needed - + matrices.translate(v1.x - cx,v1.y - cy,v1.z - cz); if (shape.facing == null) { - matrices.method_34425(new Matrix4f(camera1.getRotation())); - // or better matrices.multiply(camera1.getRotation()); - //RenderSystem.multMatrix(new Matrix4f(camera1.getRotation())); + //matrices.method_34425(new Matrix4f(camera1.getRotation())); + matrices.multiply(camera1.getRotation()); } else { @@ -295,23 +261,18 @@ public class ShapesRenderer break; case SOUTH: matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180)); - //RenderSystem.rotatef(180.0f, 0.0f, 1.0f, 0.0f); break; case EAST: matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(270)); - //RenderSystem.rotatef(270.0f, 0.0f, 1.0f, 0.0f); break; case WEST: matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90)); - //RenderSystem.rotatef(90.0f, 0.0f, 1.0f, 0.0f); break; case UP: matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90)); - //RenderSystem.rotatef(90.0f, 1.0f, 0.0f, 0.0f); break; case DOWN: matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(-90)); - //RenderSystem.rotatef(-90.0f, 1.0f, 0.0f, 0.0f); break; } } @@ -320,14 +281,11 @@ public class ShapesRenderer if (shape.tilt!=0.0f) { matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(shape.tilt)); - //RenderSystem.rotatef(shape.tilt, 0.0f, 0.0f, 1.0f); } matrices.translate(-10*shape.indent, -10*shape.height-9, (-10*renderEpsilon)-10*shape.raise); - //RenderSystem.translatef(-10*shape.indent, -10*shape.height-9, (float) (-10*renderEpsilon)-10*shape.raise); //if (visibleThroughWalls) RenderSystem.disableDepthTest(); - //RenderSystem.scalef(-1.0F, 1.0F, 1.0F); matrices.scale(-1, 1, 1); - //RenderSystem.applyModelViewMatrix(); // passed matrix directly to textRenderer.draw + //RenderSystem.applyModelViewMatrix(); // passed matrix directly to textRenderer.draw, not AffineTransformation.identity().getMatrix(), float text_x = 0; if (shape.align == 0) @@ -338,20 +296,11 @@ public class ShapesRenderer { text_x = (float)(-textRenderer.getWidth(shape.value.getString())); } - VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer()); - textRenderer.draw(shape.value, text_x, 0.0F, shape.textcolor, false, matrices.peek().getModel(), /*AffineTransformation.identity().getMatrix(),*/ immediate, false, shape.textbck, 15728880); - //textRenderer.draw(shape.value, text_x, 0.0F, shape.textcolor, false, AffineTransformation.identity().getMatrix(), immediate, false, shape.textbck, 15728880); + VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(builder); + textRenderer.draw(shape.value, text_x, 0.0F, shape.textcolor, false, matrices.peek().getModel(), immediate, false, shape.textbck, 15728880); immediate.draw(); matrices.pop(); - RenderSystem.applyModelViewMatrix(); - //RenderSystem.popMatrix(); RenderSystem.enableCull(); - //RenderSystem.enableDepthTest(); - //RenderSystem.depthFunc(515); - //RenderSystem.enableAlphaTest(); - //RenderSystem.alphaFunc(GL11.GL_GREATER, 0.003f); - - } @Override @@ -389,8 +338,6 @@ public class ShapesRenderer if (shape.a == 0.0) return; Vec3d v1 = shape.relativiseRender(client.world, shape.from, partialTick); Vec3d v2 = shape.relativiseRender(client.world, shape.to, partialTick); - RenderSystem.lineWidth(shape.lineWidth); - //DebugRenderer.drawBox(new Box(v1.x, v1.y, v1.z, v2.x, v2.y, v2.z), 0.5f, 0.5f, 0.5f, 0.5f);//shape.r, shape.g, shape.b, shape.a); drawBoxWireGLLines(tessellator, bufferBuilder, (float)(v1.x-cx-renderEpsilon), (float)(v1.y-cy-renderEpsilon), (float)(v1.z-cz-renderEpsilon), (float)(v2.x-cx+renderEpsilon), (float)(v2.y-cy+renderEpsilon), (float)(v2.z-cz+renderEpsilon), @@ -404,7 +351,8 @@ public class ShapesRenderer if (shape.fa == 0.0) return; Vec3d v1 = shape.relativiseRender(client.world, shape.from, partialTick); Vec3d v2 = shape.relativiseRender(client.world, shape.to, partialTick); - RenderSystem.lineWidth(1.0F); + // consider using built-ins + //DebugRenderer.drawBox(new Box(v1.x, v1.y, v1.z, v2.x, v2.y, v2.z), 0.5f, 0.5f, 0.5f, 0.5f);//shape.r, shape.g, shape.b, shape.a); drawBoxFaces(tessellator, bufferBuilder, (float)(v1.x-cx-renderEpsilon), (float)(v1.y-cy-renderEpsilon), (float)(v1.z-cz-renderEpsilon), (float)(v2.x-cx+renderEpsilon), (float)(v2.y-cy+renderEpsilon), (float)(v2.z-cz+renderEpsilon), @@ -426,7 +374,6 @@ public class ShapesRenderer { Vec3d v1 = shape.relativiseRender(client.world, shape.from, partialTick); Vec3d v2 = shape.relativiseRender(client.world, shape.to, partialTick); - RenderSystem.lineWidth(shape.lineWidth); drawLine(tessellator, bufferBuilder, (float)(v1.x-cx-renderEpsilon), (float)(v1.y-cy-renderEpsilon), (float)(v1.z-cz-renderEpsilon), (float)(v2.x-cx+renderEpsilon), (float)(v2.y-cy+renderEpsilon), (float)(v2.z-cz+renderEpsilon), @@ -446,7 +393,6 @@ public class ShapesRenderer { if (shape.a == 0.0) return; Vec3d vc = shape.relativiseRender(client.world, shape.center, partialTick); - RenderSystem.lineWidth(shape.lineWidth); drawSphereWireframe(tessellator, bufferBuilder, (float)(vc.x-cx), (float)(vc.y-cy), (float)(vc.z-cz), (float)(shape.radius+renderEpsilon), shape.subdivisions, @@ -457,7 +403,6 @@ public class ShapesRenderer { if (shape.fa == 0.0) return; Vec3d vc = shape.relativiseRender(client.world, shape.center, partialTick); - RenderSystem.lineWidth(1.0f); drawSphereFaces(tessellator, bufferBuilder, (float)(vc.x-cx), (float)(vc.y-cy), (float)(vc.z-cz), (float)(shape.radius+renderEpsilon), shape.subdivisions, @@ -476,7 +421,6 @@ public class ShapesRenderer { if (shape.a == 0.0) return; Vec3d vc = shape.relativiseRender(client.world, shape.center, partialTick); - RenderSystem.lineWidth(shape.lineWidth); double dir = MathHelper.sign(shape.height); drawCylinderWireframe(tessellator, bufferBuilder, (float) (vc.x - cx - dir * renderEpsilon), (float) (vc.y - cy - dir * renderEpsilon), (float) (vc.z - cz - dir * renderEpsilon), @@ -490,7 +434,6 @@ public class ShapesRenderer { if (shape.fa == 0.0) return; Vec3d vc = shape.relativiseRender(client.world, shape.center, partialTick); - RenderSystem.lineWidth(1.0f); double dir = MathHelper.sign(shape.height); drawCylinderFaces(tessellator, bufferBuilder, (float) (vc.x - cx - dir * renderEpsilon), (float) (vc.y - cy - dir * renderEpsilon), (float) (vc.z - cz - dir * renderEpsilon), @@ -503,7 +446,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(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); builder.vertex(x1, y1, z1).color(red1, grn1, blu1, alpha).next(); builder.vertex(x2, y2, z2).color(red1, grn1, blu1, alpha).next(); tessellator.draw(); @@ -516,7 +459,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(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); if (xthick) { builder.vertex(x1, y1, z1).color(red1, grn2, blu2, alpha).next(); @@ -644,7 +587,7 @@ public class ShapesRenderer for (int dh = 0; dh < hsteps; dh++) { float hh = dh*hstep; - builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip + builder.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip for (int i = 0; i <= num_steps360+1; i++) { float theta = step * i; @@ -660,7 +603,7 @@ public class ShapesRenderer { for (int i = 0; i <= num_steps180; i++) { - builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip + builder.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip float theta = step * i; float x = r * MathHelper.cos(theta); @@ -676,7 +619,7 @@ public class ShapesRenderer } else { - builder.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); for (int i = 0; i <= num_steps180; i++) { float theta = step * i; @@ -694,7 +637,7 @@ public class ShapesRenderer for (int dh = 0; dh < hsteps; dh++) { float hh = dh * hstep; - builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip + builder.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip for (int i = 0; i <= num_steps360; i++) { float theta = step * i; @@ -710,7 +653,7 @@ public class ShapesRenderer { for (int i = 0; i <= num_steps180; i++) { - builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip + builder.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip float theta = step * i; float y = r * MathHelper.cos(theta); @@ -725,7 +668,7 @@ public class ShapesRenderer } else { - builder.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); for (int i = 0; i <= num_steps180; i++) { float theta = step * i; @@ -742,7 +685,7 @@ public class ShapesRenderer for (int dh = 0; dh < hsteps; dh++) { float hh = dh * hstep; - builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip + builder.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip for (int i = 0; i <= num_steps360; i++) { float theta = step * i; @@ -757,7 +700,7 @@ public class ShapesRenderer { for (int i = 0; i <= num_steps180; i++) { - builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip + builder.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip float theta = step * i; float x = r * MathHelper.cos(theta); @@ -772,7 +715,7 @@ public class ShapesRenderer } else { - builder.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); for (int i = 0; i <= num_steps180; i++) { float theta = step * i; @@ -939,7 +882,7 @@ public class ShapesRenderer int num_steps360 = (int)(2*Math.PI / step)+1; for (int i = 0; i <= num_steps360; i++) { - builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); + builder.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR); float theta = step * i ; for (int j = 0; j <= num_steps180; j++) { @@ -953,7 +896,7 @@ public class ShapesRenderer } for (int j = 0; j <= num_steps180; j++) { - builder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip + builder.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR); // line loop to line strip float phi = step * j ; for (int i = 0; i <= num_steps360; i++) diff --git a/src/main/java/carpet/utils/FabricAPIHooks.java b/src/main/java/carpet/utils/FabricAPIHooks.java index 38c23c25..5120fb70 100644 --- a/src/main/java/carpet/utils/FabricAPIHooks.java +++ b/src/main/java/carpet/utils/FabricAPIHooks.java @@ -18,11 +18,8 @@ public class FabricAPIHooks { public static void initialize() { if (WORLD_RENDER_EVENTS) { WorldRenderEvents.BEFORE_DEBUG_RENDER.register(context -> { - if (CarpetClient.shapes != null) { - context.matrixStack().push(); + if (false) {//(CarpetClient.shapes != null) { // likely won't need it. CarpetClient.shapes.render(context.matrixStack(), context.camera(), context.tickDelta()); - context.matrixStack().pop(); - RenderSystem.applyModelViewMatrix(); } }); } From e2d376f3e934a6fae2a677f9a90bb1221a52b2f2 Mon Sep 17 00:00:00 2001 From: gnembon Date: Thu, 18 Mar 2021 00:53:02 -0300 Subject: [PATCH 041/115] merge erorr --- src/main/java/carpet/script/utils/ShapesRenderer.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/carpet/script/utils/ShapesRenderer.java b/src/main/java/carpet/script/utils/ShapesRenderer.java index 0b640c94..700a5e9e 100644 --- a/src/main/java/carpet/script/utils/ShapesRenderer.java +++ b/src/main/java/carpet/script/utils/ShapesRenderer.java @@ -282,7 +282,6 @@ public class ShapesRenderer if (shape.lean!=0.0f) matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(shape.lean)); if (shape.turn!=0.0f) matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(shape.turn)); matrices.translate(-10*shape.indent, -10*shape.height-9, (-10*renderEpsilon)-10*shape.raise); - RenderSystem.translatef(-10*shape.indent, -10*shape.height-9, (float) (-10*renderEpsilon)-10*shape.raise); //if (visibleThroughWalls) RenderSystem.disableDepthTest(); matrices.scale(-1, 1, 1); //RenderSystem.applyModelViewMatrix(); // passed matrix directly to textRenderer.draw, not AffineTransformation.identity().getMatrix(), From b246bff5a86832bfcdf8e6a8c4c2ef0ba968d8d8 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 21 Mar 2021 03:35:41 -0300 Subject: [PATCH 042/115] update --- src/main/java/carpet/script/utils/SystemInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/script/utils/SystemInfo.java b/src/main/java/carpet/script/utils/SystemInfo.java index 18c69d3e..df957900 100644 --- a/src/main/java/carpet/script/utils/SystemInfo.java +++ b/src/main/java/carpet/script/utils/SystemInfo.java @@ -61,7 +61,7 @@ public class SystemInfo { put("game_mod_name", c -> StringValue.of(c.s.getMinecraftServer().getServerModName())); put("game_version", c -> StringValue.of(c.s.getMinecraftServer().getVersion())); put("game_target", c -> StringValue.of(SharedConstants.getGameVersion().getReleaseTarget())); - put("game_protocol", c -> NumericValue.of(SharedConstants.method_31372())); + put("game_protocol", c -> NumericValue.of(SharedConstants.getProtocolVersion())); put("game_major_target", c -> { String [] vers = SharedConstants.getGameVersion().getReleaseTarget().split("\\."); return NumericValue.of((vers.length > 1)?Integer.parseInt(vers[1]):0); From 365892b9cacd89b8662c9f66bc4f7519c2235d26 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 24 Mar 2021 02:22:21 -0300 Subject: [PATCH 043/115] cleaner --- .../BaseRangeDecorator_cleanLogsMixin.java | 19 +++++++++++++++++++ src/main/resources/carpet.mixins.json | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/main/java/carpet/mixins/BaseRangeDecorator_cleanLogsMixin.java diff --git a/src/main/java/carpet/mixins/BaseRangeDecorator_cleanLogsMixin.java b/src/main/java/carpet/mixins/BaseRangeDecorator_cleanLogsMixin.java new file mode 100644 index 00000000..36621ddf --- /dev/null +++ b/src/main/java/carpet/mixins/BaseRangeDecorator_cleanLogsMixin.java @@ -0,0 +1,19 @@ +package carpet.mixins; + +import carpet.CarpetSettings; +import net.minecraft.world.gen.decorator.BaseRangeDecorator; +import org.apache.logging.log4j.Logger; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(BaseRangeDecorator.class) +public class BaseRangeDecorator_cleanLogsMixin { + @Redirect(method = "getY(Lnet/minecraft/world/gen/decorator/DecoratorContext;Ljava/util/Random;Lnet/minecraft/world/gen/decorator/RangeDecoratorConfig;I)I", + at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V") + ) + private void skipLogs(Logger logger, String message, Object p0, Object p1, Object p2) + { + if (!CarpetSettings.cleanLogs) logger.warn(message, p0, p1, p2); + } +} diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index 7e4e2089..e1ed21fe 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -197,8 +197,8 @@ "PlayerEntity_creativeNoClipMixin", "PistonBlockEntity_playerHandlingMixin", "BlockItem_creativeNoClipMixin", - "LivingEntity_creativeFlyMixin" - + "LivingEntity_creativeFlyMixin", + "BaseRangeDecorator_cleanLogsMixin" ], "client": [ "RenderTickCounter_tickSpeedMixin", From ab553187c55f3a07d33564d860f641bccfbd00ef Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 24 Mar 2021 10:35:52 -0300 Subject: [PATCH 044/115] its a doozie --- gradle.properties | 4 +- .../carpet/commands/PerimeterInfoCommand.java | 4 +- .../carpet/fakes/BlockPredicateInterface.java | 4 +- .../fakes/BlockStateArgumentInterface.java | 4 +- .../java/carpet/helpers/InventoryHelper.java | 12 +- .../BaseRangeDecorator_cleanLogsMixin.java | 2 + .../BlockStateArgument_scarpetMixin.java | 6 +- .../carpet/mixins/GuardianEntityMixin.java | 4 +- .../PistonBlockEntity_movableTEMixin.java | 12 +- .../PistonHandler_customStickyMixin.java | 10 +- .../mixins/PlayerEntity_parrotMixin.java | 18 +-- .../PlayerManager_fakePlayersMixin.java | 4 +- .../java/carpet/mixins/SpawnHelperMixin.java | 6 +- .../mixins/StatePredicate_scarpetMixin.java | 6 +- .../mixins/TagPredicate_scarpetMixin.java | 6 +- .../java/carpet/network/CarpetClient.java | 12 +- .../carpet/network/ClientNetworkHandler.java | 34 ++--- .../carpet/network/ServerNetworkHandler.java | 40 +++--- .../java/carpet/script/CarpetScriptHost.java | 10 +- .../java/carpet/script/api/Auxiliary.java | 26 ++-- src/main/java/carpet/script/api/Entities.java | 4 +- .../java/carpet/script/api/Inventories.java | 7 +- .../java/carpet/script/api/WorldAccess.java | 21 ++-- .../carpet/script/argument/FileArgument.java | 20 +-- .../java/carpet/script/bundled/Module.java | 6 +- .../carpet/script/utils/ShapeDispatcher.java | 116 +++++++++--------- .../carpet/script/utils/ShapesRenderer.java | 10 +- .../java/carpet/script/value/BlockValue.java | 32 ++--- .../carpet/script/value/BooleanValue.java | 8 +- .../java/carpet/script/value/EntityValue.java | 23 ++-- .../script/value/FormattedTextValue.java | 8 +- .../carpet/script/value/FrameworkValue.java | 4 +- .../script/value/FunctionAnnotationValue.java | 4 +- .../carpet/script/value/FunctionValue.java | 8 +- .../carpet/script/value/LazyListValue.java | 8 +- .../java/carpet/script/value/ListValue.java | 42 +++---- .../java/carpet/script/value/MapValue.java | 8 +- .../script/value/NBTSerializableValue.java | 112 ++++++++--------- .../java/carpet/script/value/NullValue.java | 8 +- .../carpet/script/value/NumericValue.java | 18 +-- .../java/carpet/script/value/StringValue.java | 8 +- .../java/carpet/script/value/ThreadValue.java | 4 +- src/main/java/carpet/script/value/Value.java | 4 +- 43 files changed, 356 insertions(+), 351 deletions(-) diff --git a/gradle.properties b/gradle.properties index 596fa804..31d70bbc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,9 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=21w11a - yarn_mappings=21w11a+build.2 + yarn_mappings=21w11a+build.20 loader_version=0.11.3 - fabric_version=0.32.2+1.17 + fabric_version=0.32.5+1.17 # Mod Properties mod_version = 1.4.30 diff --git a/src/main/java/carpet/commands/PerimeterInfoCommand.java b/src/main/java/carpet/commands/PerimeterInfoCommand.java index ab6baebc..9fb7a40b 100644 --- a/src/main/java/carpet/commands/PerimeterInfoCommand.java +++ b/src/main/java/carpet/commands/PerimeterInfoCommand.java @@ -13,7 +13,7 @@ import net.minecraft.entity.mob.MobEntity; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.command.argument.BlockPosArgumentType; import net.minecraft.command.argument.EntitySummonArgumentType; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.util.math.BlockPos; import static net.minecraft.server.command.CommandManager.argument; @@ -46,7 +46,7 @@ public class PerimeterInfoCommand private static int perimeterDiagnose(ServerCommandSource source, BlockPos pos, String mobId) { - CompoundTag nbttagcompound = new CompoundTag(); + NbtCompound nbttagcompound = new NbtCompound(); MobEntity entityliving = null; if (mobId != null) { diff --git a/src/main/java/carpet/fakes/BlockPredicateInterface.java b/src/main/java/carpet/fakes/BlockPredicateInterface.java index cd1e4349..c8d3e32b 100644 --- a/src/main/java/carpet/fakes/BlockPredicateInterface.java +++ b/src/main/java/carpet/fakes/BlockPredicateInterface.java @@ -3,7 +3,7 @@ package carpet.fakes; import carpet.script.value.Value; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.tag.Tag; import java.util.Map; @@ -13,5 +13,5 @@ public interface BlockPredicateInterface BlockState getCMBlockState(); Tag getCMBlockTag(); Map getCMProperties(); - CompoundTag getCMDataTag(); + NbtCompound getCMDataTag(); } diff --git a/src/main/java/carpet/fakes/BlockStateArgumentInterface.java b/src/main/java/carpet/fakes/BlockStateArgumentInterface.java index 20610ed3..ceda6f03 100644 --- a/src/main/java/carpet/fakes/BlockStateArgumentInterface.java +++ b/src/main/java/carpet/fakes/BlockStateArgumentInterface.java @@ -1,8 +1,8 @@ package carpet.fakes; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; public interface BlockStateArgumentInterface { - CompoundTag getCMTag(); + NbtCompound getCMTag(); } diff --git a/src/main/java/carpet/helpers/InventoryHelper.java b/src/main/java/carpet/helpers/InventoryHelper.java index acc3c0f2..73093f83 100644 --- a/src/main/java/carpet/helpers/InventoryHelper.java +++ b/src/main/java/carpet/helpers/InventoryHelper.java @@ -1,11 +1,11 @@ package carpet.helpers; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; public class InventoryHelper { - // From nbt/Tag.java createTag() + // From nbt/NbtElement.java createTag() public static final int TAG_END = 0; public static final int TAG_BYTE = 1; public static final int TAG_SHORT = 2; @@ -23,12 +23,12 @@ public class InventoryHelper public static boolean cleanUpShulkerBoxTag(ItemStack stack) { boolean changed = false; - CompoundTag tag = stack.getTag(); + NbtCompound tag = stack.getTag(); if (tag == null || !tag.contains("BlockEntityTag", TAG_COMPOUND)) return false; - CompoundTag bet = tag.getCompound("BlockEntityTag"); + NbtCompound bet = tag.getCompound("BlockEntityTag"); if (bet.contains("Items", TAG_LIST) && bet.getList("Items", TAG_COMPOUND).isEmpty()) { bet.remove("Items"); @@ -50,12 +50,12 @@ public class InventoryHelper public static boolean shulkerBoxHasItems(ItemStack stack) { - CompoundTag tag = stack.getTag(); + NbtCompound tag = stack.getTag(); if (tag == null || !tag.contains("BlockEntityTag", TAG_COMPOUND)) return false; - CompoundTag bet = tag.getCompound("BlockEntityTag"); + NbtCompound bet = tag.getCompound("BlockEntityTag"); return bet.contains("Items", TAG_LIST) && !bet.getList("Items", TAG_COMPOUND).isEmpty(); } } diff --git a/src/main/java/carpet/mixins/BaseRangeDecorator_cleanLogsMixin.java b/src/main/java/carpet/mixins/BaseRangeDecorator_cleanLogsMixin.java index 36621ddf..306a6a59 100644 --- a/src/main/java/carpet/mixins/BaseRangeDecorator_cleanLogsMixin.java +++ b/src/main/java/carpet/mixins/BaseRangeDecorator_cleanLogsMixin.java @@ -9,6 +9,8 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(BaseRangeDecorator.class) public class BaseRangeDecorator_cleanLogsMixin { + + @SuppressWarnings("UnresolvedMixinReference") @Redirect(method = "getY(Lnet/minecraft/world/gen/decorator/DecoratorContext;Ljava/util/Random;Lnet/minecraft/world/gen/decorator/RangeDecoratorConfig;I)I", at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V") ) diff --git a/src/main/java/carpet/mixins/BlockStateArgument_scarpetMixin.java b/src/main/java/carpet/mixins/BlockStateArgument_scarpetMixin.java index b4258426..16d905c7 100644 --- a/src/main/java/carpet/mixins/BlockStateArgument_scarpetMixin.java +++ b/src/main/java/carpet/mixins/BlockStateArgument_scarpetMixin.java @@ -2,7 +2,7 @@ package carpet.mixins; import carpet.fakes.BlockStateArgumentInterface; import net.minecraft.command.argument.BlockStateArgument; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -11,10 +11,10 @@ import org.spongepowered.asm.mixin.Shadow; @Mixin(BlockStateArgument.class) public class BlockStateArgument_scarpetMixin implements BlockStateArgumentInterface { - @Shadow @Final private @Nullable CompoundTag data; + @Shadow @Final private @Nullable NbtCompound data; @Override - public CompoundTag getCMTag() + public NbtCompound getCMTag() { return data; } diff --git a/src/main/java/carpet/mixins/GuardianEntityMixin.java b/src/main/java/carpet/mixins/GuardianEntityMixin.java index af188bad..69ac8840 100644 --- a/src/main/java/carpet/mixins/GuardianEntityMixin.java +++ b/src/main/java/carpet/mixins/GuardianEntityMixin.java @@ -8,7 +8,7 @@ import net.minecraft.entity.SpawnReason; import net.minecraft.entity.mob.ElderGuardianEntity; import net.minecraft.entity.mob.GuardianEntity; import net.minecraft.entity.mob.HostileEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.server.world.ServerWorld; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; @@ -28,7 +28,7 @@ public abstract class GuardianEntityMixin extends HostileEntity { ElderGuardianEntity elderGuardian = new ElderGuardianEntity(EntityType.ELDER_GUARDIAN ,this.world); elderGuardian.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), this.yaw, this.pitch); - elderGuardian.initialize(serverWorld ,this.world.getLocalDifficulty(elderGuardian.getBlockPos()), SpawnReason.CONVERSION, (EntityData)null, (CompoundTag)null); + elderGuardian.initialize(serverWorld ,this.world.getLocalDifficulty(elderGuardian.getBlockPos()), SpawnReason.CONVERSION, (EntityData)null, (NbtCompound)null); elderGuardian.setAiDisabled(this.isAiDisabled()); if (this.hasCustomName()) diff --git a/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java b/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java index 009e134a..c3ac3ff0 100644 --- a/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java @@ -10,7 +10,7 @@ import net.minecraft.block.Blocks; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.PistonBlockEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; @@ -128,25 +128,25 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple } @Inject(method = "readNbt", at = @At(value = "TAIL")) - private void onFromTag(CompoundTag compoundTag_1, CallbackInfo ci) + private void onFromTag(NbtCompound NbtCompound_1, CallbackInfo ci) { - if (CarpetSettings.movableBlockEntities && compoundTag_1.contains("carriedTileEntityCM", 10)) + if (CarpetSettings.movableBlockEntities && NbtCompound_1.contains("carriedTileEntityCM", 10)) { if (this.pushedBlock.getBlock() instanceof BlockEntityProvider) 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.readNbt(compoundTag_1.getCompound("carriedTileEntityCM")); + this.carriedBlockEntity.readNbt(NbtCompound_1.getCompound("carriedTileEntityCM")); setCarriedBlockEntity(carriedBlockEntity); } } @Inject(method = "writeNbt", at = @At(value = "RETURN", shift = At.Shift.BEFORE)) - private void onToTag(CompoundTag compoundTag_1, CallbackInfoReturnable cir) + private void onToTag(NbtCompound NbtCompound_1, CallbackInfoReturnable cir) { if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null) { //Leave name "carriedTileEntityCM" instead of "carriedBlockEntityCM" for upgrade compatibility with 1.13.2 movable TE - compoundTag_1.put("carriedTileEntityCM", this.carriedBlockEntity.writeNbt(new CompoundTag())); + NbtCompound_1.put("carriedTileEntityCM", this.carriedBlockEntity.writeNbt(new NbtCompound())); } } } diff --git a/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java b/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java index 261be608..7b4a47f2 100644 --- a/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java +++ b/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java @@ -41,7 +41,7 @@ public abstract class PistonHandler_customStickyMixin @Shadow protected abstract boolean tryMove(BlockPos blockPos_1, Direction direction_1); @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); + @Shadow protected abstract boolean tryMoveAdjacentBlock(BlockPos pos); // collects information about sticking block when backtracking. private BlockPos currentPos; @@ -169,7 +169,7 @@ public abstract class PistonHandler_customStickyMixin BlockState chainState = world.getBlockState(pos); // chain is sideways if (chainState.getBlock() == Blocks.CHAIN && !isChainOnAxis(chainState, motionDirection) - && !this.canMoveAdjacentBlock(pos)) + && !this.tryMoveAdjacentBlock(pos)) { cir.setReturnValue(false); } @@ -217,7 +217,7 @@ public abstract class PistonHandler_customStickyMixin if (CarpetSettings.doChainStone) { BlockState chainState = world.getBlockState(blockPos3); - if (chainState.getBlock() == Blocks.CHAIN && !isChainOnAxis(chainState, motionDirection) && !canMoveAdjacentBlock(blockPos3)) + if (chainState.getBlock() == Blocks.CHAIN && !isChainOnAxis(chainState, motionDirection) && !tryMoveAdjacentBlock(blockPos3)) { cir.setReturnValue(false); } @@ -228,7 +228,7 @@ public abstract class PistonHandler_customStickyMixin /** * Custom movement of blocks stuck to the sides of blocks other than slimeblocks like chains */ - @Inject(method = "canMoveAdjacentBlock", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, at = @At( + @Inject(method = "tryMoveAdjacentBlock", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, at = @At( value = "INVOKE", target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)Z", shift = At.Shift.BEFORE @@ -264,7 +264,7 @@ public abstract class PistonHandler_customStickyMixin * @param block2 * @return */ - @Redirect(method = "canMoveAdjacentBlock", at = @At( + @Redirect(method = "tryMoveAdjacentBlock", at = @At( value = "INVOKE", target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)Z") ) diff --git a/src/main/java/carpet/mixins/PlayerEntity_parrotMixin.java b/src/main/java/carpet/mixins/PlayerEntity_parrotMixin.java index 5dd06a2f..48118e7c 100644 --- a/src/main/java/carpet/mixins/PlayerEntity_parrotMixin.java +++ b/src/main/java/carpet/mixins/PlayerEntity_parrotMixin.java @@ -6,7 +6,7 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerAbilities; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -24,15 +24,15 @@ public abstract class PlayerEntity_parrotMixin extends LivingEntity @Shadow protected abstract void dropShoulderEntities(); - @Shadow public abstract CompoundTag getShoulderEntityLeft(); + @Shadow public abstract NbtCompound getShoulderEntityLeft(); - @Shadow protected abstract void setShoulderEntityLeft(CompoundTag compoundTag_1); + @Shadow protected abstract void setShoulderEntityLeft(NbtCompound NbtCompound_1); - @Shadow protected abstract void setShoulderEntityRight(CompoundTag compoundTag_1); + @Shadow protected abstract void setShoulderEntityRight(NbtCompound NbtCompound_1); - @Shadow public abstract CompoundTag getShoulderEntityRight(); + @Shadow public abstract NbtCompound getShoulderEntityRight(); - @Shadow protected abstract void dropShoulderEntity(CompoundTag entityNbt); + @Shadow protected abstract void dropShoulderEntity(NbtCompound entityNbt); protected PlayerEntity_parrotMixin(EntityType entityType_1, World world_1) { @@ -47,7 +47,7 @@ public abstract class PlayerEntity_parrotMixin extends LivingEntity } @Inject(method = "tickMovement", at = @At(value = "INVOKE", shift = At.Shift.AFTER, ordinal = 1, - target = "Lnet/minecraft/entity/player/PlayerEntity;updateShoulderEntity(Lnet/minecraft/nbt/CompoundTag;)V")) + target = "Lnet/minecraft/entity/player/PlayerEntity;updateShoulderEntity(Lnet/minecraft/nbt/NbtCompound;)V")) private void onTickMovement(CallbackInfo ci) { boolean parrots_will_drop = !CarpetSettings.persistentParrots || this.abilities.invulnerable; @@ -67,13 +67,13 @@ public abstract class PlayerEntity_parrotMixin extends LivingEntity protected void dismount_left() { dropShoulderEntity(this.getShoulderEntityLeft()); - this.setShoulderEntityLeft(new CompoundTag()); + this.setShoulderEntityLeft(new NbtCompound()); } protected void dismount_right() { dropShoulderEntity(this.getShoulderEntityRight()); - this.setShoulderEntityRight(new CompoundTag()); + this.setShoulderEntityRight(new NbtCompound()); } @Inject(method = "damage", at = @At(value = "INVOKE", shift = At.Shift.BEFORE, diff --git a/src/main/java/carpet/mixins/PlayerManager_fakePlayersMixin.java b/src/main/java/carpet/mixins/PlayerManager_fakePlayersMixin.java index 1b5f6be8..bd1f3733 100644 --- a/src/main/java/carpet/mixins/PlayerManager_fakePlayersMixin.java +++ b/src/main/java/carpet/mixins/PlayerManager_fakePlayersMixin.java @@ -1,7 +1,7 @@ package carpet.mixins; import com.mojang.authlib.GameProfile; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.network.ClientConnection; import net.minecraft.text.TranslatableText; import net.minecraft.server.MinecraftServer; @@ -31,7 +31,7 @@ public abstract class PlayerManager_fakePlayersMixin private MinecraftServer server; @Inject(method = "loadPlayerData", at = @At(value = "RETURN", shift = At.Shift.BEFORE)) - private void fixStartingPos(ServerPlayerEntity serverPlayerEntity_1, CallbackInfoReturnable cir) + private void fixStartingPos(ServerPlayerEntity serverPlayerEntity_1, CallbackInfoReturnable cir) { if (serverPlayerEntity_1 instanceof EntityPlayerMPFake) { diff --git a/src/main/java/carpet/mixins/SpawnHelperMixin.java b/src/main/java/carpet/mixins/SpawnHelperMixin.java index 61347721..f97cf954 100644 --- a/src/main/java/carpet/mixins/SpawnHelperMixin.java +++ b/src/main/java/carpet/mixins/SpawnHelperMixin.java @@ -13,7 +13,7 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnReason; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.server.world.ServerWorld; import net.minecraft.tag.BlockTags; import net.minecraft.util.math.BlockPos; @@ -175,9 +175,9 @@ public class SpawnHelperMixin @Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/SpawnGroup;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/SpawnHelper$Checker;Lnet/minecraft/world/SpawnHelper$Runner;)V", at = @At( value = "INVOKE", - target = "Lnet/minecraft/entity/mob/MobEntity;initialize(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnReason;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/entity/EntityData;" + target = "Lnet/minecraft/entity/mob/MobEntity;initialize(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnReason;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/entity/EntityData;" )) - private static EntityData spawnEntity(MobEntity mobEntity, ServerWorldAccess serverWorldAccess, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, CompoundTag entityTag) + private static EntityData spawnEntity(MobEntity mobEntity, ServerWorldAccess serverWorldAccess, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, NbtCompound entityTag) { if (!SpawnReporter.mock_spawns) // WorldAccess return mobEntity.initialize(serverWorldAccess, difficulty, spawnReason, entityData, entityTag); diff --git a/src/main/java/carpet/mixins/StatePredicate_scarpetMixin.java b/src/main/java/carpet/mixins/StatePredicate_scarpetMixin.java index 5ef599e9..f328921e 100644 --- a/src/main/java/carpet/mixins/StatePredicate_scarpetMixin.java +++ b/src/main/java/carpet/mixins/StatePredicate_scarpetMixin.java @@ -6,7 +6,7 @@ import carpet.script.value.Value; import carpet.script.value.ValueConversions; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.state.property.Property; import net.minecraft.tag.Tag; import org.spongepowered.asm.mixin.Final; @@ -23,7 +23,7 @@ public class StatePredicate_scarpetMixin implements BlockPredicateInterface @Shadow @Final private BlockState state; - @Shadow @Final /*@Nullable*/ private CompoundTag nbt; + @Shadow @Final /*@Nullable*/ private NbtCompound nbt; @Shadow @Final private Set> properties; @@ -50,7 +50,7 @@ public class StatePredicate_scarpetMixin implements BlockPredicateInterface } @Override - public CompoundTag getCMDataTag() + public NbtCompound getCMDataTag() { return nbt; } diff --git a/src/main/java/carpet/mixins/TagPredicate_scarpetMixin.java b/src/main/java/carpet/mixins/TagPredicate_scarpetMixin.java index f64062e0..d6e4fc40 100644 --- a/src/main/java/carpet/mixins/TagPredicate_scarpetMixin.java +++ b/src/main/java/carpet/mixins/TagPredicate_scarpetMixin.java @@ -5,7 +5,7 @@ import carpet.script.value.StringValue; import carpet.script.value.Value; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.tag.Tag; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -21,7 +21,7 @@ public class TagPredicate_scarpetMixin implements BlockPredicateInterface @Shadow @Final private Map properties; - @Shadow @Final /*@Nullable*/ private CompoundTag nbt; + @Shadow @Final /*@Nullable*/ private NbtCompound nbt; @Override public BlockState getCMBlockState() @@ -45,7 +45,7 @@ public class TagPredicate_scarpetMixin implements BlockPredicateInterface } @Override - public CompoundTag getCMDataTag() + public NbtCompound getCMDataTag() { return nbt; } diff --git a/src/main/java/carpet/network/CarpetClient.java b/src/main/java/carpet/network/CarpetClient.java index 4236d2d3..2d64c958 100644 --- a/src/main/java/carpet/network/CarpetClient.java +++ b/src/main/java/carpet/network/CarpetClient.java @@ -4,9 +4,9 @@ import carpet.CarpetServer; import carpet.CarpetSettings; import carpet.script.utils.ShapesRenderer; import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtList; +import net.minecraft.nbt.NbtElement; import net.minecraft.text.Text; import net.minecraft.util.Identifier; @@ -64,16 +64,16 @@ public class CarpetClient return true; } - public static void onClientCommand(Tag t) + public static void onClientCommand(NbtElement t) { CarpetSettings.LOG.info("Server Response:"); - CompoundTag tag = (CompoundTag)t; + NbtCompound tag = (NbtCompound)t; CarpetSettings.LOG.info(" - id: "+tag.getString("id")); CarpetSettings.LOG.info(" - code: "+tag.getInt("code")); if (tag.contains("error")) CarpetSettings.LOG.warn(" - error: "+tag.getString("error")); if (tag.contains("output")) { - ListTag outputTag = (ListTag) tag.get("output"); + NbtList outputTag = (NbtList) tag.get("output"); for (int i = 0; i < outputTag.size(); i++) CarpetSettings.LOG.info(" - response: " + Text.Serializer.fromJson(outputTag.getString(i)).getString()); } diff --git a/src/main/java/carpet/network/ClientNetworkHandler.java b/src/main/java/carpet/network/ClientNetworkHandler.java index 0d60acc0..9c62c4e0 100644 --- a/src/main/java/carpet/network/ClientNetworkHandler.java +++ b/src/main/java/carpet/network/ClientNetworkHandler.java @@ -8,11 +8,11 @@ import carpet.settings.ParsedRule; import carpet.settings.SettingsManager; import io.netty.buffer.Unpooled; import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.nbt.AbstractNumberTag; -import net.minecraft.nbt.ByteTag; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.AbstractNbtNumber; +import net.minecraft.nbt.NbtByte; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtList; +import net.minecraft.nbt.NbtElement; import net.minecraft.network.PacketByteBuf; import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket; @@ -22,14 +22,14 @@ import java.util.function.BiConsumer; public class ClientNetworkHandler { - private static Map> dataHandlers = new HashMap>(); + private static Map> dataHandlers = new HashMap>(); static { dataHandlers.put("Rules", (p, t) -> { - CompoundTag ruleset = (CompoundTag)t; + NbtCompound ruleset = (NbtCompound)t; for (String ruleKey: ruleset.getKeys()) { - CompoundTag ruleNBT = (CompoundTag) ruleset.get(ruleKey); + NbtCompound ruleNBT = (NbtCompound) ruleset.get(ruleKey); SettingsManager manager = null; String ruleName; if (ruleNBT.contains("Manager")) @@ -65,22 +65,22 @@ public class ClientNetworkHandler } } }); - dataHandlers.put("TickRate", (p, t) -> TickSpeed.tickrate(((AbstractNumberTag)t).getFloat(), false)); + dataHandlers.put("TickRate", (p, t) -> TickSpeed.tickrate(((AbstractNbtNumber)t).floatValue(), false)); dataHandlers.put("TickingState", (p, t) -> { - CompoundTag tickingState = (CompoundTag)t; + NbtCompound tickingState = (NbtCompound)t; TickSpeed.setFrozenState(tickingState.getBoolean("is_paused"), tickingState.getBoolean("deepFreeze")); }); dataHandlers.put("SuperHotState", (p, t) -> { - TickSpeed.is_superHot = ((ByteTag) t).equals(ByteTag.ONE); + TickSpeed.is_superHot = ((NbtByte) t).equals(NbtByte.ONE); }); - dataHandlers.put("TickPlayerActiveTimeout", (p, t) -> TickSpeed.player_active_timeout = ((AbstractNumberTag)t).getInt()); + dataHandlers.put("TickPlayerActiveTimeout", (p, t) -> TickSpeed.player_active_timeout = ((AbstractNbtNumber)t).intValue()); dataHandlers.put("scShape", (p, t) -> { // deprecated if (CarpetClient.shapes != null) - CarpetClient.shapes.addShape((CompoundTag)t); + CarpetClient.shapes.addShape((NbtCompound)t); }); dataHandlers.put("scShapes", (p, t) -> { if (CarpetClient.shapes != null) - CarpetClient.shapes.addShapes((ListTag) t); + CarpetClient.shapes.addShapes((NbtList) t); }); dataHandlers.put("clientCommand", (p, t) -> { CarpetClient.onClientCommand(t); @@ -129,7 +129,7 @@ public class ClientNetworkHandler private static void onSyncData(PacketByteBuf data, ClientPlayerEntity player) { - CompoundTag compound = data.readCompoundTag(); + NbtCompound compound = data.readCompoundTag(); if (compound == null) return; for (String key: compound.getKeys()) { @@ -142,10 +142,10 @@ public class ClientNetworkHandler public static void clientCommand(String command) { - CompoundTag tag = new CompoundTag(); + NbtCompound tag = new NbtCompound(); tag.putString("id", command); tag.putString("command", command); - CompoundTag outer = new CompoundTag(); + NbtCompound outer = new NbtCompound(); outer.put("clientCommand", tag); CarpetClient.getPlayer().networkHandler.sendPacket(new CustomPayloadC2SPacket( CarpetClient.CARPET_CHANNEL, diff --git a/src/main/java/carpet/network/ServerNetworkHandler.java b/src/main/java/carpet/network/ServerNetworkHandler.java index f5959561..25310b4c 100644 --- a/src/main/java/carpet/network/ServerNetworkHandler.java +++ b/src/main/java/carpet/network/ServerNetworkHandler.java @@ -6,10 +6,10 @@ import carpet.helpers.TickSpeed; import carpet.settings.ParsedRule; import carpet.settings.SettingsManager; import io.netty.buffer.Unpooled; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.StringTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtList; +import net.minecraft.nbt.NbtString; +import net.minecraft.nbt.NbtElement; import net.minecraft.network.PacketByteBuf; import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket; import net.minecraft.server.command.ServerCommandSource; @@ -31,9 +31,9 @@ public class ServerNetworkHandler private static Map remoteCarpetPlayers = new HashMap<>(); private static Set validCarpetPlayers = new HashSet<>(); - private static Map> dataHandlers = new HashMap>(){{ + private static Map> dataHandlers = new HashMap>(){{ put("clientCommand", (p, t) -> { - handleClientCommand(p, (CompoundTag)t); + handleClientCommand(p, (NbtCompound)t); }); }}; @@ -88,7 +88,7 @@ public class ServerNetworkHandler playerEntity.networkHandler.sendPacket(new CustomPayloadS2CPacket(CarpetClient.CARPET_CHANNEL, data.build() )); } - private static void handleClientCommand(ServerPlayerEntity player, CompoundTag commandData) + private static void handleClientCommand(ServerPlayerEntity player, NbtCompound commandData) { String command = commandData.getString("command"); String id = commandData.getString("id"); @@ -121,12 +121,12 @@ public class ServerNetworkHandler command ); }; - CompoundTag result = new CompoundTag(); + NbtCompound result = new NbtCompound(); result.putString("id", id); result.putInt("code", resultCode); if (error[0] != null) result.putString("error", error[0]); - ListTag outputResult = new ListTag(); - for (Text line: output) outputResult.add(StringTag.of(Text.Serializer.toJson(line))); + NbtList outputResult = new NbtList(); + for (Text line: output) outputResult.add(NbtString.of(Text.Serializer.toJson(line))); if (!output.isEmpty()) result.put("output", outputResult); player.networkHandler.sendPacket(new CustomPayloadS2CPacket( CarpetClient.CARPET_CHANNEL, @@ -138,7 +138,7 @@ public class ServerNetworkHandler private static void onClientData(ServerPlayerEntity player, PacketByteBuf data) { - CompoundTag compound = data.readCompoundTag(); + NbtCompound compound = data.readCompoundTag(); if (compound == null) return; for (String key: compound.getKeys()) { @@ -209,7 +209,7 @@ public class ServerNetworkHandler } } - public static void broadcastCustomCommand(String command, Tag data) + public static void broadcastCustomCommand(String command, NbtElement data) { if (CarpetSettings.superSecretSetting) return; for (ServerPlayerEntity player : validCarpetPlayers) @@ -221,7 +221,7 @@ public class ServerNetworkHandler } } - public static void sendCustomCommand(ServerPlayerEntity player, String command, Tag data) + public static void sendCustomCommand(ServerPlayerEntity player, String command, NbtElement data) { if (isValidCarpetPlayer(player)) { @@ -262,14 +262,14 @@ public class ServerNetworkHandler private static class DataBuilder { - private CompoundTag tag; + private NbtCompound tag; private static DataBuilder create() { return new DataBuilder(); } private DataBuilder() { - tag = new CompoundTag(); + tag = new NbtCompound(); } private DataBuilder withTickRate() { @@ -278,7 +278,7 @@ public class ServerNetworkHandler } private DataBuilder withFrozenState() { - CompoundTag tickingState = new CompoundTag(); + NbtCompound tickingState = new NbtCompound(); tickingState.putBoolean("is_paused", TickSpeed.isPaused()); tickingState.putBoolean("deepFreeze", TickSpeed.deeplyFrozen()); tag.put("TickingState", tickingState); @@ -296,16 +296,16 @@ public class ServerNetworkHandler } private DataBuilder withRule(ParsedRule rule) { - CompoundTag rules = (CompoundTag) tag.get("Rules"); + NbtCompound rules = (NbtCompound) tag.get("Rules"); if (rules == null) { - rules = new CompoundTag(); + rules = new NbtCompound(); tag.put("Rules", rules); } String identifier = rule.settingsManager.getIdentifier(); String key = rule.name; while (rules.contains(key)) { key = key+"2";} - CompoundTag ruleNBT = new CompoundTag(); + NbtCompound ruleNBT = new NbtCompound(); ruleNBT.putString("Value", rule.getAsString()); ruleNBT.putString("Manager",identifier); ruleNBT.putString("Rule",rule.name); @@ -313,7 +313,7 @@ public class ServerNetworkHandler return this; } - public DataBuilder withCustomNbt(String key, Tag value) + public DataBuilder withCustomNbt(String key, NbtElement value) { tag.put(key, value); return this; diff --git a/src/main/java/carpet/script/CarpetScriptHost.java b/src/main/java/carpet/script/CarpetScriptHost.java index 6c2fcac8..8397fc86 100644 --- a/src/main/java/carpet/script/CarpetScriptHost.java +++ b/src/main/java/carpet/script/CarpetScriptHost.java @@ -29,7 +29,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtElement; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; @@ -60,7 +60,7 @@ public class CarpetScriptHost extends ScriptHost private final CarpetScriptServer scriptServer; ServerCommandSource responsibleSource; - private Tag globalState; + private NbtElement globalState; private int saveTimeout; public boolean persistenceRequired; @@ -789,12 +789,12 @@ public class CarpetScriptHost extends ScriptHost Module.saveData(main, globalState); } - private Tag loadState() + private NbtElement loadState() { return Module.getData(main); } - public Tag readFileTag(FileArgument fdesc) + public NbtElement readFileTag(FileArgument fdesc) { if (getName() == null && !fdesc.isShared) return null; if (fdesc.resource != null) @@ -804,7 +804,7 @@ public class CarpetScriptHost extends ScriptHost return ((CarpetScriptHost)parent).globalState; } - public boolean writeTagFile(Tag tag, FileArgument fdesc) + public boolean writeTagFile(NbtElement tag, FileArgument fdesc) { if (getName() == null && !fdesc.isShared) return false; // if belongs to an app, cannot be default host. diff --git a/src/main/java/carpet/script/api/Auxiliary.java b/src/main/java/carpet/script/api/Auxiliary.java index c7c2ac35..b8c165d9 100644 --- a/src/main/java/carpet/script/api/Auxiliary.java +++ b/src/main/java/carpet/script/api/Auxiliary.java @@ -51,11 +51,11 @@ import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtHelper; import net.minecraft.nbt.NbtOps; -import net.minecraft.nbt.StringTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtString; +import net.minecraft.nbt.NbtElement; import net.minecraft.network.Packet; import net.minecraft.network.packet.s2c.play.ClearTitleS2CPacket; import net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket; @@ -459,7 +459,7 @@ public class Auxiliary { expression.addLazyFunction("escape_nbt", 1, (c, t, lv) -> { Value v = lv.get(0).evalValue(c); String string = v.getString(); - Value ret = new StringValue(StringTag.escape(string)); + Value ret = new StringValue(NbtString.escape(string)); return (cc, tt) -> ret; }); @@ -482,8 +482,8 @@ public class Auxiliary { if (numParam != 2 && numParam != 3) throw new InternalExpressionException("'tag_matches' requires 2 or 3 arguments"); if (lv.get(1).isNull()) return Value.TRUE; if (lv.get(0).isNull()) return Value.FALSE; - Tag source = ((NBTSerializableValue)(NBTSerializableValue.fromValue(lv.get(0)))).getTag(); - Tag match = ((NBTSerializableValue)(NBTSerializableValue.fromValue(lv.get(1)))).getTag(); + NbtElement source = ((NBTSerializableValue)(NBTSerializableValue.fromValue(lv.get(0)))).getTag(); + NbtElement match = ((NBTSerializableValue)(NBTSerializableValue.fromValue(lv.get(1)))).getTag(); return new NumericValue(NbtHelper.matches(match, source, numParam == 2 || lv.get(2).getBoolean())); }); @@ -492,7 +492,7 @@ public class Auxiliary { if (argSize==0 || argSize > 2) throw new InternalExpressionException("'encode_nbt' requires 1 or 2 parameters"); Value v = lv.get(0).evalValue(c); boolean force = (argSize > 1) && lv.get(1).evalValue(c).getBoolean(); - Tag tag; + NbtElement tag; try { tag = v.toTag(force); @@ -877,7 +877,7 @@ public class Auxiliary { Value retVal; if (fdesc.type == FileArgument.Type.NBT) { - Tag state = ((CarpetScriptHost) c.host).readFileTag(fdesc); + NbtElement state = ((CarpetScriptHost) c.host).readFileTag(fdesc); if (state == null) return LazyValue.NULL; retVal = new NBTSerializableValue(state); } @@ -916,7 +916,7 @@ public class Auxiliary { NBTSerializableValue tagValue = (val instanceof NBTSerializableValue) ? (NBTSerializableValue) val : new NBTSerializableValue(val.getString()); - Tag tag = tagValue.getTag(); + NbtElement tag = tagValue.getTag(); success = ((CarpetScriptHost) c.host).writeTagFile(tag, fdesc); } else if (fdesc.type == FileArgument.Type.JSON) @@ -963,7 +963,7 @@ public class Auxiliary { boolean shared = lv.size() > 1 && lv.get(1).evalValue(c).getBoolean(); fdesc = new FileArgument(resource, FileArgument.Type.NBT, null, false, shared, FileArgument.Reason.READ); } - Tag state = ((CarpetScriptHost) c.host).readFileTag(fdesc); + NbtElement state = ((CarpetScriptHost) c.host).readFileTag(fdesc); if (state == null) return (cc, tt) -> Value.NULL; Value retVal = new NBTSerializableValue(state); @@ -986,7 +986,7 @@ public class Auxiliary { NBTSerializableValue tagValue = (val instanceof NBTSerializableValue) ? (NBTSerializableValue) val : new NBTSerializableValue(val.getString()); - Tag tag = tagValue.getTag(); + NbtElement tag = tagValue.getTag(); boolean success = ((CarpetScriptHost) c.host).writeTagFile(tag, fdesc); return success?LazyValue.TRUE:LazyValue.FALSE; }); @@ -1074,7 +1074,7 @@ public class Auxiliary { return (_c, _t) -> ret; } String key = lv.get(0).evalValue(c).getString(); - CompoundTag old_nbt = storage.get(new Identifier(key)); + NbtCompound old_nbt = storage.get(new Identifier(key)); if (lv.size() == 2) { Value nbt = lv.get(1).evalValue(c); NBTSerializableValue new_nbt = (nbt instanceof NBTSerializableValue) ? (NBTSerializableValue) nbt @@ -1170,7 +1170,7 @@ public class Auxiliary { //not sure its needed, but doesn't seem to have a negative effect and might be used in some custom shtuff serverRM.loadRegistryTags(); - RegistryOps registryOps = RegistryOps.of(NbtOps.INSTANCE, serverRM.getResourceManager(), (DynamicRegistryManager.Impl) server.getRegistryManager()); + RegistryOps registryOps = RegistryOps.of(NbtOps.INSTANCE, serverRM.getResourceManager(), (DynamicRegistryManager.Impl) server.getRegistryManager()); SaveProperties saveProperties = session.readLevelProperties(registryOps, dataPackSettings2); if (saveProperties == null) return LazyValue.NULL; //session.backupLevelDataFile(server.getRegistryManager(), saveProperties); // no need diff --git a/src/main/java/carpet/script/api/Entities.java b/src/main/java/carpet/script/api/Entities.java index 3c025803..80f94b69 100644 --- a/src/main/java/carpet/script/api/Entities.java +++ b/src/main/java/carpet/script/api/Entities.java @@ -21,7 +21,7 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnReason; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; @@ -140,7 +140,7 @@ public class Entities { Vector3Argument position = Vector3Argument.findIn(cc, lv, 1); if (position.fromBlock) position.vec = position.vec.subtract(0, 0.5, 0); - CompoundTag tag = new CompoundTag(); + NbtCompound tag = new NbtCompound(); boolean hasTag = false; if (lv.size() > position.offset) { diff --git a/src/main/java/carpet/script/api/Inventories.java b/src/main/java/carpet/script/api/Inventories.java index 96234cd2..0e82461a 100644 --- a/src/main/java/carpet/script/api/Inventories.java +++ b/src/main/java/carpet/script/api/Inventories.java @@ -25,7 +25,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket; import net.minecraft.recipe.AbstractCookingRecipe; import net.minecraft.recipe.CuttingRecipe; @@ -35,6 +35,7 @@ import net.minecraft.recipe.ShapedRecipe; import net.minecraft.recipe.ShapelessRecipe; import net.minecraft.recipe.SpecialCraftingRecipe; import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.tag.Tag; import net.minecraft.tag.TagManager; import net.minecraft.util.Identifier; import net.minecraft.util.InvalidIdentifierException; @@ -97,7 +98,7 @@ public class Inventories { return (_c, _t) -> ret; } String tag = lv.get(1).evalValue(c).getString(); - net.minecraft.tag.Tag itemTag = tagManager.getOrCreateTagGroup(Registry.ITEM_KEY).getTag(new Identifier(tag)); + Tag itemTag = tagManager.getOrCreateTagGroup(Registry.ITEM_KEY).getTag(new Identifier(tag)); if (itemTag == null) return LazyValue.NULL; return itemTag.contains(item)?LazyValue.TRUE:LazyValue.FALSE; }); @@ -277,7 +278,7 @@ public class Inventories { syncPlayerInventory(inventoryLocator, slot); return (_c, _t) -> ListValue.fromItemStack(previousStack); } - CompoundTag nbt = null; // skipping one argument + NbtCompound nbt = null; // skipping one argument if (lv.size() > inventoryLocator.offset+3) { Value nbtValue = lv.get(inventoryLocator.offset+3).evalValue(c); diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index 85a0630b..a8f050d7 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -59,8 +59,8 @@ import net.minecraft.item.MiningToolItem; import net.minecraft.item.ShearsItem; import net.minecraft.item.SwordItem; import net.minecraft.item.TridentItem; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtElement; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ChunkTicket; import net.minecraft.server.world.ChunkTicketType; @@ -70,6 +70,7 @@ import net.minecraft.sound.SoundCategory; import net.minecraft.state.StateManager; import net.minecraft.state.property.Property; import net.minecraft.structure.StructureStart; +import net.minecraft.tag.Tag; import net.minecraft.tag.TagManager; import net.minecraft.util.ActionResult; import net.minecraft.util.Clearable; @@ -289,7 +290,7 @@ public class WorldAccess { { throw new InternalExpressionException("Block requires at least one parameter"); } - CompoundTag tag = BlockArgument.findIn(cc, lv, 0, true).block.getData(); + NbtCompound tag = BlockArgument.findIn(cc, lv, 0, true).block.getData(); if (tag == null) return (c_, t_) -> Value.NULL; Value retval = new NBTSerializableValue(tag); @@ -756,7 +757,7 @@ public class WorldAccess { BlockArgument sourceLocator = BlockArgument.findIn(cc, lv, targetLocator.offset, true); BlockState sourceBlockState = sourceLocator.block.getBlockState(); BlockState targetBlockState = world.getBlockState(targetLocator.block.getPos()); - CompoundTag data = null; + NbtCompound data = null; if (lv.size() > sourceLocator.offset) { List args = new ArrayList<>(); @@ -815,7 +816,7 @@ public class WorldAccess { } if (data == null) data = sourceLocator.block.getData(); - CompoundTag finalData = data; + NbtCompound finalData = data; if (sourceBlockState == targetBlockState && data == null) return (c_, t_) -> Value.FALSE; @@ -831,7 +832,7 @@ public class WorldAccess { BlockEntity be = world.getBlockEntity(targetPos); if (be != null) { - CompoundTag destTag = finalData.copy(); + NbtCompound destTag = finalData.copy(); destTag.putInt("x", targetPos.getX()); destTag.putInt("y", targetPos.getY()); destTag.putInt("z", targetPos.getZ()); @@ -875,7 +876,7 @@ public class WorldAccess { .orElseThrow(() -> new ThrowStatement(itemString, Throwables.UNKNOWN_ITEM)); } } - CompoundTag tag = null; + NbtCompound tag = null; if (lv.size() > locator.offset+1) { if (!playerBreak) throw new InternalExpressionException("tag is not necessary with 'destroy' with no item"); @@ -937,7 +938,7 @@ public class WorldAccess { return (c_, t_) -> Value.TRUE; if (toolBroke) return LazyValue.NULL; - Tag outtag = tool.getTag(); + NbtElement outtag = tool.getTag(); if (outtag == null) return LazyValue.TRUE; Value ret = new NBTSerializableValue(() -> outtag); @@ -1130,7 +1131,7 @@ public class WorldAccess { return (_c, _t) -> ret; } String tag = lv.get(blockLocator.offset).evalValue(c).getString(); - net.minecraft.tag.Tag blockTag = tagManager.getOrCreateTagGroup(Registry.BLOCK_KEY).getTag(new Identifier(tag)); + Tag blockTag = tagManager.getOrCreateTagGroup(Registry.BLOCK_KEY).getTag(new Identifier(tag)); if (blockTag == null) return LazyValue.NULL; return blockLocator.block.getBlockState().isIn(blockTag)?LazyValue.TRUE:LazyValue.FALSE; }); @@ -1354,7 +1355,7 @@ public class WorldAccess { return; } StructureStart start = structures.get(structure); - ChunkPos structureChunkPos = start.method_34000(); // new ChunkPos(start.getChunkX(), start.getChunkZ()); + ChunkPos structureChunkPos = start.getPos(); // new ChunkPos(start.getChunkX(), start.getChunkZ()); BlockBox box = start.getBoundingBox(); for (int chx = box.minX / 16; chx <= box.maxX / 16; chx++) { diff --git a/src/main/java/carpet/script/argument/FileArgument.java b/src/main/java/carpet/script/argument/FileArgument.java index 037ba75d..50a69f9f 100644 --- a/src/main/java/carpet/script/argument/FileArgument.java +++ b/src/main/java/carpet/script/argument/FileArgument.java @@ -15,11 +15,11 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParseException; import com.google.gson.JsonParser; import com.google.gson.stream.JsonReader; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtTagSizeTracker; -import net.minecraft.nbt.Tag; -import net.minecraft.nbt.TagReaders; +import net.minecraft.nbt.NbtElement; +import net.minecraft.nbt.NbtTypes; import net.minecraft.util.WorldSavePath; import net.minecraft.util.crash.CrashException; import org.apache.commons.io.FilenameUtils; @@ -302,7 +302,7 @@ public class FileArgument return true; } - public Tag getNbtData(Module module) // aka getData + public NbtElement getNbtData(Module module) // aka getData { try { synchronized (writeIOSync) { Path dataFile = toPath(module); @@ -316,7 +316,7 @@ public class FileArgument //copied private method from net.minecraft.nbt.NbtIo.read() // to read non-compound tags - these won't be compressed - public static Tag readTag(Path path) + public static NbtElement readTag(Path path) { try { @@ -346,7 +346,7 @@ public class FileArgument else { dataInput_1.readUTF(); - return TagReaders.of(byte_1).read(dataInput_1, 0, NbtTagSizeTracker.EMPTY); + return NbtTypes.byId(byte_1).read(dataInput_1, 0, NbtTagSizeTracker.EMPTY); } } catch (IOException ignored) @@ -361,7 +361,7 @@ public class FileArgument } } - public boolean saveNbtData(Module module, Tag tag) // aka saveData + public boolean saveNbtData(Module module, NbtElement tag) // aka saveData { try { synchronized (writeIOSync) { Path dataFile = toPath(module); @@ -376,7 +376,7 @@ public class FileArgument } //copied private method from net.minecraft.nbt.NbtIo.write() and client method safe_write - public static boolean writeTagDisk(Tag tag_1, Path path, boolean zipped) + public static boolean writeTagDisk(NbtElement tag_1, Path path, boolean zipped) { Path original = path; try @@ -387,9 +387,9 @@ public class FileArgument Files.deleteIfExists(path); } - if (tag_1 instanceof CompoundTag) + if (tag_1 instanceof NbtCompound) { - NbtIo.writeCompressed((CompoundTag) tag_1, Files.newOutputStream(path)); + NbtIo.writeCompressed((NbtCompound) tag_1, Files.newOutputStream(path)); } else { diff --git a/src/main/java/carpet/script/bundled/Module.java b/src/main/java/carpet/script/bundled/Module.java index a6d29d85..369f4197 100644 --- a/src/main/java/carpet/script/bundled/Module.java +++ b/src/main/java/carpet/script/bundled/Module.java @@ -2,7 +2,7 @@ package carpet.script.bundled; import carpet.CarpetServer; import carpet.script.argument.FileArgument; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtElement; import net.minecraft.util.WorldSavePath; import java.nio.file.Files; @@ -14,7 +14,7 @@ public abstract class Module public abstract String getCode(); public abstract boolean isLibrary(); - public static Tag getData(Module module) + public static NbtElement getData(Module module) { Path dataFile = resolveResource(module); if (dataFile == null) return null; @@ -22,7 +22,7 @@ public abstract class Module synchronized (FileArgument.writeIOSync) { return FileArgument.readTag(dataFile); } } - public static void saveData(Module module, Tag globalState) + public static void saveData(Module module, NbtElement globalState) { Path dataFile = resolveResource(module); if (dataFile == null) return; diff --git a/src/main/java/carpet/script/utils/ShapeDispatcher.java b/src/main/java/carpet/script/utils/ShapeDispatcher.java index 2e0591c3..0ad2922d 100644 --- a/src/main/java/carpet/script/utils/ShapeDispatcher.java +++ b/src/main/java/carpet/script/utils/ShapeDispatcher.java @@ -22,14 +22,14 @@ import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.command.argument.ParticleEffectArgumentType; import net.minecraft.entity.Entity; -import net.minecraft.nbt.ByteTag; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.DoubleTag; -import net.minecraft.nbt.FloatTag; -import net.minecraft.nbt.IntTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.StringTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtByte; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtDouble; +import net.minecraft.nbt.NbtFloat; +import net.minecraft.nbt.NbtInt; +import net.minecraft.nbt.NbtList; +import net.minecraft.nbt.NbtString; +import net.minecraft.nbt.NbtElement; import net.minecraft.particle.ParticleEffect; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; @@ -123,7 +123,7 @@ public class ShapeDispatcher if (!clientPlayers.isEmpty()) { - ListTag tag = new ListTag(); + NbtList tag = new NbtList(); int tagcount = 0; for (Pair> s : shapes) { @@ -131,12 +131,12 @@ public class ShapeDispatcher if (tagcount++>1000) { tagcount = 0; - Tag finalTag = tag; + NbtElement finalTag = tag; clientPlayers.forEach( p -> ServerNetworkHandler.sendCustomCommand(p, "scShapes", finalTag)); - tag = new ListTag(); + tag = new NbtList(); } } - Tag finalTag = tag; + NbtElement finalTag = tag; if (tag.size() > 0) clientPlayers.forEach( p -> ServerNetworkHandler.sendCustomCommand(p, "scShapes", finalTag)); } if (!alternativePlayers.isEmpty()) @@ -194,7 +194,7 @@ public class ShapeDispatcher } // client - public static ExpiringShape fromTag(CompoundTag tag) + public static ExpiringShape fromTag(NbtCompound tag) { Map options = new HashMap<>(); for (String key : tag.getKeys()) @@ -265,11 +265,11 @@ public class ShapeDispatcher protected ExpiringShape() { } - public static CompoundTag toTag(Map params) + public static NbtCompound toTag(Map params) { - CompoundTag tag = new CompoundTag(); + NbtCompound tag = new NbtCompound(); params.forEach((k, v) -> { - Tag valTag = Param.of.get(k).toTag(v); + NbtElement valTag = Param.of.get(k).toTag(v); if (valTag != null) tag.put(k, valTag); }); return tag; @@ -890,9 +890,9 @@ public class ShapeDispatcher this.id = id; } - public abstract Tag toTag(Value value); //validates value, returning null if not necessary to keep it and serialize + public abstract NbtElement toTag(Value value); //validates value, returning null if not necessary to keep it and serialize public abstract Value validate(Map options, CarpetContext cc, Value value); // makes sure the value is proper - public abstract Value decode(Tag tag); + public abstract Value decode(NbtElement tag); } public abstract static class StringParam extends Param @@ -900,8 +900,8 @@ public class ShapeDispatcher protected StringParam(String id) { super(id); } @Override - public Tag toTag(Value value) { return StringTag.of(value.getString()); } - public Value decode(Tag tag) { return new StringValue(tag.asString()); } + public NbtElement toTag(Value value) { return NbtString.of(value.getString()); } + public Value decode(NbtElement tag) { return new StringValue(tag.asString()); } } public static class TextParam extends StringParam { @@ -931,15 +931,15 @@ public class ShapeDispatcher } @Override - public Tag toTag(Value value) + public NbtElement toTag(Value value) { if (!(value instanceof FormattedTextValue)) value = new FormattedTextValue(new LiteralText(value.getString())); - return StringTag.of(((FormattedTextValue)value).serialize()); + return NbtString.of(((FormattedTextValue)value).serialize()); } @Override - public Value decode(Tag tag) + public Value decode(NbtElement tag) { return FormattedTextValue.deserialize(tag.asString()); } @@ -1004,24 +1004,24 @@ public class ShapeDispatcher } @Override - public Tag toTag(Value value) + public NbtElement toTag(Value value) { - return ByteTag.of(value.getBoolean()); + return NbtByte.of(value.getBoolean()); } @Override - public Value decode(Tag tag) + public Value decode(NbtElement tag) { - return new NumericValue(((ByteTag) tag).getByte() > 0); + return new NumericValue(((NbtByte) tag).byteValue() > 0); } } public static class FloatParam extends NumericParam { protected FloatParam(String id) { super(id); } @Override - public Value decode(Tag tag) { return new NumericValue(((FloatTag)tag).getFloat()); } + public Value decode(NbtElement tag) { return new NumericValue(((NbtFloat)tag).floatValue()); } @Override - public Tag toTag(Value value) { return FloatTag.of(NumericValue.asNumber(value, id).getFloat()); } + public NbtElement toTag(Value value) { return NbtFloat.of(NumericValue.asNumber(value, id).getFloat()); } } public static abstract class PositiveParam extends NumericParam @@ -1038,27 +1038,27 @@ public class ShapeDispatcher { protected PositiveFloatParam(String id) { super(id); } @Override - public Value decode(Tag tag) { return new NumericValue(((FloatTag)tag).getFloat()); } + public Value decode(NbtElement tag) { return new NumericValue(((NbtFloat)tag).floatValue()); } @Override - public Tag toTag(Value value) { return FloatTag.of(NumericValue.asNumber(value, id).getFloat()); } + public NbtElement toTag(Value value) { return NbtFloat.of(NumericValue.asNumber(value, id).getFloat()); } } public static class PositiveIntParam extends PositiveParam { protected PositiveIntParam(String id) { super(id); } @Override - public Value decode(Tag tag) { return new NumericValue(((IntTag)tag).getInt()); } + public Value decode(NbtElement tag) { return new NumericValue(((NbtInt)tag).intValue()); } @Override - public Tag toTag(Value value) { return IntTag.of(NumericValue.asNumber(value, id).getInt()); } + public NbtElement toTag(Value value) { return NbtInt.of(NumericValue.asNumber(value, id).getInt()); } } public static class NonNegativeIntParam extends NumericParam { protected NonNegativeIntParam(String id) { super(id); } @Override - public Value decode(Tag tag) { return new NumericValue(((IntTag)tag).getInt()); } + public Value decode(NbtElement tag) { return new NumericValue(((NbtInt)tag).intValue()); } @Override - public Tag toTag(Value value) { return IntTag.of(NumericValue.asNumber(value, id).getInt()); } + public NbtElement toTag(Value value) { return NbtInt.of(NumericValue.asNumber(value, id).getInt()); } @Override public Value validate(Map options, CarpetContext cc, Value value) { Value ret = super.validate(options, cc, value); @@ -1070,9 +1070,9 @@ public class ShapeDispatcher { protected NonNegativeFloatParam(String id) { super(id); } @Override - public Value decode(Tag tag) { return new NumericValue(((FloatTag)tag).getFloat()); } + public Value decode(NbtElement tag) { return new NumericValue(((NbtFloat)tag).floatValue()); } @Override - public Tag toTag(Value value) { return FloatTag.of(NumericValue.asNumber(value, id).getFloat()); } + public NbtElement toTag(Value value) { return NbtFloat.of(NumericValue.asNumber(value, id).getFloat()); } @Override public Value validate(Map options, CarpetContext cc, Value value) { Value ret = super.validate(options, cc, value); @@ -1137,9 +1137,9 @@ public class ShapeDispatcher throw new InternalExpressionException("'"+p.id+"' requires a triple, block or entity to indicate position"); } - public Value decode(Tag tag) + public Value decode(NbtElement tag) { - ListTag ctag = (ListTag)tag; + NbtList ctag = (NbtList)tag; return ListValue.of( new NumericValue(ctag.getDouble(0)), new NumericValue(ctag.getDouble(1)), @@ -1147,13 +1147,13 @@ public class ShapeDispatcher ); } @Override - public Tag toTag(Value value) + public NbtElement toTag(Value value) { List lv = ((ListValue)value).getItems(); - ListTag tag = new ListTag(); - tag.add(DoubleTag.of(NumericValue.asNumber(lv.get(0), "x").getDouble())); - tag.add(DoubleTag.of(NumericValue.asNumber(lv.get(1), "y").getDouble())); - tag.add(DoubleTag.of(NumericValue.asNumber(lv.get(2), "z").getDouble())); + NbtList tag = new NbtList(); + tag.add(NbtDouble.of(NumericValue.asNumber(lv.get(0), "x").getDouble())); + tag.add(NbtDouble.of(NumericValue.asNumber(lv.get(1), "y").getDouble())); + tag.add(NbtDouble.of(NumericValue.asNumber(lv.get(2), "z").getDouble())); return tag; } } @@ -1175,13 +1175,13 @@ public class ShapeDispatcher return ListValue.wrap(points); } - public Value decode(Tag tag) + public Value decode(NbtElement tag) { - ListTag ltag = (ListTag)tag; + NbtList ltag = (NbtList)tag; List points = new ArrayList<>(); for (int i=0, ll = ltag.size(); i lv = ((ListValue)pointsValue).getItems(); - ListTag ltag = new ListTag(); + NbtList ltag = new NbtList(); for (Value value : lv) { List coords = ((ListValue)value).getItems(); - ListTag tag = new ListTag(); - tag.add(DoubleTag.of(NumericValue.asNumber(lv.get(0), "x").getDouble())); - tag.add(DoubleTag.of(NumericValue.asNumber(lv.get(1), "y").getDouble())); - tag.add(DoubleTag.of(NumericValue.asNumber(lv.get(2), "z").getDouble())); + NbtList tag = new NbtList(); + tag.add(NbtDouble.of(NumericValue.asNumber(lv.get(0), "x").getDouble())); + tag.add(NbtDouble.of(NumericValue.asNumber(lv.get(1), "y").getDouble())); + tag.add(NbtDouble.of(NumericValue.asNumber(lv.get(2), "z").getDouble())); ltag.add(tag); } return ltag; @@ -1216,9 +1216,9 @@ public class ShapeDispatcher super(id); } - public Value decode(Tag tag) { return new NumericValue(((IntTag)tag).getInt()); } + public Value decode(NbtElement tag) { return new NumericValue(((NbtInt)tag).intValue()); } @Override - public Tag toTag(Value value) { return IntTag.of(NumericValue.asNumber(value, id).getInt()); } + public NbtElement toTag(Value value) { return NbtInt.of(NumericValue.asNumber(value, id).getInt()); } } public static class EntityParam extends Param @@ -1227,9 +1227,9 @@ public class ShapeDispatcher protected EntityParam(String id) { super(id); } @Override - public Tag toTag(Value value) + public NbtElement toTag(Value value) { - return IntTag.of(NumericValue.asNumber(value, id).getInt()); + return NbtInt.of(NumericValue.asNumber(value, id).getInt()); } @Override @@ -1242,7 +1242,7 @@ public class ShapeDispatcher return new NumericValue(player.getId()); } - public Value decode(Tag tag) { return new NumericValue(((IntTag)tag).getInt()); } + public Value decode(NbtElement tag) { return new NumericValue(((NbtInt)tag).intValue()); } } private static boolean isStraight(Vec3d from, Vec3d to, double density) diff --git a/src/main/java/carpet/script/utils/ShapesRenderer.java b/src/main/java/carpet/script/utils/ShapesRenderer.java index 700a5e9e..d01e5b8b 100644 --- a/src/main/java/carpet/script/utils/ShapesRenderer.java +++ b/src/main/java/carpet/script/utils/ShapesRenderer.java @@ -14,8 +14,8 @@ import net.minecraft.client.render.VertexFormat; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.world.ClientWorld; import net.minecraft.client.render.VertexFormats; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtList; import net.minecraft.util.math.Direction; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; @@ -60,7 +60,7 @@ public class ShapesRenderer long currentTime = client.world.getTime(); RenderSystem.disableTexture(); RenderSystem.enableDepthTest(); - RenderSystem.setShader(GameRenderer::method_34540); + RenderSystem.setShader(GameRenderer::getPositionColorShader); RenderSystem.depthFunc(515); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); @@ -122,7 +122,7 @@ public class ShapesRenderer RenderSystem.enableTexture(); } - public void addShapes(ListTag tag) + public void addShapes(NbtList tag) { for (int i=0, count = tag.size(); i < count; i++) { @@ -130,7 +130,7 @@ public class ShapesRenderer } } - public void addShape(CompoundTag tag) + public void addShape(NbtCompound tag) { ShapeDispatcher.ExpiringShape shape = ShapeDispatcher.fromTag(tag); if (shape == null) return; diff --git a/src/main/java/carpet/script/value/BlockValue.java b/src/main/java/carpet/script/value/BlockValue.java index e5f6a902..12b159e4 100644 --- a/src/main/java/carpet/script/value/BlockValue.java +++ b/src/main/java/carpet/script/value/BlockValue.java @@ -13,9 +13,9 @@ import net.minecraft.command.argument.BlockArgumentParser; import net.minecraft.block.Blocks; import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.StringTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtString; +import net.minecraft.nbt.NbtElement; import net.minecraft.server.world.ServerWorld; import net.minecraft.state.property.Property; import net.minecraft.util.dynamic.GlobalPos; @@ -45,7 +45,7 @@ public class BlockValue extends Value private BlockState blockState; private final BlockPos pos; private final ServerWorld world; - private CompoundTag data; + private NbtCompound data; public static BlockValue fromCoords(CarpetContext c, int x, int y, int z) { @@ -63,9 +63,9 @@ public class BlockValue extends Value BlockArgumentParser blockstateparser = (new BlockArgumentParser(new StringReader(str), false)).parse(true); if (blockstateparser.getBlockState() != null) { - CompoundTag bd = blockstateparser.getNbtData(); + NbtCompound bd = blockstateparser.getNbtData(); if (bd == null) - bd = new CompoundTag(); + bd = new NbtCompound(); bv = new BlockValue(blockstateparser.getBlockState(), null, null, bd ); if (bvCache.size()>10000) bvCache.clear(); @@ -107,7 +107,7 @@ public class BlockValue extends Value } - public CompoundTag getData() + public NbtCompound getData() { if (data != null) { @@ -118,7 +118,7 @@ public class BlockValue extends Value if (world != null && pos != null) { BlockEntity be = getBlockEntity(world, pos); - CompoundTag tag = new CompoundTag(); + NbtCompound tag = new NbtCompound(); if (be == null) { data = tag; @@ -139,7 +139,7 @@ public class BlockValue extends Value data = null; } - public BlockValue(BlockState state, ServerWorld world, BlockPos position, CompoundTag nbt) + public BlockValue(BlockState state, ServerWorld world, BlockPos position, NbtCompound nbt) { this.world = world; blockState = state; @@ -188,26 +188,26 @@ public class BlockValue extends Value public ServerWorld getWorld() { return world;} @Override - public Tag toTag(boolean force) + public NbtElement toTag(boolean force) { if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); // follows falling block convertion - CompoundTag tag = new CompoundTag(); - CompoundTag state = new CompoundTag(); + NbtCompound tag = new NbtCompound(); + NbtCompound state = new NbtCompound(); BlockState s = getBlockState(); - state.put("Name", StringTag.of(Registry.BLOCK.getId(s.getBlock()).toString())); + state.put("Name", NbtString.of(Registry.BLOCK.getId(s.getBlock()).toString())); Collection> properties = s.getProperties(); if (!properties.isEmpty()) { - CompoundTag props = new CompoundTag(); + NbtCompound props = new NbtCompound(); for (Property p: properties) { - props.put(p.getName(), StringTag.of(s.get(p).toString().toLowerCase(Locale.ROOT))); + props.put(p.getName(), NbtString.of(s.get(p).toString().toLowerCase(Locale.ROOT))); } state.put("Properties", props); } tag.put("BlockState", state); - CompoundTag dataTag = getData(); + NbtCompound dataTag = getData(); if (dataTag != null) { tag.put("TileEntityData", dataTag); diff --git a/src/main/java/carpet/script/value/BooleanValue.java b/src/main/java/carpet/script/value/BooleanValue.java index 19a9bc05..6968c7ee 100644 --- a/src/main/java/carpet/script/value/BooleanValue.java +++ b/src/main/java/carpet/script/value/BooleanValue.java @@ -2,8 +2,8 @@ package carpet.script.value; import com.google.gson.JsonElement; import com.google.gson.JsonPrimitive; -import net.minecraft.nbt.ByteTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtByte; +import net.minecraft.nbt.NbtElement; public class BooleanValue extends NumericValue { @@ -47,8 +47,8 @@ public class BooleanValue extends NumericValue } @Override - public Tag toTag(boolean force) { - return ByteTag.of(boolValue); + public NbtElement toTag(boolean force) { + return NbtByte.of(boolValue); } @Override diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index b342fccc..29cd88ed 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -27,8 +27,8 @@ import net.minecraft.entity.ai.brain.MemoryModuleType; import net.minecraft.entity.ai.pathing.Path; import net.minecraft.entity.projectile.ProjectileEntity; import net.minecraft.entity.vehicle.AbstractMinecartEntity; -import net.minecraft.nbt.StringTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtString; +import net.minecraft.nbt.NbtElement; import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket; import net.minecraft.network.packet.s2c.play.EntityPositionS2CPacket; import net.minecraft.network.packet.s2c.play.ExperienceBarUpdateS2CPacket; @@ -49,12 +49,13 @@ import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.PathAwareEntity; import net.minecraft.entity.passive.PassiveEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; +import net.minecraft.tag.Tag; import net.minecraft.text.LiteralText; import net.minecraft.util.Identifier; import net.minecraft.util.TypeFilter; @@ -241,7 +242,7 @@ public class EntityValue extends Value positive = false; who = who.substring(1); } - net.minecraft.tag.Tag> eTag = server.getTagManager().getOrCreateTagGroup(Registry.ENTITY_TYPE_KEY).getTag(new Identifier(who)); + Tag> eTag = server.getTagManager().getOrCreateTagGroup(Registry.ENTITY_TYPE_KEY).getTag(new Identifier(who)); if (eTag == null) throw new InternalExpressionException(who+" is not a valid entity descriptor"); if (positive) { @@ -450,7 +451,7 @@ public class EntityValue extends Value put("has_scoreboard_tag", (e, a) -> new NumericValue(e.getScoreboardTags().contains(a.getString()))); put("has_entity_tag", (e, a) -> { - net.minecraft.tag.Tag> tag = e.getServer().getTagManager().getOrCreateTagGroup(Registry.ENTITY_TYPE_KEY).getTag(new Identifier(a.getString())); + Tag> tag = e.getServer().getTagManager().getOrCreateTagGroup(Registry.ENTITY_TYPE_KEY).getTag(new Identifier(a.getString())); if (tag == null) return Value.NULL; return new NumericValue(e.getType().isIn(tag)); }); @@ -841,7 +842,7 @@ public class EntityValue extends Value }); put("nbt",(e, a) -> { - CompoundTag nbttagcompound = e.writeNbt((new CompoundTag())); + NbtCompound nbttagcompound = e.writeNbt((new NbtCompound())); if (a==null) return new NBTSerializableValue(nbttagcompound); return new NBTSerializableValue(nbttagcompound).get(a); @@ -1470,7 +1471,7 @@ public class EntityValue extends Value Value tagValue = NBTSerializableValue.fromValue(v); if (tagValue instanceof NBTSerializableValue) { - CompoundTag nbttagcompound = e.writeNbt((new CompoundTag())); + NbtCompound nbttagcompound = e.writeNbt((new NbtCompound())); nbttagcompound.copyFrom(((NBTSerializableValue) tagValue).getCompoundTag()); e.readNbt(nbttagcompound); e.setUuid(uUID); @@ -1493,12 +1494,12 @@ public class EntityValue extends Value } @Override - public Tag toTag(boolean force) + public NbtElement toTag(boolean force) { if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); - CompoundTag tag = new CompoundTag(); - tag.put("Data", getEntity().writeNbt( new CompoundTag())); - tag.put("Name", StringTag.of(Registry.ENTITY_TYPE.getId(getEntity().getType()).toString())); + NbtCompound tag = new NbtCompound(); + tag.put("Data", getEntity().writeNbt( new NbtCompound())); + tag.put("Name", NbtString.of(Registry.ENTITY_TYPE.getId(getEntity().getType()).toString())); return tag; } } diff --git a/src/main/java/carpet/script/value/FormattedTextValue.java b/src/main/java/carpet/script/value/FormattedTextValue.java index 25e45bf0..f7eb80a0 100644 --- a/src/main/java/carpet/script/value/FormattedTextValue.java +++ b/src/main/java/carpet/script/value/FormattedTextValue.java @@ -1,7 +1,7 @@ package carpet.script.value; -import net.minecraft.nbt.StringTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtString; +import net.minecraft.nbt.NbtElement; import net.minecraft.text.BaseText; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; @@ -70,10 +70,10 @@ public class FormattedTextValue extends StringValue } @Override - public Tag toTag(boolean force) + public NbtElement toTag(boolean force) { if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); - return StringTag.of(Text.Serializer.toJson(text)); + return NbtString.of(Text.Serializer.toJson(text)); } @Override diff --git a/src/main/java/carpet/script/value/FrameworkValue.java b/src/main/java/carpet/script/value/FrameworkValue.java index a432974e..a330876f 100644 --- a/src/main/java/carpet/script/value/FrameworkValue.java +++ b/src/main/java/carpet/script/value/FrameworkValue.java @@ -1,6 +1,6 @@ package carpet.script.value; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtElement; public abstract class FrameworkValue extends Value { @@ -29,7 +29,7 @@ public abstract class FrameworkValue extends Value } @Override - public Tag toTag(boolean force) + public NbtElement toTag(boolean force) { throw new UnsupportedOperationException("Scarpet language component cannot be serialized to the tag"); } diff --git a/src/main/java/carpet/script/value/FunctionAnnotationValue.java b/src/main/java/carpet/script/value/FunctionAnnotationValue.java index c15ab396..f5af71d5 100644 --- a/src/main/java/carpet/script/value/FunctionAnnotationValue.java +++ b/src/main/java/carpet/script/value/FunctionAnnotationValue.java @@ -1,7 +1,7 @@ package carpet.script.value; import carpet.script.exception.InternalExpressionException; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtElement; public class FunctionAnnotationValue extends Value { @@ -35,7 +35,7 @@ public class FunctionAnnotationValue extends Value } @Override - public Tag toTag(boolean force) + public NbtElement toTag(boolean force) { throw new UnsupportedOperationException("Global value cannot be serialized to the tag"); } diff --git a/src/main/java/carpet/script/value/FunctionValue.java b/src/main/java/carpet/script/value/FunctionValue.java index 61e97b18..fac4e09e 100644 --- a/src/main/java/carpet/script/value/FunctionValue.java +++ b/src/main/java/carpet/script/value/FunctionValue.java @@ -12,8 +12,8 @@ import carpet.script.exception.ExpressionException; import carpet.script.exception.InternalExpressionException; import carpet.script.exception.ReturnStatement; import carpet.script.exception.ThrowStatement; -import net.minecraft.nbt.StringTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtString; +import net.minecraft.nbt.NbtElement; import java.util.ArrayList; import java.util.Collections; @@ -246,10 +246,10 @@ public class FunctionValue extends Value implements Fluff.ILazyFunction public String getVarArgs() {return varArgs; } @Override - public Tag toTag(boolean force) + public NbtElement toTag(boolean force) { if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); - return StringTag.of(getString()); + return NbtString.of(getString()); } public void assertArgsOk(List list, Consumer feedback) diff --git a/src/main/java/carpet/script/value/LazyListValue.java b/src/main/java/carpet/script/value/LazyListValue.java index 5584e628..c0728155 100644 --- a/src/main/java/carpet/script/value/LazyListValue.java +++ b/src/main/java/carpet/script/value/LazyListValue.java @@ -1,8 +1,8 @@ package carpet.script.value; import carpet.script.exception.InternalExpressionException; -import net.minecraft.nbt.StringTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtString; +import net.minecraft.nbt.NbtElement; import java.util.ArrayList; import java.util.Iterator; @@ -199,9 +199,9 @@ public abstract class LazyListValue extends AbstractListValue implements Iterato } @Override - public Tag toTag(boolean force) + public NbtElement toTag(boolean force) { if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); - return StringTag.of(getString()); + return NbtString.of(getString()); } } diff --git a/src/main/java/carpet/script/value/ListValue.java b/src/main/java/carpet/script/value/ListValue.java index de316668..0d9b753e 100644 --- a/src/main/java/carpet/script/value/ListValue.java +++ b/src/main/java/carpet/script/value/ListValue.java @@ -5,14 +5,14 @@ import carpet.script.exception.InternalExpressionException; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.AbstractNumberTag; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.DoubleTag; -import net.minecraft.nbt.IntTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.LongTag; -import net.minecraft.nbt.StringTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.AbstractNbtNumber; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtDouble; +import net.minecraft.nbt.NbtInt; +import net.minecraft.nbt.NbtList; +import net.minecraft.nbt.NbtLong; +import net.minecraft.nbt.NbtString; +import net.minecraft.nbt.NbtElement; import java.util.ArrayList; import java.util.Arrays; @@ -481,31 +481,31 @@ public class ListValue extends AbstractListValue implements ContainerValueInterf LIST, MAP, STRING; - private static TagTypeCompat getType(Tag tag) + private static TagTypeCompat getType(NbtElement tag) { - if (tag instanceof IntTag) return INT; - if (tag instanceof LongTag) return LONG; - if (tag instanceof DoubleTag) return DBL; - if (tag instanceof ListTag) return LIST; - if (tag instanceof CompoundTag) return MAP; + if (tag instanceof NbtInt) return INT; + if (tag instanceof NbtLong) return LONG; + if (tag instanceof NbtDouble) return DBL; + if (tag instanceof NbtList) return LIST; + if (tag instanceof NbtCompound) return MAP; return STRING; } } @Override - public Tag toTag(boolean force) + public NbtElement toTag(boolean force) { int argSize = items.size(); - if (argSize == 0) return new ListTag(); - ListTag tag = new ListTag(); + if (argSize == 0) return new NbtList(); + NbtList tag = new NbtList(); if (argSize ==1) { tag.add(items.get(0).toTag(force)); return tag; } // figuring out the types - List tags= new ArrayList<>(); + List tags= new ArrayList<>(); items.forEach(v -> tags.add(v.toTag(force))); Set cases = EnumSet.noneOf(TagTypeCompat.class); tags.forEach(t -> cases.add(TagTypeCompat.getType(t))); @@ -519,17 +519,17 @@ public class ListValue extends AbstractListValue implements ContainerValueInterf || cases.contains(TagTypeCompat.STRING)) // incompatible types { if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); - tags.forEach(t -> tag.add(StringTag.of(t.asString()))); + tags.forEach(t -> tag.add(NbtString.of(t.asString()))); return tag; } // only numbers / mixed types if (cases.contains(TagTypeCompat.DBL)) { - tags.forEach(t -> tag.add(DoubleTag.of(((AbstractNumberTag)t).getDouble()))); + tags.forEach(t -> tag.add(NbtDouble.of(((AbstractNbtNumber)t).doubleValue()))); } else { - tags.forEach(t -> tag.add(LongTag.of(((AbstractNumberTag)t).getLong()))); + tags.forEach(t -> tag.add(NbtLong.of(((AbstractNbtNumber)t).longValue()))); } return tag; } diff --git a/src/main/java/carpet/script/value/MapValue.java b/src/main/java/carpet/script/value/MapValue.java index 10d11f24..cbdb48ef 100644 --- a/src/main/java/carpet/script/value/MapValue.java +++ b/src/main/java/carpet/script/value/MapValue.java @@ -3,8 +3,8 @@ package carpet.script.value; import carpet.script.exception.InternalExpressionException; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtElement; import java.util.ArrayList; import java.util.Collections; @@ -254,9 +254,9 @@ public class MapValue extends AbstractListValue implements ContainerValueInterfa } @Override - public Tag toTag(boolean force) + public NbtElement toTag(boolean force) { - CompoundTag tag = new CompoundTag() ; + NbtCompound tag = new NbtCompound() ; map.forEach( (k, v) -> { if (!force && !(k instanceof StringValue)) throw new NBTSerializableValue.IncompatibleTypeException(k); diff --git a/src/main/java/carpet/script/value/NBTSerializableValue.java b/src/main/java/carpet/script/value/NBTSerializableValue.java index 9fef4954..e4e51334 100644 --- a/src/main/java/carpet/script/value/NBTSerializableValue.java +++ b/src/main/java/carpet/script/value/NBTSerializableValue.java @@ -25,13 +25,13 @@ import net.minecraft.entity.passive.VillagerEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.AbstractListTag; -import net.minecraft.nbt.AbstractNumberTag; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.AbstractNbtList; +import net.minecraft.nbt.AbstractNbtNumber; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtList; import net.minecraft.nbt.StringNbtReader; -import net.minecraft.nbt.StringTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtString; +import net.minecraft.nbt.NbtElement; import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; @@ -53,8 +53,8 @@ import java.util.stream.Collectors; public class NBTSerializableValue extends Value implements ContainerValueInterface { private String nbtString = null; - private Tag nbtTag = null; - private Supplier nbtSupplier = null; + private NbtElement nbtTag = null; + private Supplier nbtSupplier = null; private boolean owned = false; private NBTSerializableValue() {} @@ -65,7 +65,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa { try { - return (new StringNbtReader(new StringReader(nbtString))).parseTag(); + return (new StringNbtReader(new StringReader(nbtString))).parseElement(); } catch (CommandSyntaxException e) { @@ -75,13 +75,13 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa owned = true; } - public NBTSerializableValue(Tag tag) + public NBTSerializableValue(NbtElement tag) { nbtTag = tag; owned = true; } - public NBTSerializableValue(Supplier tagSupplier) + public NBTSerializableValue(Supplier tagSupplier) { nbtSupplier = tagSupplier; } @@ -108,10 +108,10 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa public static NBTSerializableValue parseString(String nbtString, boolean fail) { - Tag tag; + NbtElement tag; try { - tag = (new StringNbtReader(new StringReader(nbtString))).parseTag(); + tag = (new StringNbtReader(new StringReader(nbtString))).parseElement(); } catch (CommandSyntaxException e) { @@ -276,7 +276,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa return parseItem(itemString, null); } - public static ItemStackArgument parseItem(String itemString, CompoundTag customTag) + public static ItemStackArgument parseItem(String itemString, NbtCompound customTag) { try { @@ -313,12 +313,12 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa return slot; } - private static Value decodeTag(Tag t) + private static Value decodeTag(NbtElement t) { - if (t instanceof CompoundTag) + if (t instanceof NbtCompound) return new NBTSerializableValue(() -> t); - if (t instanceof AbstractNumberTag) - return new NumericValue(((AbstractNumberTag) t).getDouble()); + if (t instanceof AbstractNbtNumber) + return new NumericValue(((AbstractNbtNumber) t).doubleValue()); // more can be done here return new StringValue(t.asString()); } @@ -338,35 +338,35 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa } - private static Value decodeTagDeep(Tag t) + private static Value decodeTagDeep(NbtElement t) { - if (t instanceof CompoundTag) + if (t instanceof NbtCompound) { Map pairs = new HashMap<>(); - CompoundTag ctag = (CompoundTag)t; + NbtCompound ctag = (NbtCompound)t; for (String key: ctag.getKeys()) { pairs.put(new StringValue(key), decodeTagDeep(ctag.get(key))); } return MapValue.wrap(pairs); } - if (t instanceof AbstractListTag) + if (t instanceof AbstractNbtList) { List elems = new ArrayList<>(); - AbstractListTag ltag = (AbstractListTag)t; - for (Tag elem: ltag) + AbstractNbtList ltag = (AbstractNbtList)t; + for (NbtElement elem: ltag) { elems.add(decodeTagDeep(elem)); } return ListValue.wrap(elems); } - if (t instanceof AbstractNumberTag) - return new NumericValue(((AbstractNumberTag) t).getDouble()); + if (t instanceof AbstractNbtNumber) + return new NumericValue(((AbstractNbtNumber) t).doubleValue()); // more can be done here return new StringValue(t.asString()); } - public Tag getTag() + public NbtElement getTag() { if (nbtTag == null) nbtTag = nbtSupplier.get(); @@ -392,24 +392,24 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa @Override public boolean getBoolean() { - Tag tag = getTag(); - if (tag instanceof CompoundTag) - return !((CompoundTag) tag).isEmpty(); - if (tag instanceof AbstractListTag) - return ((AbstractListTag) tag).isEmpty(); - if (tag instanceof AbstractNumberTag) - return ((AbstractNumberTag) tag).getDouble()!=0.0; - if (tag instanceof StringTag) + NbtElement tag = getTag(); + if (tag instanceof NbtCompound) + return !((NbtCompound) tag).isEmpty(); + if (tag instanceof AbstractNbtList) + return ((AbstractNbtList) tag).isEmpty(); + if (tag instanceof AbstractNbtNumber) + return ((AbstractNbtNumber) tag).doubleValue()!=0.0; + if (tag instanceof NbtString) return tag.asString().isEmpty(); return true; } - public CompoundTag getCompoundTag() + public NbtCompound getCompoundTag() { try { ensureOwnership(); - return (CompoundTag) getTag(); + return (NbtCompound) getTag(); } catch (ClassCastException e) { @@ -429,7 +429,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa /// WIP ensureOwnership(); NbtPathArgumentType.NbtPath path = cachePath(where.getString()); - Tag tagToInsert = value instanceof NBTSerializableValue ? + NbtElement tagToInsert = value instanceof NBTSerializableValue ? ((NBTSerializableValue) value).getTag() : new NBTSerializableValue(value.getString()).getTag(); boolean modifiedTag; @@ -459,17 +459,17 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa - private boolean modify_insert(int index, NbtPathArgumentType.NbtPath nbtPath, Tag newElement) + private boolean modify_insert(int index, NbtPathArgumentType.NbtPath nbtPath, NbtElement newElement) { return modify_insert(index, nbtPath, newElement, this.getTag()); } - private boolean modify_insert(int index, NbtPathArgumentType.NbtPath nbtPath, Tag newElement, Tag currentTag) + private boolean modify_insert(int index, NbtPathArgumentType.NbtPath nbtPath, NbtElement newElement, NbtElement currentTag) { - Collection targets; + Collection targets; try { - targets = nbtPath.getOrInit(currentTag, ListTag::new); + targets = nbtPath.getOrInit(currentTag, NbtList::new); } catch (CommandSyntaxException e) { @@ -477,16 +477,16 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa } boolean modified = false; - for (Tag target : targets) + for (NbtElement target : targets) { - if (!(target instanceof AbstractListTag)) + if (!(target instanceof AbstractNbtList)) { continue; } try { - AbstractListTag targetList = (AbstractListTag) target; - if (!targetList.addTag(index < 0 ? targetList.size() + index + 1 : index, newElement.copy())) + AbstractNbtList targetList = (AbstractNbtList) target; + if (!targetList.addElement(index < 0 ? targetList.size() + index + 1 : index, newElement.copy())) return false; modified = true; } @@ -498,22 +498,22 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa } - private boolean modify_merge(NbtPathArgumentType.NbtPath nbtPath, Tag replacement) //nbtPathArgumentType$NbtPath_1, list_1) + private boolean modify_merge(NbtPathArgumentType.NbtPath nbtPath, NbtElement replacement) //nbtPathArgumentType$NbtPath_1, list_1) { - if (!(replacement instanceof CompoundTag)) + if (!(replacement instanceof NbtCompound)) { return false; } - Tag ownTag = getTag(); + NbtElement ownTag = getTag(); try { - for (Tag target : nbtPath.getOrInit(ownTag, CompoundTag::new)) + for (NbtElement target : nbtPath.getOrInit(ownTag, NbtCompound::new)) { - if (!(target instanceof CompoundTag)) + if (!(target instanceof NbtCompound)) { continue; } - ((CompoundTag) target).copyFrom((CompoundTag) replacement); + ((NbtCompound) target).copyFrom((NbtCompound) replacement); } } catch (CommandSyntaxException ignored) @@ -523,9 +523,9 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa return true; } - private boolean modify_replace(NbtPathArgumentType.NbtPath nbtPath, Tag replacement) //nbtPathArgumentType$NbtPath_1, list_1) + private boolean modify_replace(NbtPathArgumentType.NbtPath nbtPath, NbtElement replacement) //nbtPathArgumentType$NbtPath_1, list_1) { - Tag tag = getTag(); + NbtElement tag = getTag(); String pathText = nbtPath.toString(); if (pathText.endsWith("]")) // workaround for array replacement or item in the array replacement { @@ -572,7 +572,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa NbtPathArgumentType.NbtPath path = cachePath(value.getString()); try { - List tags = path.get(getTag()); + List tags = path.get(getTag()); if (tags.size()==0) return Value.NULL; if (tags.size()==1) @@ -669,7 +669,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa @Override - public Tag toTag(boolean force) + public NbtElement toTag(boolean force) { if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); ensureOwnership(); diff --git a/src/main/java/carpet/script/value/NullValue.java b/src/main/java/carpet/script/value/NullValue.java index 1e5f08a0..8374e51f 100644 --- a/src/main/java/carpet/script/value/NullValue.java +++ b/src/main/java/carpet/script/value/NullValue.java @@ -4,8 +4,8 @@ import java.util.ArrayList; import com.google.gson.JsonElement; import com.google.gson.JsonNull; -import net.minecraft.nbt.StringTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtString; +import net.minecraft.nbt.NbtElement; public class NullValue extends NumericValue // TODO check nonsingleton code { @@ -80,10 +80,10 @@ public class NullValue extends NumericValue // TODO check nonsingleton code } @Override - public Tag toTag(boolean force) + public NbtElement toTag(boolean force) { if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); - return StringTag.of("null"); + return NbtString.of("null"); } @Override diff --git a/src/main/java/carpet/script/value/NumericValue.java b/src/main/java/carpet/script/value/NumericValue.java index 00a506f4..e3d99cdb 100644 --- a/src/main/java/carpet/script/value/NumericValue.java +++ b/src/main/java/carpet/script/value/NumericValue.java @@ -3,10 +3,10 @@ package carpet.script.value; import carpet.script.exception.InternalExpressionException; import com.google.gson.JsonElement; import com.google.gson.JsonPrimitive; -import net.minecraft.nbt.DoubleTag; -import net.minecraft.nbt.IntTag; -import net.minecraft.nbt.LongTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtDouble; +import net.minecraft.nbt.NbtInt; +import net.minecraft.nbt.NbtLong; +import net.minecraft.nbt.NbtElement; import org.apache.commons.lang3.StringUtils; import java.math.BigDecimal; @@ -271,20 +271,20 @@ public class NumericValue extends Value } @Override - public Tag toTag(boolean force) + public NbtElement toTag(boolean force) { if (longValue != null) - return LongTag.of(longValue); + return NbtLong.of(longValue); long lv = getLong(); if (value == (double)lv) { if (abs(value) < Integer.MAX_VALUE-2) - return IntTag.of((int)lv); - return LongTag.of(getLong()); + return NbtInt.of((int)lv); + return NbtLong.of(getLong()); } else { - return DoubleTag.of(value); + return NbtDouble.of(value); } } diff --git a/src/main/java/carpet/script/value/StringValue.java b/src/main/java/carpet/script/value/StringValue.java index 48fea7c1..65d7553c 100644 --- a/src/main/java/carpet/script/value/StringValue.java +++ b/src/main/java/carpet/script/value/StringValue.java @@ -1,7 +1,7 @@ package carpet.script.value; -import net.minecraft.nbt.StringTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtString; +import net.minecraft.nbt.NbtElement; public class StringValue extends Value { @@ -43,8 +43,8 @@ public class StringValue extends Value } @Override - public Tag toTag(boolean force) + public NbtElement toTag(boolean force) { - return StringTag.of(str); + return NbtString.of(str); } } diff --git a/src/main/java/carpet/script/value/ThreadValue.java b/src/main/java/carpet/script/value/ThreadValue.java index fd833bec..7c22fa46 100644 --- a/src/main/java/carpet/script/value/ThreadValue.java +++ b/src/main/java/carpet/script/value/ThreadValue.java @@ -6,7 +6,7 @@ import carpet.script.Tokenizer; import carpet.script.exception.ExitStatement; import carpet.script.exception.ExpressionException; import carpet.script.exception.InternalExpressionException; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtElement; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -117,7 +117,7 @@ public class ThreadValue extends Value } @Override - public Tag toTag(boolean force) + public NbtElement toTag(boolean force) { if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); return getValue().toTag(true); diff --git a/src/main/java/carpet/script/value/Value.java b/src/main/java/carpet/script/value/Value.java index 389ede83..5c89684e 100644 --- a/src/main/java/carpet/script/value/Value.java +++ b/src/main/java/carpet/script/value/Value.java @@ -3,7 +3,7 @@ package carpet.script.value; import carpet.script.exception.InternalExpressionException; import com.google.gson.JsonElement; import com.google.gson.JsonPrimitive; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.NbtElement; import java.util.ArrayList; import java.util.Arrays; @@ -251,7 +251,7 @@ public abstract class Value implements Comparable, Cloneable } } - public abstract Tag toTag(boolean force); + public abstract NbtElement toTag(boolean force); public JsonElement toJson() { From b49b99aea6493e79a52aa36447da51e05134a7ff Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 31 Mar 2021 19:20:44 -0300 Subject: [PATCH 045/115] 21w11a mappings --- gradle.properties | 2 +- src/main/java/carpet/mixins/ItemEntityMixin.java | 8 ++++---- .../carpet/mixins/PlayerEntity_creativeNoClipMixin.java | 2 +- src/main/java/carpet/network/ClientNetworkHandler.java | 4 ++-- src/main/java/carpet/network/ServerNetworkHandler.java | 4 ++-- src/main/java/carpet/patches/EntityPlayerMPFake.java | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gradle.properties b/gradle.properties index 31d70bbc..ded7b2bc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=21w11a - yarn_mappings=21w11a+build.20 + yarn_mappings=21w11a+build.46 loader_version=0.11.3 fabric_version=0.32.5+1.17 diff --git a/src/main/java/carpet/mixins/ItemEntityMixin.java b/src/main/java/carpet/mixins/ItemEntityMixin.java index 84510d21..233540e8 100644 --- a/src/main/java/carpet/mixins/ItemEntityMixin.java +++ b/src/main/java/carpet/mixins/ItemEntityMixin.java @@ -24,7 +24,7 @@ public abstract class ItemEntityMixin extends Entity implements ItemEntityInterf { private static final int SHULKERBOX_MAX_STACK_AMOUNT = 64; - @Shadow private int age; + @Shadow private int itemAge; @Shadow private int pickupDelay; public ItemEntityMixin(EntityType entityType_1, World world_1) { @@ -34,7 +34,7 @@ public abstract class ItemEntityMixin extends Entity implements ItemEntityInterf @Override public void onStruckByLightning(ServerWorld world, LightningEntity lightning) { if (CarpetSettings.lightningKillsDropsFix) { - if (this.age > 8) { //Only kill item if its older then 8 ticks + if (this.itemAge > 8) { //Only kill item if its older then 8 ticks super.onStruckByLightning(world, lightning); } } else { @@ -44,7 +44,7 @@ public abstract class ItemEntityMixin extends Entity implements ItemEntityInterf @Override public int getAgeCM() { - return this.age; + return this.itemAge; } @Override @@ -105,7 +105,7 @@ public abstract class ItemEntityMixin extends Entity implements ItemEntityInterf self.setStack(selfStack); this.pickupDelay = Math.max(((ItemEntityInterface)other).getPickupDelayCM(), this.pickupDelay); - this.age = Math.min(((ItemEntityInterface)other).getAgeCM(), this.age); + this.itemAge = Math.min(((ItemEntityInterface)other).getAgeCM(), this.itemAge); otherStack.decrement(amount); if (otherStack.isEmpty()) diff --git a/src/main/java/carpet/mixins/PlayerEntity_creativeNoClipMixin.java b/src/main/java/carpet/mixins/PlayerEntity_creativeNoClipMixin.java index 342783e4..d0e51b81 100644 --- a/src/main/java/carpet/mixins/PlayerEntity_creativeNoClipMixin.java +++ b/src/main/java/carpet/mixins/PlayerEntity_creativeNoClipMixin.java @@ -36,7 +36,7 @@ public abstract class PlayerEntity_creativeNoClipMixin extends LivingEntity return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.getAbilities().flying); } - @Redirect(method = "updateSize", at = @At( + @Redirect(method = "updatePose", at = @At( value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isSpectator()Z") ) diff --git a/src/main/java/carpet/network/ClientNetworkHandler.java b/src/main/java/carpet/network/ClientNetworkHandler.java index 9c62c4e0..094b75f3 100644 --- a/src/main/java/carpet/network/ClientNetworkHandler.java +++ b/src/main/java/carpet/network/ClientNetworkHandler.java @@ -129,7 +129,7 @@ public class ClientNetworkHandler private static void onSyncData(PacketByteBuf data, ClientPlayerEntity player) { - NbtCompound compound = data.readCompoundTag(); + NbtCompound compound = data.readCompound(); if (compound == null) return; for (String key: compound.getKeys()) { @@ -149,7 +149,7 @@ public class ClientNetworkHandler outer.put("clientCommand", tag); CarpetClient.getPlayer().networkHandler.sendPacket(new CustomPayloadC2SPacket( CarpetClient.CARPET_CHANNEL, - (new PacketByteBuf(Unpooled.buffer())).writeVarInt(CarpetClient.DATA).writeCompoundTag(outer) + (new PacketByteBuf(Unpooled.buffer())).writeVarInt(CarpetClient.DATA).writeCompound(outer) )); } } diff --git a/src/main/java/carpet/network/ServerNetworkHandler.java b/src/main/java/carpet/network/ServerNetworkHandler.java index 25310b4c..59a4b89d 100644 --- a/src/main/java/carpet/network/ServerNetworkHandler.java +++ b/src/main/java/carpet/network/ServerNetworkHandler.java @@ -138,7 +138,7 @@ public class ServerNetworkHandler private static void onClientData(ServerPlayerEntity player, PacketByteBuf data) { - NbtCompound compound = data.readCompoundTag(); + NbtCompound compound = data.readCompound(); if (compound == null) return; for (String key: compound.getKeys()) { @@ -323,7 +323,7 @@ public class ServerNetworkHandler { PacketByteBuf packetBuf = new PacketByteBuf(Unpooled.buffer()); packetBuf.writeVarInt(CarpetClient.DATA); - packetBuf.writeCompoundTag(tag); + packetBuf.writeCompound(tag); return packetBuf; } diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index 39808ad4..0a567ebc 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -52,7 +52,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity instance.interactionManager.changeGameMode(gamemode); server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(instance, (byte) (instance.headYaw * 256 / 360)), dimensionId);//instance.dimension); server.getPlayerManager().sendToDimension(new EntityPositionS2CPacket(instance), dimensionId);//instance.dimension); - instance.getServerWorld().getChunkManager().updateCameraPosition(instance); + instance.getServerWorld().getChunkManager().updatePosition(instance); instance.dataTracker.set(PLAYER_MODEL_PARTS, (byte) 0x7f); // show all model layers (incl. capes) return instance; } @@ -76,7 +76,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(playerShadow, (byte) (player.headYaw * 256 / 360)), playerShadow.world.getRegistryKey()); server.getPlayerManager().sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, playerShadow)); - player.getServerWorld().getChunkManager().updateCameraPosition(playerShadow); + player.getServerWorld().getChunkManager().updatePosition(playerShadow); return playerShadow; } @@ -111,7 +111,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity if (this.getServer().getTicks() % 10 == 0) { this.networkHandler.syncWithPlayerPosition(); - this.getServerWorld().getChunkManager().updateCameraPosition(this); + this.getServerWorld().getChunkManager().updatePosition(this); onTeleportationDone(); //<- causes hard crash but would need to be done to enable portals // not as of 1.17 } super.tick(); From 0320de5d6de194fa8115528665dc209f2d401276 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 31 Mar 2021 22:02:09 -0300 Subject: [PATCH 046/115] 21w13a --- gradle.properties | 4 +-- src/main/java/carpet/CarpetSettings.java | 3 -- .../java/carpet/commands/ScriptCommand.java | 34 +++++++++---------- .../fakes/InventoryBearerInterface.java | 3 +- .../java/carpet/helpers/BlockRotator.java | 2 +- .../java/carpet/helpers/FeatureGenerator.java | 2 +- .../mixins/BastionRemnantFeatureMixin.java | 8 +++-- .../mixins/DesertPyramidFeatureMixin.java | 9 ++--- .../carpet/mixins/EndCityFeatureMixin.java | 7 ++-- .../EntityNavigation_pathfindingMixin.java | 15 ++++---- .../mixins/ExperienceOrbEntityMixin.java | 18 ---------- .../mixins/FlatChunkGeneratorMixin.java | 3 +- .../FluidBlock_renewableBlackstoneMixin.java | 2 +- .../carpet/mixins/HopperBlockEntityMixin.java | 2 +- .../NoiseChunkGenerator_husksSpawnMixin.java | 3 +- .../PistonHandler_customStickyMixin.java | 2 +- .../carpet/mixins/StructureFeatureMixin.java | 6 ++-- .../carpet/script/api/BlockIterators.java | 8 ++--- .../java/carpet/script/api/WorldAccess.java | 10 +++--- .../script/value/NBTSerializableValue.java | 4 ++- .../carpet/script/value/ValueConversions.java | 14 ++++---- .../carpet/utils/PerimeterDiagnostics.java | 6 ++-- src/main/java/carpet/utils/SpawnReporter.java | 2 +- 23 files changed, 78 insertions(+), 89 deletions(-) diff --git a/gradle.properties b/gradle.properties index ded7b2bc..72a418cc 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=21w11a - yarn_mappings=21w11a+build.46 + minecraft_version=21w13a + yarn_mappings=21w13a+build.2 loader_version=0.11.3 fabric_version=0.32.5+1.17 diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index abd6287e..1ba4331e 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -184,9 +184,6 @@ public class CarpetSettings @Rule( desc = "Players absorb XP instantly, without delay", category = CREATIVE ) public static boolean xpNoCooldown = false; - @Rule( desc = "xpfix", category = SURVIVAL ) - public static boolean xpfix = false; - @Rule( desc = "XP orbs combine with other into bigger orbs", category = FEATURE ) public static boolean combineXPOrbs = false; diff --git a/src/main/java/carpet/commands/ScriptCommand.java b/src/main/java/carpet/commands/ScriptCommand.java index ceda769d..bc9d5b4e 100644 --- a/src/main/java/carpet/commands/ScriptCommand.java +++ b/src/main/java/carpet/commands/ScriptCommand.java @@ -470,7 +470,7 @@ public class ScriptCommand CarpetScriptHost host = getHost(context); BlockBox area = BlockBox.create(a, b); CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin); - int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ(); + int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.method_35414(); // X Y Z if (int_1 > CarpetSettings.fillLimit) { Messenger.m(source, "r too many blocks to evaluate: " + int_1); @@ -480,11 +480,11 @@ public class ScriptCommand CarpetSettings.impendingFillSkipUpdates = !CarpetSettings.fillUpdates; try { - for (int x = area.minX; x <= area.maxX; x++) + for (int x = area.method_35420(); x <= area.method_35417(); x++) //minx maxx { - for (int y = area.minY; y <= area.maxY; y++) + for (int y = area.method_35415(); y <= area.method_35418(); y++) // miny maxy { - for (int z = area.minZ; z <= area.maxZ; z++) + for (int z = area.method_35416(); z <= area.method_35419(); z++) // minz maxz { try { @@ -519,29 +519,29 @@ public class ScriptCommand CarpetScriptHost host = getHost(context); BlockBox area = BlockBox.create(a, b); CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin); - int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ(); + int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.method_35414(); if (int_1 > CarpetSettings.fillLimit) { Messenger.m(source, "r too many blocks to evaluate: "+ int_1); return 1; } - boolean[][][] volume = new boolean[area.getBlockCountX()][area.getBlockCountY()][area.getBlockCountZ()]; + boolean[][][] volume = new boolean[area.getBlockCountY()][area.method_35414()][area.getBlockCountX()]; //X then Y then Z got messedup BlockPos.Mutable mbpos = origin.mutableCopy(); ServerWorld world = source.getWorld(); - for (int x = area.minX; x <= area.maxX; x++) + for (int x = area.method_35420(); x <= area.method_35417(); x++) //minx maxx { - for (int y = area.minY; y <= area.maxY; y++) + for (int y = area.method_35415(); y <= area.method_35418(); y++) // miny maxy { - for (int z = area.minZ; z <= area.maxZ; z++) + for (int z = area.method_35416(); z <= area.method_35419(); z++) // minz maxz { try { if (cexpr.fillAndScanCommand(host, x, y, z)) { - volume[x-area.minX][y-area.minY][z-area.minZ]=true; + volume[x-area.method_35420()][y-area.method_35415()][z-area.method_35416()]=true; } } catch (CarpetExpressionException e) @@ -555,12 +555,12 @@ public class ScriptCommand } } } - final int maxx = area.getBlockCountX()-1; - final int maxy = area.getBlockCountY()-1; - final int maxz = area.getBlockCountZ()-1; + final int maxx = area.getBlockCountY()-1; //x + final int maxy = area.method_35414()-1; //y + final int maxz = area.getBlockCountX()-1; //z if ("outline".equalsIgnoreCase(mode)) { - boolean[][][] newVolume = new boolean[area.getBlockCountX()][area.getBlockCountY()][area.getBlockCountZ()]; + boolean[][][] newVolume = new boolean[area.getBlockCountY()][area.method_35414()][area.getBlockCountX()]; //X then Y then Z got messedup for (int x = 0; x <= maxx; x++) { for (int y = 0; y <= maxy; y++) @@ -596,7 +596,7 @@ public class ScriptCommand { if (volume[x][y][z]) { - mbpos.set(x+area.minX, y+area.minY, z+area.minZ); + mbpos.set(x+area.method_35420(), y+area.method_35415(), z+area.method_35416()); if (replacement == null || replacement.test( new CachedBlockPosition( world, mbpos, true))) { @@ -624,7 +624,7 @@ public class ScriptCommand { if (volume[x][y][z]) { - mbpos.set(x+area.minX, y+area.minY, z+area.minZ); + mbpos.set(x+area.method_35420(), y+area.method_35415(), z+area.method_35416()); Block blokc = world.getBlockState(mbpos).getBlock(); world.updateNeighbors(mbpos, blokc); } @@ -632,7 +632,7 @@ public class ScriptCommand } } } - Messenger.m(source, "gi Affected "+affected+" blocks in "+area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ()+" block volume"); + Messenger.m(source, "gi Affected "+affected+" blocks in "+area.getBlockCountX() * area.getBlockCountY() * area.method_35414()+" block volume"); return 1; } } diff --git a/src/main/java/carpet/fakes/InventoryBearerInterface.java b/src/main/java/carpet/fakes/InventoryBearerInterface.java index aa282382..a1426973 100644 --- a/src/main/java/carpet/fakes/InventoryBearerInterface.java +++ b/src/main/java/carpet/fakes/InventoryBearerInterface.java @@ -1,8 +1,9 @@ package carpet.fakes; +import net.minecraft.class_6067; import net.minecraft.inventory.Inventory; public interface InventoryBearerInterface { - Inventory getCMInventory(); + Inventory getCMInventory(); // can be removed in 1.17 due to class_6067 } diff --git a/src/main/java/carpet/helpers/BlockRotator.java b/src/main/java/carpet/helpers/BlockRotator.java index e0b27d3f..8f9e9936 100644 --- a/src/main/java/carpet/helpers/BlockRotator.java +++ b/src/main/java/carpet/helpers/BlockRotator.java @@ -226,7 +226,7 @@ public class BlockRotator { Direction sourceFace = source.getBlockState().get(DispenserBlock.FACING); World world = source.getWorld(); - BlockPos blockpos = source.getBlockPos().offset(sourceFace); + BlockPos blockpos = source.getBlockPos().method_35851(sourceFace); // offset BlockState iblockstate = world.getBlockState(blockpos); Block block = iblockstate.getBlock(); diff --git a/src/main/java/carpet/helpers/FeatureGenerator.java b/src/main/java/carpet/helpers/FeatureGenerator.java index c2fd2be0..fc1c500a 100644 --- a/src/main/java/carpet/helpers/FeatureGenerator.java +++ b/src/main/java/carpet/helpers/FeatureGenerator.java @@ -162,7 +162,7 @@ public class FeatureGenerator { if (!computeBox) return StructureStart.DEFAULT; StructureManager manager = world.getStructureManager(); - StructureStart structureStart3 = structure.getStructureStartFactory().create((StructureFeature) configuredFeature.feature, chunkPos, BlockBox.empty(), 0, seed); + StructureStart structureStart3 = structure.getStructureStartFactory().create((StructureFeature) configuredFeature.feature, chunkPos, 0, seed); structureStart3.init(world.getRegistryManager(), generator, manager, chunkPos, biome, (T) configuredFeature.config, world); if (!structureStart3.hasChildren()) return null; return structureStart3; diff --git a/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java b/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java index bee4a591..9e3024cf 100644 --- a/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java +++ b/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java @@ -4,7 +4,9 @@ import carpet.CarpetSettings; import com.google.common.collect.Lists; import com.mojang.serialization.Codec; +import net.minecraft.class_6012; import net.minecraft.entity.EntityType; +import net.minecraft.world.MobSpawnerLogic; import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.gen.feature.BastionRemnantFeature; @@ -18,7 +20,7 @@ import java.util.List; @Mixin(BastionRemnantFeature.class) public abstract class BastionRemnantFeatureMixin extends JigsawFeature { - private static final List spawnList = Lists.newArrayList( + private static final class_6012 spawnList = class_6012.method_34989( new SpawnSettings.SpawnEntry(EntityType.PIGLIN_BRUTE, 5, 1, 2), new SpawnSettings.SpawnEntry(EntityType.PIGLIN, 10, 2, 4), new SpawnSettings.SpawnEntry(EntityType.HOGLIN, 2, 1, 2) @@ -30,10 +32,10 @@ public abstract class BastionRemnantFeatureMixin extends JigsawFeature } @Override - public List getMonsterSpawns() + public class_6012 getMonsterSpawns() { if (CarpetSettings.piglinsSpawningInBastions) return spawnList; - return Collections.emptyList(); + return SpawnSettings.field_30982; // empty spawn list } } diff --git a/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java b/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java index 0b08e722..379f8bcf 100644 --- a/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java +++ b/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java @@ -3,6 +3,7 @@ package carpet.mixins; import carpet.CarpetSettings; import com.google.common.collect.Lists; import com.mojang.serialization.Codec; +import net.minecraft.class_6012; import net.minecraft.entity.EntityType; import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -16,11 +17,11 @@ import java.util.List; @Mixin(DesertPyramidFeature.class) public abstract class DesertPyramidFeatureMixin extends StructureFeature { - private static final List MONSTER_SPAWNS; + private static final class_6012 MONSTER_SPAWNS; static { - MONSTER_SPAWNS = Lists.newArrayList(new SpawnSettings.SpawnEntry(EntityType.HUSK, 1, 1, 1)); + MONSTER_SPAWNS = class_6012.method_34989(new SpawnSettings.SpawnEntry(EntityType.HUSK, 1, 1, 1)); } public DesertPyramidFeatureMixin(Codec codec) @@ -30,13 +31,13 @@ public abstract class DesertPyramidFeatureMixin extends StructureFeature getMonsterSpawns() + public class_6012 getMonsterSpawns() { if (CarpetSettings.huskSpawningInTemples) { return MONSTER_SPAWNS; } - return Collections.emptyList(); + return SpawnSettings.field_30982; // empty spawn list } } diff --git a/src/main/java/carpet/mixins/EndCityFeatureMixin.java b/src/main/java/carpet/mixins/EndCityFeatureMixin.java index 7ff4227c..6deefc73 100644 --- a/src/main/java/carpet/mixins/EndCityFeatureMixin.java +++ b/src/main/java/carpet/mixins/EndCityFeatureMixin.java @@ -3,6 +3,7 @@ package carpet.mixins; import carpet.CarpetSettings; import com.google.common.collect.Lists; import com.mojang.serialization.Codec; +import net.minecraft.class_6012; import net.minecraft.entity.EntityType; import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -16,7 +17,7 @@ import java.util.List; @Mixin(EndCityFeature.class) public abstract class EndCityFeatureMixin extends StructureFeature { - private static final List spawnList = Lists.newArrayList(new SpawnSettings.SpawnEntry(EntityType.SHULKER, 10, 4, 4)); + private static final class_6012 spawnList = class_6012.method_34989(new SpawnSettings.SpawnEntry(EntityType.SHULKER, 10, 4, 4)); public EndCityFeatureMixin(Codec codec) { @@ -24,10 +25,10 @@ public abstract class EndCityFeatureMixin extends StructureFeature getMonsterSpawns() + public class_6012 getMonsterSpawns() { if (CarpetSettings.shulkerSpawningInEndCities) return spawnList; - return Collections.emptyList(); + return SpawnSettings.field_30982; // empty spawn list } } diff --git a/src/main/java/carpet/mixins/EntityNavigation_pathfindingMixin.java b/src/main/java/carpet/mixins/EntityNavigation_pathfindingMixin.java index b819f013..45d402f9 100644 --- a/src/main/java/carpet/mixins/EntityNavigation_pathfindingMixin.java +++ b/src/main/java/carpet/mixins/EntityNavigation_pathfindingMixin.java @@ -7,6 +7,7 @@ import net.minecraft.entity.ai.pathing.Path; import net.minecraft.entity.mob.MobEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -22,18 +23,18 @@ public abstract class EntityNavigation_pathfindingMixin @Shadow @Final protected MobEntity entity; - @Shadow /*@Nullable*/ protected abstract Path findPathToAny(Set set_1, int int_1, boolean boolean_1, int int_2); + @Shadow protected @Nullable abstract Path method_35142(Set set, int i, boolean bl, int j); @Redirect(method = "findPathTo(Lnet/minecraft/util/math/BlockPos;I)Lnet/minecraft/entity/ai/pathing/Path;", at = @At( value = "INVOKE", - target = "Lnet/minecraft/entity/ai/pathing/EntityNavigation;findPathToAny(Ljava/util/Set;IZI)Lnet/minecraft/entity/ai/pathing/Path;" + target = "Lnet/minecraft/entity/ai/pathing/EntityNavigation;method_35142(Ljava/util/Set;IZI)Lnet/minecraft/entity/ai/pathing/Path;" )) private Path pathToBlock(EntityNavigation entityNavigation, Set set_1, int int_1, boolean boolean_1, int int_2) { if (!LoggerRegistry.__pathfinding) - return findPathToAny(set_1, int_1, boolean_1, int_2); + return method_35142(set_1, int_1, boolean_1, int_2); long start = System.nanoTime(); - Path path = findPathToAny(set_1, int_1, boolean_1, int_2); + Path path = method_35142(set_1, int_1, boolean_1, int_2); long finish = System.nanoTime(); float duration = (1.0F*((finish - start)/1000))/1000; set_1.forEach(b -> PathfindingVisualizer.slowPath(entity, Vec3d.ofBottomCenter(b), duration, path != null)); // ground centered position @@ -42,14 +43,14 @@ public abstract class EntityNavigation_pathfindingMixin @Redirect(method = "findPathTo(Lnet/minecraft/entity/Entity;I)Lnet/minecraft/entity/ai/pathing/Path;", at = @At( value = "INVOKE", - target = "Lnet/minecraft/entity/ai/pathing/EntityNavigation;findPathToAny(Ljava/util/Set;IZI)Lnet/minecraft/entity/ai/pathing/Path;" + target = "Lnet/minecraft/entity/ai/pathing/EntityNavigation;method_35142(Ljava/util/Set;IZI)Lnet/minecraft/entity/ai/pathing/Path;" )) private Path pathToEntity(EntityNavigation entityNavigation, Set set_1, int int_1, boolean boolean_1, int int_2) { if (!LoggerRegistry.__pathfinding) - return findPathToAny(set_1, int_1, boolean_1, int_2); + return method_35142(set_1, int_1, boolean_1, int_2); long start = System.nanoTime(); - Path path = findPathToAny(set_1, int_1, boolean_1, int_2); + Path path = method_35142(set_1, int_1, boolean_1, int_2); long finish = System.nanoTime(); float duration = (1.0F*((finish - start)/1000))/1000; set_1.forEach(b -> PathfindingVisualizer.slowPath(entity, Vec3d.ofBottomCenter(b), duration, path != null)); diff --git a/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java b/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java index e07d3d49..30aa4a50 100644 --- a/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java +++ b/src/main/java/carpet/mixins/ExperienceOrbEntityMixin.java @@ -84,22 +84,4 @@ public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface playerEntity.addExperience(experience); } } - - // temporary until gets fixed game-side - @Inject(method = "onPlayerCollision", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, at = @At( - value = "INVOKE", - target = "Lnet/minecraft/entity/ExperienceOrbEntity;getMendingRepairAmount(I)I" - )) - void cancelApplication(PlayerEntity player, CallbackInfo ci, Map.Entry entry, ItemStack itemStack) - { - if (CarpetSettings.xpfix && pickingCount > 1) - { - int i = Math.min(getMendingRepairAmount(this.amount), itemStack.getDamage()); - pickingCount--; - itemStack.setDamage(itemStack.getDamage() - i); - // cancel effects of mending application - ci.cancel(); - } - } - } diff --git a/src/main/java/carpet/mixins/FlatChunkGeneratorMixin.java b/src/main/java/carpet/mixins/FlatChunkGeneratorMixin.java index 5dfa9edd..0124e0d4 100644 --- a/src/main/java/carpet/mixins/FlatChunkGeneratorMixin.java +++ b/src/main/java/carpet/mixins/FlatChunkGeneratorMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; +import net.minecraft.class_6012; import net.minecraft.entity.SpawnGroup; import net.minecraft.util.math.BlockPos; import net.minecraft.world.biome.Biome; @@ -25,7 +26,7 @@ public abstract class FlatChunkGeneratorMixin extends ChunkGenerator } @Override - public List getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos) + public class_6012 getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos) { if (CarpetSettings.flatWorldStructureSpawning) { diff --git a/src/main/java/carpet/mixins/FluidBlock_renewableBlackstoneMixin.java b/src/main/java/carpet/mixins/FluidBlock_renewableBlackstoneMixin.java index e3b620d8..5a522daa 100644 --- a/src/main/java/carpet/mixins/FluidBlock_renewableBlackstoneMixin.java +++ b/src/main/java/carpet/mixins/FluidBlock_renewableBlackstoneMixin.java @@ -33,7 +33,7 @@ public abstract class FluidBlock_renewableBlackstoneMixin for(Direction direction : Direction.values()) { if (direction != Direction.DOWN) { - BlockPos blockPos = pos.offset(direction); + BlockPos blockPos = pos.method_35851(direction); // offset if (world.getBlockState(blockPos).isOf(Blocks.BLUE_ICE)) { world.setBlockState(pos, Blocks.BLACKSTONE.getDefaultState()); playExtinguishSound(world, pos); diff --git a/src/main/java/carpet/mixins/HopperBlockEntityMixin.java b/src/main/java/carpet/mixins/HopperBlockEntityMixin.java index 15840d29..10225ef9 100644 --- a/src/main/java/carpet/mixins/HopperBlockEntityMixin.java +++ b/src/main/java/carpet/mixins/HopperBlockEntityMixin.java @@ -36,7 +36,7 @@ public abstract class HopperBlockEntityMixin extends LootableContainerBlockEntit if (CarpetSettings.hopperCounters) { DyeColor wool_color = WoolTool.getWoolColorAtPosition( world, - blockPos.offset(blockState.get(HopperBlock.FACING))); + blockPos.method_35851(blockState.get(HopperBlock.FACING))); // offset if (wool_color != null) { for (int i = 0; i < inventory.size(); ++i) diff --git a/src/main/java/carpet/mixins/NoiseChunkGenerator_husksSpawnMixin.java b/src/main/java/carpet/mixins/NoiseChunkGenerator_husksSpawnMixin.java index d547b313..a855596d 100644 --- a/src/main/java/carpet/mixins/NoiseChunkGenerator_husksSpawnMixin.java +++ b/src/main/java/carpet/mixins/NoiseChunkGenerator_husksSpawnMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; +import net.minecraft.class_6012; import net.minecraft.entity.SpawnGroup; import net.minecraft.util.math.BlockPos; import net.minecraft.world.biome.Biome; @@ -29,7 +30,7 @@ public abstract class NoiseChunkGenerator_husksSpawnMixin extends ChunkGenerator } @Inject(method = "getEntitySpawnList", at = @At("HEAD"), cancellable = true) - private void isInsidePyramid(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos, CallbackInfoReturnable> cir) + private void isInsidePyramid(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos, CallbackInfoReturnable> cir) { if (CarpetSettings.huskSpawningInTemples && group == SpawnGroup.MONSTER) { diff --git a/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java b/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java index 7b4a47f2..9a026549 100644 --- a/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java +++ b/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java @@ -196,7 +196,7 @@ public abstract class PistonHandler_customStickyMixin // stickyDirection = blockState_1.get(FacingBlock.FACING); //} - return stickyDirection == null || this.tryMove(blockPos_1.offset(stickyDirection), stickyDirection); + return stickyDirection == null || this.tryMove(blockPos_1.method_35851(stickyDirection), stickyDirection); //offset } diff --git a/src/main/java/carpet/mixins/StructureFeatureMixin.java b/src/main/java/carpet/mixins/StructureFeatureMixin.java index 62a8d2f0..d62055a9 100644 --- a/src/main/java/carpet/mixins/StructureFeatureMixin.java +++ b/src/main/java/carpet/mixins/StructureFeatureMixin.java @@ -50,13 +50,13 @@ public abstract class StructureFeatureMixin implements } world.getChunk(j, k).addStructureReference((StructureFeature) (Object)this, chId); - BlockBox box = structurestart.getBoundingBox(); + BlockBox box = structurestart.setBoundingBoxFromChildren(); // getBB if (!wireOnly) { structurestart.generateStructure(world, world.getStructureAccessor(), generator, rand,box, new ChunkPos(j, k)); } //structurestart.notifyPostProcessAt(new ChunkPos(j, k)); - int i = Math.max(box.getBlockCountX(),box.getBlockCountZ())/16+1; //size + int i = Math.max(box.getBlockCountY(),box.getBlockCountX())/16+1; // X Z //int i = getRadius(); for (int k1 = j - i; k1 <= j + i; ++k1) @@ -105,7 +105,7 @@ public abstract class StructureFeatureMixin implements if (biome == null) biome_1 = generator.getBiomeSource().getBiomeForNoiseGen((chunkpos.getStartX() + 9) >> 2, 0, (chunkpos.getStartZ() + 9) >> 2 ); - StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos, BlockBox.empty(),0,worldIn.getSeed()); + StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos,0,worldIn.getSeed()); if (config == null) config = new DefaultFeatureConfig(); structurestart1.init(worldIn.getRegistryManager(), generator, worldIn.getStructureManager() , chunkpos, biome_1, config, ichunk); diff --git a/src/main/java/carpet/script/api/BlockIterators.java b/src/main/java/carpet/script/api/BlockIterators.java index 03582021..a16b733e 100644 --- a/src/main/java/carpet/script/api/BlockIterators.java +++ b/src/main/java/carpet/script/api/BlockIterators.java @@ -216,10 +216,10 @@ public class BlockIterators { List neighbours = new ArrayList<>(); neighbours.add(new BlockValue(null, world, center.up())); neighbours.add(new BlockValue(null, world, center.down())); - neighbours.add(new BlockValue(null, world, center.north())); - neighbours.add(new BlockValue(null, world, center.south())); - neighbours.add(new BlockValue(null, world, center.east())); - neighbours.add(new BlockValue(null, world, center.west())); + neighbours.add(new BlockValue(null, world, center.method_35861())); // north + neighbours.add(new BlockValue(null, world, center.method_35859())); // sourh + neighbours.add(new BlockValue(null, world, center.method_35855())); // east + neighbours.add(new BlockValue(null, world, center.method_35857())); // west Value retval = ListValue.wrap(neighbours); 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 a8f050d7..78affeb0 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -1304,10 +1304,10 @@ public class WorldAccess { StructureStart start = entry.getValue(); if (start == StructureStart.DEFAULT) continue; - BlockBox box = start.getBoundingBox(); + BlockBox box = start.setBoundingBoxFromChildren(); structureList.put( new StringValue(NBTSerializableValue.nameFromRegistryId(Registry.STRUCTURE_FEATURE.getId(entry.getKey()))), - ListValue.of(ListValue.fromTriple(box.minX, box.minY, box.minZ), ListValue.fromTriple(box.maxX, box.maxY, box.maxZ)) + ListValue.of(ListValue.fromTriple(box.method_35420(), box.method_35415(), box.method_35416()), ListValue.fromTriple(box.method_35417(), box.method_35418(), box.method_35419())) ); } Value ret = MapValue.wrap(structureList); @@ -1356,10 +1356,10 @@ public class WorldAccess { } StructureStart start = structures.get(structure); ChunkPos structureChunkPos = start.getPos(); // new ChunkPos(start.getChunkX(), start.getChunkZ()); - BlockBox box = start.getBoundingBox(); - for (int chx = box.minX / 16; chx <= box.maxX / 16; chx++) + BlockBox box = start.setBoundingBoxFromChildren(); + for (int chx = box.method_35420() / 16; chx <= box.method_35417() / 16; chx++) // minx maxx { - for (int chz = box.minZ / 16; chz <= box.maxZ / 16; chz++) + for (int chz = box.method_35416() / 16; chz <= box.method_35419() / 16; chz++) //minZ maxZ { ChunkPos chpos = new ChunkPos(chx, chz); // getting a chunk will convert it to full, allowing to modify references diff --git a/src/main/java/carpet/script/value/NBTSerializableValue.java b/src/main/java/carpet/script/value/NBTSerializableValue.java index e4e51334..88ffe668 100644 --- a/src/main/java/carpet/script/value/NBTSerializableValue.java +++ b/src/main/java/carpet/script/value/NBTSerializableValue.java @@ -15,12 +15,14 @@ import net.minecraft.block.ChestBlock; import net.minecraft.block.InventoryProvider; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.ChestBlockEntity; +import net.minecraft.class_6067; import net.minecraft.command.argument.ItemStackArgument; import net.minecraft.command.argument.ItemStringReader; import net.minecraft.command.argument.NbtPathArgumentType; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.mob.MobEntity; +import net.minecraft.entity.passive.MerchantEntity; import net.minecraft.entity.passive.VillagerEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.Inventory; @@ -224,7 +226,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa Entity e = ((EntityValue) v1).getEntity(); if (e instanceof PlayerEntity) inv = ((PlayerEntity) e).getInventory(); else if (e instanceof Inventory) inv = (Inventory) e; - else if (e instanceof VillagerEntity) inv = ((VillagerEntity) e).getInventory(); + else if (e instanceof class_6067) inv = ((class_6067) e).method_35199(); // getInentory // now covers pillagers else if (e instanceof InventoryBearerInterface) inv = ((InventoryBearerInterface)e).getCMInventory(); else if (e instanceof LivingEntity) return new InventoryLocator(e, e.getBlockPos(), new EquipmentInventory((MobEntity) e), offset+1); if (inv == null) diff --git a/src/main/java/carpet/script/value/ValueConversions.java b/src/main/java/carpet/script/value/ValueConversions.java index 51d431af..38199c8c 100644 --- a/src/main/java/carpet/script/value/ValueConversions.java +++ b/src/main/java/carpet/script/value/ValueConversions.java @@ -305,24 +305,24 @@ public class ValueConversions public static Value of(StructureStart structure) { if (structure == null || structure == StructureStart.DEFAULT) return Value.NULL; - BlockBox boundingBox = structure.getBoundingBox(); - if (boundingBox.maxX < boundingBox.minX || boundingBox.maxY < boundingBox.minY || boundingBox.maxZ < boundingBox.minZ) return Value.NULL; + BlockBox boundingBox = structure.setBoundingBoxFromChildren(); + if (boundingBox.method_35417() < boundingBox.method_35420() || boundingBox.method_35418() < boundingBox.method_35415() || boundingBox.method_35419() < boundingBox.method_35416()) return Value.NULL; Map ret = new HashMap<>(); ret.put(new StringValue("box"), ListValue.of( - ListValue.fromTriple(boundingBox.minX, boundingBox.minY, boundingBox.minZ), - ListValue.fromTriple(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ) + ListValue.fromTriple(boundingBox.method_35420(), boundingBox.method_35415(), boundingBox.method_35416()), + ListValue.fromTriple(boundingBox.method_35417(), boundingBox.method_35418(), boundingBox.method_35419()) )); List pieces = new ArrayList<>(); for (StructurePiece piece : structure.getChildren()) { BlockBox box = piece.getBoundingBox(); - if (box.maxX >= box.minX && box.maxY >= box.minY && box.maxZ >= box.minZ) + if (box.method_35417() >= box.method_35420() && box.method_35418() >= box.method_35415() && box.method_35419() >= box.method_35416()) { pieces.add(ListValue.of( new StringValue(NBTSerializableValue.nameFromRegistryId(Registry.STRUCTURE_PIECE.getId(piece.getType()))), (piece.getFacing() == null) ? Value.NULL : new StringValue(piece.getFacing().getName()), - ListValue.fromTriple(box.minX, box.minY, box.minZ), - ListValue.fromTriple(box.maxX, box.maxY, box.maxZ) + ListValue.fromTriple(box.method_35420(), box.method_35415(), box.method_35416()), + ListValue.fromTriple(box.method_35417(), box.method_35418(), box.method_35419()) )); } } diff --git a/src/main/java/carpet/utils/PerimeterDiagnostics.java b/src/main/java/carpet/utils/PerimeterDiagnostics.java index 8fab4bd8..aef09385 100644 --- a/src/main/java/carpet/utils/PerimeterDiagnostics.java +++ b/src/main/java/carpet/utils/PerimeterDiagnostics.java @@ -159,10 +159,10 @@ public class PerimeterDiagnostics private boolean check_entity_spawn(BlockPos pos) { - if (sle == null || !worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(worldServer.getBiome(pos), worldServer.getStructureAccessor(), ctype, pos).contains(sle)) + if (sle == null || !worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(worldServer.getBiome(pos), worldServer.getStructureAccessor(), ctype, pos).method_34994().contains(sle)) { sle = null; - for (SpawnSettings.SpawnEntry sle: worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(worldServer.getBiome(pos), worldServer.getStructureAccessor(), ctype, pos)) + for (SpawnSettings.SpawnEntry sle: worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(worldServer.getBiome(pos), worldServer.getStructureAccessor(), ctype, pos).method_34994()) { if (el.getType() == sle.type) { @@ -170,7 +170,7 @@ public class PerimeterDiagnostics break; } } - if (sle == null || !worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(worldServer.getBiome(pos), worldServer.getStructureAccessor(), ctype, pos).contains(sle)) + if (sle == null || !worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(worldServer.getBiome(pos), worldServer.getStructureAccessor(), ctype, pos).method_34994().contains(sle)) { return false; } diff --git a/src/main/java/carpet/utils/SpawnReporter.java b/src/main/java/carpet/utils/SpawnReporter.java index 1c17dd40..63b8831b 100644 --- a/src/main/java/carpet/utils/SpawnReporter.java +++ b/src/main/java/carpet/utils/SpawnReporter.java @@ -420,7 +420,7 @@ public class SpawnReporter // yeeted from SpawnHelper - temporary fix private static List method_29950(ServerWorld serverWorld, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, SpawnGroup spawnGroup, BlockPos blockPos, /*@Nullable*/ Biome biome) { - return spawnGroup == SpawnGroup.MONSTER && serverWorld.getBlockState(blockPos.down()).getBlock() == Blocks.NETHER_BRICKS && structureAccessor.getStructureAt(blockPos, false, StructureFeature.FORTRESS).hasChildren() ? StructureFeature.FORTRESS.getMonsterSpawns() : chunkGenerator.getEntitySpawnList(biome != null ? biome : serverWorld.getBiome(blockPos), structureAccessor, spawnGroup, blockPos); + return spawnGroup == SpawnGroup.MONSTER && serverWorld.getBlockState(blockPos.down()).getBlock() == Blocks.NETHER_BRICKS && structureAccessor.getStructureAt(blockPos, false, StructureFeature.FORTRESS).hasChildren() ? StructureFeature.FORTRESS.getMonsterSpawns().method_34994() : chunkGenerator.getEntitySpawnList(biome != null ? biome : serverWorld.getBiome(blockPos), structureAccessor, spawnGroup, blockPos).method_34994(); } public static List report(BlockPos pos, ServerWorld worldIn) From 5dd2a12aa72b119f254ec7585cc93f9e89ad487d Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 2 Apr 2021 18:38:55 -0300 Subject: [PATCH 047/115] mapping --- gradle.properties | 4 +-- .../java/carpet/commands/ScriptCommand.java | 34 +++++++++---------- .../fakes/InventoryBearerInterface.java | 1 - .../java/carpet/helpers/BlockRotator.java | 2 +- .../java/carpet/helpers/FeatureGenerator.java | 8 ++--- .../FluidBlock_renewableBlackstoneMixin.java | 2 +- .../carpet/mixins/HopperBlockEntityMixin.java | 2 +- .../mixins/PillagerEntity_scarpetMixin.java | 21 ------------ .../PistonHandler_customStickyMixin.java | 2 +- .../carpet/mixins/StructureFeatureMixin.java | 2 +- .../java/carpet/script/api/Auxiliary.java | 6 ++-- .../carpet/script/api/BlockIterators.java | 8 ++--- .../java/carpet/script/api/WorldAccess.java | 6 ++-- .../java/carpet/script/utils/BiomeInfo.java | 4 +-- .../carpet/script/utils/ShapeDispatcher.java | 2 +- .../java/carpet/script/utils/WorldTools.java | 6 ++-- .../script/value/NBTSerializableValue.java | 6 ++-- .../carpet/script/value/ValueConversions.java | 21 +++++++----- src/main/java/carpet/utils/BlockInfo.java | 2 +- src/main/resources/carpet.mixins.json | 1 - 20 files changed, 61 insertions(+), 79 deletions(-) delete mode 100644 src/main/java/carpet/mixins/PillagerEntity_scarpetMixin.java diff --git a/gradle.properties b/gradle.properties index 72a418cc..f061ddd8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,9 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=21w13a - yarn_mappings=21w13a+build.2 + yarn_mappings=21w13a+build.34 loader_version=0.11.3 - fabric_version=0.32.5+1.17 + fabric_version=0.32.6+1.17 # Mod Properties mod_version = 1.4.30 diff --git a/src/main/java/carpet/commands/ScriptCommand.java b/src/main/java/carpet/commands/ScriptCommand.java index bc9d5b4e..679474ef 100644 --- a/src/main/java/carpet/commands/ScriptCommand.java +++ b/src/main/java/carpet/commands/ScriptCommand.java @@ -470,7 +470,7 @@ public class ScriptCommand CarpetScriptHost host = getHost(context); BlockBox area = BlockBox.create(a, b); CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin); - int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.method_35414(); // X Y Z + int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ(); // X Y Z if (int_1 > CarpetSettings.fillLimit) { Messenger.m(source, "r too many blocks to evaluate: " + int_1); @@ -480,11 +480,11 @@ public class ScriptCommand CarpetSettings.impendingFillSkipUpdates = !CarpetSettings.fillUpdates; try { - for (int x = area.method_35420(); x <= area.method_35417(); x++) //minx maxx + for (int x = area.getMinX(); x <= area.getMaxX(); x++) { - for (int y = area.method_35415(); y <= area.method_35418(); y++) // miny maxy + for (int y = area.getMinY(); y <= area.getMaxY(); y++) { - for (int z = area.method_35416(); z <= area.method_35419(); z++) // minz maxz + for (int z = area.getMinZ(); z <= area.getMaxZ(); z++) { try { @@ -519,29 +519,29 @@ public class ScriptCommand CarpetScriptHost host = getHost(context); BlockBox area = BlockBox.create(a, b); CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin); - int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.method_35414(); + int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ(); if (int_1 > CarpetSettings.fillLimit) { Messenger.m(source, "r too many blocks to evaluate: "+ int_1); return 1; } - boolean[][][] volume = new boolean[area.getBlockCountY()][area.method_35414()][area.getBlockCountX()]; //X then Y then Z got messedup + boolean[][][] volume = new boolean[area.getBlockCountX()][area.getBlockCountY()][area.getBlockCountZ()]; //X then Y then Z got messedup BlockPos.Mutable mbpos = origin.mutableCopy(); ServerWorld world = source.getWorld(); - for (int x = area.method_35420(); x <= area.method_35417(); x++) //minx maxx + for (int x = area.getMinX(); x <= area.getMaxX(); x++) { - for (int y = area.method_35415(); y <= area.method_35418(); y++) // miny maxy + for (int y = area.getMinY(); y <= area.getMaxY(); y++) { - for (int z = area.method_35416(); z <= area.method_35419(); z++) // minz maxz + for (int z = area.getMinZ(); z <= area.getMaxZ(); z++) { try { if (cexpr.fillAndScanCommand(host, x, y, z)) { - volume[x-area.method_35420()][y-area.method_35415()][z-area.method_35416()]=true; + volume[x-area.getMinX()][y-area.getMinY()][z-area.getMinZ()]=true; } } catch (CarpetExpressionException e) @@ -555,12 +555,12 @@ public class ScriptCommand } } } - final int maxx = area.getBlockCountY()-1; //x - final int maxy = area.method_35414()-1; //y - final int maxz = area.getBlockCountX()-1; //z + final int maxx = area.getBlockCountX()-1; + final int maxy = area.getBlockCountY()-1; + final int maxz = area.getBlockCountZ()-1; if ("outline".equalsIgnoreCase(mode)) { - boolean[][][] newVolume = new boolean[area.getBlockCountY()][area.method_35414()][area.getBlockCountX()]; //X then Y then Z got messedup + boolean[][][] newVolume = new boolean[area.getBlockCountX()][area.getBlockCountY()][area.getBlockCountZ()]; for (int x = 0; x <= maxx; x++) { for (int y = 0; y <= maxy; y++) @@ -596,7 +596,7 @@ public class ScriptCommand { if (volume[x][y][z]) { - mbpos.set(x+area.method_35420(), y+area.method_35415(), z+area.method_35416()); + mbpos.set(x+area.getMinX(), y+area.getMinY(), z+area.getMinZ()); if (replacement == null || replacement.test( new CachedBlockPosition( world, mbpos, true))) { @@ -624,7 +624,7 @@ public class ScriptCommand { if (volume[x][y][z]) { - mbpos.set(x+area.method_35420(), y+area.method_35415(), z+area.method_35416()); + mbpos.set(x+area.getMinX(), y+area.getMinY(), z+area.getMinZ()); Block blokc = world.getBlockState(mbpos).getBlock(); world.updateNeighbors(mbpos, blokc); } @@ -632,7 +632,7 @@ public class ScriptCommand } } } - Messenger.m(source, "gi Affected "+affected+" blocks in "+area.getBlockCountX() * area.getBlockCountY() * area.method_35414()+" block volume"); + Messenger.m(source, "gi Affected "+affected+" blocks in "+area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ()+" block volume"); return 1; } } diff --git a/src/main/java/carpet/fakes/InventoryBearerInterface.java b/src/main/java/carpet/fakes/InventoryBearerInterface.java index a1426973..5355786b 100644 --- a/src/main/java/carpet/fakes/InventoryBearerInterface.java +++ b/src/main/java/carpet/fakes/InventoryBearerInterface.java @@ -1,6 +1,5 @@ package carpet.fakes; -import net.minecraft.class_6067; import net.minecraft.inventory.Inventory; public interface InventoryBearerInterface diff --git a/src/main/java/carpet/helpers/BlockRotator.java b/src/main/java/carpet/helpers/BlockRotator.java index 8f9e9936..fe3cd568 100644 --- a/src/main/java/carpet/helpers/BlockRotator.java +++ b/src/main/java/carpet/helpers/BlockRotator.java @@ -226,7 +226,7 @@ public class BlockRotator { Direction sourceFace = source.getBlockState().get(DispenserBlock.FACING); World world = source.getWorld(); - BlockPos blockpos = source.getBlockPos().method_35851(sourceFace); // offset + BlockPos blockpos = source.getBlockPos().offset(sourceFace); // offset BlockState iblockstate = world.getBlockState(blockpos); Block block = iblockstate.getBlock(); diff --git a/src/main/java/carpet/helpers/FeatureGenerator.java b/src/main/java/carpet/helpers/FeatureGenerator.java index fc1c500a..e5062707 100644 --- a/src/main/java/carpet/helpers/FeatureGenerator.java +++ b/src/main/java/carpet/helpers/FeatureGenerator.java @@ -49,7 +49,7 @@ public class FeatureGenerator return custom.plop(world, pos); } Identifier id = new Identifier(featureName); - ConfiguredStructureFeature structureFeature = world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_WORLDGEN).get(id); + ConfiguredStructureFeature structureFeature = world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY).get(id); if (structureFeature != null) { return ((StructureFeatureInterface)structureFeature.feature).plopAnywhere( @@ -58,7 +58,7 @@ public class FeatureGenerator } - ConfiguredFeature feature = world.getRegistryManager().get(Registry.CONFIGURED_FEATURE_WORLDGEN).get(id); + ConfiguredFeature feature = world.getRegistryManager().get(Registry.CONFIGURED_FEATURE_KEY).get(id); if (feature != null) { CarpetSettings.skipGenerationChecks = true; @@ -77,7 +77,7 @@ public class FeatureGenerator public static ConfiguredStructureFeature resolveConfiguredStructure(String name, ServerWorld world, BlockPos pos) { Identifier id = new Identifier(name); - ConfiguredStructureFeature configuredStructureFeature = world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_WORLDGEN).get(id); + ConfiguredStructureFeature configuredStructureFeature = world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY).get(id); if (configuredStructureFeature != null) return configuredStructureFeature; StructureFeature structureFeature = Registry.STRUCTURE_FEATURE.get(id); if (structureFeature == null) return null; @@ -137,7 +137,7 @@ public class FeatureGenerator { ConfiguredStructureFeature configuredFeature = world.getBiome(pos).getGenerationSettings().method_30978(structure.configure(null)); if (configuredFeature.config != null || !tryHard) return configuredFeature; - return world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_WORLDGEN).getEntries().stream(). + return world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY).getEntries().stream(). filter(cS -> cS.getValue().feature == structure). findFirst().map(Map.Entry::getValue).orElse(null); } diff --git a/src/main/java/carpet/mixins/FluidBlock_renewableBlackstoneMixin.java b/src/main/java/carpet/mixins/FluidBlock_renewableBlackstoneMixin.java index 5a522daa..1a55a6af 100644 --- a/src/main/java/carpet/mixins/FluidBlock_renewableBlackstoneMixin.java +++ b/src/main/java/carpet/mixins/FluidBlock_renewableBlackstoneMixin.java @@ -33,7 +33,7 @@ public abstract class FluidBlock_renewableBlackstoneMixin for(Direction direction : Direction.values()) { if (direction != Direction.DOWN) { - BlockPos blockPos = pos.method_35851(direction); // offset + BlockPos blockPos = pos.offset(direction); // offset if (world.getBlockState(blockPos).isOf(Blocks.BLUE_ICE)) { world.setBlockState(pos, Blocks.BLACKSTONE.getDefaultState()); playExtinguishSound(world, pos); diff --git a/src/main/java/carpet/mixins/HopperBlockEntityMixin.java b/src/main/java/carpet/mixins/HopperBlockEntityMixin.java index 10225ef9..60e7f2cf 100644 --- a/src/main/java/carpet/mixins/HopperBlockEntityMixin.java +++ b/src/main/java/carpet/mixins/HopperBlockEntityMixin.java @@ -36,7 +36,7 @@ public abstract class HopperBlockEntityMixin extends LootableContainerBlockEntit if (CarpetSettings.hopperCounters) { DyeColor wool_color = WoolTool.getWoolColorAtPosition( world, - blockPos.method_35851(blockState.get(HopperBlock.FACING))); // offset + blockPos.offset(blockState.get(HopperBlock.FACING))); // offset if (wool_color != null) { for (int i = 0; i < inventory.size(); ++i) diff --git a/src/main/java/carpet/mixins/PillagerEntity_scarpetMixin.java b/src/main/java/carpet/mixins/PillagerEntity_scarpetMixin.java deleted file mode 100644 index 66db248f..00000000 --- a/src/main/java/carpet/mixins/PillagerEntity_scarpetMixin.java +++ /dev/null @@ -1,21 +0,0 @@ -package carpet.mixins; - -import carpet.fakes.InventoryBearerInterface; -import net.minecraft.entity.mob.PillagerEntity; -import net.minecraft.inventory.Inventory; -import net.minecraft.inventory.SimpleInventory; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(PillagerEntity.class) -public class PillagerEntity_scarpetMixin implements InventoryBearerInterface -{ - @Shadow @Final private SimpleInventory inventory; - - @Override - public Inventory getCMInventory() - { - return inventory; - } -} diff --git a/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java b/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java index 9a026549..a251f251 100644 --- a/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java +++ b/src/main/java/carpet/mixins/PistonHandler_customStickyMixin.java @@ -196,7 +196,7 @@ public abstract class PistonHandler_customStickyMixin // stickyDirection = blockState_1.get(FacingBlock.FACING); //} - return stickyDirection == null || this.tryMove(blockPos_1.method_35851(stickyDirection), stickyDirection); //offset + return stickyDirection == null || this.tryMove(blockPos_1.offset(stickyDirection), stickyDirection); //offset } diff --git a/src/main/java/carpet/mixins/StructureFeatureMixin.java b/src/main/java/carpet/mixins/StructureFeatureMixin.java index d62055a9..d65a771c 100644 --- a/src/main/java/carpet/mixins/StructureFeatureMixin.java +++ b/src/main/java/carpet/mixins/StructureFeatureMixin.java @@ -56,7 +56,7 @@ public abstract class StructureFeatureMixin implements structurestart.generateStructure(world, world.getStructureAccessor(), generator, rand,box, new ChunkPos(j, k)); } //structurestart.notifyPostProcessAt(new ChunkPos(j, k)); - int i = Math.max(box.getBlockCountY(),box.getBlockCountX())/16+1; // X Z + int i = Math.max(box.getBlockCountX(),box.getBlockCountZ())/16+1; //int i = getRadius(); for (int k1 = j - i; k1 <= j + i; ++k1) diff --git a/src/main/java/carpet/script/api/Auxiliary.java b/src/main/java/carpet/script/api/Auxiliary.java index b8c165d9..1428e029 100644 --- a/src/main/java/carpet/script/api/Auxiliary.java +++ b/src/main/java/carpet/script/api/Auxiliary.java @@ -788,13 +788,13 @@ public class Auxiliary { ListValue.wrap(Registry.FEATURE.getIds().stream().sorted().map(ValueConversions::of).collect(Collectors.toList())) ); plopData.put(StringValue.of("configured_features"), - ListValue.wrap(registryManager.get(Registry.CONFIGURED_FEATURE_WORLDGEN).getIds().stream().sorted().map(ValueConversions::of).collect(Collectors.toList())) + ListValue.wrap(registryManager.get(Registry.CONFIGURED_FEATURE_KEY).getIds().stream().sorted().map(ValueConversions::of).collect(Collectors.toList())) ); plopData.put(StringValue.of("structures"), ListValue.wrap(Registry.STRUCTURE_FEATURE.getIds().stream().sorted().map(ValueConversions::of).collect(Collectors.toList())) ); plopData.put(StringValue.of("configured_structures"), - ListValue.wrap(registryManager.get(Registry.CONFIGURED_STRUCTURE_FEATURE_WORLDGEN).getIds().stream().sorted().map(ValueConversions::of).collect(Collectors.toList())) + ListValue.wrap(registryManager.get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY).getIds().stream().sorted().map(ValueConversions::of).collect(Collectors.toList())) ); Value ret = MapValue.wrap(plopData); return (_c, _t) -> ret; @@ -1188,7 +1188,7 @@ public class Auxiliary { if (!existing_worlds.containsKey(registryKey)) { addeds.add(ValueConversions.of(registryKey.getValue())); - RegistryKey registryKey2 = RegistryKey.of(Registry.DIMENSION, registryKey.getValue()); + RegistryKey registryKey2 = RegistryKey.of(Registry.WORLD_KEY, registryKey.getValue()); DimensionType dimensionType3 = entry.getValue().getDimensionType(); ChunkGenerator chunkGenerator3 = entry.getValue().getChunkGenerator(); UnmodifiableLevelProperties unmodifiableLevelProperties = new UnmodifiableLevelProperties(saveProperties, ((ServerWorldInterface) server.getOverworld()).getWorldPropertiesCM()); diff --git a/src/main/java/carpet/script/api/BlockIterators.java b/src/main/java/carpet/script/api/BlockIterators.java index a16b733e..03582021 100644 --- a/src/main/java/carpet/script/api/BlockIterators.java +++ b/src/main/java/carpet/script/api/BlockIterators.java @@ -216,10 +216,10 @@ public class BlockIterators { List neighbours = new ArrayList<>(); neighbours.add(new BlockValue(null, world, center.up())); neighbours.add(new BlockValue(null, world, center.down())); - neighbours.add(new BlockValue(null, world, center.method_35861())); // north - neighbours.add(new BlockValue(null, world, center.method_35859())); // sourh - neighbours.add(new BlockValue(null, world, center.method_35855())); // east - neighbours.add(new BlockValue(null, world, center.method_35857())); // west + neighbours.add(new BlockValue(null, world, center.north())); + neighbours.add(new BlockValue(null, world, center.south())); + neighbours.add(new BlockValue(null, world, center.east())); + neighbours.add(new BlockValue(null, world, center.west())); Value retval = ListValue.wrap(neighbours); 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 78affeb0..71404393 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -1307,7 +1307,7 @@ public class WorldAccess { BlockBox box = start.setBoundingBoxFromChildren(); structureList.put( new StringValue(NBTSerializableValue.nameFromRegistryId(Registry.STRUCTURE_FEATURE.getId(entry.getKey()))), - ListValue.of(ListValue.fromTriple(box.method_35420(), box.method_35415(), box.method_35416()), ListValue.fromTriple(box.method_35417(), box.method_35418(), box.method_35419())) + ListValue.of(ListValue.fromTriple(box.getMinX(), box.getMinY(), box.getMinZ()), ListValue.fromTriple(box.getMaxX(), box.getMaxY(), box.getMaxZ())) ); } Value ret = MapValue.wrap(structureList); @@ -1357,9 +1357,9 @@ public class WorldAccess { StructureStart start = structures.get(structure); ChunkPos structureChunkPos = start.getPos(); // new ChunkPos(start.getChunkX(), start.getChunkZ()); BlockBox box = start.setBoundingBoxFromChildren(); - for (int chx = box.method_35420() / 16; chx <= box.method_35417() / 16; chx++) // minx maxx + for (int chx = box.getMinX() / 16; chx <= box.getMaxX() / 16; chx++) // minx maxx { - for (int chz = box.method_35416() / 16; chz <= box.method_35419() / 16; chz++) //minZ maxZ + for (int chz = box.getMinZ() / 16; chz <= box.getMaxZ() / 16; chz++) //minZ maxZ { ChunkPos chpos = new ChunkPos(chx, chz); // getting a chunk will convert it to full, allowing to modify references diff --git a/src/main/java/carpet/script/utils/BiomeInfo.java b/src/main/java/carpet/script/utils/BiomeInfo.java index 9ff63005..db5bad46 100644 --- a/src/main/java/carpet/script/utils/BiomeInfo.java +++ b/src/main/java/carpet/script/utils/BiomeInfo.java @@ -34,7 +34,7 @@ public class BiomeInfo put("scale", (w, b) -> NumericValue.of(b.getScale())); put("features", (w, b) -> { - Registry> registry = w.getRegistryManager().get(Registry.CONFIGURED_FEATURE_WORLDGEN); + Registry> registry = w.getRegistryManager().get(Registry.CONFIGURED_FEATURE_KEY); return ListValue.wrap( b.getGenerationSettings().getFeatures().stream().map(step -> ListValue.wrap(step.stream().map(cfp -> @@ -44,7 +44,7 @@ public class BiomeInfo ); }); put("structures", (w, b) -> { - Registry> registry = w.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_WORLDGEN); + Registry> registry = w.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY); return ListValue.wrap(b.getGenerationSettings().getStructureFeatures().stream().map(str -> ValueConversions.of(registry.getId(str.get())))); }); }}; diff --git a/src/main/java/carpet/script/utils/ShapeDispatcher.java b/src/main/java/carpet/script/utils/ShapeDispatcher.java index 0ad2922d..1e48f591 100644 --- a/src/main/java/carpet/script/utils/ShapeDispatcher.java +++ b/src/main/java/carpet/script/utils/ShapeDispatcher.java @@ -314,7 +314,7 @@ public class ShapeDispatcher key = 0; followEntity = -1; - shapeDimension = RegistryKey.of(Registry.DIMENSION, new Identifier(options.get("dim").getString())); + shapeDimension = RegistryKey.of(Registry.WORLD_KEY, new Identifier(options.get("dim").getString())); if (options.containsKey("follow")) { followEntity = NumericValue.asNumber(options.getOrDefault("follow", optional.get("follow"))).getInt(); diff --git a/src/main/java/carpet/script/utils/WorldTools.java b/src/main/java/carpet/script/utils/WorldTools.java index 1fcd553d..e90f3d44 100644 --- a/src/main/java/carpet/script/utils/WorldTools.java +++ b/src/main/java/carpet/script/utils/WorldTools.java @@ -100,20 +100,20 @@ public class WorldTools DimensionType dimensionType2; if (dimensionOptions == null) { dimensionType2 = server.getRegistryManager().getMutable(Registry.DIMENSION_TYPE_KEY).getOrThrow(DimensionType.OVERWORLD_REGISTRY_KEY); - chunkGenerator2 = GeneratorOptions.createOverworldGenerator(server.getRegistryManager().get(Registry.BIOME_KEY), server.getRegistryManager().get(Registry.NOISE_SETTINGS_WORLDGEN), (new Random()).nextLong()); + chunkGenerator2 = GeneratorOptions.createOverworldGenerator(server.getRegistryManager().get(Registry.BIOME_KEY), server.getRegistryManager().get(Registry.CHUNK_GENERATOR_SETTINGS_KEY), (new Random()).nextLong()); } else { dimensionType2 = dimensionOptions.getDimensionType(); chunkGenerator2 = dimensionOptions.getChunkGenerator(); } - RegistryKey customWorld = RegistryKey.of(Registry.DIMENSION, worldId); + RegistryKey customWorld = RegistryKey.of(Registry.WORLD_KEY, worldId); //chunkGenerator2 = GeneratorOptions.createOverworldGenerator(server.getRegistryManager().get(Registry.BIOME_KEY), server.getRegistryManager().get(Registry.NOISE_SETTINGS_WORLDGEN), (seed==null)?l:seed); chunkGenerator2 = new NoiseChunkGenerator( new VanillaLayeredBiomeSource((seed==null)?l:seed, false, false, server.getRegistryManager().get(Registry.BIOME_KEY)), (seed==null)?l:seed, - () -> server.getRegistryManager().get(Registry.NOISE_SETTINGS_WORLDGEN).getOrThrow(ChunkGeneratorSettings.OVERWORLD) + () -> server.getRegistryManager().get(Registry.CHUNK_GENERATOR_SETTINGS_KEY).getOrThrow(ChunkGeneratorSettings.OVERWORLD) ); ServerWorld serverWorld = new ServerWorld( diff --git a/src/main/java/carpet/script/value/NBTSerializableValue.java b/src/main/java/carpet/script/value/NBTSerializableValue.java index 88ffe668..98bcf052 100644 --- a/src/main/java/carpet/script/value/NBTSerializableValue.java +++ b/src/main/java/carpet/script/value/NBTSerializableValue.java @@ -15,11 +15,11 @@ import net.minecraft.block.ChestBlock; import net.minecraft.block.InventoryProvider; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.ChestBlockEntity; -import net.minecraft.class_6067; import net.minecraft.command.argument.ItemStackArgument; import net.minecraft.command.argument.ItemStringReader; import net.minecraft.command.argument.NbtPathArgumentType; import net.minecraft.entity.Entity; +import net.minecraft.entity.InventoryOwner; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.passive.MerchantEntity; @@ -226,8 +226,8 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa Entity e = ((EntityValue) v1).getEntity(); if (e instanceof PlayerEntity) inv = ((PlayerEntity) e).getInventory(); else if (e instanceof Inventory) inv = (Inventory) e; - else if (e instanceof class_6067) inv = ((class_6067) e).method_35199(); // getInentory // now covers pillagers - else if (e instanceof InventoryBearerInterface) inv = ((InventoryBearerInterface)e).getCMInventory(); + else if (e instanceof InventoryOwner) inv = ((InventoryOwner) e).getInventory(); + else if (e instanceof InventoryBearerInterface) inv = ((InventoryBearerInterface)e).getCMInventory(); // horse only else if (e instanceof LivingEntity) return new InventoryLocator(e, e.getBlockPos(), new EquipmentInventory((MobEntity) e), offset+1); if (inv == null) return null; diff --git a/src/main/java/carpet/script/value/ValueConversions.java b/src/main/java/carpet/script/value/ValueConversions.java index 38199c8c..d0c92ecf 100644 --- a/src/main/java/carpet/script/value/ValueConversions.java +++ b/src/main/java/carpet/script/value/ValueConversions.java @@ -302,27 +302,32 @@ public class ValueConversions ); } + public static Value of(BlockBox box) + { + return ListValue.of( + ListValue.fromTriple(box.getMinX(), box.getMinY(), box.getMinZ()), + ListValue.fromTriple(box.getMaxX(), box.getMaxY(), box.getMaxZ()) + ); + } + public static Value of(StructureStart structure) { if (structure == null || structure == StructureStart.DEFAULT) return Value.NULL; BlockBox boundingBox = structure.setBoundingBoxFromChildren(); - if (boundingBox.method_35417() < boundingBox.method_35420() || boundingBox.method_35418() < boundingBox.method_35415() || boundingBox.method_35419() < boundingBox.method_35416()) return Value.NULL; + if (boundingBox.getMaxX() < boundingBox.getMinX() || boundingBox.getMaxY() < boundingBox.getMinY() || boundingBox.getMaxZ() < boundingBox.getMinZ()) return Value.NULL; Map ret = new HashMap<>(); - ret.put(new StringValue("box"), ListValue.of( - ListValue.fromTriple(boundingBox.method_35420(), boundingBox.method_35415(), boundingBox.method_35416()), - ListValue.fromTriple(boundingBox.method_35417(), boundingBox.method_35418(), boundingBox.method_35419()) - )); + ret.put(new StringValue("box"), of(boundingBox)); List pieces = new ArrayList<>(); for (StructurePiece piece : structure.getChildren()) { BlockBox box = piece.getBoundingBox(); - if (box.method_35417() >= box.method_35420() && box.method_35418() >= box.method_35415() && box.method_35419() >= box.method_35416()) + if (box.getMaxX() >= box.getMinX() && box.getMaxY() >= box.getMinY() && box.getMaxZ() >= box.getMinZ()) { pieces.add(ListValue.of( new StringValue(NBTSerializableValue.nameFromRegistryId(Registry.STRUCTURE_PIECE.getId(piece.getType()))), (piece.getFacing() == null) ? Value.NULL : new StringValue(piece.getFacing().getName()), - ListValue.fromTriple(box.method_35420(), box.method_35415(), box.method_35416()), - ListValue.fromTriple(box.method_35417(), box.method_35418(), box.method_35419()) + ListValue.fromTriple(box.getMinX(), box.getMinY(), box.getMinZ()), + ListValue.fromTriple(box.getMaxX(), box.getMaxY(), box.getMaxZ()) )); } } diff --git a/src/main/java/carpet/utils/BlockInfo.java b/src/main/java/carpet/utils/BlockInfo.java index a3aa1886..1a7a933c 100644 --- a/src/main/java/carpet/utils/BlockInfo.java +++ b/src/main/java/carpet/utils/BlockInfo.java @@ -184,7 +184,7 @@ public class BlockInfo put(Material.REPAIR_STATION , "anvil" ); put(Material.BARRIER , "barrier" ); put(Material.PISTON , "piston" ); - put(Material.UNUSED_PLANT , "coral" ); + put(Material.MOSS_BLOCK , "moss" ); put(Material.GOURD , "gourd" ); put(Material.EGG , "dragon_egg" ); put(Material.CAKE , "cake" ); diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index e1ed21fe..83f5c19e 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -186,7 +186,6 @@ "StatePredicate_scarpetMixin", "TagPredicate_scarpetMixin", "HorseBaseEntity_scarpetMixin", - "PillagerEntity_scarpetMixin", "BlockEntity_movableBEMixin", "PistonBlock_movableTEMixin", From b96ef34e31f16589db58e7aaa37a7660c9d303cd Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 4 Apr 2021 22:36:04 -0300 Subject: [PATCH 048/115] merge fix --- .../mixins/WallStandingBlockItem_creativeNoClipMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/mixins/WallStandingBlockItem_creativeNoClipMixin.java b/src/main/java/carpet/mixins/WallStandingBlockItem_creativeNoClipMixin.java index b8035233..d71bb474 100644 --- a/src/main/java/carpet/mixins/WallStandingBlockItem_creativeNoClipMixin.java +++ b/src/main/java/carpet/mixins/WallStandingBlockItem_creativeNoClipMixin.java @@ -26,7 +26,7 @@ public class WallStandingBlockItem_creativeNoClipMixin ) { PlayerEntity player = itemcontext.getPlayer(); - if (CarpetSettings.creativeNoClip && player != null && player.isCreative() && player.abilities.flying) + if (CarpetSettings.creativeNoClip && player != null && player.isCreative() && player.getAbilities().flying) { // copy from canPlace VoxelShape voxelShape = state.getCollisionShape(worldView, pos, context); From 2e3a49756b20ca7a727ca925588b860168054ad6 Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 6 Apr 2021 21:05:34 -0300 Subject: [PATCH 049/115] mapping --- gradle.properties | 2 +- src/main/java/carpet/script/command/CommandArgument.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index f061ddd8..caa9c9c8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=21w13a - yarn_mappings=21w13a+build.34 + yarn_mappings=21w13a+build.55 loader_version=0.11.3 fabric_version=0.32.6+1.17 diff --git a/src/main/java/carpet/script/command/CommandArgument.java b/src/main/java/carpet/script/command/CommandArgument.java index 80f6062b..6406373a 100644 --- a/src/main/java/carpet/script/command/CommandArgument.java +++ b/src/main/java/carpet/script/command/CommandArgument.java @@ -56,7 +56,7 @@ import net.minecraft.command.argument.MessageArgumentType; import net.minecraft.command.argument.StatusEffectArgumentType; import net.minecraft.command.argument.NbtCompoundTagArgumentType; import net.minecraft.command.argument.NbtPathArgumentType; -import net.minecraft.command.argument.NbtTagArgumentType; +import net.minecraft.command.argument.NbtElementArgumentType; import net.minecraft.command.argument.NumberRangeArgumentType; import net.minecraft.command.argument.ScoreboardObjectiveArgumentType; import net.minecraft.command.argument.ScoreboardCriterionArgumentType; @@ -697,16 +697,16 @@ public abstract class CommandArgument @Override protected ArgumentType getArgumentType() { - return mapRequired?NbtCompoundTagArgumentType.nbtCompound(): NbtTagArgumentType.nbtTag(); + return mapRequired?NbtCompoundTagArgumentType.nbtCompound(): NbtElementArgumentType.nbtElement(); } @Override protected Value getValueFromContext(CommandContext context, String param) throws CommandSyntaxException { if (mapRequired) - return new NBTSerializableValue(NbtCompoundTagArgumentType.getCompoundTag(context, param)); + return new NBTSerializableValue(NbtCompoundTagArgumentType.getNbtCompound(context, param)); else - return new NBTSerializableValue(NbtTagArgumentType.getTag(context, param)); + return new NBTSerializableValue(NbtElementArgumentType.getNbtElement(context, param)); } @Override From 8054e0336d8fd8ae33ba83002f89773b561686a8 Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 6 Apr 2021 23:52:20 -0300 Subject: [PATCH 050/115] mapping --- src/main/java/carpet/network/ClientNetworkHandler.java | 4 ++-- src/main/java/carpet/network/ServerNetworkHandler.java | 4 ++-- src/main/java/carpet/script/value/NBTSerializableValue.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/carpet/network/ClientNetworkHandler.java b/src/main/java/carpet/network/ClientNetworkHandler.java index 69867a9e..cf5b6379 100644 --- a/src/main/java/carpet/network/ClientNetworkHandler.java +++ b/src/main/java/carpet/network/ClientNetworkHandler.java @@ -129,7 +129,7 @@ public class ClientNetworkHandler private static void onSyncData(PacketByteBuf data, ClientPlayerEntity player) { - NbtCompound compound = data.readCompound(); + NbtCompound compound = data.readNbt(); if (compound == null) return; for (String key: compound.getKeys()) { @@ -149,7 +149,7 @@ public class ClientNetworkHandler outer.put("clientCommand", tag); CarpetClient.getPlayer().networkHandler.sendPacket(new CustomPayloadC2SPacket( CarpetClient.CARPET_CHANNEL, - (new PacketByteBuf(Unpooled.buffer())).writeVarInt(CarpetClient.DATA).writeCompound(outer) + (new PacketByteBuf(Unpooled.buffer())).writeVarInt(CarpetClient.DATA).writeNbt(outer) )); } } diff --git a/src/main/java/carpet/network/ServerNetworkHandler.java b/src/main/java/carpet/network/ServerNetworkHandler.java index 59a4b89d..a3f23622 100644 --- a/src/main/java/carpet/network/ServerNetworkHandler.java +++ b/src/main/java/carpet/network/ServerNetworkHandler.java @@ -138,7 +138,7 @@ public class ServerNetworkHandler private static void onClientData(ServerPlayerEntity player, PacketByteBuf data) { - NbtCompound compound = data.readCompound(); + NbtCompound compound = data.readNbt(); if (compound == null) return; for (String key: compound.getKeys()) { @@ -323,7 +323,7 @@ public class ServerNetworkHandler { PacketByteBuf packetBuf = new PacketByteBuf(Unpooled.buffer()); packetBuf.writeVarInt(CarpetClient.DATA); - packetBuf.writeCompound(tag); + packetBuf.writeNbt(tag); return packetBuf; } diff --git a/src/main/java/carpet/script/value/NBTSerializableValue.java b/src/main/java/carpet/script/value/NBTSerializableValue.java index 98bcf052..1e96d67a 100644 --- a/src/main/java/carpet/script/value/NBTSerializableValue.java +++ b/src/main/java/carpet/script/value/NBTSerializableValue.java @@ -290,7 +290,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa return new ItemStackArgument(res.getItem(), customTag); ItemStringReader parser = (new ItemStringReader(new StringReader(itemString), false)).consume(); - res = new ItemStackArgument(parser.getItem(), parser.getTag()); + res = new ItemStackArgument(parser.getItem(), parser.getNbt()); itemCache.put(itemString, res); if (itemCache.size()>64000) itemCache.clear(); From 75a823f99407a00c11358c3299b199e898dd5da2 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 7 Apr 2021 19:05:45 -0300 Subject: [PATCH 051/115] mapping --- gradle.properties | 4 ++-- .../java/carpet/mixins/BastionRemnantFeatureMixin.java | 6 +++--- .../java/carpet/mixins/DesertPyramidFeatureMixin.java | 8 ++++---- src/main/java/carpet/mixins/EndCityFeatureMixin.java | 6 +++--- src/main/java/carpet/mixins/FlatChunkGeneratorMixin.java | 4 ++-- .../mixins/NoiseChunkGenerator_husksSpawnMixin.java | 4 ++-- src/main/java/carpet/utils/PerimeterDiagnostics.java | 6 +++--- src/main/java/carpet/utils/SpawnReporter.java | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/gradle.properties b/gradle.properties index caa9c9c8..a4dc4896 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,9 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=21w13a - yarn_mappings=21w13a+build.55 + yarn_mappings=21w13a+build.59 loader_version=0.11.3 - fabric_version=0.32.6+1.17 + fabric_version=0.32.7+1.17 # Mod Properties mod_version = 1.4.30 diff --git a/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java b/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java index 9e3024cf..497d0c71 100644 --- a/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java +++ b/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java @@ -4,8 +4,8 @@ import carpet.CarpetSettings; import com.google.common.collect.Lists; import com.mojang.serialization.Codec; -import net.minecraft.class_6012; import net.minecraft.entity.EntityType; +import net.minecraft.util.collection.Pool; import net.minecraft.world.MobSpawnerLogic; import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.gen.feature.BastionRemnantFeature; @@ -20,7 +20,7 @@ import java.util.List; @Mixin(BastionRemnantFeature.class) public abstract class BastionRemnantFeatureMixin extends JigsawFeature { - private static final class_6012 spawnList = class_6012.method_34989( + private static final Pool spawnList = Pool.of( new SpawnSettings.SpawnEntry(EntityType.PIGLIN_BRUTE, 5, 1, 2), new SpawnSettings.SpawnEntry(EntityType.PIGLIN, 10, 2, 4), new SpawnSettings.SpawnEntry(EntityType.HOGLIN, 2, 1, 2) @@ -32,7 +32,7 @@ public abstract class BastionRemnantFeatureMixin extends JigsawFeature } @Override - public class_6012 getMonsterSpawns() + public Pool getMonsterSpawns() { if (CarpetSettings.piglinsSpawningInBastions) return spawnList; diff --git a/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java b/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java index 379f8bcf..842c8a73 100644 --- a/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java +++ b/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java @@ -3,8 +3,8 @@ package carpet.mixins; import carpet.CarpetSettings; import com.google.common.collect.Lists; import com.mojang.serialization.Codec; -import net.minecraft.class_6012; import net.minecraft.entity.EntityType; +import net.minecraft.util.collection.Pool; import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.gen.feature.DefaultFeatureConfig; import net.minecraft.world.gen.feature.DesertPyramidFeature; @@ -17,11 +17,11 @@ import java.util.List; @Mixin(DesertPyramidFeature.class) public abstract class DesertPyramidFeatureMixin extends StructureFeature { - private static final class_6012 MONSTER_SPAWNS; + private static final Pool MONSTER_SPAWNS; static { - MONSTER_SPAWNS = class_6012.method_34989(new SpawnSettings.SpawnEntry(EntityType.HUSK, 1, 1, 1)); + MONSTER_SPAWNS = Pool.of(new SpawnSettings.SpawnEntry(EntityType.HUSK, 1, 1, 1)); } public DesertPyramidFeatureMixin(Codec codec) @@ -31,7 +31,7 @@ public abstract class DesertPyramidFeatureMixin extends StructureFeature getMonsterSpawns() + public Pool getMonsterSpawns() { if (CarpetSettings.huskSpawningInTemples) { diff --git a/src/main/java/carpet/mixins/EndCityFeatureMixin.java b/src/main/java/carpet/mixins/EndCityFeatureMixin.java index 6deefc73..641a2f55 100644 --- a/src/main/java/carpet/mixins/EndCityFeatureMixin.java +++ b/src/main/java/carpet/mixins/EndCityFeatureMixin.java @@ -3,8 +3,8 @@ package carpet.mixins; import carpet.CarpetSettings; import com.google.common.collect.Lists; import com.mojang.serialization.Codec; -import net.minecraft.class_6012; import net.minecraft.entity.EntityType; +import net.minecraft.util.collection.Pool; import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.gen.feature.DefaultFeatureConfig; import net.minecraft.world.gen.feature.EndCityFeature; @@ -17,7 +17,7 @@ import java.util.List; @Mixin(EndCityFeature.class) public abstract class EndCityFeatureMixin extends StructureFeature { - private static final class_6012 spawnList = class_6012.method_34989(new SpawnSettings.SpawnEntry(EntityType.SHULKER, 10, 4, 4)); + private static final Pool spawnList = Pool.of(new SpawnSettings.SpawnEntry(EntityType.SHULKER, 10, 4, 4)); public EndCityFeatureMixin(Codec codec) { @@ -25,7 +25,7 @@ public abstract class EndCityFeatureMixin extends StructureFeature getMonsterSpawns() + public Pool getMonsterSpawns() { if (CarpetSettings.shulkerSpawningInEndCities) return spawnList; diff --git a/src/main/java/carpet/mixins/FlatChunkGeneratorMixin.java b/src/main/java/carpet/mixins/FlatChunkGeneratorMixin.java index 0124e0d4..7a6adc4c 100644 --- a/src/main/java/carpet/mixins/FlatChunkGeneratorMixin.java +++ b/src/main/java/carpet/mixins/FlatChunkGeneratorMixin.java @@ -1,8 +1,8 @@ package carpet.mixins; import carpet.CarpetSettings; -import net.minecraft.class_6012; import net.minecraft.entity.SpawnGroup; +import net.minecraft.util.collection.Pool; import net.minecraft.util.math.BlockPos; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.SpawnSettings; @@ -26,7 +26,7 @@ public abstract class FlatChunkGeneratorMixin extends ChunkGenerator } @Override - public class_6012 getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos) + public Pool getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos) { if (CarpetSettings.flatWorldStructureSpawning) { diff --git a/src/main/java/carpet/mixins/NoiseChunkGenerator_husksSpawnMixin.java b/src/main/java/carpet/mixins/NoiseChunkGenerator_husksSpawnMixin.java index a855596d..8f563592 100644 --- a/src/main/java/carpet/mixins/NoiseChunkGenerator_husksSpawnMixin.java +++ b/src/main/java/carpet/mixins/NoiseChunkGenerator_husksSpawnMixin.java @@ -1,8 +1,8 @@ package carpet.mixins; import carpet.CarpetSettings; -import net.minecraft.class_6012; import net.minecraft.entity.SpawnGroup; +import net.minecraft.util.collection.Pool; import net.minecraft.util.math.BlockPos; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.SpawnSettings; @@ -30,7 +30,7 @@ public abstract class NoiseChunkGenerator_husksSpawnMixin extends ChunkGenerator } @Inject(method = "getEntitySpawnList", at = @At("HEAD"), cancellable = true) - private void isInsidePyramid(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos, CallbackInfoReturnable> cir) + private void isInsidePyramid(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos, CallbackInfoReturnable> cir) { if (CarpetSettings.huskSpawningInTemples && group == SpawnGroup.MONSTER) { diff --git a/src/main/java/carpet/utils/PerimeterDiagnostics.java b/src/main/java/carpet/utils/PerimeterDiagnostics.java index aef09385..257068fd 100644 --- a/src/main/java/carpet/utils/PerimeterDiagnostics.java +++ b/src/main/java/carpet/utils/PerimeterDiagnostics.java @@ -159,10 +159,10 @@ public class PerimeterDiagnostics private boolean check_entity_spawn(BlockPos pos) { - if (sle == null || !worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(worldServer.getBiome(pos), worldServer.getStructureAccessor(), ctype, pos).method_34994().contains(sle)) + if (sle == null || !worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(worldServer.getBiome(pos), worldServer.getStructureAccessor(), ctype, pos).getEntries().contains(sle)) { sle = null; - for (SpawnSettings.SpawnEntry sle: worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(worldServer.getBiome(pos), worldServer.getStructureAccessor(), ctype, pos).method_34994()) + for (SpawnSettings.SpawnEntry sle: worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(worldServer.getBiome(pos), worldServer.getStructureAccessor(), ctype, pos).getEntries()) { if (el.getType() == sle.type) { @@ -170,7 +170,7 @@ public class PerimeterDiagnostics break; } } - if (sle == null || !worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(worldServer.getBiome(pos), worldServer.getStructureAccessor(), ctype, pos).method_34994().contains(sle)) + if (sle == null || !worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(worldServer.getBiome(pos), worldServer.getStructureAccessor(), ctype, pos).getEntries().contains(sle)) { return false; } diff --git a/src/main/java/carpet/utils/SpawnReporter.java b/src/main/java/carpet/utils/SpawnReporter.java index 63b8831b..52aef85d 100644 --- a/src/main/java/carpet/utils/SpawnReporter.java +++ b/src/main/java/carpet/utils/SpawnReporter.java @@ -420,7 +420,7 @@ public class SpawnReporter // yeeted from SpawnHelper - temporary fix private static List method_29950(ServerWorld serverWorld, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, SpawnGroup spawnGroup, BlockPos blockPos, /*@Nullable*/ Biome biome) { - return spawnGroup == SpawnGroup.MONSTER && serverWorld.getBlockState(blockPos.down()).getBlock() == Blocks.NETHER_BRICKS && structureAccessor.getStructureAt(blockPos, false, StructureFeature.FORTRESS).hasChildren() ? StructureFeature.FORTRESS.getMonsterSpawns().method_34994() : chunkGenerator.getEntitySpawnList(biome != null ? biome : serverWorld.getBiome(blockPos), structureAccessor, spawnGroup, blockPos).method_34994(); + return spawnGroup == SpawnGroup.MONSTER && serverWorld.getBlockState(blockPos.down()).getBlock() == Blocks.NETHER_BRICKS && structureAccessor.getStructureAt(blockPos, false, StructureFeature.FORTRESS).hasChildren() ? StructureFeature.FORTRESS.getMonsterSpawns().getEntries() : chunkGenerator.getEntitySpawnList(biome != null ? biome : serverWorld.getBiome(blockPos), structureAccessor, spawnGroup, blockPos).getEntries(); } public static List report(BlockPos pos, ServerWorld worldIn) From 6c9dbdda12813d93765952a1c05a776a249cb3f7 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 7 Apr 2021 19:11:59 -0300 Subject: [PATCH 052/115] 21w14a --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index a4dc4896..05a3e057 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=21w13a - yarn_mappings=21w13a+build.59 + minecraft_version=21w14a + yarn_mappings=21w14a+build.2 loader_version=0.11.3 fabric_version=0.32.7+1.17 From 93c989e2b6389edde4eeb07e3808d951874a8dad Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 9 Apr 2021 01:42:57 -0300 Subject: [PATCH 053/115] added `create_explosion` and more event handlers. --- src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java b/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java index 76c690a5..9e1cbf80 100644 --- a/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java +++ b/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java @@ -18,7 +18,6 @@ import net.minecraft.world.explosion.ExplosionBehavior; import net.minecraft.world.level.ServerWorldProperties; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; -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; From 37a6913e72ca86f87f24c33f440ef38ae9020c8c Mon Sep 17 00:00:00 2001 From: gnembon Date: Sat, 10 Apr 2021 02:19:24 -0300 Subject: [PATCH 054/115] mark off unnecessary iface --- src/main/java/carpet/mixins/WeightedPickerEntryMixin.java | 4 ++-- src/main/java/carpet/utils/SpawnReporter.java | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/carpet/mixins/WeightedPickerEntryMixin.java b/src/main/java/carpet/mixins/WeightedPickerEntryMixin.java index 59fd71c1..c4c07802 100644 --- a/src/main/java/carpet/mixins/WeightedPickerEntryMixin.java +++ b/src/main/java/carpet/mixins/WeightedPickerEntryMixin.java @@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(WeightedPicker.Entry.class) public interface WeightedPickerEntryMixin -{ +{/* /// not needed in 1.17 @Accessor("weight") - int getWeight(); + int getWeight();*/ } diff --git a/src/main/java/carpet/utils/SpawnReporter.java b/src/main/java/carpet/utils/SpawnReporter.java index 52aef85d..e3ce055d 100644 --- a/src/main/java/carpet/utils/SpawnReporter.java +++ b/src/main/java/carpet/utils/SpawnReporter.java @@ -1,7 +1,6 @@ package carpet.utils; -import carpet.mixins.WeightedPickerEntryMixin; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2LongMap; import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; @@ -520,7 +519,7 @@ public class SpawnReporter String creature_name = mob.getType().getName().getString(); String pack_size = String.format("%d", mob.getLimitPerChunk());//String.format("%d-%d", animal.minGroupCount, animal.maxGroupCount); - int weight = ((WeightedPickerEntryMixin) spawnEntry).getWeight(); + int weight = spawnEntry.getWeight().getValue();// ((WeightedPickerEntryMixin) spawnEntry).getWeight(); if (canspawn) { String c = (fits_true && will_spawn>0)?"e":"gi"; From c878ffd6374be50fa77afd4f86e1d6c6a46de41d Mon Sep 17 00:00:00 2001 From: replaceitem <40722305+replaceitem@users.noreply.github.com> Date: Tue, 13 Apr 2021 15:44:49 +0200 Subject: [PATCH 055/115] Added renewableDeepslate (#806) * Added renewableDeepslate * Check for stillness Co-authored-by: gnembon <41132274+gnembon@users.noreply.github.com> --- src/main/java/carpet/CarpetSettings.java | 6 ++++ .../FluidBlock_renewableDeepslateMixin.java | 30 +++++++++++++++++++ .../LavaFluid_renewableDeepslateMixin.java | 30 +++++++++++++++++++ src/main/resources/carpet.mixins.json | 2 ++ 4 files changed, 68 insertions(+) create mode 100644 src/main/java/carpet/mixins/FluidBlock_renewableDeepslateMixin.java create mode 100644 src/main/java/carpet/mixins/LavaFluid_renewableDeepslateMixin.java diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index b96d28d8..61b51d6e 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -723,6 +723,12 @@ public class CarpetSettings ) public static boolean renewableBlackstone = false; + @Rule( + desc = "Lava and water generate deepslate and cobbled deepslate instead below y0", + category = FEATURE + ) + public static boolean renewableDeepslate = false; + @Rule(desc = "fixes block placement rotation issue when player rotates quickly while placing blocks", category = BUGFIX) public static boolean placementRotationFix = false; diff --git a/src/main/java/carpet/mixins/FluidBlock_renewableDeepslateMixin.java b/src/main/java/carpet/mixins/FluidBlock_renewableDeepslateMixin.java new file mode 100644 index 00000000..5f588d37 --- /dev/null +++ b/src/main/java/carpet/mixins/FluidBlock_renewableDeepslateMixin.java @@ -0,0 +1,30 @@ +package carpet.mixins; + +import carpet.CarpetSettings; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.FluidBlock; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.WorldAccess; +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.callback.CallbackInfoReturnable; + +@Mixin(FluidBlock.class) +public abstract class FluidBlock_renewableDeepslateMixin { + + @Shadow protected abstract void playExtinguishSound(WorldAccess world, BlockPos pos); + + @Inject(method = "receiveNeighborFluids", at = @At(value = "INVOKE",target = "Lnet/minecraft/fluid/FluidState;isStill()Z"), cancellable = true) + private void receiveFluidToDeepslate(World world, BlockPos pos, BlockState state, CallbackInfoReturnable cir) { + if(CarpetSettings.renewableDeepslate && !world.getFluidState(pos).isStill() && pos.getY() < 0 && world.getRegistryKey() == World.OVERWORLD ) { + world.setBlockState(pos, Blocks.COBBLED_DEEPSLATE.getDefaultState()); + this.playExtinguishSound(world, pos); + cir.setReturnValue(false); + cir.cancel(); + } + } +} diff --git a/src/main/java/carpet/mixins/LavaFluid_renewableDeepslateMixin.java b/src/main/java/carpet/mixins/LavaFluid_renewableDeepslateMixin.java new file mode 100644 index 00000000..770ccf51 --- /dev/null +++ b/src/main/java/carpet/mixins/LavaFluid_renewableDeepslateMixin.java @@ -0,0 +1,30 @@ +package carpet.mixins; + +import carpet.CarpetSettings; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.fluid.FluidState; +import net.minecraft.fluid.LavaFluid; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.world.World; +import net.minecraft.world.WorldAccess; +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.callback.CallbackInfo; + +@Mixin(LavaFluid.class) +public abstract class LavaFluid_renewableDeepslateMixin { + @Shadow protected abstract void playExtinguishEvent(WorldAccess world, BlockPos pos); + + @Inject(method = "flow", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;getDefaultState()Lnet/minecraft/block/BlockState;"), cancellable = true) + private void generateDeepslate(WorldAccess world, BlockPos pos, BlockState state, Direction direction, FluidState fluidState, CallbackInfo ci) { + if(CarpetSettings.renewableDeepslate && pos.getY() < 0 && ((World)world).getRegistryKey() == World.OVERWORLD) { + world.setBlockState(pos, Blocks.DEEPSLATE.getDefaultState(), 3); + this.playExtinguishEvent(world, pos); + ci.cancel(); + } + } +} diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index 68405701..dc178cae 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -86,6 +86,8 @@ "CoralBlockMixin", "CoralFeatureMixin", "FluidBlock_renewableBlackstoneMixin", + "FluidBlock_renewableDeepslateMixin", + "LavaFluid_renewableDeepslateMixin", "StructureFeatureMixin", "World_scarpetPlopMixin", "ChunkRegion_scarpetPlopMixin", From cc3723ae12faab6b4642ff077acb38999b5f7649 Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 13 Apr 2021 19:54:23 -0300 Subject: [PATCH 056/115] mapping --- gradle.properties | 2 +- .../mixins/EntityNavigation_pathfindingMixin.java | 14 +++++++------- src/main/java/carpet/script/api/Inventories.java | 2 +- .../java/carpet/script/value/ValueConversions.java | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gradle.properties b/gradle.properties index 83a409dc..7c59f26b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=21w14a - yarn_mappings=21w14a+build.2 + yarn_mappings=21w14a+build.27 loader_version=0.11.3 fabric_version=0.32.7+1.17 diff --git a/src/main/java/carpet/mixins/EntityNavigation_pathfindingMixin.java b/src/main/java/carpet/mixins/EntityNavigation_pathfindingMixin.java index 45d402f9..b85704cd 100644 --- a/src/main/java/carpet/mixins/EntityNavigation_pathfindingMixin.java +++ b/src/main/java/carpet/mixins/EntityNavigation_pathfindingMixin.java @@ -23,18 +23,18 @@ public abstract class EntityNavigation_pathfindingMixin @Shadow @Final protected MobEntity entity; - @Shadow protected @Nullable abstract Path method_35142(Set set, int i, boolean bl, int j); + @Shadow protected @Nullable abstract Path findPathTo(Set set, int i, boolean bl, int j); @Redirect(method = "findPathTo(Lnet/minecraft/util/math/BlockPos;I)Lnet/minecraft/entity/ai/pathing/Path;", at = @At( value = "INVOKE", - target = "Lnet/minecraft/entity/ai/pathing/EntityNavigation;method_35142(Ljava/util/Set;IZI)Lnet/minecraft/entity/ai/pathing/Path;" + target = "Lnet/minecraft/entity/ai/pathing/EntityNavigation;findPathTo(Ljava/util/Set;IZI)Lnet/minecraft/entity/ai/pathing/Path;" )) private Path pathToBlock(EntityNavigation entityNavigation, Set set_1, int int_1, boolean boolean_1, int int_2) { if (!LoggerRegistry.__pathfinding) - return method_35142(set_1, int_1, boolean_1, int_2); + return findPathTo(set_1, int_1, boolean_1, int_2); long start = System.nanoTime(); - Path path = method_35142(set_1, int_1, boolean_1, int_2); + Path path = findPathTo(set_1, int_1, boolean_1, int_2); long finish = System.nanoTime(); float duration = (1.0F*((finish - start)/1000))/1000; set_1.forEach(b -> PathfindingVisualizer.slowPath(entity, Vec3d.ofBottomCenter(b), duration, path != null)); // ground centered position @@ -43,14 +43,14 @@ public abstract class EntityNavigation_pathfindingMixin @Redirect(method = "findPathTo(Lnet/minecraft/entity/Entity;I)Lnet/minecraft/entity/ai/pathing/Path;", at = @At( value = "INVOKE", - target = "Lnet/minecraft/entity/ai/pathing/EntityNavigation;method_35142(Ljava/util/Set;IZI)Lnet/minecraft/entity/ai/pathing/Path;" + target = "Lnet/minecraft/entity/ai/pathing/EntityNavigation;findPathTo(Ljava/util/Set;IZI)Lnet/minecraft/entity/ai/pathing/Path;" )) private Path pathToEntity(EntityNavigation entityNavigation, Set set_1, int int_1, boolean boolean_1, int int_2) { if (!LoggerRegistry.__pathfinding) - return method_35142(set_1, int_1, boolean_1, int_2); + return findPathTo(set_1, int_1, boolean_1, int_2); long start = System.nanoTime(); - Path path = method_35142(set_1, int_1, boolean_1, int_2); + Path path = findPathTo(set_1, int_1, boolean_1, int_2); long finish = System.nanoTime(); float duration = (1.0F*((finish - start)/1000))/1000; set_1.forEach(b -> PathfindingVisualizer.slowPath(entity, Vec3d.ofBottomCenter(b), duration, path != null)); diff --git a/src/main/java/carpet/script/api/Inventories.java b/src/main/java/carpet/script/api/Inventories.java index 0e82461a..a483e11d 100644 --- a/src/main/java/carpet/script/api/Inventories.java +++ b/src/main/java/carpet/script/api/Inventories.java @@ -130,7 +130,7 @@ public class Inventories { { ItemStack result = recipe.getOutput(); List ingredientValue = new ArrayList<>(); - recipe.getPreviewInputs().forEach( + recipe.getIngredients().forEach( ingredient -> { // I am flattening ingredient lists per slot. diff --git a/src/main/java/carpet/script/value/ValueConversions.java b/src/main/java/carpet/script/value/ValueConversions.java index 3cf8c8e8..aadd48e2 100644 --- a/src/main/java/carpet/script/value/ValueConversions.java +++ b/src/main/java/carpet/script/value/ValueConversions.java @@ -206,7 +206,7 @@ public class ValueConversions { PathNode node = path.getNode(i); nodes.add( ListValue.of( - new BlockValue(null, world, node.getPos()), + new BlockValue(null, world, node.getBlockPos()), new StringValue(node.type.name().toLowerCase(Locale.ROOT)), new NumericValue(node.penalty), new NumericValue(node.visited) From d3295e6b4ed863822da63addfa0b9acba5689440 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 14 Apr 2021 15:07:08 -0300 Subject: [PATCH 057/115] 21w15a --- gradle.properties | 4 ++-- .../BaseRangeDecorator2_cleanLogsMixin.java | 21 +++++++++++++++++++ .../BaseRangeDecorator_cleanLogsMixin.java | 14 ++++++------- .../mixins/Explosion_scarpetEventMixin.java | 11 ++++++++-- src/main/resources/carpet.mixins.json | 2 +- 5 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 src/main/java/carpet/mixins/BaseRangeDecorator2_cleanLogsMixin.java diff --git a/gradle.properties b/gradle.properties index 7c59f26b..cebcb6fd 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=21w14a - yarn_mappings=21w14a+build.27 + minecraft_version=21w15a + yarn_mappings=21w15a+build.1 loader_version=0.11.3 fabric_version=0.32.7+1.17 diff --git a/src/main/java/carpet/mixins/BaseRangeDecorator2_cleanLogsMixin.java b/src/main/java/carpet/mixins/BaseRangeDecorator2_cleanLogsMixin.java new file mode 100644 index 00000000..1295c0b4 --- /dev/null +++ b/src/main/java/carpet/mixins/BaseRangeDecorator2_cleanLogsMixin.java @@ -0,0 +1,21 @@ +package carpet.mixins; + +import carpet.CarpetSettings; +import net.minecraft.class_6342; +import org.apache.logging.log4j.Logger; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(class_6342.class) +public class BaseRangeDecorator2_cleanLogsMixin { + + //@SuppressWarnings("UnresolvedMixinReference") + @Redirect(method = "get", + at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V") + ) + private void skipLogs(Logger logger, String message, Object p0) + { + if (!CarpetSettings.cleanLogs) logger.warn(message, p0); + } +} diff --git a/src/main/java/carpet/mixins/BaseRangeDecorator_cleanLogsMixin.java b/src/main/java/carpet/mixins/BaseRangeDecorator_cleanLogsMixin.java index 306a6a59..d52f77ad 100644 --- a/src/main/java/carpet/mixins/BaseRangeDecorator_cleanLogsMixin.java +++ b/src/main/java/carpet/mixins/BaseRangeDecorator_cleanLogsMixin.java @@ -1,21 +1,21 @@ package carpet.mixins; import carpet.CarpetSettings; -import net.minecraft.world.gen.decorator.BaseRangeDecorator; +import net.minecraft.class_6343; import org.apache.logging.log4j.Logger; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -@Mixin(BaseRangeDecorator.class) +@Mixin(class_6343.class) public class BaseRangeDecorator_cleanLogsMixin { - @SuppressWarnings("UnresolvedMixinReference") - @Redirect(method = "getY(Lnet/minecraft/world/gen/decorator/DecoratorContext;Ljava/util/Random;Lnet/minecraft/world/gen/decorator/RangeDecoratorConfig;I)I", - at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V") + //@SuppressWarnings("UnresolvedMixinReference") + @Redirect(method = "get", + at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V") ) - private void skipLogs(Logger logger, String message, Object p0, Object p1, Object p2) + private void skipLogs(Logger logger, String message, Object p0) { - if (!CarpetSettings.cleanLogs) logger.warn(message, p0, p1, p2); + if (!CarpetSettings.cleanLogs) logger.warn(message, p0); } } diff --git a/src/main/java/carpet/mixins/Explosion_scarpetEventMixin.java b/src/main/java/carpet/mixins/Explosion_scarpetEventMixin.java index 8bca895d..24810333 100644 --- a/src/main/java/carpet/mixins/Explosion_scarpetEventMixin.java +++ b/src/main/java/carpet/mixins/Explosion_scarpetEventMixin.java @@ -15,6 +15,7 @@ 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; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @@ -39,6 +40,8 @@ public abstract class Explosion_scarpetEventMixin @Shadow /*@Nullable*/ public abstract /*@Nullable*/ LivingEntity getCausingEntity(); + @Shadow public static float getExposure(Vec3d source, Entity entity) {return 0.0f;} + private List affectedEntities; @Inject(method = "(Lnet/minecraft/world/World;Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/damage/DamageSource;Lnet/minecraft/world/explosion/ExplosionBehavior;DDDFZLnet/minecraft/world/explosion/Explosion$DestructionType;)V", @@ -51,13 +54,17 @@ public abstract class Explosion_scarpetEventMixin } } - @Inject(method = "collectBlocksAndDamageEntities", locals= LocalCapture.CAPTURE_FAILHARD, at=@At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;damage(Lnet/minecraft/entity/damage/DamageSource;F)Z")) - private void onExplosion(CallbackInfo ci, Set s1, float f1, int i1, int i2, int i3, int i4, int i5, int i6, List l1, Vec3d v1, int i7, Entity entity) + @Redirect(method = "collectBlocksAndDamageEntities", at=@At( + value = "INVOKE", + target = "Lnet/minecraft/world/explosion/Explosion;getExposure(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/entity/Entity;)F") + ) + private float onExplosion(Vec3d source, Entity entity) { if (affectedEntities != null) { affectedEntities.add(entity); } + return getExposure(source, entity); } @Inject(method = "affectWorld", at = @At("HEAD")) diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index dc178cae..a58001ce 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -201,7 +201,7 @@ "BlockItem_creativeNoClipMixin", "WallStandingBlockItem_creativeNoClipMixin", "LivingEntity_creativeFlyMixin", - "BaseRangeDecorator_cleanLogsMixin" + "BaseRangeDecorator_cleanLogsMixin", "BaseRangeDecorator2_cleanLogsMixin" ], "client": [ "RenderTickCounter_tickSpeedMixin", From 9a6b598e48725ceec984b4b94091fbc7e8d61b14 Mon Sep 17 00:00:00 2001 From: gnembon Date: Thu, 15 Apr 2021 14:59:12 -0300 Subject: [PATCH 058/115] taste the rainbow --- .../java/carpet/helpers/HopperCounter.java | 20 ++++++----- src/main/java/carpet/utils/WoolTool.java | 34 +++++++++---------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/main/java/carpet/helpers/HopperCounter.java b/src/main/java/carpet/helpers/HopperCounter.java index a20108a3..b6c6ef45 100644 --- a/src/main/java/carpet/helpers/HopperCounter.java +++ b/src/main/java/carpet/helpers/HopperCounter.java @@ -12,7 +12,7 @@ import it.unimi.dsi.fastutil.objects.Object2LongMap; import net.minecraft.block.AbstractBannerBlock; import net.minecraft.block.Block; import net.minecraft.block.Blocks; -import net.minecraft.block.MaterialColor; +import net.minecraft.block.MapColor; import net.minecraft.block.Stainable; import net.minecraft.item.BlockItem; import net.minecraft.item.DyeItem; @@ -68,7 +68,7 @@ public class HopperCounter { startTick = -1; this.color = color; - this.prettyColour = WoolTool.Material2DyeName.getOrDefault(color.getMaterialColor(),"w ") + color.getName(); + this.prettyColour = WoolTool.Material2DyeName.getOrDefault(color.getMapColor(),"w ") + color.getName(); } public void add(MinecraftServer server, ItemStack stack) @@ -174,7 +174,7 @@ public class HopperCounter public static int appropriateColor(int color) { - if (color == 0) return MaterialColor.WHITE.color; + if (color == 0) return MapColor.WHITE.color; int r = (color >> 16 & 255); int g = (color >> 8 & 255); int b = (color & 255); @@ -267,12 +267,14 @@ public class HopperCounter .put(Items.PHANTOM_MEMBRANE,Blocks.BONE_BLOCK) .put(Items.EGG,Blocks.BONE_BLOCK) //.put(Items.,Blocks.) + .put(Items.COPPER_INGOT,Blocks.COPPER_BLOCK) + .put(Items.AMETHYST_SHARD, Blocks.AMETHYST_BLOCK) .build(); public static TextColor fromItem(Item item) { - if (DEFAULTS.containsKey(item)) return TextColor.fromRgb(appropriateColor(DEFAULTS.get(item).getDefaultMaterialColor().color)); - if (item instanceof DyeItem) return TextColor.fromRgb(appropriateColor(((DyeItem) item).getColor().getMaterialColor().color)); + if (DEFAULTS.containsKey(item)) return TextColor.fromRgb(appropriateColor(DEFAULTS.get(item).getDefaultMapColor().color)); + if (item instanceof DyeItem) return TextColor.fromRgb(appropriateColor(((DyeItem) item).getColor().getMapColor().color)); Block block = null; Identifier id = Registry.ITEM.getId(item); if (item instanceof BlockItem) @@ -285,9 +287,9 @@ public class HopperCounter } if (block != null) { - if (block instanceof AbstractBannerBlock) return TextColor.fromRgb(appropriateColor(((AbstractBannerBlock) block).getColor().getMaterialColor().color)); - if (block instanceof Stainable) return TextColor.fromRgb(appropriateColor( ((Stainable) block).getColor().getMaterialColor().color)); - return TextColor.fromRgb(appropriateColor( block.getDefaultMaterialColor().color)); + if (block instanceof AbstractBannerBlock) return TextColor.fromRgb(appropriateColor(((AbstractBannerBlock) block).getColor().getMapColor().color)); + if (block instanceof Stainable) return TextColor.fromRgb(appropriateColor( ((Stainable) block).getColor().getMapColor().color)); + return TextColor.fromRgb(appropriateColor( block.getDefaultMapColor().color)); } return null; } @@ -302,7 +304,7 @@ public class HopperCounter { for (Recipe r: ((RecipeManagerInterface) CarpetServer.minecraft_server.getRecipeManager()).getAllMatching(type, id)) { - for (Ingredient ingredient: r.getPreviewInputs()) + for (Ingredient ingredient: r.getIngredients()) { for (Collection stacks : ((IngredientInterface) (Object) ingredient).getRecipeStacks()) { diff --git a/src/main/java/carpet/utils/WoolTool.java b/src/main/java/carpet/utils/WoolTool.java index 6f6e6fd4..08e02282 100644 --- a/src/main/java/carpet/utils/WoolTool.java +++ b/src/main/java/carpet/utils/WoolTool.java @@ -22,23 +22,23 @@ public class WoolTool { private static final HashMap Material2Dye = new HashMap<>(); - public static final HashMap Material2DyeName = new HashMap(){{ - put(MaterialColor.WHITE, "w "); - put(MaterialColor.ORANGE, "#F9801D "); - put(MaterialColor.MAGENTA, "m "); - put(MaterialColor.LIGHT_BLUE, "t "); - put(MaterialColor.YELLOW, "y "); - put(MaterialColor.LAPIS, "l "); - put(MaterialColor.PINK, "#FFACCB "); - put(MaterialColor.GRAY, "f "); - put(MaterialColor.LIGHT_GRAY, "g "); - put(MaterialColor.CYAN, "c "); - put(MaterialColor.PURPLE, "p "); - put(MaterialColor.BLUE, "v "); - put(MaterialColor.BROWN, "#835432 "); - put(MaterialColor.GREEN, "e "); - put(MaterialColor.RED, "r "); - put(MaterialColor.BLACK, "k "); + public static final HashMap Material2DyeName = new HashMap(){{ + put(MapColor.WHITE, "w "); + put(MapColor.ORANGE, "#F9801D "); + put(MapColor.MAGENTA, "m "); + put(MapColor.LIGHT_BLUE, "t "); + put(MapColor.YELLOW, "y "); + put(MapColor.LIME, "l "); + put(MapColor.PINK, "#FFACCB "); + put(MapColor.GRAY, "f "); + put(MapColor.LIGHT_GRAY, "g "); + put(MapColor.CYAN, "c "); + put(MapColor.PURPLE, "p "); + put(MapColor.BLUE, "v "); + put(MapColor.BROWN, "#835432 "); + put(MapColor.GREEN, "e "); + put(MapColor.RED, "r "); + put(MapColor.BLACK, "k "); }}; static { From 587e04c8db2b4a04c75dfcc3e4d6f984e6e2ffe9 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sat, 17 Apr 2021 01:56:37 -0300 Subject: [PATCH 059/115] 1.17 update --- .../java/carpet/mixins/BiomeArray_cleanLogsMixin.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java b/src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java index cf7fc1a0..3b76571d 100644 --- a/src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java +++ b/src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java @@ -10,12 +10,12 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(BiomeArray.class) public class BiomeArray_cleanLogsMixin { - @Redirect(method = "(Lnet/minecraft/util/collection/IndexedIterable;[I)V", at = @At( + @Redirect(method = "(Lnet/minecraft/util/collection/IndexedIterable;Lnet/minecraft/world/HeightLimitView;[I)V", at = @At( value = "INVOKE", - target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;)V") + target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V") ) - private void skipLog(Logger logger, String message) + private void skipLog(Logger logger, String message, Object p0) { - if (!CarpetSettings.cleanLogs) logger.warn(message); + if (!CarpetSettings.cleanLogs) logger.warn(message, p0); } } From ee6ea80ce6ac54c23d1a987dad8e67eb98f2ef66 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 18 Apr 2021 01:56:59 -0300 Subject: [PATCH 060/115] update --- src/main/java/carpet/script/api/Auxiliary.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/java/carpet/script/api/Auxiliary.java b/src/main/java/carpet/script/api/Auxiliary.java index 40d6f074..107e497a 100644 --- a/src/main/java/carpet/script/api/Auxiliary.java +++ b/src/main/java/carpet/script/api/Auxiliary.java @@ -7,8 +7,6 @@ import carpet.fakes.ServerWorldInterface; import carpet.fakes.StatTypeInterface; import carpet.fakes.ThreadedAnvilChunkStorageInterface; import carpet.helpers.FeatureGenerator; -import carpet.mixins.PlayerListHeaderS2CPacketMixin; -import carpet.script.bundled.Module; import carpet.script.argument.FileArgument; import carpet.script.CarpetContext; import carpet.script.CarpetEventServer; @@ -85,7 +83,6 @@ import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.InvalidIdentifierException; -import net.minecraft.util.crash.CrashException; import net.minecraft.util.Util; import net.minecraft.util.WorldSavePath; import net.minecraft.util.dynamic.RegistryOps; @@ -112,7 +109,6 @@ import org.apache.commons.lang3.tuple.Pair; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; import java.io.BufferedWriter; import java.io.IOException; @@ -613,9 +609,7 @@ public class Auxiliary { footer = new LiteralText(pVal.getString()); } - PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket(); - ((PlayerListHeaderS2CPacketMixin) packet).setFooter(footer); - ((PlayerListHeaderS2CPacketMixin) packet).setHeader(header); + PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket(header, footer); AtomicInteger total = new AtomicInteger(0); targets.forEach(p -> { p.networkHandler.sendPacket(packet); From e438fbf56dcc6e17fafbf42e6604c3fbed9babfa Mon Sep 17 00:00:00 2001 From: gnembon Date: Mon, 19 Apr 2021 03:57:59 -0300 Subject: [PATCH 061/115] fix --- src/main/java/carpet/logging/HUDController.java | 4 ++-- src/main/java/carpet/script/api/Auxiliary.java | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/carpet/logging/HUDController.java b/src/main/java/carpet/logging/HUDController.java index 76963fab..c54a907e 100644 --- a/src/main/java/carpet/logging/HUDController.java +++ b/src/main/java/carpet/logging/HUDController.java @@ -120,8 +120,8 @@ public class HUDController for (ServerPlayerEntity player: targets) { PacketByteBuf packetData = new PacketByteBuf(Unpooled.buffer()). - writeText(new LiteralText("")). - writeText(Messenger.c(player_huds.get(player).toArray(new Object[0]))); + writeText(scarpet_headers.getOrDefault(player, new LiteralText(""))). + writeText(Messenger.c(player_huds.getOrDefault(player, Collections.emptyList()).toArray(new Object[0]))); PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket(packetData); //PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket(); diff --git a/src/main/java/carpet/script/api/Auxiliary.java b/src/main/java/carpet/script/api/Auxiliary.java index 5ce1eb80..63d23f6f 100644 --- a/src/main/java/carpet/script/api/Auxiliary.java +++ b/src/main/java/carpet/script/api/Auxiliary.java @@ -552,7 +552,7 @@ public class Auxiliary { if (player == null) throw new InternalExpressionException("'display_title' requires a valid online player or a list of players as first argument. "+v.getString()+" is not a player."); return player; }); - Function> packetGetter; + Function> packetGetter = null; //TitleS2CPacket.Action action; String actionString = lv.get(1).evalValue(c).getString().toLowerCase(Locale.ROOT); switch (actionString) @@ -584,7 +584,6 @@ public class Auxiliary { break; case "player_list_header": case "player_list_footer": - action = null; break; default: throw new InternalExpressionException("'display_title' requires 'title', 'subtitle', 'actionbar', 'player_list_header', 'player_list_footer' or 'clear' as second argument"); @@ -608,7 +607,7 @@ public class Auxiliary { } } else title = null; // Will never happen, just to make lambda happy - if (action == null) + if (packetGetter == null) { Map map; if (actionString.equals("player_list_header")) From 0d71d9c0a1b0ea0158fe538a04fc5686e60c34fc Mon Sep 17 00:00:00 2001 From: gnembon Date: Mon, 19 Apr 2021 09:35:01 -0300 Subject: [PATCH 062/115] name --- src/main/java/carpet/script/utils/FixedCommandSource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/script/utils/FixedCommandSource.java b/src/main/java/carpet/script/utils/FixedCommandSource.java index 2355e9b7..65bde16a 100644 --- a/src/main/java/carpet/script/utils/FixedCommandSource.java +++ b/src/main/java/carpet/script/utils/FixedCommandSource.java @@ -110,7 +110,7 @@ public class FixedCommandSource extends ServerCommandSource public ServerCommandSource withWorld(ServerWorld world) { this.world = world; - double d = DimensionType.method_31109(this.world.getDimension(), world.getDimension()); + double d = DimensionType.getCoordinateScaleFactor(this.world.getDimension(), world.getDimension()); this.position = new Vec3d(this.position.x * d, this.position.y, this.position.z * d); return this; } From 4b85bdcb86f7deeceed281ef94db63585c6a6735 Mon Sep 17 00:00:00 2001 From: gnembon Date: Mon, 19 Apr 2021 23:48:55 -0300 Subject: [PATCH 063/115] merge errors --- src/main/java/carpet/network/ServerNetworkHandler.java | 2 +- src/main/java/carpet/script/utils/SnoopyCommandSource.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/carpet/network/ServerNetworkHandler.java b/src/main/java/carpet/network/ServerNetworkHandler.java index b647306f..aee49d03 100644 --- a/src/main/java/carpet/network/ServerNetworkHandler.java +++ b/src/main/java/carpet/network/ServerNetworkHandler.java @@ -105,7 +105,7 @@ public class ServerNetworkHandler new SnoopyCommandSource(player, error, output), command ); } - CompoundTag result = new CompoundTag(); + NbtCompound result = new NbtCompound(); result.putString("id", id); result.putInt("code", resultCode); if (error[0] != null) result.putString("error", error[0].asString()); diff --git a/src/main/java/carpet/script/utils/SnoopyCommandSource.java b/src/main/java/carpet/script/utils/SnoopyCommandSource.java index 5747d8a2..8a2508d6 100644 --- a/src/main/java/carpet/script/utils/SnoopyCommandSource.java +++ b/src/main/java/carpet/script/utils/SnoopyCommandSource.java @@ -2,7 +2,6 @@ package carpet.script.utils; import carpet.CarpetSettings; import com.mojang.brigadier.ResultConsumer; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.command.argument.EntityAnchorArgumentType; import net.minecraft.entity.Entity; import net.minecraft.server.MinecraftServer; @@ -123,7 +122,8 @@ public class SnoopyCommandSource extends ServerCommandSource return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, consumer, entityAnchor, error, chatOutput); } - public ServerCommandSource mergeConsumers(ResultConsumer consumer, BinaryOperator> binaryOperator) { + public ServerCommandSource mergeConsumers(ResultConsumer consumer, BinaryOperator> binaryOperator) + { ResultConsumer resultConsumer = binaryOperator.apply(this.resultConsumer, consumer); return this.withConsumer(resultConsumer); } @@ -158,7 +158,8 @@ public class SnoopyCommandSource extends ServerCommandSource return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, resultConsumer, entityAnchor, error, chatOutput); } - public ServerCommandSource withLookingAt(Vec3d position) throws CommandSyntaxException { + public ServerCommandSource withLookingAt(Vec3d position) + { Vec3d vec3d = this.entityAnchor.positionAt(this); double d = position.x - vec3d.x; double e = position.y - vec3d.y; From 8870c245ff9f84cf6ece65701d306640f2a5acfc Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 20 Apr 2021 00:09:00 -0300 Subject: [PATCH 064/115] mapping --- gradle.properties | 4 ++-- ...xin.java => TrapezoidHeightProvider_cleanLogsMixin.java} | 6 +++--- ...=> VeryBiasedToBottomHeightProvider_cleanLogsMixin.java} | 6 +++--- src/main/resources/carpet.mixins.json | 4 +++- 4 files changed, 11 insertions(+), 9 deletions(-) rename src/main/java/carpet/mixins/{BaseRangeDecorator2_cleanLogsMixin.java => TrapezoidHeightProvider_cleanLogsMixin.java} (78%) rename src/main/java/carpet/mixins/{BaseRangeDecorator_cleanLogsMixin.java => VeryBiasedToBottomHeightProvider_cleanLogsMixin.java} (75%) diff --git a/gradle.properties b/gradle.properties index 9660afe0..dcb56dc8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,9 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=21w15a - yarn_mappings=21w15a+build.1 + yarn_mappings=21w15a+build.16 loader_version=0.11.3 - fabric_version=0.32.7+1.17 + fabric_version=0.33.0+1.17 # Mod Properties mod_version = 1.4.32 diff --git a/src/main/java/carpet/mixins/BaseRangeDecorator2_cleanLogsMixin.java b/src/main/java/carpet/mixins/TrapezoidHeightProvider_cleanLogsMixin.java similarity index 78% rename from src/main/java/carpet/mixins/BaseRangeDecorator2_cleanLogsMixin.java rename to src/main/java/carpet/mixins/TrapezoidHeightProvider_cleanLogsMixin.java index 1295c0b4..34030c74 100644 --- a/src/main/java/carpet/mixins/BaseRangeDecorator2_cleanLogsMixin.java +++ b/src/main/java/carpet/mixins/TrapezoidHeightProvider_cleanLogsMixin.java @@ -1,14 +1,14 @@ package carpet.mixins; import carpet.CarpetSettings; -import net.minecraft.class_6342; +import net.minecraft.world.gen.heightprovider.TrapezoidHeightProvider; import org.apache.logging.log4j.Logger; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -@Mixin(class_6342.class) -public class BaseRangeDecorator2_cleanLogsMixin { +@Mixin(TrapezoidHeightProvider.class) +public class TrapezoidHeightProvider_cleanLogsMixin { //@SuppressWarnings("UnresolvedMixinReference") @Redirect(method = "get", diff --git a/src/main/java/carpet/mixins/BaseRangeDecorator_cleanLogsMixin.java b/src/main/java/carpet/mixins/VeryBiasedToBottomHeightProvider_cleanLogsMixin.java similarity index 75% rename from src/main/java/carpet/mixins/BaseRangeDecorator_cleanLogsMixin.java rename to src/main/java/carpet/mixins/VeryBiasedToBottomHeightProvider_cleanLogsMixin.java index d52f77ad..d64569eb 100644 --- a/src/main/java/carpet/mixins/BaseRangeDecorator_cleanLogsMixin.java +++ b/src/main/java/carpet/mixins/VeryBiasedToBottomHeightProvider_cleanLogsMixin.java @@ -1,14 +1,14 @@ package carpet.mixins; import carpet.CarpetSettings; -import net.minecraft.class_6343; +import net.minecraft.world.gen.heightprovider.VeryBiasedToBottomHeightProvider; import org.apache.logging.log4j.Logger; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -@Mixin(class_6343.class) -public class BaseRangeDecorator_cleanLogsMixin { +@Mixin(VeryBiasedToBottomHeightProvider.class) +public class VeryBiasedToBottomHeightProvider_cleanLogsMixin { //@SuppressWarnings("UnresolvedMixinReference") @Redirect(method = "get", diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index 026c8537..3ecc0180 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -202,7 +202,9 @@ "BlockItem_creativeNoClipMixin", "WallStandingBlockItem_creativeNoClipMixin", "LivingEntity_creativeFlyMixin", - "BaseRangeDecorator_cleanLogsMixin", "BaseRangeDecorator2_cleanLogsMixin" + + "VeryBiasedToBottomHeightProvider_cleanLogsMixin", + "TrapezoidHeightProvider_cleanLogsMixin" ], "client": [ "RenderTickCounter_tickSpeedMixin", From fc87053978d40577e54152c140b9b871d0377928 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 21 Apr 2021 20:12:44 -0300 Subject: [PATCH 065/115] 21w16a --- gradle.properties | 4 ++-- src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java | 1 + .../mixins/TrapezoidHeightProvider_cleanLogsMixin.java | 2 +- src/main/java/carpet/mixins/WitherEntity_extremeMixin.java | 5 ++++- src/main/java/carpet/script/CarpetEventServer.java | 4 +++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 4f784ccb..e408e70e 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=21w15a - yarn_mappings=21w15a+build.16 + minecraft_version=21w16a + yarn_mappings=21w16a+build.1 loader_version=0.11.3 fabric_version=0.33.0+1.17 diff --git a/src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java b/src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java index 3b76571d..7c703e6e 100644 --- a/src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java +++ b/src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java @@ -10,6 +10,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(BiomeArray.class) public class BiomeArray_cleanLogsMixin { + @SuppressWarnings("UnresolvedMixinReference") @Redirect(method = "(Lnet/minecraft/util/collection/IndexedIterable;Lnet/minecraft/world/HeightLimitView;[I)V", at = @At( value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V") diff --git a/src/main/java/carpet/mixins/TrapezoidHeightProvider_cleanLogsMixin.java b/src/main/java/carpet/mixins/TrapezoidHeightProvider_cleanLogsMixin.java index 34030c74..4c024ba4 100644 --- a/src/main/java/carpet/mixins/TrapezoidHeightProvider_cleanLogsMixin.java +++ b/src/main/java/carpet/mixins/TrapezoidHeightProvider_cleanLogsMixin.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(TrapezoidHeightProvider.class) public class TrapezoidHeightProvider_cleanLogsMixin { - //@SuppressWarnings("UnresolvedMixinReference") + @SuppressWarnings("UnresolvedMixinReference") @Redirect(method = "get", at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V") ) diff --git a/src/main/java/carpet/mixins/WitherEntity_extremeMixin.java b/src/main/java/carpet/mixins/WitherEntity_extremeMixin.java index e6b5aca4..07bacb52 100644 --- a/src/main/java/carpet/mixins/WitherEntity_extremeMixin.java +++ b/src/main/java/carpet/mixins/WitherEntity_extremeMixin.java @@ -12,7 +12,10 @@ import java.util.Random; @Mixin(WitherEntity.class) public class WitherEntity_extremeMixin { - @Redirect(method = "method_6878", at = @At(value = "INVOKE", target = "Ljava/util/Random;nextFloat()F")) + @Redirect(method = "shootSkullAt(ILnet/minecraft/entity/LivingEntity;)V", at = @At( + value = "INVOKE", + target = "Ljava/util/Random;nextFloat()F") + ) private float nextFloatAmplfied(Random random) { if (CarpetSettings.extremeBehaviours) return random.nextFloat()/100; diff --git a/src/main/java/carpet/script/CarpetEventServer.java b/src/main/java/carpet/script/CarpetEventServer.java index 4534d667..194207ad 100644 --- a/src/main/java/carpet/script/CarpetEventServer.java +++ b/src/main/java/carpet/script/CarpetEventServer.java @@ -824,7 +824,9 @@ public class CarpetEventServer private final Set skippedStats = new HashSet(){{ add(Stats.TIME_SINCE_DEATH); add(Stats.TIME_SINCE_REST); - add(Stats.PLAY_ONE_MINUTE); + //add(Stats.PLAY_ONE_MINUTE); + add(Stats.PLAY_TIME); + add(Stats.TOTAL_WORLD_TIME); }}; @Override public void onPlayerStatistic(ServerPlayerEntity player, Stat stat, int amount) From e8f135872dae0e1892bd4e889e8961fd6cb517ab Mon Sep 17 00:00:00 2001 From: gnembon Date: Thu, 22 Apr 2021 08:41:27 -0300 Subject: [PATCH 066/115] fixes #827 --- .../java/carpet/mixins/PlayerManager_scarpetEventsMixin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/carpet/mixins/PlayerManager_scarpetEventsMixin.java b/src/main/java/carpet/mixins/PlayerManager_scarpetEventsMixin.java index a4b6a6bd..2c63ef02 100644 --- a/src/main/java/carpet/mixins/PlayerManager_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/PlayerManager_scarpetEventsMixin.java @@ -23,8 +23,8 @@ public class PlayerManager_scarpetEventsMixin @Inject(method = "respawnPlayer", at = @At( value = "INVOKE", - //target = "Lnet/minecraft/server/network/ServerPlayerEntity;onSpawn()V" - target = "Lnet/minecraft/server/network/ServerPlayerEntity;method_34225()V" + target = "Lnet/minecraft/server/network/ServerPlayerEntity;onSpawn()V" + //target = "Lnet/minecraft/server/network/ServerPlayerEntity;method_34225()V" )) private void invalidatePreviousInstance(ServerPlayerEntity player, boolean alive, CallbackInfoReturnable cir) { From 99e8db192a5eabba243623e56eb1090be876416d Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 28 Apr 2021 01:42:49 -0300 Subject: [PATCH 067/115] mappings --- gradle.properties | 2 +- src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java | 2 +- src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java | 2 +- src/main/java/carpet/mixins/EndCityFeatureMixin.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index e408e70e..3f6c6c96 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=21w16a - yarn_mappings=21w16a+build.1 + yarn_mappings=21w16a+build.12 loader_version=0.11.3 fabric_version=0.33.0+1.17 diff --git a/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java b/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java index 497d0c71..0633874c 100644 --- a/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java +++ b/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java @@ -36,6 +36,6 @@ public abstract class BastionRemnantFeatureMixin extends JigsawFeature { if (CarpetSettings.piglinsSpawningInBastions) return spawnList; - return SpawnSettings.field_30982; // empty spawn list + return SpawnSettings.EMPTY_ENTRY_POOL; } } diff --git a/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java b/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java index 842c8a73..ff46ca42 100644 --- a/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java +++ b/src/main/java/carpet/mixins/DesertPyramidFeatureMixin.java @@ -37,7 +37,7 @@ public abstract class DesertPyramidFeatureMixin extends StructureFeature Date: Wed, 28 Apr 2021 17:05:42 -0300 Subject: [PATCH 068/115] 21w17a --- gradle.properties | 6 ++--- .../carpet/commands/PerimeterInfoCommand.java | 2 +- .../helpers/EntityPlayerActionPack.java | 10 +++---- src/main/java/carpet/helpers/XPcombine.java | 2 +- .../carpet/mixins/GuardianEntityMixin.java | 2 +- .../carpet/patches/EntityPlayerMPFake.java | 2 +- src/main/java/carpet/script/api/Entities.java | 2 +- .../java/carpet/script/value/EntityValue.java | 26 +++++++++---------- src/main/java/carpet/utils/MobAI.java | 2 +- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/gradle.properties b/gradle.properties index 0df84997..09acba33 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=21w16a - yarn_mappings=21w16a+build.12 + minecraft_version=21w17a + yarn_mappings=21w17a+build.2 loader_version=0.11.3 - fabric_version=0.33.0+1.17 + fabric_version=0.33.3+1.17 # Mod Properties mod_version = 1.4.34 diff --git a/src/main/java/carpet/commands/PerimeterInfoCommand.java b/src/main/java/carpet/commands/PerimeterInfoCommand.java index 73fce328..f259b44d 100644 --- a/src/main/java/carpet/commands/PerimeterInfoCommand.java +++ b/src/main/java/carpet/commands/PerimeterInfoCommand.java @@ -52,7 +52,7 @@ public class PerimeterInfoCommand { nbttagcompound.putString("id", mobId); Entity baseEntity = EntityType.loadEntityWithPassengers(nbttagcompound, source.getWorld(), (entity_1x) -> { - entity_1x.refreshPositionAndAngles(new BlockPos(pos.getX(), -10, pos.getZ()), entity_1x.yaw, entity_1x.pitch); + entity_1x.refreshPositionAndAngles(new BlockPos(pos.getX(), -10, pos.getZ()), entity_1x.method_36454(), entity_1x.method_36455()); // yaw pitch return !source.getWorld().tryLoadEntity(entity_1x) ? null : entity_1x; }); if (!(baseEntity instanceof MobEntity)) diff --git a/src/main/java/carpet/helpers/EntityPlayerActionPack.java b/src/main/java/carpet/helpers/EntityPlayerActionPack.java index 971d6647..77d67010 100644 --- a/src/main/java/carpet/helpers/EntityPlayerActionPack.java +++ b/src/main/java/carpet/helpers/EntityPlayerActionPack.java @@ -116,8 +116,8 @@ public class EntityPlayerActionPack case SOUTH: return look(0, 0); case EAST: return look(-90, 0); case WEST: return look(90, 0); - case UP: return look(player.yaw, -90); - case DOWN: return look(player.yaw, 90); + case UP: return look(player.method_36454(), -90); + case DOWN: return look(player.method_36454(), 90); } return this; } @@ -128,8 +128,8 @@ public class EntityPlayerActionPack public EntityPlayerActionPack look(float yaw, float pitch) { - player.yaw = yaw % 360; - player.pitch = MathHelper.clamp(pitch, -90, 90); + player.method_36456(yaw % 360); //setYaw + player.method_36457(MathHelper.clamp(pitch, -90, 90)); // setPitch // maybe player.setPositionAndAngles(player.x, player.y, player.z, yaw, MathHelper.clamp(pitch,-90.0F, 90.0F)); return this; } @@ -142,7 +142,7 @@ public class EntityPlayerActionPack public EntityPlayerActionPack turn(float yaw, float pitch) { - return look(player.yaw + yaw, player.pitch + pitch); + return look(player.method_36454() + yaw, player.method_36455() + pitch); } public EntityPlayerActionPack turn(Vec2f rotation) diff --git a/src/main/java/carpet/helpers/XPcombine.java b/src/main/java/carpet/helpers/XPcombine.java index 00826d8d..26750b25 100644 --- a/src/main/java/carpet/helpers/XPcombine.java +++ b/src/main/java/carpet/helpers/XPcombine.java @@ -50,7 +50,7 @@ public class XPcombine if (getTextureByXP(first.getExperienceAmount()) != size) { newOrb = new ExperienceOrbEntity(EntityType.EXPERIENCE_ORB, first.world); - newOrb.refreshPositionAndAngles(first.getX(), first.getY(), first.getZ(), first.yaw, first.pitch); + newOrb.refreshPositionAndAngles(first.getX(), first.getY(), first.getZ(), first.method_36454(), first.method_36455()); ((ExperienceOrbInterface)newOrb).setAmount(first.getExperienceAmount()); first.world.spawnEntity(newOrb); diff --git a/src/main/java/carpet/mixins/GuardianEntityMixin.java b/src/main/java/carpet/mixins/GuardianEntityMixin.java index 69ac8840..66e24502 100644 --- a/src/main/java/carpet/mixins/GuardianEntityMixin.java +++ b/src/main/java/carpet/mixins/GuardianEntityMixin.java @@ -27,7 +27,7 @@ public abstract class GuardianEntityMixin extends HostileEntity 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); + elderGuardian.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), this.method_36454(), this.method_36455()); elderGuardian.initialize(serverWorld ,this.world.getLocalDifficulty(elderGuardian.getBlockPos()), SpawnReason.CONVERSION, (EntityData)null, (NbtCompound)null); elderGuardian.setAiDisabled(this.isAiDisabled()); diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index 7a920c5a..e59b2420 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -69,7 +69,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity server.getPlayerManager().onPlayerConnect(new NetworkManagerFake(NetworkSide.SERVERBOUND), playerShadow); playerShadow.setHealth(player.getHealth()); - playerShadow.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.yaw, player.pitch); + playerShadow.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.method_36454(), player.method_36455()); playerShadow.interactionManager.changeGameMode(player.interactionManager.getGameMode()); ((ServerPlayerEntityInterface) playerShadow).getActionPack().copyFrom(((ServerPlayerEntityInterface) player).getActionPack()); playerShadow.stepHeight = 0.6F; diff --git a/src/main/java/carpet/script/api/Entities.java b/src/main/java/carpet/script/api/Entities.java index c5c465dc..283ff917 100644 --- a/src/main/java/carpet/script/api/Entities.java +++ b/src/main/java/carpet/script/api/Entities.java @@ -142,7 +142,7 @@ public class Entities { ServerWorld serverWorld = cc.s.getWorld(); Entity entity_1 = EntityType.loadEntityWithPassengers(tag, serverWorld, (entity_1x) -> { - entity_1x.refreshPositionAndAngles(vec3d.x, vec3d.y, vec3d.z, entity_1x.yaw, entity_1x.pitch); + entity_1x.refreshPositionAndAngles(vec3d.x, vec3d.y, vec3d.z, entity_1x.method_36454(), entity_1x.method_36455()); return !serverWorld.tryLoadEntity(entity_1x) ? null : entity_1x; }); if (entity_1 == null) { diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index b6eab7f1..4c57dfb9 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -429,7 +429,7 @@ public class EntityValue extends Value put("uuid",(e, a) -> new StringValue(e.getUuidAsString())); put("id",(e, a) -> new NumericValue(e.getId())); put("pos", (e, a) -> ListValue.of(new NumericValue(e.getX()), new NumericValue(e.getY()), new NumericValue(e.getZ()))); - put("location", (e, a) -> ListValue.of(new NumericValue(e.getX()), new NumericValue(e.getY()), new NumericValue(e.getZ()), new NumericValue(e.yaw), new NumericValue(e.pitch))); + put("location", (e, a) -> ListValue.of(new NumericValue(e.getX()), new NumericValue(e.getY()), new NumericValue(e.getZ()), new NumericValue(e.method_36454()), new NumericValue(e.method_36455()))); put("x", (e, a) -> new NumericValue(e.getX())); put("y", (e, a) -> new NumericValue(e.getY())); put("z", (e, a) -> new NumericValue(e.getZ())); @@ -467,7 +467,7 @@ public class EntityValue extends Value return new NumericValue(e.getType().isIn(tag)); }); - put("yaw", (e, a)-> new NumericValue(e.yaw)); + put("yaw", (e, a)-> new NumericValue(e.method_36454())); put("head_yaw", (e, a)-> { if (e instanceof LivingEntity) { @@ -483,7 +483,7 @@ public class EntityValue extends Value return Value.NULL; }); - put("pitch", (e, a)-> new NumericValue(e.pitch)); + put("pitch", (e, a)-> new NumericValue(e.method_36455())); put("look", (e, a) -> { Vec3d look = e.getRotationVector(); return ListValue.of(new NumericValue(look.x),new NumericValue(look.y),new NumericValue(look.z)); @@ -1010,25 +1010,25 @@ public class EntityValue extends Value NumericValue.asNumber(coords.get(0)).getDouble(), NumericValue.asNumber(coords.get(1)).getDouble(), NumericValue.asNumber(coords.get(2)).getDouble(), - e.yaw, - e.pitch + e.method_36454(), + e.method_36455() ); }); put("x", (e, v) -> { - updatePosition(e, NumericValue.asNumber(v).getDouble(), e.getY(), e.getZ(), e.yaw, e.pitch); + updatePosition(e, NumericValue.asNumber(v).getDouble(), e.getY(), e.getZ(), e.method_36454(), e.method_36455()); }); put("y", (e, v) -> { - updatePosition(e, e.getX(), NumericValue.asNumber(v).getDouble(), e.getZ(), e.yaw, e.pitch); + updatePosition(e, e.getX(), NumericValue.asNumber(v).getDouble(), e.getZ(), e.method_36454(), e.method_36455()); }); put("z", (e, v) -> { - updatePosition(e, e.getX(), e.getY(), NumericValue.asNumber(v).getDouble(), e.yaw, e.pitch); + updatePosition(e, e.getX(), e.getY(), NumericValue.asNumber(v).getDouble(), e.method_36454(), e.method_36455()); }); put("yaw", (e, v) -> { - updatePosition(e, e.getX(), e.getY(), e.getZ(), ((float)NumericValue.asNumber(v).getDouble()) % 360, e.pitch); + updatePosition(e, e.getX(), e.getY(), e.getZ(), ((float)NumericValue.asNumber(v).getDouble()) % 360, e.method_36455()); }); put("head_yaw", (e, v) -> { @@ -1047,7 +1047,7 @@ public class EntityValue extends Value put("pitch", (e, v) -> { - updatePosition(e, e.getX(), e.getY(), e.getZ(), e.yaw, MathHelper.clamp((float)NumericValue.asNumber(v).getDouble(), -90, 90)); + updatePosition(e, e.getX(), e.getY(), e.getZ(), e.method_36454(), MathHelper.clamp((float)NumericValue.asNumber(v).getDouble(), -90, 90)); }); //"look" @@ -1065,8 +1065,8 @@ public class EntityValue extends Value e.getX() + NumericValue.asNumber(coords.get(0)).getDouble(), e.getY() + NumericValue.asNumber(coords.get(1)).getDouble(), e.getZ() + NumericValue.asNumber(coords.get(2)).getDouble(), - e.yaw, - e.pitch + e.method_36454(), + e.method_36455() ); }); @@ -1290,7 +1290,7 @@ public class EntityValue extends Value BlockValue bv= (BlockValue)a; if (bv.getPos()==null || bv.getWorld() == null) throw new InternalExpressionException("block for spawn modification should be localised in the world"); - spe.setSpawnPoint(bv.getWorld().getRegistryKey(), bv.getPos(), e.yaw, true, false); + spe.setSpawnPoint(bv.getWorld().getRegistryKey(), bv.getPos(), e.method_36454(), true, false); // yaw } else if (a.isNull()) { diff --git a/src/main/java/carpet/utils/MobAI.java b/src/main/java/carpet/utils/MobAI.java index 1f59e4b4..134a0979 100644 --- a/src/main/java/carpet/utils/MobAI.java +++ b/src/main/java/carpet/utils/MobAI.java @@ -114,7 +114,7 @@ public class MobAI e.setVelocity(vec3d.x, jumpStrength, vec3d.z); if (e.isSprinting()) { - float u = e.yaw * 0.017453292F; + float u = e.method_36454() * 0.017453292F; // yaw e.setVelocity(e.getVelocity().add((-MathHelper.sin(g) * 0.2F), 0.0D, (MathHelper.cos(u) * 0.2F))); } e.velocityDirty = true; From e4ebeda1d0464f1961251486c3d56f73350752a6 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 5 May 2021 01:44:05 -0300 Subject: [PATCH 069/115] mapping --- gradle.properties | 4 ++-- src/main/java/carpet/script/command/CommandArgument.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index 09acba33..12c8d678 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,9 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=21w17a - yarn_mappings=21w17a+build.2 + yarn_mappings=21w17a+build.19 loader_version=0.11.3 - fabric_version=0.33.3+1.17 + fabric_version=0.34.0+1.17 # Mod Properties mod_version = 1.4.34 diff --git a/src/main/java/carpet/script/command/CommandArgument.java b/src/main/java/carpet/script/command/CommandArgument.java index f2cb3996..a0278f0c 100644 --- a/src/main/java/carpet/script/command/CommandArgument.java +++ b/src/main/java/carpet/script/command/CommandArgument.java @@ -54,7 +54,7 @@ import net.minecraft.command.argument.ItemSlotArgumentType; import net.minecraft.command.argument.ItemStackArgumentType; import net.minecraft.command.argument.MessageArgumentType; import net.minecraft.command.argument.StatusEffectArgumentType; -import net.minecraft.command.argument.NbtCompoundTagArgumentType; +import net.minecraft.command.argument.NbtCompoundArgumentType; import net.minecraft.command.argument.NbtPathArgumentType; import net.minecraft.command.argument.NbtElementArgumentType; import net.minecraft.command.argument.NumberRangeArgumentType; @@ -691,20 +691,20 @@ public abstract class CommandArgument boolean mapRequired; private TagArgument() { - super("tag", NbtCompoundTagArgumentType.nbtCompound().getExamples(), false); + super("tag", NbtCompoundArgumentType.nbtCompound().getExamples(), false); mapRequired = true; } @Override protected ArgumentType getArgumentType() { - return mapRequired?NbtCompoundTagArgumentType.nbtCompound(): NbtElementArgumentType.nbtElement(); + return mapRequired?NbtCompoundArgumentType.nbtCompound(): NbtElementArgumentType.nbtElement(); } @Override protected Value getValueFromContext(CommandContext context, String param) throws CommandSyntaxException { if (mapRequired) - return new NBTSerializableValue(NbtCompoundTagArgumentType.getNbtCompound(context, param)); + return new NBTSerializableValue(NbtCompoundArgumentType.getNbtCompound(context, param)); else return new NBTSerializableValue(NbtElementArgumentType.getNbtElement(context, param)); } From 5ac22aa000ab55b58cac76390e76a3b0030e1d21 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 5 May 2021 01:50:04 -0300 Subject: [PATCH 070/115] mapping --- .../carpet/commands/PerimeterInfoCommand.java | 2 +- .../helpers/EntityPlayerActionPack.java | 10 +++---- src/main/java/carpet/helpers/XPcombine.java | 2 +- .../carpet/mixins/GuardianEntityMixin.java | 2 +- .../carpet/patches/EntityPlayerMPFake.java | 2 +- src/main/java/carpet/script/api/Entities.java | 2 +- .../java/carpet/script/value/EntityValue.java | 26 +++++++++---------- src/main/java/carpet/utils/MobAI.java | 2 +- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/main/java/carpet/commands/PerimeterInfoCommand.java b/src/main/java/carpet/commands/PerimeterInfoCommand.java index f259b44d..d700dd3b 100644 --- a/src/main/java/carpet/commands/PerimeterInfoCommand.java +++ b/src/main/java/carpet/commands/PerimeterInfoCommand.java @@ -52,7 +52,7 @@ public class PerimeterInfoCommand { nbttagcompound.putString("id", mobId); Entity baseEntity = EntityType.loadEntityWithPassengers(nbttagcompound, source.getWorld(), (entity_1x) -> { - entity_1x.refreshPositionAndAngles(new BlockPos(pos.getX(), -10, pos.getZ()), entity_1x.method_36454(), entity_1x.method_36455()); // yaw pitch + entity_1x.refreshPositionAndAngles(new BlockPos(pos.getX(), -10, pos.getZ()), entity_1x.getYaw(), entity_1x. getPitch()); return !source.getWorld().tryLoadEntity(entity_1x) ? null : entity_1x; }); if (!(baseEntity instanceof MobEntity)) diff --git a/src/main/java/carpet/helpers/EntityPlayerActionPack.java b/src/main/java/carpet/helpers/EntityPlayerActionPack.java index 77d67010..c4b57553 100644 --- a/src/main/java/carpet/helpers/EntityPlayerActionPack.java +++ b/src/main/java/carpet/helpers/EntityPlayerActionPack.java @@ -116,8 +116,8 @@ public class EntityPlayerActionPack case SOUTH: return look(0, 0); case EAST: return look(-90, 0); case WEST: return look(90, 0); - case UP: return look(player.method_36454(), -90); - case DOWN: return look(player.method_36454(), 90); + case UP: return look(player.getYaw(), -90); + case DOWN: return look(player.getYaw(), 90); } return this; } @@ -128,8 +128,8 @@ public class EntityPlayerActionPack public EntityPlayerActionPack look(float yaw, float pitch) { - player.method_36456(yaw % 360); //setYaw - player.method_36457(MathHelper.clamp(pitch, -90, 90)); // setPitch + player.setYaw(yaw % 360); //setYaw + player.setPitch(MathHelper.clamp(pitch, -90, 90)); // setPitch // maybe player.setPositionAndAngles(player.x, player.y, player.z, yaw, MathHelper.clamp(pitch,-90.0F, 90.0F)); return this; } @@ -142,7 +142,7 @@ public class EntityPlayerActionPack public EntityPlayerActionPack turn(float yaw, float pitch) { - return look(player.method_36454() + yaw, player.method_36455() + pitch); + return look(player.getYaw() + yaw, player.getPitch() + pitch); } public EntityPlayerActionPack turn(Vec2f rotation) diff --git a/src/main/java/carpet/helpers/XPcombine.java b/src/main/java/carpet/helpers/XPcombine.java index 26750b25..e75a2931 100644 --- a/src/main/java/carpet/helpers/XPcombine.java +++ b/src/main/java/carpet/helpers/XPcombine.java @@ -50,7 +50,7 @@ public class XPcombine if (getTextureByXP(first.getExperienceAmount()) != size) { newOrb = new ExperienceOrbEntity(EntityType.EXPERIENCE_ORB, first.world); - newOrb.refreshPositionAndAngles(first.getX(), first.getY(), first.getZ(), first.method_36454(), first.method_36455()); + newOrb.refreshPositionAndAngles(first.getX(), first.getY(), first.getZ(), first.getYaw(), first.getPitch()); ((ExperienceOrbInterface)newOrb).setAmount(first.getExperienceAmount()); first.world.spawnEntity(newOrb); diff --git a/src/main/java/carpet/mixins/GuardianEntityMixin.java b/src/main/java/carpet/mixins/GuardianEntityMixin.java index 66e24502..6ec860c5 100644 --- a/src/main/java/carpet/mixins/GuardianEntityMixin.java +++ b/src/main/java/carpet/mixins/GuardianEntityMixin.java @@ -27,7 +27,7 @@ public abstract class GuardianEntityMixin extends HostileEntity 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.method_36454(), this.method_36455()); + elderGuardian.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), this.getYaw(), this.getPitch()); elderGuardian.initialize(serverWorld ,this.world.getLocalDifficulty(elderGuardian.getBlockPos()), SpawnReason.CONVERSION, (EntityData)null, (NbtCompound)null); elderGuardian.setAiDisabled(this.isAiDisabled()); diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index e59b2420..4892ffc7 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -69,7 +69,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity server.getPlayerManager().onPlayerConnect(new NetworkManagerFake(NetworkSide.SERVERBOUND), playerShadow); playerShadow.setHealth(player.getHealth()); - playerShadow.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.method_36454(), player.method_36455()); + playerShadow.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.getYaw(), player.getPitch()); playerShadow.interactionManager.changeGameMode(player.interactionManager.getGameMode()); ((ServerPlayerEntityInterface) playerShadow).getActionPack().copyFrom(((ServerPlayerEntityInterface) player).getActionPack()); playerShadow.stepHeight = 0.6F; diff --git a/src/main/java/carpet/script/api/Entities.java b/src/main/java/carpet/script/api/Entities.java index 283ff917..28f1ae48 100644 --- a/src/main/java/carpet/script/api/Entities.java +++ b/src/main/java/carpet/script/api/Entities.java @@ -142,7 +142,7 @@ public class Entities { ServerWorld serverWorld = cc.s.getWorld(); Entity entity_1 = EntityType.loadEntityWithPassengers(tag, serverWorld, (entity_1x) -> { - entity_1x.refreshPositionAndAngles(vec3d.x, vec3d.y, vec3d.z, entity_1x.method_36454(), entity_1x.method_36455()); + entity_1x.refreshPositionAndAngles(vec3d.x, vec3d.y, vec3d.z, entity_1x.getYaw(), entity_1x.getPitch()); return !serverWorld.tryLoadEntity(entity_1x) ? null : entity_1x; }); if (entity_1 == null) { diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 4c57dfb9..a4bba21b 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -429,7 +429,7 @@ public class EntityValue extends Value put("uuid",(e, a) -> new StringValue(e.getUuidAsString())); put("id",(e, a) -> new NumericValue(e.getId())); put("pos", (e, a) -> ListValue.of(new NumericValue(e.getX()), new NumericValue(e.getY()), new NumericValue(e.getZ()))); - put("location", (e, a) -> ListValue.of(new NumericValue(e.getX()), new NumericValue(e.getY()), new NumericValue(e.getZ()), new NumericValue(e.method_36454()), new NumericValue(e.method_36455()))); + put("location", (e, a) -> ListValue.of(new NumericValue(e.getX()), new NumericValue(e.getY()), new NumericValue(e.getZ()), new NumericValue(e.getYaw()), new NumericValue(e.getPitch()))); put("x", (e, a) -> new NumericValue(e.getX())); put("y", (e, a) -> new NumericValue(e.getY())); put("z", (e, a) -> new NumericValue(e.getZ())); @@ -467,7 +467,7 @@ public class EntityValue extends Value return new NumericValue(e.getType().isIn(tag)); }); - put("yaw", (e, a)-> new NumericValue(e.method_36454())); + put("yaw", (e, a)-> new NumericValue(e.getYaw())); put("head_yaw", (e, a)-> { if (e instanceof LivingEntity) { @@ -483,7 +483,7 @@ public class EntityValue extends Value return Value.NULL; }); - put("pitch", (e, a)-> new NumericValue(e.method_36455())); + put("pitch", (e, a)-> new NumericValue(e.getPitch())); put("look", (e, a) -> { Vec3d look = e.getRotationVector(); return ListValue.of(new NumericValue(look.x),new NumericValue(look.y),new NumericValue(look.z)); @@ -1010,25 +1010,25 @@ public class EntityValue extends Value NumericValue.asNumber(coords.get(0)).getDouble(), NumericValue.asNumber(coords.get(1)).getDouble(), NumericValue.asNumber(coords.get(2)).getDouble(), - e.method_36454(), - e.method_36455() + e.getYaw(), + e.getPitch() ); }); put("x", (e, v) -> { - updatePosition(e, NumericValue.asNumber(v).getDouble(), e.getY(), e.getZ(), e.method_36454(), e.method_36455()); + updatePosition(e, NumericValue.asNumber(v).getDouble(), e.getY(), e.getZ(), e.getYaw(), e.getPitch()); }); put("y", (e, v) -> { - updatePosition(e, e.getX(), NumericValue.asNumber(v).getDouble(), e.getZ(), e.method_36454(), e.method_36455()); + updatePosition(e, e.getX(), NumericValue.asNumber(v).getDouble(), e.getZ(), e.getYaw(), e.getPitch()); }); put("z", (e, v) -> { - updatePosition(e, e.getX(), e.getY(), NumericValue.asNumber(v).getDouble(), e.method_36454(), e.method_36455()); + updatePosition(e, e.getX(), e.getY(), NumericValue.asNumber(v).getDouble(), e.getYaw(), e.getPitch()); }); put("yaw", (e, v) -> { - updatePosition(e, e.getX(), e.getY(), e.getZ(), ((float)NumericValue.asNumber(v).getDouble()) % 360, e.method_36455()); + updatePosition(e, e.getX(), e.getY(), e.getZ(), ((float)NumericValue.asNumber(v).getDouble()) % 360, e.getPitch()); }); put("head_yaw", (e, v) -> { @@ -1047,7 +1047,7 @@ public class EntityValue extends Value put("pitch", (e, v) -> { - updatePosition(e, e.getX(), e.getY(), e.getZ(), e.method_36454(), MathHelper.clamp((float)NumericValue.asNumber(v).getDouble(), -90, 90)); + updatePosition(e, e.getX(), e.getY(), e.getZ(), e.getYaw(), MathHelper.clamp((float)NumericValue.asNumber(v).getDouble(), -90, 90)); }); //"look" @@ -1065,8 +1065,8 @@ public class EntityValue extends Value e.getX() + NumericValue.asNumber(coords.get(0)).getDouble(), e.getY() + NumericValue.asNumber(coords.get(1)).getDouble(), e.getZ() + NumericValue.asNumber(coords.get(2)).getDouble(), - e.method_36454(), - e.method_36455() + e.getYaw(), + e.getPitch() ); }); @@ -1290,7 +1290,7 @@ public class EntityValue extends Value BlockValue bv= (BlockValue)a; if (bv.getPos()==null || bv.getWorld() == null) throw new InternalExpressionException("block for spawn modification should be localised in the world"); - spe.setSpawnPoint(bv.getWorld().getRegistryKey(), bv.getPos(), e.method_36454(), true, false); // yaw + spe.setSpawnPoint(bv.getWorld().getRegistryKey(), bv.getPos(), e.getYaw(), true, false); // yaw } else if (a.isNull()) { diff --git a/src/main/java/carpet/utils/MobAI.java b/src/main/java/carpet/utils/MobAI.java index 134a0979..eb5b58f6 100644 --- a/src/main/java/carpet/utils/MobAI.java +++ b/src/main/java/carpet/utils/MobAI.java @@ -114,7 +114,7 @@ public class MobAI e.setVelocity(vec3d.x, jumpStrength, vec3d.z); if (e.isSprinting()) { - float u = e.method_36454() * 0.017453292F; // yaw + float u = e.getYaw() * 0.017453292F; // yaw e.setVelocity(e.getVelocity().add((-MathHelper.sin(g) * 0.2F), 0.0D, (MathHelper.cos(u) * 0.2F))); } e.velocityDirty = true; From 4d15e07baee4d529f3b1e18ea71022f645c90ddf Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 5 May 2021 08:38:38 -0300 Subject: [PATCH 071/115] merge conflcts --- src/main/java/carpet/patches/EntityPlayerMPFake.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index 8c405be9..34674f7b 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -36,11 +36,6 @@ public class EntityPlayerMPFake extends ServerPlayerEntity { //prolly half of that crap is not necessary, but it works ServerWorld worldIn = server.getWorld(dimensionId); - GameProfile gameprofile = server.getUserCache().findByName(username); - if (gameprofile == null) - { - return null; - ServerPlayerInteractionManager interactionManagerIn = new ServerPlayerInteractionManager(worldIn); UserCache.setUseRemote(false); GameProfile gameprofile; try { From dfa826bb24f8fe084ee511ee5ee0f2c19b32bcfc Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 5 May 2021 20:34:59 -0300 Subject: [PATCH 072/115] 21w18a --- gradle.properties | 6 +++--- src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index acdb6d1d..562c1794 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=21w17a - yarn_mappings=21w17a+build.19 + minecraft_version=21w18a + yarn_mappings=21w18a+build.3 loader_version=0.11.3 - fabric_version=0.34.0+1.17 + fabric_version=0.34.2+1.17 # Mod Properties mod_version = 1.4.35 diff --git a/src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java b/src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java index 7c703e6e..109f7e29 100644 --- a/src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java +++ b/src/main/java/carpet/mixins/BiomeArray_cleanLogsMixin.java @@ -10,13 +10,14 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(BiomeArray.class) public class BiomeArray_cleanLogsMixin { + // this changed in 21w18a - maybe its not needed anymore, please check @SuppressWarnings("UnresolvedMixinReference") @Redirect(method = "(Lnet/minecraft/util/collection/IndexedIterable;Lnet/minecraft/world/HeightLimitView;[I)V", at = @At( value = "INVOKE", - target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V") + target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V") ) - private void skipLog(Logger logger, String message, Object p0) + private void skipLog(Logger logger, String message, Object p0, Object p1) { - if (!CarpetSettings.cleanLogs) logger.warn(message, p0); + if (!CarpetSettings.cleanLogs) logger.warn(message, p0, p1); } } From c9ff5fea34edc7499550abcd2ae114242f20b237 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 12 May 2021 12:12:33 -0300 Subject: [PATCH 073/115] snapshot --- src/main/java/carpet/script/value/EntityValue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index c5d313d6..4e0ea42f 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -1062,7 +1062,7 @@ public class EntityValue extends Value y /= l; z /= l; float pitch = (float) -Math.asin(y) / 0.017453292F; - float yaw = (float) (x==0 && z==0 ? e.yaw : MathHelper.atan2(-x,z) / 0.017453292F); + float yaw = (float) (x==0 && z==0 ? e.getYaw() : MathHelper.atan2(-x,z) / 0.017453292F); updatePosition(e, e.getX(), e.getY(), e.getZ(), yaw, pitch); }); From 7a8914a0cba10375e5c81edeed5de50bf198d646 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 12 May 2021 17:03:34 -0300 Subject: [PATCH 074/115] mapping --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 562c1794..9a871d59 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,9 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=21w18a - yarn_mappings=21w18a+build.3 + yarn_mappings=21w18a+build.10 loader_version=0.11.3 - fabric_version=0.34.2+1.17 + fabric_version=0.34.3+1.17 # Mod Properties mod_version = 1.4.35 From 727bdd7b1ab0193ea343c1baee012c5b104215c8 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 12 May 2021 23:40:09 -0300 Subject: [PATCH 075/115] 21w19a --- build.gradle | 14 ++------- gradle.properties | 6 ++-- .../java/carpet/helpers/FeatureGenerator.java | 2 +- .../mixins/PickaxeItem_missingToolsMixin.java | 30 +++++++++++-------- .../carpet/script/argument/FileArgument.java | 3 +- src/main/resources/carpet.accesswidener | 3 +- src/main/resources/carpet.mixins.json | 2 +- src/main/resources/fabric.mod.json | 3 +- 8 files changed, 32 insertions(+), 31 deletions(-) diff --git a/build.gradle b/build.gradle index 83f535d4..40276d84 100644 --- a/build.gradle +++ b/build.gradle @@ -3,8 +3,8 @@ plugins { id 'maven-publish' } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_16 +targetCompatibility = JavaVersion.VERSION_16 archivesBaseName = project.archives_base_name version = project.minecraft_version+'-'+project.mod_version+'+v'+new Date().format('yyMMdd') @@ -52,16 +52,8 @@ tasks.withType(JavaCompile).configureEach { // If Javadoc is generated, this must be specified in that task too. it.options.encoding = "UTF-8" - // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too - // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. - // We'll use that if it's available, but otherwise we'll use the older option. - def targetVersion = 8 - if (JavaVersion.current().isJava9Compatible()) { - it.options.release = targetVersion - } - // Minecraft 1.17 (21w19a) upwards uses Java 16. - //it.options.release = 16 + it.options.release = 16 } java { diff --git a/gradle.properties b/gradle.properties index 98672d10..3d192496 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=21w18a - yarn_mappings=21w18a+build.10 + minecraft_version=21w19a + yarn_mappings=21w19a+build.2 loader_version=0.11.3 - fabric_version=0.34.3+1.17 + fabric_version=0.34.4+1.17 # Mod Properties mod_version = 1.4.36 diff --git a/src/main/java/carpet/helpers/FeatureGenerator.java b/src/main/java/carpet/helpers/FeatureGenerator.java index e5062707..f7e812e5 100644 --- a/src/main/java/carpet/helpers/FeatureGenerator.java +++ b/src/main/java/carpet/helpers/FeatureGenerator.java @@ -142,7 +142,7 @@ public class FeatureGenerator findFirst().map(Map.Entry::getValue).orElse(null); } - public static StructureStart shouldStructureStartAt(ServerWorld world, BlockPos pos, StructureFeature structure, boolean computeBox) + synchronized public static StructureStart shouldStructureStartAt(ServerWorld world, BlockPos pos, StructureFeature structure, boolean computeBox) { long seed = world.getSeed(); ChunkGenerator generator = world.getChunkManager().getChunkGenerator(); diff --git a/src/main/java/carpet/mixins/PickaxeItem_missingToolsMixin.java b/src/main/java/carpet/mixins/PickaxeItem_missingToolsMixin.java index 6cb12ded..ed77613f 100644 --- a/src/main/java/carpet/mixins/PickaxeItem_missingToolsMixin.java +++ b/src/main/java/carpet/mixins/PickaxeItem_missingToolsMixin.java @@ -1,25 +1,31 @@ package carpet.mixins; import carpet.CarpetSettings; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Material; +import net.minecraft.item.ItemStack; +import net.minecraft.item.MiningToolItem; import net.minecraft.item.PickaxeItem; +import net.minecraft.item.ToolMaterial; +import net.minecraft.tag.Tag; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; +//import org.spongepowered.asm.mixin.injection.At; +//import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(PickaxeItem.class) -public class PickaxeItem_missingToolsMixin +public class PickaxeItem_missingToolsMixin extends MiningToolItem { - @Redirect(method = "getMiningSpeedMultiplier", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/block/BlockState;getMaterial()Lnet/minecraft/block/Material;" - )) - private Material getCustomMaterial(BlockState blockState) - { - Material material = blockState.getMaterial(); + + protected PickaxeItem_missingToolsMixin(float attackDamage, float attackSpeed, ToolMaterial material, Tag tag, Settings settings) { + super(attackDamage, attackSpeed, material, tag, settings); + } + + @Override + public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { + Material material = state.getMaterial(); if (CarpetSettings.missingTools && material == Material.GLASS) - material = Material.STONE; - return material; + return miningSpeed; + return super.getMiningSpeedMultiplier(stack, state); } } diff --git a/src/main/java/carpet/script/argument/FileArgument.java b/src/main/java/carpet/script/argument/FileArgument.java index b1f100a4..d43d5d11 100644 --- a/src/main/java/carpet/script/argument/FileArgument.java +++ b/src/main/java/carpet/script/argument/FileArgument.java @@ -189,7 +189,8 @@ public class FileArgument } catch (IOException e) { - throw new ThrowStatement("Unable to open zip file: "+zipContainer, Throwables.IO_EXCEPTION); + return null; // undr java 16 no file throws IOException - will take care of it later + //throw new ThrowStatement("Unable to open zip file: "+zipContainer, Throwables.IO_EXCEPTION); } } return zfs.getPath(resource+(isFolder?"/":type.extension)); diff --git a/src/main/resources/carpet.accesswidener b/src/main/resources/carpet.accesswidener index e9dad565..625c69ec 100644 --- a/src/main/resources/carpet.accesswidener +++ b/src/main/resources/carpet.accesswidener @@ -2,4 +2,5 @@ accessWidener v1 named accessible class net/minecraft/server/world/ThreadedAnvilChunkStorage$TicketManager accessible class net/minecraft/server/world/ServerLightingProvider$Stage -accessible class net/minecraft/recipe/Ingredient$Entry \ No newline at end of file +accessible class net/minecraft/recipe/Ingredient$Entry +accessible class net/minecraft/world/chunk/light/BlockLightStorage$Data \ No newline at end of file diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index 8186b459..224f08e2 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -2,7 +2,7 @@ "required": true, "refmap": "fabric-carpet-refmap.json", "package": "carpet.mixins", - "compatibilityLevel": "JAVA_8", + "compatibilityLevel": "JAVA_16", "mixins": [ "SpawnHelperInnerMixin", "CommandManagerMixin", diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2eee13cc..76f27d3e 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -33,6 +33,7 @@ "depends": { "minecraft": "1.17.x", - "fabricloader": ">=0.7.1" + "fabricloader": ">=0.11.3", + "java": ">=16" } } From fb40120460215e5856ff6948002e768534ab0fcf Mon Sep 17 00:00:00 2001 From: gnembon Date: Thu, 13 May 2021 02:00:05 -0300 Subject: [PATCH 076/115] cluenap --- src/main/java/carpet/helpers/FeatureGenerator.java | 2 +- src/main/java/carpet/script/argument/FileArgument.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/carpet/helpers/FeatureGenerator.java b/src/main/java/carpet/helpers/FeatureGenerator.java index 07a2aee4..af00e669 100644 --- a/src/main/java/carpet/helpers/FeatureGenerator.java +++ b/src/main/java/carpet/helpers/FeatureGenerator.java @@ -142,7 +142,7 @@ public class FeatureGenerator findFirst().map(Map.Entry::getValue).orElse(null); } - synchronized public static StructureStart shouldStructureStartAt(ServerWorld world, BlockPos pos, StructureFeature structure, boolean computeBox) + public static StructureStart shouldStructureStartAt(ServerWorld world, BlockPos pos, StructureFeature structure, boolean computeBox) { long seed = world.getSeed(); ChunkGenerator generator = world.getChunkManager().getChunkGenerator(); diff --git a/src/main/java/carpet/script/argument/FileArgument.java b/src/main/java/carpet/script/argument/FileArgument.java index e8d1f2f8..c27e4acc 100644 --- a/src/main/java/carpet/script/argument/FileArgument.java +++ b/src/main/java/carpet/script/argument/FileArgument.java @@ -184,8 +184,7 @@ public class FileArgument } catch (FileSystemNotFoundException | IOException fsnfe) { - return null; // undr java 16 no file throws IOException - will take care of it later - //throw new ThrowStatement("Unable to open zip file: "+zipContainer, Throwables.IO_EXCEPTION); + throw new ThrowStatement("Unable to open zip file: "+zipContainer, Throwables.IO_EXCEPTION); } } return zfs.getPath(resource+(isFolder?"/":type.extension)); From 1942726e20cb02e220d35a7b8377bdb4123b938e Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 19 May 2021 15:30:20 -0300 Subject: [PATCH 077/115] 21w20a --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 3d192496..a3a67c7c 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=21w19a - yarn_mappings=21w19a+build.2 + minecraft_version=21w20a + yarn_mappings=21w20a+build.2 loader_version=0.11.3 fabric_version=0.34.4+1.17 From 1b49bfe21fff38990127b489d33d454494d9968d Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 21 May 2021 04:45:23 -0300 Subject: [PATCH 078/115] updates --- .../java/carpet/script/annotation/FunctionsTestClass.java | 3 ++- src/main/java/carpet/script/annotation/OutputConverter.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/carpet/script/annotation/FunctionsTestClass.java b/src/main/java/carpet/script/annotation/FunctionsTestClass.java index 8f81ff6c..31461015 100644 --- a/src/main/java/carpet/script/annotation/FunctionsTestClass.java +++ b/src/main/java/carpet/script/annotation/FunctionsTestClass.java @@ -12,7 +12,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Optional; - +/* There is no worse example to use for 1.17 compatibility import static net.minecraft.network.packet.s2c.play.TitleS2CPacket.Action; public class FunctionsTestClass { @@ -58,3 +58,4 @@ public class FunctionsTestClass { return targets.size(); } } +*/ \ No newline at end of file diff --git a/src/main/java/carpet/script/annotation/OutputConverter.java b/src/main/java/carpet/script/annotation/OutputConverter.java index 22bd7954..da4f64ee 100644 --- a/src/main/java/carpet/script/annotation/OutputConverter.java +++ b/src/main/java/carpet/script/annotation/OutputConverter.java @@ -5,6 +5,7 @@ import java.util.Map; import java.util.Objects; import java.util.function.Function; +import net.minecraft.nbt.NbtElement; import org.apache.commons.lang3.ClassUtils; import carpet.script.LazyValue; @@ -17,7 +18,6 @@ import carpet.script.value.Value; import carpet.script.value.ValueConversions; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.Tag; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.dynamic.GlobalPos; @@ -48,7 +48,7 @@ public final class OutputConverter registerToValue(String.class, StringValue::new); registerToValue(Entity.class, EntityValue::new); registerToValue(Text.class, FormattedTextValue::new); - registerToValue(Tag.class, NBTSerializableValue::new); + registerToValue(NbtElement.class, NBTSerializableValue::new); registerToValue(BlockPos.class, ValueConversions::of); registerToValue(Vec3d.class, ValueConversions::of); registerToValue(ItemStack.class, ValueConversions::of); From 69d1558e4d11961f6e0d1498c73b7e6a57ccece8 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sat, 22 May 2021 22:19:28 -0300 Subject: [PATCH 079/115] mappings --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index e60a52da..6f0c6ffc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,9 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=21w20a - yarn_mappings=21w20a+build.2 + yarn_mappings=21w20a+build.10 loader_version=0.11.3 - fabric_version=0.34.4+1.17 + fabric_version=0.34.5+1.17 # Mod Properties mod_version = 1.4.37 From 1091171870578f12af62263df8193790ba64c57f Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 23 May 2021 18:06:45 -0300 Subject: [PATCH 080/115] fix cast exception --- src/main/java/carpet/utils/SpawnReporter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/carpet/utils/SpawnReporter.java b/src/main/java/carpet/utils/SpawnReporter.java index e3ce055d..0b71532d 100644 --- a/src/main/java/carpet/utils/SpawnReporter.java +++ b/src/main/java/carpet/utils/SpawnReporter.java @@ -19,6 +19,7 @@ import net.minecraft.tag.BlockTags; import net.minecraft.text.BaseText; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.DyeColor; +import net.minecraft.util.TypeFilter; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.registry.RegistryKey; @@ -275,7 +276,7 @@ public class SpawnReporter { List lst = new ArrayList<>(); lst.add( Messenger.s(String.format("Loaded entities for %s class:", get_type_string(cat)))); - for (Entity entity : ((ServerWorld)worldIn).getEntitiesByType(null, (e) -> e.getType().getSpawnGroup()==cat)) + for (Entity entity : ((ServerWorld)worldIn).getEntitiesByType(TypeFilter.instanceOf(Entity.class), (e) -> e.getType().getSpawnGroup()==cat)) { boolean persistent = entity instanceof MobEntity && ( ((MobEntity) entity).isPersistent() || ((MobEntity) entity).cannotDespawn()); if (!all && persistent) From f64cf67e41723d7879aa5489debd32e3840f9c60 Mon Sep 17 00:00:00 2001 From: gnembon Date: Thu, 27 May 2021 15:01:07 -0300 Subject: [PATCH 081/115] 1.17-pre1 --- gradle.properties | 6 +++--- src/main/java/carpet/helpers/OptimizedExplosion.java | 4 ++-- .../carpet/mixins/MinecraftServer_tickspeedMixin.java | 9 ++++++--- src/main/java/carpet/patches/EntityPlayerMPFake.java | 7 +++++-- src/main/java/carpet/script/api/WorldAccess.java | 2 +- src/main/java/carpet/script/utils/ShapeDispatcher.java | 2 +- .../java/carpet/script/utils/SnoopyCommandSource.java | 2 +- src/main/java/carpet/utils/DistanceCalculator.java | 4 ++-- 8 files changed, 21 insertions(+), 15 deletions(-) diff --git a/gradle.properties b/gradle.properties index 6f0c6ffc..f08562d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=21w20a - yarn_mappings=21w20a+build.10 + minecraft_version=1.17-pre1 + yarn_mappings=1.17-pre1+build.1 loader_version=0.11.3 - fabric_version=0.34.5+1.17 + fabric_version=0.34.7+1.17 # Mod Properties mod_version = 1.4.37 diff --git a/src/main/java/carpet/helpers/OptimizedExplosion.java b/src/main/java/carpet/helpers/OptimizedExplosion.java index dc086344..cfd8316a 100644 --- a/src/main/java/carpet/helpers/OptimizedExplosion.java +++ b/src/main/java/carpet/helpers/OptimizedExplosion.java @@ -134,14 +134,14 @@ public class OptimizedExplosion } if (!entity.isImmuneToExplosion()) { - double d12 = MathHelper.sqrt(entity.squaredDistanceTo(eAccess.getX(), eAccess.getY(), eAccess.getZ())) / (double) f3; + double d12 = Math.sqrt(entity.squaredDistanceTo(eAccess.getX(), eAccess.getY(), eAccess.getZ())) / (double) f3; if (d12 <= 1.0D) { double d5 = entity.getX() - eAccess.getX(); // Change in 1.16 snapshots to fix a bug with TNT jumping double d7 = (entity instanceof TntEntity ? entity.getY() : entity.getEyeY()) - eAccess.getY(); double d9 = entity.getZ() - eAccess.getZ(); - double d13 = (double) MathHelper.sqrt(d5 * d5 + d7 * d7 + d9 * d9); + double d13 = (double) Math.sqrt(d5 * d5 + d7 * d7 + d9 * d9); if (d13 != 0.0D) { d5 = d5 / d13; diff --git a/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java b/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java index 944183ee..ff3b508e 100644 --- a/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java +++ b/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java @@ -46,7 +46,9 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec @Shadow private volatile boolean loading; - @Shadow protected abstract void startMonitor(TickDurationMonitor monitor); + //@Shadow protected abstract void startMonitor(TickDurationMonitor monitor); + + @Shadow protected abstract void startMonitor(); @Shadow private long lastTimeReference; @@ -116,8 +118,9 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec } this.timeReference += msThisTick;//50L; - TickDurationMonitor tickDurationMonitor = TickDurationMonitor.create("Server"); - this.startMonitor(tickDurationMonitor); + //TickDurationMonitor tickDurationMonitor = TickDurationMonitor.create("Server"); + //this.startMonitor(tickDurationMonitor); + this.startMonitor(); this.profiler.startTick(); this.profiler.push("tick"); this.tick(TickSpeed.time_warp_start_time != 0 ? ()->true : this::shouldKeepTicking); diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index ef8675a3..d8cd0175 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -17,7 +17,6 @@ import net.minecraft.text.TranslatableText; import net.minecraft.server.MinecraftServer; import net.minecraft.server.ServerTask; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.network.ServerPlayerInteractionManager; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.UserCache; import net.minecraft.util.registry.RegistryKey; @@ -26,6 +25,8 @@ import net.minecraft.world.World; import carpet.fakes.ServerPlayerEntityInterface; import carpet.utils.Messenger; +import java.util.concurrent.atomic.AtomicReference; + @SuppressWarnings("EntityConstructor") public class EntityPlayerMPFake extends ServerPlayerEntity { @@ -55,7 +56,9 @@ public class EntityPlayerMPFake extends ServerPlayerEntity } if (gameprofile.getProperties().containsKey("textures")) { - gameprofile = SkullBlockEntity.loadProperties(gameprofile); + AtomicReference result = new AtomicReference<>(); + SkullBlockEntity.loadProperties(gameprofile, result::set); + gameprofile = result.get(); } EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, gameprofile, false); instance.fixStartingPosition = () -> instance.refreshPositionAndAngles(d0, d1, d2, (float) yaw, (float) pitch); diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index fb142a3c..e464c4a0 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -576,7 +576,7 @@ public class WorldAccess { { c.host.issueDeprecation("loaded_ep(...)"); BlockPos pos = BlockArgument.findIn((CarpetContext)c, lv, 0).block.getPos(); - return BooleanValue.of(((CarpetContext)c).s.getWorld().getChunkManager().shouldTickChunk(new ChunkPos(pos))); + return BooleanValue.of(((CarpetContext)c).s.getWorld().method_37118(pos));// 1.17pre1 getChunkManager().shouldTickChunk(new ChunkPos(pos))); }); expression.addContextFunction("loaded_status", -1, (c, t, lv) -> diff --git a/src/main/java/carpet/script/utils/ShapeDispatcher.java b/src/main/java/carpet/script/utils/ShapeDispatcher.java index 6b281e3d..9a6225bc 100644 --- a/src/main/java/carpet/script/utils/ShapeDispatcher.java +++ b/src/main/java/carpet/script/utils/ShapeDispatcher.java @@ -1328,7 +1328,7 @@ public class ShapeDispatcher } if (isStraight(from, to, density)) return drawOptimizedParticleLine(players, particle, from, to, density); - Vec3d incvec = to.subtract(from).multiply(2*density/MathHelper.sqrt(distance)); + Vec3d incvec = to.subtract(from).multiply(2*density/Math.sqrt(distance)); for (Vec3d delta = new Vec3d(0.0,0.0,0.0); delta.lengthSquared() res = new ArrayList<>(); res.add(Messenger.c("w Distance between ", Messenger.tp("c",pos1),"w and ", From c55019d048375570e5d191a86f1c597265974206 Mon Sep 17 00:00:00 2001 From: gnembon Date: Mon, 31 May 2021 15:40:44 -0300 Subject: [PATCH 082/115] fixed broken movable TEs under Java 16 --- .../java/carpet/fakes/BlockEntityInterface.java | 8 ++++++++ .../mixins/BlockEntity_movableBEMixin.java | 16 ++++++++++++---- .../mixins/PistonBlockEntity_movableTEMixin.java | 3 ++- 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 src/main/java/carpet/fakes/BlockEntityInterface.java diff --git a/src/main/java/carpet/fakes/BlockEntityInterface.java b/src/main/java/carpet/fakes/BlockEntityInterface.java new file mode 100644 index 00000000..ca734897 --- /dev/null +++ b/src/main/java/carpet/fakes/BlockEntityInterface.java @@ -0,0 +1,8 @@ +package carpet.fakes; + +import net.minecraft.util.math.BlockPos; + +public interface BlockEntityInterface +{ + void setCMPos(BlockPos pos); +} diff --git a/src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java b/src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java index 3c9c13e3..a848ee2e 100644 --- a/src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java +++ b/src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java @@ -1,13 +1,21 @@ package carpet.mixins; +import carpet.fakes.BlockEntityInterface; import net.minecraft.block.entity.BlockEntity; import net.minecraft.util.math.BlockPos; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.Shadow; @Mixin(BlockEntity.class) -public interface BlockEntity_movableBEMixin +public abstract class BlockEntity_movableBEMixin implements BlockEntityInterface { - @Accessor - void setPos(BlockPos pos); + @Mutable + @Shadow @Final protected BlockPos pos; + + public void setCMPos(BlockPos newPos) + { + pos = newPos; + }; } diff --git a/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java b/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java index c3ac3ff0..a8a8bacd 100644 --- a/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; +import carpet.fakes.BlockEntityInterface; import carpet.fakes.PistonBlockEntityInterface; import carpet.fakes.WorldInterface; import net.minecraft.block.Block; @@ -57,7 +58,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple this.carriedBlockEntity = blockEntity; if (this.carriedBlockEntity != null) { - ((BlockEntity_movableBEMixin)carriedBlockEntity).setPos(pos); + ((BlockEntityInterface)carriedBlockEntity).setCMPos(pos); // this might be little dangerous since pos is final for a hashing reason? if (world != null) carriedBlockEntity.setWorld(world); } From 38b2e83d055bb471d7fa134825c6137f65d950ba Mon Sep 17 00:00:00 2001 From: gnembon Date: Mon, 31 May 2021 16:14:10 -0300 Subject: [PATCH 083/115] fixed crash report for 1.17 --- gradle.properties | 4 ++-- .../mixins/CrashReport_addScarpetAppsMixin.java | 15 +++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/gradle.properties b/gradle.properties index 1ac9e902..8d7be438 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,9 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=1.17-pre1 - yarn_mappings=1.17-pre1+build.1 + yarn_mappings=1.17-pre1+build.14 loader_version=0.11.3 - fabric_version=0.34.7+1.17 + fabric_version=0.34.8+1.17 # Mod Properties mod_version = 1.4.38 diff --git a/src/main/java/carpet/mixins/CrashReport_addScarpetAppsMixin.java b/src/main/java/carpet/mixins/CrashReport_addScarpetAppsMixin.java index dd156441..676654a7 100644 --- a/src/main/java/carpet/mixins/CrashReport_addScarpetAppsMixin.java +++ b/src/main/java/carpet/mixins/CrashReport_addScarpetAppsMixin.java @@ -1,7 +1,9 @@ package carpet.mixins; +import java.util.function.Supplier; import java.util.stream.Collectors; +import net.minecraft.class_6396; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -9,19 +11,16 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import carpet.CarpetServer; -import net.minecraft.util.crash.CrashReport; -import net.minecraft.util.crash.CrashReportSection; -@Mixin(CrashReport.class) +@Mixin(class_6396.class) public abstract class CrashReport_addScarpetAppsMixin { - @Shadow - public abstract CrashReportSection getSystemDetailsSection(); - - @Inject(at = @At("RETURN"), method = "fillSystemDetails") + @Shadow public abstract void method_37123(String string, Supplier supplier); + + @Inject(method = "", at = @At("RETURN")) private void fillSystemDetails(CallbackInfo info) { if (CarpetServer.scriptServer == null || CarpetServer.scriptServer.modules.isEmpty()) return; - getSystemDetailsSection().add("Loaded Scarpet Apps", () -> { + method_37123("Loaded Scarpet Apps", () -> { return CarpetServer.scriptServer.modules.keySet().stream().collect(Collectors.joining("\n\t\t", "\n\t\t", "")); }); } From a3954d50f488bd8b90205607ed2c4d91d04dfff0 Mon Sep 17 00:00:00 2001 From: hugeblank Date: Mon, 31 May 2021 12:15:16 -0700 Subject: [PATCH 084/115] Add Movable Amethyst Rule (#894) * Add Pushable Amethyst Rule As discussed in #79 of ilmangos peaceful challenge. He said he'd do it, I figured I could beat him to the punch :) https://youtu.be/0-fAKpr_J8k?t=1076 * Name change - movableAmethyst Co-authored-by: hugeblank --- src/main/java/carpet/CarpetSettings.java | 3 +++ ...ngAmethystBlock_getPistonBehaviorMixin.java | 18 ++++++++++++++++++ src/main/resources/carpet.mixins.json | 1 + 3 files changed, 22 insertions(+) create mode 100644 src/main/java/carpet/mixins/BuddingAmethystBlock_getPistonBehaviorMixin.java diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 132c0c64..c76989f2 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -315,6 +315,9 @@ public class CarpetSettings ) public static boolean hopperCounters = false; + @Rule( desc = "Allows Budding Amethyst blocks to be moved by pistons", category = FEATURE ) + public static boolean movableAmethyst = false; + @Rule( desc = "Guardians turn into Elder Guardian when struck by lightning", category = FEATURE ) public static boolean renewableSponges = false; diff --git a/src/main/java/carpet/mixins/BuddingAmethystBlock_getPistonBehaviorMixin.java b/src/main/java/carpet/mixins/BuddingAmethystBlock_getPistonBehaviorMixin.java new file mode 100644 index 00000000..03085c47 --- /dev/null +++ b/src/main/java/carpet/mixins/BuddingAmethystBlock_getPistonBehaviorMixin.java @@ -0,0 +1,18 @@ +package carpet.mixins; + +import carpet.CarpetSettings; +import net.minecraft.block.BlockState; +import net.minecraft.block.BuddingAmethystBlock; +import net.minecraft.block.piston.PistonBehavior; +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.callback.CallbackInfoReturnable; + +@Mixin(BuddingAmethystBlock.class) +public class BuddingAmethystBlock_getPistonBehaviorMixin { + @Inject(at = @At("HEAD"), method = "getPistonBehavior(Lnet/minecraft/block/BlockState;)Lnet/minecraft/block/piston/PistonBehavior;", cancellable = true) + void getPistonBehavior(BlockState state, CallbackInfoReturnable cir) { + if (CarpetSettings.movableAmethyst) cir.setReturnValue(PistonBehavior.NORMAL); + } +} diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index 4fdcaafd..f6f49e46 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -89,6 +89,7 @@ "ServerWorld_onePlayerSleepingMixin", "CoralBlockMixin", "CoralFeatureMixin", + "BuddingAmethystBlock_getPistonBehaviorMixin", "FluidBlock_renewableBlackstoneMixin", "FluidBlock_renewableDeepslateMixin", "LavaFluid_renewableDeepslateMixin", From 020dd6a8f4fe80cda1cb8fe3bfd0bc2efc0de962 Mon Sep 17 00:00:00 2001 From: gnembon Date: Mon, 31 May 2021 17:00:42 -0300 Subject: [PATCH 085/115] movableAmethyst extension --- src/main/java/carpet/CarpetSettings.java | 9 +++- ...gAmethystBlock_getPistonBehaviorMixin.java | 18 -------- ...ingAmethystBlock_movableAmethystMixin.java | 45 +++++++++++++++++++ src/main/resources/carpet.mixins.json | 2 +- 4 files changed, 54 insertions(+), 20 deletions(-) delete mode 100644 src/main/java/carpet/mixins/BuddingAmethystBlock_getPistonBehaviorMixin.java create mode 100644 src/main/java/carpet/mixins/BuddingAmethystBlock_movableAmethystMixin.java diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index c76989f2..6e3556d4 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -315,7 +315,14 @@ public class CarpetSettings ) public static boolean hopperCounters = false; - @Rule( desc = "Allows Budding Amethyst blocks to be moved by pistons", category = FEATURE ) + @Rule( + desc = "Allows Budding Amethyst blocks to be moved", + extra = { + "Allow for them to be moved by pistons", + "as well as adds extra drop when mining with silk touch pickaxe" + }, + category = FEATURE + ) public static boolean movableAmethyst = false; @Rule( desc = "Guardians turn into Elder Guardian when struck by lightning", category = FEATURE ) diff --git a/src/main/java/carpet/mixins/BuddingAmethystBlock_getPistonBehaviorMixin.java b/src/main/java/carpet/mixins/BuddingAmethystBlock_getPistonBehaviorMixin.java deleted file mode 100644 index 03085c47..00000000 --- a/src/main/java/carpet/mixins/BuddingAmethystBlock_getPistonBehaviorMixin.java +++ /dev/null @@ -1,18 +0,0 @@ -package carpet.mixins; - -import carpet.CarpetSettings; -import net.minecraft.block.BlockState; -import net.minecraft.block.BuddingAmethystBlock; -import net.minecraft.block.piston.PistonBehavior; -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.callback.CallbackInfoReturnable; - -@Mixin(BuddingAmethystBlock.class) -public class BuddingAmethystBlock_getPistonBehaviorMixin { - @Inject(at = @At("HEAD"), method = "getPistonBehavior(Lnet/minecraft/block/BlockState;)Lnet/minecraft/block/piston/PistonBehavior;", cancellable = true) - void getPistonBehavior(BlockState state, CallbackInfoReturnable cir) { - if (CarpetSettings.movableAmethyst) cir.setReturnValue(PistonBehavior.NORMAL); - } -} diff --git a/src/main/java/carpet/mixins/BuddingAmethystBlock_movableAmethystMixin.java b/src/main/java/carpet/mixins/BuddingAmethystBlock_movableAmethystMixin.java new file mode 100644 index 00000000..3e9c2449 --- /dev/null +++ b/src/main/java/carpet/mixins/BuddingAmethystBlock_movableAmethystMixin.java @@ -0,0 +1,45 @@ +package carpet.mixins; + +import carpet.CarpetSettings; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.BuddingAmethystBlock; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.block.piston.PistonBehavior; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.item.PickaxeItem; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; +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.callback.CallbackInfoReturnable; + +@Mixin(BuddingAmethystBlock.class) +public class BuddingAmethystBlock_movableAmethystMixin extends Block { + public BuddingAmethystBlock_movableAmethystMixin(Settings settings) { + super(settings); + } + + @Inject(at = @At("HEAD"), method = "getPistonBehavior(Lnet/minecraft/block/BlockState;)Lnet/minecraft/block/piston/PistonBehavior;", cancellable = true) + void getPistonBehavior(BlockState state, CallbackInfoReturnable cir) { + if (CarpetSettings.movableAmethyst) cir.setReturnValue(PistonBehavior.NORMAL); + } + + @Override + public void afterBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack stack) { + super.afterBreak(world, player, pos, state, blockEntity, stack); + // doing it here rather than though loottables since loottables are loaded on reload + // drawback - not controlled via loottables, but hey + if (CarpetSettings.movableAmethyst && + stack.getItem() instanceof PickaxeItem && + EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, stack) > 0 + ) + dropStack(world, pos, Items.BUDDING_AMETHYST.getDefaultStack()); + } +} diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index f6f49e46..14e5062e 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -89,7 +89,7 @@ "ServerWorld_onePlayerSleepingMixin", "CoralBlockMixin", "CoralFeatureMixin", - "BuddingAmethystBlock_getPistonBehaviorMixin", + "BuddingAmethystBlock_movableAmethystMixin", "FluidBlock_renewableBlackstoneMixin", "FluidBlock_renewableDeepslateMixin", "LavaFluid_renewableDeepslateMixin", From 090eb61ece709b3ebc26ae70aad1760e48a25236 Mon Sep 17 00:00:00 2001 From: gnembon Date: Mon, 31 May 2021 17:08:50 -0300 Subject: [PATCH 086/115] 1.17-pre2 --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index ebf17873..ea4700d6 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.17-pre1 - yarn_mappings=1.17-pre1+build.14 + minecraft_version=1.17-pre2 + yarn_mappings=1.17-pre2+build.1 loader_version=0.11.3 fabric_version=0.34.8+1.17 From 4ccae7abe0c8608abc648d1fd168b06576c65464 Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 1 Jun 2021 19:53:35 -0300 Subject: [PATCH 087/115] 1.17-pre3 --- gradle.properties | 4 ++-- .../carpet/mixins/CrashReport_addScarpetAppsMixin.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index ea4700d6..ce343b58 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.17-pre2 - yarn_mappings=1.17-pre2+build.1 + minecraft_version=1.17-pre3 + yarn_mappings=1.17-pre3+build.1 loader_version=0.11.3 fabric_version=0.34.8+1.17 diff --git a/src/main/java/carpet/mixins/CrashReport_addScarpetAppsMixin.java b/src/main/java/carpet/mixins/CrashReport_addScarpetAppsMixin.java index 676654a7..e2dcf2d7 100644 --- a/src/main/java/carpet/mixins/CrashReport_addScarpetAppsMixin.java +++ b/src/main/java/carpet/mixins/CrashReport_addScarpetAppsMixin.java @@ -3,7 +3,7 @@ package carpet.mixins; import java.util.function.Supplier; import java.util.stream.Collectors; -import net.minecraft.class_6396; +import net.minecraft.util.SystemDetails; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -12,15 +12,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import carpet.CarpetServer; -@Mixin(class_6396.class) +@Mixin(SystemDetails.class) public abstract class CrashReport_addScarpetAppsMixin { - @Shadow public abstract void method_37123(String string, Supplier supplier); + @Shadow public abstract void addSection(String name, Supplier valueSupplier); @Inject(method = "", at = @At("RETURN")) private void fillSystemDetails(CallbackInfo info) { if (CarpetServer.scriptServer == null || CarpetServer.scriptServer.modules.isEmpty()) return; - method_37123("Loaded Scarpet Apps", () -> { + addSection("Loaded Scarpet Apps", () -> { return CarpetServer.scriptServer.modules.keySet().stream().collect(Collectors.joining("\n\t\t", "\n\t\t", "")); }); } From 69cb3b98c311b98469347421e0526a76b4074a96 Mon Sep 17 00:00:00 2001 From: gnembon Date: Thu, 3 Jun 2021 17:49:57 -0300 Subject: [PATCH 088/115] up --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index ce343b58..91acb26c 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.17-pre3 - yarn_mappings=1.17-pre3+build.1 + minecraft_version=1.17-pre5 + yarn_mappings=1.17-pre5+build.1 loader_version=0.11.3 fabric_version=0.34.8+1.17 From a48a7df386cf05bc70f4c9f7656957e355568186 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 6 Jun 2021 10:32:22 -0300 Subject: [PATCH 089/115] added perf command support --- gradle.properties | 4 +- src/main/java/carpet/CarpetServer.java | 11 +++- src/main/java/carpet/CarpetSettings.java | 7 +++ .../carpet/mixins/CommandManagerMixin.java | 1 + .../MinecraftServer_tickspeedMixin.java | 41 ++++++++++++-- .../mixins/PerfCommand_permissionMixin.java | 21 ++++++++ .../carpet/patches/CopyProfilerResult.java | 54 +++++++++++++++++++ .../assets/carpet/scripts/ai_tracker.sc | 3 +- src/main/resources/carpet.mixins.json | 1 + 9 files changed, 136 insertions(+), 7 deletions(-) create mode 100644 src/main/java/carpet/mixins/PerfCommand_permissionMixin.java create mode 100644 src/main/java/carpet/patches/CopyProfilerResult.java diff --git a/gradle.properties b/gradle.properties index 91acb26c..f5a646ed 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.17-pre5 - yarn_mappings=1.17-pre5+build.1 + minecraft_version=1.17-rc1 + yarn_mappings=1.17-rc1+build.4 loader_version=0.11.3 fabric_version=0.34.8+1.17 diff --git a/src/main/java/carpet/CarpetServer.java b/src/main/java/carpet/CarpetServer.java index 00b7ca93..fb0afbdc 100644 --- a/src/main/java/carpet/CarpetServer.java +++ b/src/main/java/carpet/CarpetServer.java @@ -33,8 +33,10 @@ import com.mojang.brigadier.CommandDispatcher; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.DedicatedServerModInitializer; import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.dedicated.command.PerfCommand; import net.minecraft.server.network.ServerPlayerEntity; public class CarpetServer implements ClientModInitializer,DedicatedServerModInitializer // static for now - easier to handle all around the code, its one anyways @@ -122,7 +124,11 @@ public class CarpetServer implements ClientModInitializer,DedicatedServerModInit extensions.forEach(e -> e.onTick(server)); } - public static void registerCarpetCommands(CommandDispatcher dispatcher) + @Deprecated + public static void registerCarpetCommands(CommandDispatcher dispatcher) { + } + + public static void registerCarpetCommands(CommandDispatcher dispatcher, CommandManager.RegistrationEnvironment environment) { settingsManager.registerCommand(dispatcher); extensions.forEach(e -> { @@ -146,6 +152,9 @@ public class CarpetServer implements ClientModInitializer,DedicatedServerModInit // for all other, they will have them registered when they add themselves extensions.forEach(e -> e.registerCommands(dispatcher)); currentCommandDispatcher = dispatcher; + + if (environment != CommandManager.RegistrationEnvironment.DEDICATED) + PerfCommand.register(dispatcher); if (FabricLoader.getInstance().isDevelopmentEnvironment()) TestCommand.register(dispatcher); diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 10b27cb2..b197524f 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -375,6 +375,13 @@ public class CarpetSettings ) public static String commandProfile = "true"; + @Rule( + desc = "Required permission level for /perf command", + options = {"2", "4"}, + category = CREATIVE + ) + public static int perfPermissionLevel = 4; + @Rule(desc = "Enables /log command to monitor events via chat and overlays", category = COMMAND) public static String commandLog = "true"; diff --git a/src/main/java/carpet/mixins/CommandManagerMixin.java b/src/main/java/carpet/mixins/CommandManagerMixin.java index 0b3ef549..05e82a37 100644 --- a/src/main/java/carpet/mixins/CommandManagerMixin.java +++ b/src/main/java/carpet/mixins/CommandManagerMixin.java @@ -27,6 +27,7 @@ public abstract class CommandManagerMixin @Inject(method = "", at = @At("RETURN")) private void onRegister(CommandManager.RegistrationEnvironment arg, CallbackInfo ci) { CarpetServer.registerCarpetCommands(this.dispatcher); + CarpetServer.registerCarpetCommands(this.dispatcher, arg); } @Inject(method = "execute", at = @At("HEAD")) diff --git a/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java b/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java index ff3b508e..29acd733 100644 --- a/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java +++ b/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java @@ -1,14 +1,17 @@ package carpet.mixins; import carpet.helpers.TickSpeed; +import carpet.patches.CopyProfilerResult; import carpet.utils.CarpetProfiler; import net.minecraft.server.MinecraftServer; import net.minecraft.server.ServerTask; -import net.minecraft.util.TickDurationMonitor; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Util; +import net.minecraft.util.profiler.EmptyProfileResult; +import net.minecraft.util.profiler.ProfileResult; import net.minecraft.util.profiler.Profiler; import net.minecraft.util.thread.ReentrantThreadExecutor; +import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.Logger; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -17,6 +20,7 @@ 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.CallbackInfoReturnable; import java.util.function.BooleanSupplier; @@ -56,6 +60,10 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec @Shadow public abstract Iterable getWorlds(); + @Shadow protected abstract void endMonitor(); + + @Shadow private boolean profilerEnabled; + @Shadow private int ticks; CarpetProfiler.ProfilerToken currentSection; private float carpetMsptAccum = 0.0f; @@ -117,11 +125,15 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec this.lastTimeReference = this.timeReference; } + if (this.profilerEnabled) { + this.profilerEnabled = false; + this.profilerTimings = Pair.of(Util.getMeasuringTimeNano(), ticks); + //this.field_33978 = new MinecraftServer.class_6414(Util.getMeasuringTimeNano(), this.ticks); + } this.timeReference += msThisTick;//50L; //TickDurationMonitor tickDurationMonitor = TickDurationMonitor.create("Server"); //this.startMonitor(tickDurationMonitor); this.startMonitor(); - this.profiler.startTick(); this.profiler.push("tick"); this.tick(TickSpeed.time_warp_start_time != 0 ? ()->true : this::shouldKeepTicking); this.profiler.swap("nextTickWait"); @@ -134,12 +146,35 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec // run all tasks (this will not do a lot when warping), but that's fine since we already run them this.method_16208(); this.profiler.pop(); - this.profiler.endTick(); + this.endMonitor(); this.loading = true; } } + // just because profilerTimings class is public + Pair profilerTimings = null; + /// overworld around profiler timings + @Inject(method = "isDebugRunning", at = @At("HEAD"), cancellable = true) + public void isCMDebugRunning(CallbackInfoReturnable cir) + { + cir.setReturnValue(profilerEnabled || profilerTimings != null); + } + @Inject(method = "stopDebug", at = @At("HEAD"), cancellable = true) + public void stopCMDebug(CallbackInfoReturnable cir) + { + if (this.profilerTimings == null) { + cir.setReturnValue(EmptyProfileResult.INSTANCE); + } else { + ProfileResult profileResult = new CopyProfilerResult( + profilerTimings.getRight(), profilerTimings.getLeft(), + this.ticks, Util.getMeasuringTimeNano() + ); + this.profilerTimings = null; + cir.setReturnValue(profileResult); + } + } + private boolean runEveryTask() { if (super.runTask()) { diff --git a/src/main/java/carpet/mixins/PerfCommand_permissionMixin.java b/src/main/java/carpet/mixins/PerfCommand_permissionMixin.java new file mode 100644 index 00000000..014e1d32 --- /dev/null +++ b/src/main/java/carpet/mixins/PerfCommand_permissionMixin.java @@ -0,0 +1,21 @@ +package carpet.mixins; + +import carpet.CarpetSettings; +import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.server.dedicated.command.PerfCommand; +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.callback.CallbackInfoReturnable; + +@Mixin(PerfCommand.class) +public class PerfCommand_permissionMixin +{ + @SuppressWarnings("UnresolvedMixinReference") + @Inject(method = "method_37340(Lnet/minecraft/server/command/ServerCommandSource;)Z", at = @At("HEAD"), cancellable = true) + private static void canRun(ServerCommandSource source, CallbackInfoReturnable cir) + { + cir.setReturnValue(source.hasPermissionLevel(CarpetSettings.perfPermissionLevel)); + } + +} diff --git a/src/main/java/carpet/patches/CopyProfilerResult.java b/src/main/java/carpet/patches/CopyProfilerResult.java new file mode 100644 index 00000000..07a13782 --- /dev/null +++ b/src/main/java/carpet/patches/CopyProfilerResult.java @@ -0,0 +1,54 @@ +package carpet.patches; + +import net.minecraft.util.profiler.ProfileResult; +import net.minecraft.util.profiler.ProfilerTiming; + +import java.nio.file.Path; +import java.util.Collections; +import java.util.List; + +public class CopyProfilerResult implements ProfileResult { + int startI, endI; + long startL, endL; + public CopyProfilerResult(int startI, long startL, int endI, long endL) + { + this.startI = startI; + this.startL = startL; + this.endI = endI; + this.endL = endL; + } + @Override + public List getTimings(String parentPath) { + return Collections.emptyList(); + } + + @Override + public boolean save(Path path) { + return false; + } + + @Override + public long getStartTime() { + return startL; + } + + @Override + public int getStartTick() { + return startI; + } + + @Override + public long getEndTime() { + return endL; + } + + @Override + public int getEndTick() { + return endI; + } + + @Override + public String getRootTimings() { + return ""; + } +} diff --git a/src/main/resources/assets/carpet/scripts/ai_tracker.sc b/src/main/resources/assets/carpet/scripts/ai_tracker.sc index 3345edd6..636d7977 100644 --- a/src/main/resources/assets/carpet/scripts/ai_tracker.sc +++ b/src/main/resources/assets/carpet/scripts/ai_tracker.sc @@ -285,7 +285,8 @@ global_functions = { 'health' -> { '*' -> [ _(arg) -> _(e) -> ( - [[], [], [['health', 'health:', e~'health']]] + health = e~'health'; + [[], [], if (health != null, [['health', 'health:', e~'health']], [])] ), , null diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index 14e5062e..3a9766ca 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -12,6 +12,7 @@ "ServerPlayNetworkHandlerMixin", "CustomPayloadC2SPacketMixin", + "PerfCommand_permissionMixin", "FillCommandMixin", "CloneCommandMixin", "SetBlockCommandMixin", From 561589590b815d9645a5657acb3a08db9c5492d2 Mon Sep 17 00:00:00 2001 From: gnembon Date: Mon, 7 Jun 2021 15:19:21 -0300 Subject: [PATCH 090/115] 1.17-pre2 --- gradle.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index f5a646ed..d1c24bdf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=1.17-rc1 - yarn_mappings=1.17-rc1+build.4 + minecraft_version=1.17-rc2 + yarn_mappings=1.17-rc2+build.10 loader_version=0.11.3 - fabric_version=0.34.8+1.17 + fabric_version=0.34.9+1.17 # Mod Properties mod_version = 1.4.39 From 74e88e736aad4d0ecf08092d35f706d53297b336 Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 8 Jun 2021 16:24:38 -0300 Subject: [PATCH 091/115] 1.17 --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index d1c24bdf..2fa8c3d5 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.17-rc2 - yarn_mappings=1.17-rc2+build.10 + minecraft_version=1.17 + yarn_mappings=1.17+build.1 loader_version=0.11.3 fabric_version=0.34.9+1.17 From 8093ac995d74472dc94f2ae64676e9df04d8c496 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 13 Jun 2021 11:49:01 -0300 Subject: [PATCH 092/115] update --- .../mixins/ShulkerBoxBlockEntity_creativeNoClipMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/mixins/ShulkerBoxBlockEntity_creativeNoClipMixin.java b/src/main/java/carpet/mixins/ShulkerBoxBlockEntity_creativeNoClipMixin.java index d3deec9c..f662c1c3 100644 --- a/src/main/java/carpet/mixins/ShulkerBoxBlockEntity_creativeNoClipMixin.java +++ b/src/main/java/carpet/mixins/ShulkerBoxBlockEntity_creativeNoClipMixin.java @@ -18,7 +18,7 @@ public class ShulkerBoxBlockEntity_creativeNoClipMixin )) private PistonBehavior getPistonBehaviourOfNoClipPlayers(Entity entity) { - if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).abilities.flying) + if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).getAbilities().flying) return PistonBehavior.IGNORE; return entity.getPistonBehavior(); } From c7b059fdb8b57a360bdafdbcd9664a61d0dbb569 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 13 Jun 2021 11:50:18 -0300 Subject: [PATCH 093/115] update --- src/main/resources/carpet.mixins.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index 69503545..83617ae4 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -210,7 +210,7 @@ "BlockItem_creativeNoClipMixin", "WallStandingBlockItem_creativeNoClipMixin", "ShulkerBoxBlockEntity_creativeNoClipMixin", - "LivingEntity_creativeFlyMixin" + "LivingEntity_creativeFlyMixin", "VeryBiasedToBottomHeightProvider_cleanLogsMixin", "TrapezoidHeightProvider_cleanLogsMixin" From b581c3bea675770a80ca0251ca930149c8b9cb61 Mon Sep 17 00:00:00 2001 From: gnembon Date: Thu, 17 Jun 2021 21:21:59 -0300 Subject: [PATCH 094/115] well --- src/main/java/carpet/script/value/ValueConversions.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/main/java/carpet/script/value/ValueConversions.java b/src/main/java/carpet/script/value/ValueConversions.java index e1223538..2d9999b9 100644 --- a/src/main/java/carpet/script/value/ValueConversions.java +++ b/src/main/java/carpet/script/value/ValueConversions.java @@ -310,15 +310,6 @@ public class ValueConversions ListValue.fromTriple(box.maxX, box.maxY, box.maxZ) ); } - - public static Value of(BlockBox box) - { - return ListValue.of( - ListValue.fromTriple(box.minX, box.minY, box.minZ), - ListValue.fromTriple(box.maxX, box.maxY, box.maxZ) - ); - } - public static Value of(BlockBox box) { return ListValue.of( From a4cec8165be36fb651633911f178dca72b4a8998 Mon Sep 17 00:00:00 2001 From: gnembon Date: Thu, 17 Jun 2021 21:34:36 -0300 Subject: [PATCH 095/115] fixing scoreboard API --- .../java/carpet/mixins/ScoreboardObjective_scarpetMixin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/carpet/mixins/ScoreboardObjective_scarpetMixin.java b/src/main/java/carpet/mixins/ScoreboardObjective_scarpetMixin.java index a7506dde..78cd63dc 100644 --- a/src/main/java/carpet/mixins/ScoreboardObjective_scarpetMixin.java +++ b/src/main/java/carpet/mixins/ScoreboardObjective_scarpetMixin.java @@ -3,10 +3,11 @@ package carpet.mixins; import net.minecraft.scoreboard.ScoreboardCriterion; import net.minecraft.scoreboard.ScoreboardObjective; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(ScoreboardObjective.class) public interface ScoreboardObjective_scarpetMixin { - @Accessor("criterion") + @Mutable @Accessor("criterion") void setCriterion(ScoreboardCriterion criterion); } From 0937ba8352496698acc6f677025ba9cea3a815a1 Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 18 Jun 2021 23:43:47 -0300 Subject: [PATCH 096/115] 1.17.1-pre1 --- gradle.properties | 8 ++++---- src/main/java/carpet/helpers/EntityPlayerActionPack.java | 4 ++-- src/main/java/carpet/helpers/FeatureGenerator.java | 8 ++++---- .../ServerPlayNetworkHandler_scarpetEventsMixin.java | 4 ++-- src/main/java/carpet/script/api/Inventories.java | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5829a745..ac8a7f04 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=1.17 - yarn_mappings=1.17+build.1 - loader_version=0.11.3 - fabric_version=0.34.9+1.17 + minecraft_version=1.17.1-pre1 + yarn_mappings=1.17.1-pre1+build.1 + loader_version=0.11.6 + fabric_version=0.35.2+1.17 # Mod Properties mod_version = 1.4.40 diff --git a/src/main/java/carpet/helpers/EntityPlayerActionPack.java b/src/main/java/carpet/helpers/EntityPlayerActionPack.java index c4b57553..4c63e35e 100644 --- a/src/main/java/carpet/helpers/EntityPlayerActionPack.java +++ b/src/main/java/carpet/helpers/EntityPlayerActionPack.java @@ -487,7 +487,7 @@ public class EntityPlayerActionPack boolean execute(ServerPlayerEntity player, Action action) { player.updateLastActionTime(); - player.dropSelectedItem(false); + player.method_37413(false); // dropSelectedItem return false; } }, @@ -497,7 +497,7 @@ public class EntityPlayerActionPack boolean execute(ServerPlayerEntity player, Action action) { player.updateLastActionTime(); - player.dropSelectedItem(true); + player.method_37413(true); // dropSelectedItem return false; } }, diff --git a/src/main/java/carpet/helpers/FeatureGenerator.java b/src/main/java/carpet/helpers/FeatureGenerator.java index 0cb97fc4..05ed8afa 100644 --- a/src/main/java/carpet/helpers/FeatureGenerator.java +++ b/src/main/java/carpet/helpers/FeatureGenerator.java @@ -192,7 +192,7 @@ public class FeatureGenerator new Identifier("bastion/starts"), new Identifier("empty"), ImmutableList.of( - Pair.of(StructurePoolElement.method_30435("bastion/units/air_base", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1) + Pair.of(StructurePoolElement.ofProcessedSingle("bastion/units/air_base", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1) ), StructurePool.Projection.RIGID ), 6), @@ -204,7 +204,7 @@ public class FeatureGenerator new Identifier("bastion/starts"), new Identifier("empty"), ImmutableList.of( - Pair.of(StructurePoolElement.method_30435("bastion/hoglin_stable/air_base", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1) + Pair.of(StructurePoolElement.ofProcessedSingle("bastion/hoglin_stable/air_base", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1) ), StructurePool.Projection.RIGID ), 6), @@ -216,7 +216,7 @@ public class FeatureGenerator new Identifier("bastion/starts"), new Identifier("empty"), ImmutableList.of( - Pair.of(StructurePoolElement.method_30435("bastion/treasure/big_air_full", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1) + Pair.of(StructurePoolElement.ofProcessedSingle("bastion/treasure/big_air_full", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1) ), StructurePool.Projection.RIGID ), 6), @@ -228,7 +228,7 @@ public class FeatureGenerator new Identifier("bastion/starts"), new Identifier("empty"), ImmutableList.of( - Pair.of(StructurePoolElement.method_30435("bastion/bridge/starting_pieces/entrance_base", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1) + Pair.of(StructurePoolElement.ofProcessedSingle("bastion/bridge/starting_pieces/entrance_base", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1) ), StructurePool.Projection.RIGID ), 6), diff --git a/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java b/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java index c1f91226..3811ddb2 100644 --- a/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java @@ -62,7 +62,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin @Inject(method = "onPlayerAction", at = @At( value = "INVOKE", - target = "Lnet/minecraft/server/network/ServerPlayerEntity;dropSelectedItem(Z)Z", + target = "Lnet/minecraft/server/network/ServerPlayerEntity;method_37413(Z)Z", // dropSelectedItem ordinal = 0, shift = At.Shift.BEFORE )) @@ -84,7 +84,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin @Inject(method = "onPlayerAction", at = @At( value = "INVOKE", - target = "Lnet/minecraft/server/network/ServerPlayerEntity;dropSelectedItem(Z)Z", + target = "Lnet/minecraft/server/network/ServerPlayerEntity;method_37413(Z)Z", // dropSelectedItem ordinal = 1, shift = At.Shift.BEFORE )) diff --git a/src/main/java/carpet/script/api/Inventories.java b/src/main/java/carpet/script/api/Inventories.java index 211e6275..70d4dfac 100644 --- a/src/main/java/carpet/script/api/Inventories.java +++ b/src/main/java/carpet/script/api/Inventories.java @@ -396,7 +396,7 @@ public class Inventories { { ServerPlayerEntity player = (ServerPlayerEntity) inventory.owner; player.networkHandler.sendPacket(new ScreenHandlerSlotUpdateS2CPacket( - -2, + -2, 0, // resolve mystery argument int_1, inventory.inventory.getStack(int_1) )); From 4dd19ee4ea92774eb983e37006add4a75d3b90b2 Mon Sep 17 00:00:00 2001 From: replaceitem <40722305+replaceitem@users.noreply.github.com> Date: Sat, 19 Jun 2021 17:45:01 +0200 Subject: [PATCH 097/115] Made deepslate generate below y16 (#914) * Made deepslate generate below y16 * Update src/main/java/carpet/CarpetSettings.java Co-authored-by: gnembon <41132274+gnembon@users.noreply.github.com> --- src/main/java/carpet/CarpetSettings.java | 3 ++- .../carpet/mixins/FluidBlock_renewableDeepslateMixin.java | 6 ++++-- .../carpet/mixins/LavaFluid_renewableDeepslateMixin.java | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 7cf6ba66..48621d0a 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -769,7 +769,8 @@ public class CarpetSettings public static boolean renewableBlackstone = false; @Rule( - desc = "Lava and water generate deepslate and cobbled deepslate instead below y0", + desc = "Lava and water generate deepslate and cobbled deepslate instead below Y16", + extra = "This rule may change Y value to 0 with 1.18", category = FEATURE ) public static boolean renewableDeepslate = false; diff --git a/src/main/java/carpet/mixins/FluidBlock_renewableDeepslateMixin.java b/src/main/java/carpet/mixins/FluidBlock_renewableDeepslateMixin.java index 5f588d37..2a7a3e8c 100644 --- a/src/main/java/carpet/mixins/FluidBlock_renewableDeepslateMixin.java +++ b/src/main/java/carpet/mixins/FluidBlock_renewableDeepslateMixin.java @@ -19,8 +19,10 @@ public abstract class FluidBlock_renewableDeepslateMixin { @Shadow protected abstract void playExtinguishSound(WorldAccess world, BlockPos pos); @Inject(method = "receiveNeighborFluids", at = @At(value = "INVOKE",target = "Lnet/minecraft/fluid/FluidState;isStill()Z"), cancellable = true) - private void receiveFluidToDeepslate(World world, BlockPos pos, BlockState state, CallbackInfoReturnable cir) { - if(CarpetSettings.renewableDeepslate && !world.getFluidState(pos).isStill() && pos.getY() < 0 && world.getRegistryKey() == World.OVERWORLD ) { + private void receiveFluidToDeepslate(World world, BlockPos pos, BlockState state, CallbackInfoReturnable cir) + { + if(CarpetSettings.renewableDeepslate && !world.getFluidState(pos).isStill() && world.getRegistryKey() == World.OVERWORLD && pos.getY() < 16) + { world.setBlockState(pos, Blocks.COBBLED_DEEPSLATE.getDefaultState()); this.playExtinguishSound(world, pos); cir.setReturnValue(false); diff --git a/src/main/java/carpet/mixins/LavaFluid_renewableDeepslateMixin.java b/src/main/java/carpet/mixins/LavaFluid_renewableDeepslateMixin.java index 770ccf51..8d902f65 100644 --- a/src/main/java/carpet/mixins/LavaFluid_renewableDeepslateMixin.java +++ b/src/main/java/carpet/mixins/LavaFluid_renewableDeepslateMixin.java @@ -20,8 +20,10 @@ public abstract class LavaFluid_renewableDeepslateMixin { @Shadow protected abstract void playExtinguishEvent(WorldAccess world, BlockPos pos); @Inject(method = "flow", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;getDefaultState()Lnet/minecraft/block/BlockState;"), cancellable = true) - private void generateDeepslate(WorldAccess world, BlockPos pos, BlockState state, Direction direction, FluidState fluidState, CallbackInfo ci) { - if(CarpetSettings.renewableDeepslate && pos.getY() < 0 && ((World)world).getRegistryKey() == World.OVERWORLD) { + private void generateDeepslate(WorldAccess world, BlockPos pos, BlockState state, Direction direction, FluidState fluidState, CallbackInfo ci) + { + if(CarpetSettings.renewableDeepslate && ((World)world).getRegistryKey() == World.OVERWORLD && pos.getY() < 16) + { world.setBlockState(pos, Blocks.DEEPSLATE.getDefaultState(), 3); this.playExtinguishEvent(world, pos); ci.cancel(); From 6d76403433055faef63913a489871ce6d8427159 Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 22 Jun 2021 01:32:53 -0300 Subject: [PATCH 098/115] updates --- src/main/java/carpet/CarpetSettings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 914e6909..c75fb8d5 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -833,7 +833,7 @@ public class CarpetSettings public static boolean isCreativeFlying(Entity entity) { // #todo replace after merger to 1.17 - return CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).abilities.flying; + return CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).getAbilities().flying; } From 127416c8c1a604c0f530ee8c53992e4b746a18ed Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 22 Jun 2021 01:44:03 -0300 Subject: [PATCH 099/115] fixed glow item frame classification. fixes #933 --- src/main/java/carpet/script/value/EntityValue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 06cf665f..bcbce4ed 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -312,7 +312,7 @@ public class EntityValue extends Value Set> deads = Sets.newHashSet( EntityType.AREA_EFFECT_CLOUD, EntityType.BOAT, EntityType.END_CRYSTAL, EntityType.EVOKER_FANGS, EntityType.EXPERIENCE_ORB, EntityType.EYE_OF_ENDER, - EntityType.FALLING_BLOCK, EntityType.ITEM, EntityType.ITEM_FRAME, + EntityType.FALLING_BLOCK, EntityType.ITEM, EntityType.ITEM_FRAME, EntityType.GLOW_ITEM_FRAME, EntityType.LEASH_KNOT, EntityType.LIGHTNING_BOLT, EntityType.PAINTING, EntityType.TNT From 26f9badb9574a2fae4baeeee0ce1ccf493510546 Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 22 Jun 2021 14:56:07 -0300 Subject: [PATCH 100/115] classified marker --- src/main/java/carpet/script/value/EntityValue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index bcbce4ed..38fecae6 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -310,7 +310,7 @@ public class EntityValue extends Value EntityType.TRIDENT, EntityType.WITHER_SKULL, EntityType.FISHING_BOBBER ); Set> deads = Sets.newHashSet( - EntityType.AREA_EFFECT_CLOUD, EntityType.BOAT, EntityType.END_CRYSTAL, + EntityType.AREA_EFFECT_CLOUD, EntityType.MARKER, EntityType.BOAT, EntityType.END_CRYSTAL, EntityType.EVOKER_FANGS, EntityType.EXPERIENCE_ORB, EntityType.EYE_OF_ENDER, EntityType.FALLING_BLOCK, EntityType.ITEM, EntityType.ITEM_FRAME, EntityType.GLOW_ITEM_FRAME, EntityType.LEASH_KNOT, EntityType.LIGHTNING_BOLT, EntityType.PAINTING, From aa38fe4e85205ec15cf4a1c8d8f23190907e9151 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 23 Jun 2021 03:46:47 -0300 Subject: [PATCH 101/115] update --- src/main/java/carpet/commands/PlayerCommand.java | 2 +- src/main/java/carpet/patches/EntityPlayerMPFake.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/carpet/commands/PlayerCommand.java b/src/main/java/carpet/commands/PlayerCommand.java index 04afba9c..6c4e8fd0 100644 --- a/src/main/java/carpet/commands/PlayerCommand.java +++ b/src/main/java/carpet/commands/PlayerCommand.java @@ -270,7 +270,7 @@ public class PlayerCommand { ServerPlayerEntity player = context.getSource().getPlayer(); mode = player.interactionManager.getGameMode(); - flying = player.abilities.flying; + flying = player.getAbilities().flying; } catch (CommandSyntaxException ignored) {} String playerName = StringArgumentType.getString(context, "player"); diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index 123b73a5..9d811029 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -72,7 +72,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity server.getPlayerManager().sendToDimension(new EntityPositionS2CPacket(instance), dimensionId);//instance.dimension); instance.getServerWorld().getChunkManager().updatePosition(instance); instance.dataTracker.set(PLAYER_MODEL_PARTS, (byte) 0x7f); // show all model layers (incl. capes) - instance.abilities.flying = flying; + instance.getAbilities().flying = flying; return instance; } @@ -96,7 +96,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(playerShadow, (byte) (player.headYaw * 256 / 360)), playerShadow.world.getRegistryKey()); server.getPlayerManager().sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, playerShadow)); player.getServerWorld().getChunkManager().updatePosition(playerShadow); - playerShadow.abilities.flying = player.abilities.flying; + playerShadow.getAbilities().flying = player.getAbilities().flying; return playerShadow; } From f2aae4ec92d3840c98b0a5c73b44feb197d22278 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 23 Jun 2021 13:18:45 -0300 Subject: [PATCH 102/115] added is_freezing, frost, immune_to_frost to entity API, Fixes #932 --- src/main/java/carpet/script/value/EntityValue.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 27ca9a3e..00c29988 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -488,9 +488,12 @@ public class EntityValue extends Value }); put("is_burning", (e, a) -> BooleanValue.of(e.isOnFire())); put("fire", (e, a) -> new NumericValue(e.getFireTicks())); + put("is_freezing", (e, a) -> BooleanValue.of(e.isFreezing())); + put("frost", (e, a) -> new NumericValue(e.getFrozenTicks())); put("silent", (e, a)-> BooleanValue.of(e.isSilent())); put("gravity", (e, a) -> BooleanValue.of(!e.hasNoGravity())); put("immune_to_fire", (e, a) -> BooleanValue.of(e.isFireImmune())); + put("immune_to_frost", (e, a) -> BooleanValue.of(!e.canFreeze())); put("invulnerable", (e, a) -> BooleanValue.of(e.isInvulnerable())); put("dimension", (e, a) -> new StringValue(nameFromRegistryId(e.world.getRegistryKey().getValue()))); // getDimId @@ -1462,6 +1465,7 @@ public class EntityValue extends Value put("invulnerable",(e,v)-> e.setInvulnerable(v.getBoolean())); put("fire",(e,v)-> e.setFireTicks((int)NumericValue.asNumber(v).getLong())); + put("frost",(e,v)-> e.setFrozenTicks((int)NumericValue.asNumber(v).getLong())); put("hunger", (e, v)-> { if(e instanceof PlayerEntity) ((PlayerEntity) e).getHungerManager().setFoodLevel((int) NumericValue.asNumber(v).getLong()); From 481fc975450ec58db1faf14f776205127b0365c0 Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 25 Jun 2021 18:38:49 -0300 Subject: [PATCH 103/115] changes to entity load handler / not backwards compatible --- .../ServerEntityManager_scarpetMixin.java | 38 +++++++++++++++++++ .../mixins/ServerWorld_scarpetMixin.java | 4 +- .../java/carpet/script/CarpetEventServer.java | 11 +++--- src/main/resources/carpet.mixins.json | 1 + 4 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 src/main/java/carpet/mixins/ServerEntityManager_scarpetMixin.java diff --git a/src/main/java/carpet/mixins/ServerEntityManager_scarpetMixin.java b/src/main/java/carpet/mixins/ServerEntityManager_scarpetMixin.java new file mode 100644 index 00000000..04191e62 --- /dev/null +++ b/src/main/java/carpet/mixins/ServerEntityManager_scarpetMixin.java @@ -0,0 +1,38 @@ +package carpet.mixins; + +import carpet.script.CarpetEventServer; +import carpet.script.CarpetScriptServer; +import net.minecraft.entity.Entity; +import net.minecraft.server.world.ServerEntityManager; +import net.minecraft.world.entity.EntityLike; +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.callback.CallbackInfoReturnable; + +@Mixin(ServerEntityManager.class) +public class ServerEntityManager_scarpetMixin +{ + @Inject(method = "addEntity(Lnet/minecraft/world/entity/EntityLike;Z)Z", at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/EntityTrackingStatus;shouldTick()Z" + )) + private void handleAddedEntity(EntityLike entityLike, boolean existing, CallbackInfoReturnable cir) + { + Entity entity = (Entity)entityLike; + CarpetEventServer.Event event = CarpetEventServer.Event.ENTITY_LOAD.get(entity.getType()); + if (event != null) + { + if (event.isNeeded()) + { + event.onEntityAction(entity, !existing); + } + } + else + { + CarpetScriptServer.LOG.error("Failed to handle entity type " + entity.getType().getTranslationKey()); + } + + } + +} diff --git a/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java b/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java index eed77037..592eaf53 100644 --- a/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java +++ b/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java @@ -26,7 +26,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import static carpet.script.CarpetEventServer.Event.ENTITY_LOAD; import static carpet.script.CarpetEventServer.Event.EXPLOSION; import static carpet.script.CarpetEventServer.Event.LIGHTNING; @@ -46,6 +45,8 @@ public class ServerWorld_scarpetMixin implements ServerWorldInterface if (LIGHTNING.isNeeded()) LIGHTNING.onWorldEventFlag((ServerWorld) (Object)this, blockPos, bl2?1:0); } + /* + moved to ServerEntityManager_scarpetMixin in 1.17 @Redirect(method = "addEntity", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/world/ServerEntityManager;addEntity(Lnet/minecraft/world/entity/EntityLike;)Z" @@ -66,6 +67,7 @@ public class ServerWorld_scarpetMixin implements ServerWorldInterface }; return success; } + */ @Inject(method = "createExplosion", at = @At("HEAD")) private void handleExplosion(/*@Nullable*/ Entity entity, /*@Nullable*/ DamageSource damageSource, /*@Nullable*/ ExplosionBehavior explosionBehavior, double d, double e, double f, float g, boolean bl, Explosion.DestructionType destructionType, CallbackInfoReturnable cir) diff --git a/src/main/java/carpet/script/CarpetEventServer.java b/src/main/java/carpet/script/CarpetEventServer.java index 03bc08d7..5b3d8a19 100644 --- a/src/main/java/carpet/script/CarpetEventServer.java +++ b/src/main/java/carpet/script/CarpetEventServer.java @@ -933,16 +933,17 @@ public class CarpetEventServer return "entity_loaded_" + ValueConversions.of(Registry.ENTITY_TYPE.getId(et)).getString(); } - public static final Map, Event> ENTITY_LOAD= new HashMap, Event>() {{ + public static final Map, Event> ENTITY_LOAD= new HashMap<>() + {{ EntityType.get("zombie"); Registry.ENTITY_TYPE.forEach(et -> { - put(et, new Event(getEntityLoadEventName(et), 1, true, false) + put(et, new Event(getEntityLoadEventName(et), 2, true, false) { @Override - public void onEntityAction(Entity entity) + public void onEntityAction(Entity entity, boolean created) { handler.call( - () -> Collections.singletonList(new EntityValue(entity)), + () -> Arrays.asList(new EntityValue(entity), BooleanValue.of(created)), () -> CarpetServer.minecraft_server.getCommandSource().withWorld((ServerWorld) entity.world).withLevel(CarpetSettings.runPermissionLevel) ); } @@ -1040,7 +1041,7 @@ public class CarpetEventServer public void onBlockPlaced(ServerPlayerEntity player, BlockPos pos, Hand enumhand, ItemStack itemstack) { } public void onEntityHandAction(ServerPlayerEntity player, Entity entity, Hand enumhand) { } public void onHandAction(ServerPlayerEntity player, Hand enumhand) { } - public void onEntityAction(Entity entity) { } + public void onEntityAction(Entity entity, boolean created) { } public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, RegistryKey fromDim, RegistryKey dimTo) {} public void onDamage(Entity target, float amount, DamageSource source) { } public void onRecipeSelected(ServerPlayerEntity player, Identifier recipe, boolean fullStack) {} diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index e0cc1ada..56c8e365 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -188,6 +188,7 @@ "StatType_scarpetMixin", "PointOfInterest_scarpetMixin", "ServerWorld_scarpetMixin", + "ServerEntityManager_scarpetMixin", "HungerManagerMixin_scarpetEventsMixin", "ReloadCommand_reloadAppsMixin", "CrashReport_addScarpetAppsMixin", From ac24a67c006ea40a87187d930d089cd1c14bffb1 Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 25 Jun 2021 20:18:12 -0300 Subject: [PATCH 104/115] changes to entity load handler keeping it backwards compatible. Fixes #929 --- .../mixins/ServerEntityManager_scarpetMixin.java | 15 ++++++++++++++- .../java/carpet/script/CarpetEventServer.java | 6 ++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/carpet/mixins/ServerEntityManager_scarpetMixin.java b/src/main/java/carpet/mixins/ServerEntityManager_scarpetMixin.java index 04191e62..bdf7327e 100644 --- a/src/main/java/carpet/mixins/ServerEntityManager_scarpetMixin.java +++ b/src/main/java/carpet/mixins/ServerEntityManager_scarpetMixin.java @@ -20,7 +20,7 @@ public class ServerEntityManager_scarpetMixin private void handleAddedEntity(EntityLike entityLike, boolean existing, CallbackInfoReturnable cir) { Entity entity = (Entity)entityLike; - CarpetEventServer.Event event = CarpetEventServer.Event.ENTITY_LOAD.get(entity.getType()); + CarpetEventServer.Event event = CarpetEventServer.Event.ENTITY_HANDLER.get(entity.getType()); if (event != null) { if (event.isNeeded()) @@ -33,6 +33,19 @@ public class ServerEntityManager_scarpetMixin CarpetScriptServer.LOG.error("Failed to handle entity type " + entity.getType().getTranslationKey()); } + event = CarpetEventServer.Event.ENTITY_LOAD.get(entity.getType()); + if (event != null) + { + if (event.isNeeded()) + { + event.onEntityAction(entity, true); + } + } + else + { + CarpetScriptServer.LOG.error("Failed to handle entity type " + entity.getType().getTranslationKey()); + } + } } diff --git a/src/main/java/carpet/script/CarpetEventServer.java b/src/main/java/carpet/script/CarpetEventServer.java index 7b066d37..a0949876 100644 --- a/src/main/java/carpet/script/CarpetEventServer.java +++ b/src/main/java/carpet/script/CarpetEventServer.java @@ -935,7 +935,8 @@ public class CarpetEventServer } @Deprecated - public static final Map, Event> ENTITY_LOAD= new HashMap, Event>() {{ + public static final Map, Event> ENTITY_LOAD= new HashMap<>() + {{ EntityType.get("zombie"); Registry.ENTITY_TYPE.forEach(et -> { put(et, new Event(getEntityLoadEventName(et), 1, true, false) @@ -957,7 +958,8 @@ public class CarpetEventServer return "entity_handler_" + ValueConversions.of(Registry.ENTITY_TYPE.getId(et)).getString(); } - public static final Map, Event> ENTITY_HANDLER= new HashMap, Event>() {{ + public static final Map, Event> ENTITY_HANDLER= new HashMap<>() + {{ EntityType.get("zombie"); Registry.ENTITY_TYPE.forEach(et -> { put(et, new Event(getEntityHandlerEventName(et), 2, true, false) From 96a6e8676eff3350b65dd8f91ec0c795b7661dfe Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 25 Jun 2021 22:54:53 -0300 Subject: [PATCH 105/115] removes retained player references, Fixes #953 --- src/main/java/carpet/logging/HUDController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/logging/HUDController.java b/src/main/java/carpet/logging/HUDController.java index 4b65d287..6cabcfc4 100644 --- a/src/main/java/carpet/logging/HUDController.java +++ b/src/main/java/carpet/logging/HUDController.java @@ -124,7 +124,7 @@ public class HUDController for (ServerPlayerEntity player: targets) { PacketByteBuf packetData = new PacketByteBuf(Unpooled.buffer()). - writeText(scarpet_headers.getOrDefault(player, new LiteralText(""))). + writeText(scarpet_headers.getOrDefault(player.getEntityName(), new LiteralText(""))). writeText(Messenger.c(player_huds.getOrDefault(player, Collections.emptyList()).toArray(new Object[0]))); PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket(packetData); From b3cc32f676b9db04cac97521e5f9e5148bdd0da9 Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 25 Jun 2021 23:57:42 -0300 Subject: [PATCH 106/115] mappings --- gradle.properties | 4 ++-- .../mixins/EndGatewayBlockEntity_creativeNoClipMixin.java | 2 +- .../mixins/StructureBlockBlockEntityRenderer_mixin.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index ac8a7f04..f66ae0b4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,9 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=1.17.1-pre1 - yarn_mappings=1.17.1-pre1+build.1 + yarn_mappings=1.17.1-pre1+build.9 loader_version=0.11.6 - fabric_version=0.35.2+1.17 + fabric_version=0.36.0+1.17 # Mod Properties mod_version = 1.4.40 diff --git a/src/main/java/carpet/mixins/EndGatewayBlockEntity_creativeNoClipMixin.java b/src/main/java/carpet/mixins/EndGatewayBlockEntity_creativeNoClipMixin.java index 8d3703d0..36df899d 100644 --- a/src/main/java/carpet/mixins/EndGatewayBlockEntity_creativeNoClipMixin.java +++ b/src/main/java/carpet/mixins/EndGatewayBlockEntity_creativeNoClipMixin.java @@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(EndGatewayBlockEntity.class) public class EndGatewayBlockEntity_creativeNoClipMixin { - @Inject(method = "method_30276", cancellable = true, at = @At("HEAD")) + @Inject(method = "canTeleport", cancellable = true, at = @At("HEAD")) private static void checkFlyingCreative(Entity entity, CallbackInfoReturnable cir) { if (CarpetSettings.isCreativeFlying(entity)) cir.setReturnValue(false); diff --git a/src/main/java/carpet/mixins/StructureBlockBlockEntityRenderer_mixin.java b/src/main/java/carpet/mixins/StructureBlockBlockEntityRenderer_mixin.java index 25f25786..57cf46c6 100644 --- a/src/main/java/carpet/mixins/StructureBlockBlockEntityRenderer_mixin.java +++ b/src/main/java/carpet/mixins/StructureBlockBlockEntityRenderer_mixin.java @@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(StructureBlockBlockEntityRenderer.class) public abstract class StructureBlockBlockEntityRenderer_mixin implements BlockEntityRenderer { - @Inject(method = "method_33893", at = @At("HEAD"), cancellable = true) + @Inject(method = "getRenderDistance", at = @At("HEAD"), cancellable = true) void newLimit(CallbackInfoReturnable cir) { if (CarpetSettings.structureBlockOutlineDistance != 96) From ca59c8f30a9ca099e7df87ce498a0d154892cdaf Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 29 Jun 2021 02:21:47 -0300 Subject: [PATCH 107/115] reloading chunks is not needed when resetting, fixing entities removed. --- src/main/java/carpet/fakes/ServerWorldInterface.java | 3 +++ .../carpet/fakes/SimpleEntityLookupInterface.java | 11 +++++++++++ .../java/carpet/mixins/ServerWorld_scarpetMixin.java | 8 ++++++++ ...dAnvilChunkStorage_scarpetChunkCreationMixin.java | 12 +++++++++++- src/main/java/carpet/script/api/WorldAccess.java | 4 ++-- src/main/resources/carpet.mixins.json | 1 + 6 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 src/main/java/carpet/fakes/SimpleEntityLookupInterface.java diff --git a/src/main/java/carpet/fakes/ServerWorldInterface.java b/src/main/java/carpet/fakes/ServerWorldInterface.java index 67414706..106eb72a 100644 --- a/src/main/java/carpet/fakes/ServerWorldInterface.java +++ b/src/main/java/carpet/fakes/ServerWorldInterface.java @@ -1,7 +1,10 @@ package carpet.fakes; +import net.minecraft.entity.Entity; +import net.minecraft.world.entity.EntityLookup; import net.minecraft.world.level.ServerWorldProperties; public interface ServerWorldInterface { ServerWorldProperties getWorldPropertiesCM(); + EntityLookup getEntityLookupCMPublic(); } diff --git a/src/main/java/carpet/fakes/SimpleEntityLookupInterface.java b/src/main/java/carpet/fakes/SimpleEntityLookupInterface.java new file mode 100644 index 00000000..2802581d --- /dev/null +++ b/src/main/java/carpet/fakes/SimpleEntityLookupInterface.java @@ -0,0 +1,11 @@ +package carpet.fakes; + +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.entity.EntityLike; + +import java.util.List; + +public interface SimpleEntityLookupInterface +{ + List getChunkEntities(ChunkPos chpos); +} diff --git a/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java b/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java index 592eaf53..cb5277ed 100644 --- a/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java +++ b/src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java @@ -13,6 +13,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.profiler.Profiler; import net.minecraft.world.chunk.WorldChunk; +import net.minecraft.world.entity.EntityLookup; import net.minecraft.world.explosion.Explosion; import net.minecraft.world.explosion.ExplosionBehavior; import net.minecraft.world.level.ServerWorldProperties; @@ -79,7 +80,14 @@ public class ServerWorld_scarpetMixin implements ServerWorldInterface @Final @Shadow private ServerWorldProperties worldProperties; + @Shadow @Final private ServerEntityManager entityManager; + public ServerWorldProperties getWorldPropertiesCM(){ return worldProperties; } + + @Override + public EntityLookup getEntityLookupCMPublic() { + return entityManager.getLookup(); + } } diff --git a/src/main/java/carpet/mixins/ThreadedAnvilChunkStorage_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/ThreadedAnvilChunkStorage_scarpetChunkCreationMixin.java index 96102f56..526a7c41 100644 --- a/src/main/java/carpet/mixins/ThreadedAnvilChunkStorage_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/ThreadedAnvilChunkStorage_scarpetChunkCreationMixin.java @@ -12,6 +12,10 @@ import java.util.concurrent.Future; import java.util.function.IntFunction; import java.util.stream.Collectors; +import carpet.fakes.SimpleEntityLookupInterface; +import carpet.fakes.ServerWorldInterface; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.MinecraftServer; import net.minecraft.server.ServerTask; import org.apache.commons.lang3.tuple.Pair; @@ -358,11 +362,17 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem { final ChunkPos pos = chunk.getPos(); + // remove entities + long longPos = pos.toLong(); + if (this.loadedChunks.contains(longPos) && chunk instanceof WorldChunk) + ((SimpleEntityLookupInterface)((ServerWorldInterface)world).getEntityLookupCMPublic()).getChunkEntities(pos).forEach(entity -> { if (!(entity instanceof PlayerEntity)) entity.discard();}); + + if (chunk instanceof WorldChunk) ((WorldChunk) chunk).setLoadedToWorld(false); if (this.loadedChunks.remove(pos.toLong()) && chunk instanceof WorldChunk) - this.world.unloadEntities((WorldChunk) chunk); + this.world.unloadEntities((WorldChunk) chunk); // block entities only ((ServerLightingProviderInterface) this.serverLightingProvider).invokeUpdateChunkStatus(pos); ((ServerLightingProviderInterface) this.serverLightingProvider).removeLightData(chunk); diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index e464c4a0..4d199af3 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -1469,13 +1469,13 @@ public class WorldAccess { ((CarpetContext)c).s.getMinecraftServer().submitAndJoin( () -> { Map report = ((ThreadedAnvilChunkStorageInterface) world.getChunkManager().threadedAnvilChunkStorage).regenerateChunkRegion(requestedChunks); - for (ChunkPos chpos: requestedChunks) + /*for (ChunkPos chpos: requestedChunks) // needed in 1.16 only { if (world.getChunk(chpos.x, chpos.z, ChunkStatus.FULL, false) != null) { WorldTools.forceChunkUpdate(chpos.getStartPos(), world); } - } + }*/ result[0] = MapValue.wrap(report.entrySet().stream().collect(Collectors.toMap( e -> new StringValue((String)((Map.Entry) e).getKey()), e -> new NumericValue((Integer)((Map.Entry) e).getValue()) diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index a9c777f6..1f9f0c2a 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -41,6 +41,7 @@ "CommandFunctionManager_tickMixin", "ThreadedAnvilChunkStorage_scarpetChunkCreationMixin", + "SimpleEntityLookup_scarpetMixin", "ChunkHolder_scarpetChunkCreationMixin", "ServerLightingProvider_scarpetMixin", "LevelPropagator_resetChunkInterface", From 9a4e15da48a42812571c90a98c29623251c034c1 Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 29 Jun 2021 17:28:58 -0300 Subject: [PATCH 108/115] mappings --- gradle.properties | 2 +- src/main/java/carpet/CarpetSettings.java | 2 +- .../java/carpet/commands/CounterCommand.java | 8 ++-- src/main/java/carpet/commands/LogCommand.java | 8 ++-- .../java/carpet/commands/PlayerCommand.java | 10 ++--- .../java/carpet/commands/SpawnCommand.java | 14 +++---- .../java/carpet/helpers/BlockRotator.java | 4 +- .../helpers/EntityPlayerActionPack.java | 4 +- src/main/java/carpet/helpers/TickSpeed.java | 2 +- .../MinecraftServer_tickspeedMixin.java | 33 +++++++-------- .../mixins/ReloadCommand_reloadAppsMixin.java | 2 +- .../SimpleEntityLookup_scarpetMixin.java | 28 +++++++++++++ ...hunkStorage_scarpetChunkCreationMixin.java | 16 +++---- .../java/carpet/script/CarpetScriptHost.java | 4 +- .../carpet/script/CarpetScriptServer.java | 6 +-- .../java/carpet/script/api/Auxiliary.java | 42 +++++++++---------- src/main/java/carpet/script/api/Entities.java | 14 +++---- .../java/carpet/script/api/Inventories.java | 6 +-- .../java/carpet/script/api/Scoreboards.java | 30 ++++++------- .../java/carpet/script/api/Threading.java | 6 +-- .../java/carpet/script/api/WorldAccess.java | 20 ++++----- .../script/command/CommandArgument.java | 10 ++--- .../carpet/script/utils/AppStoreManager.java | 4 +- .../script/utils/SnoopyCommandSource.java | 4 +- .../java/carpet/script/utils/SystemInfo.java | 38 ++++++++--------- .../script/value/NBTSerializableValue.java | 4 +- .../java/carpet/utils/CarpetProfiler.java | 2 +- src/main/java/carpet/utils/Messenger.java | 2 +- 28 files changed, 176 insertions(+), 149 deletions(-) create mode 100644 src/main/java/carpet/mixins/SimpleEntityLookup_scarpetMixin.java diff --git a/gradle.properties b/gradle.properties index 268e9ac1..9d76deec 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=1.17.1-pre1 - yarn_mappings=1.17.1-pre1+build.9 + yarn_mappings=1.17.1-pre1+build.19 loader_version=0.11.6 fabric_version=0.36.0+1.17 diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index e54bc992..83559aa9 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -636,7 +636,7 @@ public class CarpetSettings Messenger.m(source, "r view distance has to be between 0 and 32"); return null; } - MinecraftServer server = source.getMinecraftServer(); + MinecraftServer server = source.getServer(); if (server.isDedicated()) { diff --git a/src/main/java/carpet/commands/CounterCommand.java b/src/main/java/carpet/commands/CounterCommand.java index 973bfa01..484a7b4d 100644 --- a/src/main/java/carpet/commands/CounterCommand.java +++ b/src/main/java/carpet/commands/CounterCommand.java @@ -56,7 +56,7 @@ public class CounterCommand HopperCounter counter = HopperCounter.getCounter(color); if (counter == null) throw new CommandException(Messenger.s("Unknown wool color: "+color)); - for (BaseText message: counter.format(source.getMinecraftServer(), realtime, false)) + for (BaseText message: counter.format(source.getServer(), realtime, false)) { source.sendFeedback(message, false); } @@ -72,14 +72,14 @@ public class CounterCommand { if (color == null) { - HopperCounter.resetAll(source.getMinecraftServer(), false); + HopperCounter.resetAll(source.getServer(), false); Messenger.m(source, "w Restarted all counters"); } else { HopperCounter counter = HopperCounter.getCounter(color); if (counter == null) throw new CommandException(Messenger.s("Unknown wool color")); - counter.reset(source.getMinecraftServer()); + counter.reset(source.getServer()); Messenger.m(source, "w Restarted "+color+" counter"); } return 1; @@ -92,7 +92,7 @@ public class CounterCommand */ private static int listAllCounters(ServerCommandSource source, boolean realtime) { - for (BaseText message: HopperCounter.formatAll(source.getMinecraftServer(), realtime)) + for (BaseText message: HopperCounter.formatAll(source.getServer(), realtime)) { source.sendFeedback(message, false); } diff --git a/src/main/java/carpet/commands/LogCommand.java b/src/main/java/carpet/commands/LogCommand.java index e347885b..d7400183 100644 --- a/src/main/java/carpet/commands/LogCommand.java +++ b/src/main/java/carpet/commands/LogCommand.java @@ -133,7 +133,7 @@ public class LogCommand } private static int unsubFromAll(ServerCommandSource source, String player_name) { - PlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(player_name); + PlayerEntity player = source.getServer().getPlayerManager().getPlayer(player_name); if (player == null) { Messenger.m(source, "r No player specified"); @@ -148,7 +148,7 @@ public class LogCommand } private static int unsubFromLogger(ServerCommandSource source, String player_name, String logname) { - PlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(player_name); + PlayerEntity player = source.getServer().getPlayerManager().getPlayer(player_name); if (player == null) { Messenger.m(source, "r No player specified"); @@ -166,7 +166,7 @@ public class LogCommand private static int toggleSubscription(ServerCommandSource source, String player_name, String logName) { - PlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(player_name); + PlayerEntity player = source.getServer().getPlayerManager().getPlayer(player_name); if (player == null) { Messenger.m(source, "r No player specified"); @@ -190,7 +190,7 @@ public class LogCommand } private static int subscribePlayer(ServerCommandSource source, String player_name, String logname, String option) { - PlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(player_name); + PlayerEntity player = source.getServer().getPlayerManager().getPlayer(player_name); if (player == null) { Messenger.m(source, "r No player specified"); diff --git a/src/main/java/carpet/commands/PlayerCommand.java b/src/main/java/carpet/commands/PlayerCommand.java index 6c4e8fd0..3e24e3c6 100644 --- a/src/main/java/carpet/commands/PlayerCommand.java +++ b/src/main/java/carpet/commands/PlayerCommand.java @@ -136,7 +136,7 @@ public class PlayerCommand private static ServerPlayerEntity getPlayer(CommandContext context) { String playerName = StringArgumentType.getString(context, "player"); - MinecraftServer server = context.getSource().getMinecraftServer(); + MinecraftServer server = context.getSource().getServer(); return server.getPlayerManager().getPlayer(playerName); } @@ -158,7 +158,7 @@ public class PlayerCommand return false; } - if (!context.getSource().getMinecraftServer().getPlayerManager().isOperator(sendingPlayer.getGameProfile())) + if (!context.getSource().getServer().getPlayerManager().isOperator(sendingPlayer.getGameProfile())) { if (sendingPlayer != player && !(player instanceof EntityPlayerMPFake)) { @@ -181,7 +181,7 @@ public class PlayerCommand private static boolean cantSpawn(CommandContext context) { String playerName = StringArgumentType.getString(context, "player"); - MinecraftServer server = context.getSource().getMinecraftServer(); + MinecraftServer server = context.getSource().getServer(); PlayerManager manager = server.getPlayerManager(); PlayerEntity player = manager.getPlayer(playerName); if (player != null) @@ -274,13 +274,13 @@ public class PlayerCommand } catch (CommandSyntaxException ignored) {} String playerName = StringArgumentType.getString(context, "player"); - if (playerName.length()>maxPlayerLength(source.getMinecraftServer())) + if (playerName.length()>maxPlayerLength(source.getServer())) { Messenger.m(context.getSource(), "rb Player name: "+playerName+" is too long"); return 0; } - MinecraftServer server = source.getMinecraftServer(); + MinecraftServer server = source.getServer(); if (!World.isValid(new BlockPos(pos.x, pos.y, pos.z))) { Messenger.m(context.getSource(), "rb Player "+playerName+" cannot be placed outside of the world"); diff --git a/src/main/java/carpet/commands/SpawnCommand.java b/src/main/java/carpet/commands/SpawnCommand.java index 5d1e075e..1f9010d4 100644 --- a/src/main/java/carpet/commands/SpawnCommand.java +++ b/src/main/java/carpet/commands/SpawnCommand.java @@ -146,8 +146,8 @@ public class SpawnCommand Math.max(a.getY(), b.getY()), Math.max(a.getZ(), b.getZ()) ); } - SpawnReporter.reset_spawn_stats(source.getMinecraftServer(), false); - SpawnReporter.track_spawns = (long) source.getMinecraftServer().getTicks(); + SpawnReporter.reset_spawn_stats(source.getServer(), false); + SpawnReporter.track_spawns = (long) source.getServer().getTicks(); SpawnReporter.lower_spawning_limit = lsl; SpawnReporter.upper_spawning_limit = usl; Messenger.m(source, "gi Spawning tracking started."); @@ -157,7 +157,7 @@ public class SpawnCommand private static int stopTracking(ServerCommandSource source) { Messenger.send(source, SpawnReporter.tracking_report(source.getWorld())); - SpawnReporter.reset_spawn_stats(source.getMinecraftServer(),false); + SpawnReporter.reset_spawn_stats(source.getServer(),false); SpawnReporter.track_spawns = 0L; SpawnReporter.lower_spawning_limit = null; SpawnReporter.upper_spawning_limit = null; @@ -175,19 +175,19 @@ public class SpawnCommand private static int runTest(ServerCommandSource source, int ticks, String counter) { //stop tracking - SpawnReporter.reset_spawn_stats(source.getMinecraftServer(),false); + SpawnReporter.reset_spawn_stats(source.getServer(),false); //start tracking - SpawnReporter.track_spawns = (long) source.getMinecraftServer().getTicks(); + SpawnReporter.track_spawns = (long) source.getServer().getTicks(); //counter reset if (counter == null) { - HopperCounter.resetAll(source.getMinecraftServer(), false); + HopperCounter.resetAll(source.getServer(), false); } else { HopperCounter hCounter = HopperCounter.getCounter(counter); if (hCounter != null) - hCounter.reset(source.getMinecraftServer()); + hCounter.reset(source.getServer()); } diff --git a/src/main/java/carpet/helpers/BlockRotator.java b/src/main/java/carpet/helpers/BlockRotator.java index 2d7f6b6a..f2ee22d7 100644 --- a/src/main/java/carpet/helpers/BlockRotator.java +++ b/src/main/java/carpet/helpers/BlockRotator.java @@ -226,7 +226,7 @@ public class BlockRotator { Direction sourceFace = source.getBlockState().get(DispenserBlock.FACING); World world = source.getWorld(); - BlockPos blockpos = source.getBlockPos().offset(sourceFace); // offset + BlockPos blockpos = source.getPos().offset(sourceFace); // offset BlockState iblockstate = world.getBlockState(blockpos); Block block = iblockstate.getBlock(); @@ -274,7 +274,7 @@ public class BlockRotator } } // Send block update to the block that just have been rotated. - world.updateNeighbor(blockpos, block, source.getBlockPos()); + world.updateNeighbor(blockpos, block, source.getPos()); return stack; } diff --git a/src/main/java/carpet/helpers/EntityPlayerActionPack.java b/src/main/java/carpet/helpers/EntityPlayerActionPack.java index 4c63e35e..e722abbd 100644 --- a/src/main/java/carpet/helpers/EntityPlayerActionPack.java +++ b/src/main/java/carpet/helpers/EntityPlayerActionPack.java @@ -487,7 +487,7 @@ public class EntityPlayerActionPack boolean execute(ServerPlayerEntity player, Action action) { player.updateLastActionTime(); - player.method_37413(false); // dropSelectedItem + player.dropSelectedItem(false); // dropSelectedItem return false; } }, @@ -497,7 +497,7 @@ public class EntityPlayerActionPack boolean execute(ServerPlayerEntity player, Action action) { player.updateLastActionTime(); - player.method_37413(true); // dropSelectedItem + player.dropSelectedItem(true); // dropSelectedItem return false; } }, diff --git a/src/main/java/carpet/helpers/TickSpeed.java b/src/main/java/carpet/helpers/TickSpeed.java index ffee2e27..0ee668be 100644 --- a/src/main/java/carpet/helpers/TickSpeed.java +++ b/src/main/java/carpet/helpers/TickSpeed.java @@ -147,7 +147,7 @@ public class TickSpeed time_warp_start_time = 0; if (tick_warp_callback != null) { - CommandManager icommandmanager = tick_warp_sender.getMinecraftServer().getCommandManager(); + CommandManager icommandmanager = tick_warp_sender.getServer().getCommandManager(); try { icommandmanager.execute(tick_warp_sender, tick_warp_callback); diff --git a/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java b/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java index 29acd733..6a94c2eb 100644 --- a/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java +++ b/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java @@ -46,24 +46,23 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec @Shadow private long nextTickTimestamp; - @Shadow protected abstract void method_16208(); - @Shadow private volatile boolean loading; - //@Shadow protected abstract void startMonitor(TickDurationMonitor monitor); - - @Shadow protected abstract void startMonitor(); - @Shadow private long lastTimeReference; @Shadow private boolean waitingForNextTick; @Shadow public abstract Iterable getWorlds(); - @Shadow protected abstract void endMonitor(); - - @Shadow private boolean profilerEnabled; @Shadow private int ticks; + + @Shadow protected abstract void runTasksTillTickEnd(); + + @Shadow protected abstract void startTickMetrics(); + + @Shadow protected abstract void endTickMetrics(); + + @Shadow private boolean needsDebugSetup; CarpetProfiler.ProfilerToken currentSection; private float carpetMsptAccum = 0.0f; @@ -125,15 +124,15 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec this.lastTimeReference = this.timeReference; } - if (this.profilerEnabled) { - this.profilerEnabled = false; + if (this.needsDebugSetup) { + this.needsDebugSetup = false; this.profilerTimings = Pair.of(Util.getMeasuringTimeNano(), ticks); //this.field_33978 = new MinecraftServer.class_6414(Util.getMeasuringTimeNano(), this.ticks); } this.timeReference += msThisTick;//50L; //TickDurationMonitor tickDurationMonitor = TickDurationMonitor.create("Server"); //this.startMonitor(tickDurationMonitor); - this.startMonitor(); + this.startTickMetrics(); this.profiler.push("tick"); this.tick(TickSpeed.time_warp_start_time != 0 ? ()->true : this::shouldKeepTicking); this.profiler.swap("nextTickWait"); @@ -144,9 +143,9 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec this.waitingForNextTick = true; this.nextTickTimestamp = Math.max(Util.getMeasuringTimeMs() + /*50L*/ msThisTick, this.timeReference); // run all tasks (this will not do a lot when warping), but that's fine since we already run them - this.method_16208(); + this.runTasksTillTickEnd(); this.profiler.pop(); - this.endMonitor(); + this.endTickMetrics(); this.loading = true; } @@ -158,7 +157,7 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec @Inject(method = "isDebugRunning", at = @At("HEAD"), cancellable = true) public void isCMDebugRunning(CallbackInfoReturnable cir) { - cir.setReturnValue(profilerEnabled || profilerTimings != null); + cir.setReturnValue(needsDebugSetup || profilerTimings != null); } @Inject(method = "stopDebug", at = @At("HEAD"), cancellable = true) public void stopCMDebug(CallbackInfoReturnable cir) @@ -232,12 +231,12 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec CarpetProfiler.end_current_section(currentSection); } - @Inject(method = "method_16208", at = @At("HEAD")) + @Inject(method = "runTasksTillTickEnd", at = @At("HEAD")) private void startAsync(CallbackInfo ci) { currentSection = CarpetProfiler.start_section(null, "Async Tasks", CarpetProfiler.TYPE.GENERAL); } - @Inject(method = "method_16208", at = @At( + @Inject(method = "runTasksTillTickEnd", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;runTasks(Ljava/util/function/BooleanSupplier;)V", shift = At.Shift.BEFORE diff --git a/src/main/java/carpet/mixins/ReloadCommand_reloadAppsMixin.java b/src/main/java/carpet/mixins/ReloadCommand_reloadAppsMixin.java index bf460603..ef5a8644 100644 --- a/src/main/java/carpet/mixins/ReloadCommand_reloadAppsMixin.java +++ b/src/main/java/carpet/mixins/ReloadCommand_reloadAppsMixin.java @@ -18,6 +18,6 @@ public class ReloadCommand_reloadAppsMixin { private static void onReload(CommandContext context, CallbackInfoReturnable cir) { // can't fetch here the reference to the server - CarpetServer.onReload(context.getSource().getMinecraftServer()); + CarpetServer.onReload(context.getSource().getServer()); } } diff --git a/src/main/java/carpet/mixins/SimpleEntityLookup_scarpetMixin.java b/src/main/java/carpet/mixins/SimpleEntityLookup_scarpetMixin.java new file mode 100644 index 00000000..eeb85747 --- /dev/null +++ b/src/main/java/carpet/mixins/SimpleEntityLookup_scarpetMixin.java @@ -0,0 +1,28 @@ +package carpet.mixins; + +import carpet.fakes.SimpleEntityLookupInterface; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.entity.EntityLike; +import net.minecraft.world.entity.EntityTrackingSection; +import net.minecraft.world.entity.SectionedEntityCache; +import net.minecraft.world.entity.SimpleEntityLookup; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +import java.util.List; +import java.util.stream.Collectors; + +@Mixin(SimpleEntityLookup.class) +public class SimpleEntityLookup_scarpetMixin implements SimpleEntityLookupInterface +{ + + @Shadow @Final private SectionedEntityCache cache; + + @Override + public List getChunkEntities(ChunkPos chpos) { + return this.cache.getTrackingSections(chpos.toLong()).flatMap(EntityTrackingSection::stream).collect(Collectors.toList()); + } +} + + diff --git a/src/main/java/carpet/mixins/ThreadedAnvilChunkStorage_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/ThreadedAnvilChunkStorage_scarpetChunkCreationMixin.java index 526a7c41..3940b5ee 100644 --- a/src/main/java/carpet/mixins/ThreadedAnvilChunkStorage_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/ThreadedAnvilChunkStorage_scarpetChunkCreationMixin.java @@ -78,7 +78,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem @Shadow @Final - private ServerLightingProvider serverLightingProvider; + private ServerLightingProvider lightingProvider; @Shadow @Final @@ -289,12 +289,12 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem this.currentChunkHolders.get(pos.toLong()).getChunkAt(ChunkStatus.EMPTY, (ThreadedAnvilChunkStorage) (Object) this); final Chunk chunk = this.getCurrentChunk(pos); if (!(chunk.getStatus().isAtLeast(ChunkStatus.LIGHT.getPrevious()))) return; - ((ServerLightingProviderInterface) this.serverLightingProvider).removeLightData(chunk); + ((ServerLightingProviderInterface) this.lightingProvider).removeLightData(chunk); this.addRelightTicket(pos); final CompletableFuture lightFuture = this.getRegion (pos, 1, (pos_) -> ChunkStatus.LIGHT) .thenCompose( either -> either.map( - list -> ((ServerLightingProviderInterface) this.serverLightingProvider).relight(chunk), + list -> ((ServerLightingProviderInterface) this.lightingProvider).relight(chunk), unloaded -> { this.releaseRelightTicket(pos); return CompletableFuture.completedFuture(null); @@ -374,8 +374,8 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem if (this.loadedChunks.remove(pos.toLong()) && chunk instanceof WorldChunk) this.world.unloadEntities((WorldChunk) chunk); // block entities only - ((ServerLightingProviderInterface) this.serverLightingProvider).invokeUpdateChunkStatus(pos); - ((ServerLightingProviderInterface) this.serverLightingProvider).removeLightData(chunk); + ((ServerLightingProviderInterface) this.lightingProvider).invokeUpdateChunkStatus(pos); + ((ServerLightingProviderInterface) this.lightingProvider).removeLightData(chunk); this.worldGenerationProgressListener.setChunkStatus(pos, null); } @@ -388,7 +388,7 @@ 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(), world, this.serverLightingProvider, this.chunkTaskPrioritySystem, (ChunkHolder.PlayersWatchingChunkProvider) this); + final ChunkHolder newHolder = new ChunkHolder(cPos, oldHolder.getLevel(), world, this.lightingProvider, this.chunkTaskPrioritySystem, (ChunkHolder.PlayersWatchingChunkProvider) this); ((ChunkHolderInterface) newHolder).setDefaultProtoChunk(cPos, this.mainThreadExecutor, world); this.currentChunkHolders.put(pos, newHolder); @@ -401,7 +401,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem // Remove light for affected neighbors for (final Chunk chunk : affectedNeighbors) - ((ServerLightingProviderInterface) this.serverLightingProvider).removeLightData(chunk); + ((ServerLightingProviderInterface) this.lightingProvider).removeLightData(chunk); // Schedule relighting of neighbors @@ -418,7 +418,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem lightFutures.add(this.getRegion (pos, 1, (pos_) -> ChunkStatus.LIGHT).thenCompose( either -> either.map( - list -> ((ServerLightingProviderInterface) this.serverLightingProvider).relight(chunk), + list -> ((ServerLightingProviderInterface) this.lightingProvider).relight(chunk), unloaded -> { this.releaseRelightTicket(pos); return CompletableFuture.completedFuture(null); diff --git a/src/main/java/carpet/script/CarpetScriptHost.java b/src/main/java/carpet/script/CarpetScriptHost.java index e7b5b8ca..2ef6515b 100644 --- a/src/main/java/carpet/script/CarpetScriptHost.java +++ b/src/main/java/carpet/script/CarpetScriptHost.java @@ -642,7 +642,7 @@ public class CarpetScriptHost extends ScriptHost { if (optionalTarget == null) { - for (ServerPlayerEntity player : source.getMinecraftServer().getPlayerManager().getPlayerList()) + for (ServerPlayerEntity player : source.getServer().getPlayerManager().getPlayerList()) { CarpetScriptHost host = (CarpetScriptHost) retrieveForExecution(player.getEntityName()); targets.add(host); @@ -651,7 +651,7 @@ public class CarpetScriptHost extends ScriptHost } else { - ServerPlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(optionalTarget); + ServerPlayerEntity player = source.getServer().getPlayerManager().getPlayer(optionalTarget); if (player != null) { CarpetScriptHost host = (CarpetScriptHost) retrieveForExecution(player.getEntityName()); diff --git a/src/main/java/carpet/script/CarpetScriptServer.java b/src/main/java/carpet/script/CarpetScriptServer.java index e76a61ba..f6000cb5 100644 --- a/src/main/java/carpet/script/CarpetScriptServer.java +++ b/src/main/java/carpet/script/CarpetScriptServer.java @@ -383,7 +383,7 @@ public class CarpetScriptServer ServerPlayerEntity target = null; if (optionalTarget != null) { - target = sender.getMinecraftServer().getPlayerManager().getPlayer(optionalTarget); + target = sender.getServer().getPlayerManager().getPlayer(optionalTarget); if (target == null) return false; } int successes = signal(sender, target, hostname, udf, argv, true ); @@ -436,8 +436,8 @@ public class CarpetScriptServer { // getPlayer will always return nonnull cause retrieve for execution only returns hosts for existing players. ServerCommandSource executingSource = host.perUser - ? source.getMinecraftServer().getPlayerManager().getPlayer(host.user).getCommandSource() - : source.getMinecraftServer().getCommandSource(); + ? source.getServer().getPlayerManager().getPlayer(host.user).getCommandSource() + : source.getServer().getCommandSource(); try { host.callUDF(BlockPos.ORIGIN, source.withLevel(CarpetSettings.runPermissionLevel), udf, argv); diff --git a/src/main/java/carpet/script/api/Auxiliary.java b/src/main/java/carpet/script/api/Auxiliary.java index 9a55f98e..55996022 100644 --- a/src/main/java/carpet/script/api/Auxiliary.java +++ b/src/main/java/carpet/script/api/Auxiliary.java @@ -198,7 +198,7 @@ public class Auxiliary { { CarpetContext cc = (CarpetContext)c; if (lv.size() == 0) return ListValue.wrap(Registry.PARTICLE_TYPE.getIds().stream().map(ValueConversions::of)); - MinecraftServer ms = cc.s.getMinecraftServer(); + MinecraftServer ms = cc.s.getServer(); ServerWorld world = cc.s.getWorld(); Vector3Argument locator = Vector3Argument.findIn(lv, 1); String particleName = lv.get(0).getString(); @@ -270,7 +270,7 @@ public class Auxiliary { } else { - player = cc.s.getMinecraftServer().getPlayerManager().getPlayer(playerValue.getString()); + player = cc.s.getServer().getPlayerManager().getPlayer(playerValue.getString()); } } } @@ -310,7 +310,7 @@ public class Auxiliary { } else { - player = cc.s.getMinecraftServer().getPlayerManager().getPlayer(playerValue.getString()); + player = cc.s.getServer().getPlayerManager().getPlayer(playerValue.getString()); } } } @@ -485,7 +485,7 @@ public class Auxiliary { { if (lv.size() == 0 || lv.size() > 2) throw new InternalExpressionException("'print' takes one or two arguments"); ServerCommandSource s = ((CarpetContext)c).s; - MinecraftServer server = s.getMinecraftServer(); + MinecraftServer server = s.getServer(); Value res = lv.get(0); List targets = null; if (lv.size() == 2) @@ -516,7 +516,7 @@ public class Auxiliary { if (lv.size() < 2) throw new InternalExpressionException("'display_title' needs at least a target, type and message, and optionally times"); Value pVal = lv.get(0); if (!(pVal instanceof ListValue)) pVal = ListValue.of(pVal); - MinecraftServer server = ((CarpetContext)c).s.getMinecraftServer(); + MinecraftServer server = ((CarpetContext)c).s.getServer(); Stream targets = ((ListValue) pVal).getItems().stream().map(v -> { ServerPlayerEntity player = EntityValue.getPlayerByValue(server, v); @@ -590,7 +590,7 @@ public class Auxiliary { map.put(target.getEntityName(), (BaseText) title); total.getAndIncrement(); }); - HUDController.update_hud(((CarpetContext)c).s.getMinecraftServer(), targetList); + HUDController.update_hud(((CarpetContext)c).s.getServer(), targetList); return NumericValue.of(total.get()); } TitleFadeS2CPacket timesPacket; // TimesPacket @@ -630,7 +630,7 @@ public class Auxiliary { { Text[] error = {null}; List output = new ArrayList<>(); - Value retval = new NumericValue(s.getMinecraftServer().getCommandManager().execute( + Value retval = new NumericValue(s.getServer().getCommandManager().execute( new SnoopyCommandSource(s, error, output), lv.get(0).getString()) ); @@ -649,15 +649,15 @@ public class Auxiliary { expression.addContextFunction("save", 0, (c, t, lv) -> { ServerCommandSource s = ((CarpetContext)c).s; - s.getMinecraftServer().getPlayerManager().saveAllPlayerData(); - s.getMinecraftServer().save(true,true,true); + s.getServer().getPlayerManager().saveAllPlayerData(); + s.getServer().save(true,true,true); s.getWorld().getChunkManager().tick(() -> true); CarpetScriptServer.LOG.warn("Saved chunks"); return Value.TRUE; }); expression.addContextFunction("tick_time", 0, (c, t, lv) -> - new NumericValue(((CarpetContext) c).s.getMinecraftServer().getTicks())); + new NumericValue(((CarpetContext) c).s.getServer().getTicks())); expression.addContextFunction("world_time", 0, (c, t, lv) -> new NumericValue(((CarpetContext) c).s.getWorld().getTime())); @@ -678,9 +678,9 @@ public class Auxiliary { { //assuming we are in the tick world section // might be off one tick when run in the off tasks or asynchronously. - int currentReportedTick = ((CarpetContext) c).s.getMinecraftServer().getTicks()-1; + int currentReportedTick = ((CarpetContext) c).s.getServer().getTicks()-1; List ticks = new ArrayList<>(100); - final long[] tickArray = ((CarpetContext) c).s.getMinecraftServer().lastTickLengths; + final long[] tickArray = ((CarpetContext) c).s.getServer().lastTickLengths; for (int i=currentReportedTick+100; i > currentReportedTick; i--) { ticks.add(new NumericValue(((double)tickArray[i % 100])/1000000.0)); @@ -692,12 +692,12 @@ public class Auxiliary { expression.addContextFunction("game_tick", -1, (c, t, lv) -> { CarpetContext cc = (CarpetContext)c; ServerCommandSource s = cc.s; - if (!s.getMinecraftServer().isOnThread()) throw new InternalExpressionException("Unable to run ticks from threads"); + if (!s.getServer().isOnThread()) throw new InternalExpressionException("Unable to run ticks from threads"); if (CarpetServer.scriptServer.tickDepth > 16) throw new InternalExpressionException("'game_tick' function caused other 'game_tick' functions to run. You should not allow that."); try { CarpetServer.scriptServer.tickDepth ++; - ((MinecraftServerInterface) s.getMinecraftServer()).forceTick(() -> System.nanoTime() - CarpetServer.scriptServer.tickStart < 50000000L); + ((MinecraftServerInterface) s.getServer()).forceTick(() -> System.nanoTime() - CarpetServer.scriptServer.tickStart < 50000000L); if (lv.size() > 0) { long ms_total = NumericValue.asNumber(lv.get(0)).getLong(); @@ -747,13 +747,13 @@ public class Auxiliary { ValueConversions.of( ((CarpetContext)c).s.getWorld())); expression.addContextFunction("view_distance", 0, (c, t, lv) -> - new NumericValue(((CarpetContext)c).s.getMinecraftServer().getPlayerManager().getViewDistance())); + new NumericValue(((CarpetContext)c).s.getServer().getPlayerManager().getViewDistance())); // lazy due to passthrough and context changing ability expression.addLazyFunction("in_dimension", 2, (c, t, lv) -> { ServerCommandSource outerSource = ((CarpetContext)c).s; Value dimensionValue = lv.get(0).evalValue(c); - World world = ValueConversions.dimFromValue(dimensionValue, outerSource.getMinecraftServer()); + World world = ValueConversions.dimFromValue(dimensionValue, outerSource.getServer()); if (world == outerSource.getWorld()) return lv.get(1); ServerCommandSource innerSource = outerSource.withWorld((ServerWorld)world); Context newCtx = c.recreate(); @@ -791,7 +791,7 @@ public class Auxiliary { throw new InternalExpressionException("'plop' needs extra argument indicating what to plop"); String what = lv.get(locator.offset).getString(); Value [] result = new Value[]{Value.NULL}; - ((CarpetContext)c).s.getMinecraftServer().submitAndJoin( () -> + ((CarpetContext)c).s.getServer().submitAndJoin( () -> { Boolean res = FeatureGenerator.plop(what, ((CarpetContext) c).s.getWorld(), locator.block.getPos()); @@ -969,7 +969,7 @@ public class Auxiliary { expression.addContextFunction("statistic", 3, (c, t, lv) -> { CarpetContext cc = (CarpetContext)c; - ServerPlayerEntity player = EntityValue.getPlayerByValue(cc.s.getMinecraftServer(), lv.get(0)); + ServerPlayerEntity player = EntityValue.getPlayerByValue(cc.s.getServer(), lv.get(0)); if (player == null) return Value.NULL; Identifier category; Identifier statName; @@ -1030,7 +1030,7 @@ public class Auxiliary { expression.addContextFunction("nbt_storage", -1, (c, t, lv) -> { if (lv.size() > 2) throw new InternalExpressionException("'nbt_storage' requires 0, 1 or 2 arguments."); CarpetContext cc = (CarpetContext) c; - DataCommandStorage storage = cc.s.getMinecraftServer().getDataCommandStorage(); + DataCommandStorage storage = cc.s.getServer().getDataCommandStorage(); if (lv.size() == 0) return ListValue.wrap(storage.getIds().map(i -> new StringValue(nameFromRegistryId(i))).collect(Collectors.toList())); String key = lv.get(0).getString(); @@ -1049,7 +1049,7 @@ public class Auxiliary { CarpetContext cc = (CarpetContext)c; String origName = lv.get(0).getString(); String name = InputValidator.validateSimpleString(origName, true); - MinecraftServer server = cc.s.getMinecraftServer(); + MinecraftServer server = cc.s.getServer(); for (String dpName : server.getDataPackManager().getNames()) { if (dpName.equalsIgnoreCase("file/"+name+".zip") || @@ -1114,7 +1114,7 @@ public class Auxiliary { expression.addContextFunction("enable_hidden_dimensions", 0, (c, t, lv) -> { CarpetContext cc = (CarpetContext)c; // from minecraft.server.Main.main - MinecraftServer server = cc.s.getMinecraftServer(); + MinecraftServer server = cc.s.getServer(); LevelStorage.Session session = ((MinecraftServerInterface)server).getCMSession(); DataPackSettings dataPackSettings = session.getDataPackSettings(); ResourcePackManager resourcePackManager = server.getDataPackManager(); diff --git a/src/main/java/carpet/script/api/Entities.java b/src/main/java/carpet/script/api/Entities.java index 091e3f1f..db68f7be 100644 --- a/src/main/java/carpet/script/api/Entities.java +++ b/src/main/java/carpet/script/api/Entities.java @@ -48,7 +48,7 @@ public class Entities { CarpetContext cc = (CarpetContext)c; if (cc.host.user != null) { - ServerPlayerEntity player = cc.s.getMinecraftServer().getPlayerManager().getPlayer(cc.host.user); + ServerPlayerEntity player = cc.s.getServer().getPlayerManager().getPlayer(cc.host.user); return EntityValue.of(player); } Entity callingEntity = cc.s.getEntity(); @@ -62,7 +62,7 @@ public class Entities { if ("all".equalsIgnoreCase(playerName)) { retval = ListValue.wrap( - ((CarpetContext)c).s.getMinecraftServer().getPlayerManager().getPlayerList(). + ((CarpetContext)c).s.getServer().getPlayerManager().getPlayerList(). stream().map(EntityValue::new).collect(Collectors.toList())); } else if ("*".equalsIgnoreCase(playerName)) @@ -97,7 +97,7 @@ public class Entities { } else { - ServerPlayerEntity player = ((CarpetContext) c).s.getMinecraftServer().getPlayerManager().getPlayer(playerName); + ServerPlayerEntity player = ((CarpetContext) c).s.getServer().getPlayerManager().getPlayer(playerName); if (player != null) retval = new EntityValue(player); } @@ -167,7 +167,7 @@ public class Entities { { String who = lv.get(0).getString(); ServerCommandSource source = ((CarpetContext)c).s; - EntityValue.EntityClassDescriptor eDesc = EntityValue.getEntityDescriptor(who, source.getMinecraftServer()); + EntityValue.EntityClassDescriptor eDesc = EntityValue.getEntityDescriptor(who, source.getServer()); List entityList = source.getWorld().getEntitiesByType(eDesc.directType, eDesc.filteringPredicate); return ListValue.wrap(entityList.stream().map(EntityValue::new).collect(Collectors.toList())); }); @@ -195,7 +195,7 @@ public class Entities { throw new InternalExpressionException("Range of 'entity_area' cannot come from a block argument"); Vec3d range = rangeLocator.vec; Box area = centerBox.expand(range.x, range.y, range.z); - EntityValue.EntityClassDescriptor eDesc = EntityValue.getEntityDescriptor(who, cc.s.getMinecraftServer()); + EntityValue.EntityClassDescriptor eDesc = EntityValue.getEntityDescriptor(who, cc.s.getServer()); List entityList = cc.s.getWorld().getEntitiesByType(eDesc.directType, area,eDesc.filteringPredicate); return ListValue.wrap(entityList.stream().map(EntityValue::new).collect(Collectors.toList())); }); @@ -257,7 +257,7 @@ public class Entities { { if (lv.size() > 1) throw new InternalExpressionException("'entity_types' requires one or no arguments"); String desc = (lv.size() == 1)?lv.get(0).getString():"*"; - return EntityValue.getEntityDescriptor(desc, ((CarpetContext) c).s.getMinecraftServer()).listValue; + return EntityValue.getEntityDescriptor(desc, ((CarpetContext) c).s.getServer()).listValue; }); expression.addContextFunction("entity_load_handler", -1, (c, t, lv) -> @@ -269,7 +269,7 @@ public class Entities { ? ((ListValue) entityValue).getItems().stream().map(Value::getString).collect(Collectors.toList()) : Collections.singletonList(entityValue.getString()); Set> types = new HashSet<>(); - descriptors.forEach(s -> types.addAll(EntityValue.getEntityDescriptor(s, ((CarpetContext) c).s.getMinecraftServer()).typeList)); + descriptors.forEach(s -> types.addAll(EntityValue.getEntityDescriptor(s, ((CarpetContext) c).s.getServer()).typeList)); FunctionArgument funArg = FunctionArgument.findIn(c, expression.module, lv, 1, true, false); CarpetEventServer events = ((CarpetScriptHost)c.host).getScriptServer().events; if (funArg.function == null) diff --git a/src/main/java/carpet/script/api/Inventories.java b/src/main/java/carpet/script/api/Inventories.java index 70d4dfac..638ad17e 100644 --- a/src/main/java/carpet/script/api/Inventories.java +++ b/src/main/java/carpet/script/api/Inventories.java @@ -65,7 +65,7 @@ public class Inventories { if (lv.size() == 0) return ListValue.wrap(Registry.ITEM.getIds().stream().map(ValueConversions::of).collect(Collectors.toList())); CarpetContext cc = (CarpetContext)c; - TagManager tagManager = cc.s.getMinecraftServer().getTagManager(); + TagManager tagManager = cc.s.getServer().getTagManager(); String tag = lv.get(0).getString(); net.minecraft.tag.Tag itemTag = tagManager.getOrCreateTagGroup(Registry.ITEM_KEY).getTag(new Identifier(tag)); if (itemTag == null) return Value.NULL; @@ -75,7 +75,7 @@ public class Inventories { expression.addContextFunction("item_tags", -1, (c, t, lv) -> { CarpetContext cc = (CarpetContext)c; - TagManager tagManager = cc.s.getMinecraftServer().getTagManager(); + TagManager tagManager = cc.s.getServer().getTagManager(); if (lv.size() == 0) return ListValue.wrap(tagManager.getOrCreateTagGroup(Registry.ITEM_KEY).getTagIds().stream().map(ValueConversions::of).collect(Collectors.toList())); Item item = NBTSerializableValue.parseItem(lv.get(0).getString()).getItem(); @@ -106,7 +106,7 @@ public class Inventories { } } List> recipes; - recipes = ((RecipeManagerInterface) cc.s.getMinecraftServer().getRecipeManager()).getAllMatching(type, new Identifier(recipeName)); + recipes = ((RecipeManagerInterface) cc.s.getServer().getRecipeManager()).getAllMatching(type, new Identifier(recipeName)); if (recipes.isEmpty()) return Value.NULL; List recipesOutput = new ArrayList<>(); diff --git a/src/main/java/carpet/script/api/Scoreboards.java b/src/main/java/carpet/script/api/Scoreboards.java index ea21a957..8b52627e 100644 --- a/src/main/java/carpet/script/api/Scoreboards.java +++ b/src/main/java/carpet/script/api/Scoreboards.java @@ -69,7 +69,7 @@ public class Scoreboards { expression.addContextFunction("scoreboard", -1, (c, t, lv) -> { CarpetContext cc = (CarpetContext)c; - Scoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard(); + Scoreboard scoreboard = cc.s.getServer().getScoreboard(); if (lv.size()==0) return ListValue.wrap(scoreboard.getObjectiveNames().stream().map(StringValue::new).collect(Collectors.toList())); String objectiveName = lv.get(0).getString(); @@ -102,7 +102,7 @@ public class Scoreboards { { if (lv.size()==0) throw new InternalExpressionException("'scoreboard_remove' requires at least one parameter"); CarpetContext cc = (CarpetContext)c; - Scoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard(); + Scoreboard scoreboard = cc.s.getServer().getScoreboard(); String objectiveName = lv.get(0).getString(); ScoreboardObjective objective = scoreboard.getObjective(objectiveName); if (objective == null) return Value.FALSE; @@ -125,7 +125,7 @@ public class Scoreboards { expression.addContextFunction("scoreboard_add", -1, (c, t, lv)-> { CarpetContext cc = (CarpetContext)c; - Scoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard(); + Scoreboard scoreboard = cc.s.getServer().getScoreboard(); if (lv.size() == 0 || lv.size()>2) throw new InternalExpressionException("'scoreboard_add' should have one or two parameters"); String objectiveName = lv.get(0).getString(); ScoreboardCriterion criterion; @@ -163,7 +163,7 @@ public class Scoreboards { { if(lv.size() < 2) throw new InternalExpressionException("'scoreboard_property' requires at least two parameters"); CarpetContext cc = (CarpetContext)c; - Scoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard(); + Scoreboard scoreboard = cc.s.getServer().getScoreboard(); ScoreboardObjective objective = scoreboard.getObjective(lv.get(0).getString()); if(objective == null) return Value.NULL; @@ -228,7 +228,7 @@ public class Scoreboards { expression.addContextFunction("scoreboard_display", 2, (c, t, lv) -> { CarpetContext cc = (CarpetContext)c; - Scoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard(); + Scoreboard scoreboard = cc.s.getServer().getScoreboard(); String location = lv.get(0).getString(); int slot = Scoreboard.getDisplaySlotId(location); if (slot < 0) throw new InternalExpressionException("Invalid objective slot: "+location); @@ -249,7 +249,7 @@ public class Scoreboards { { if(lv.size() > 1) throw new InternalExpressionException("'team_list' requires zero or one parameters"); CarpetContext cc = (CarpetContext)c; - ServerScoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard(); + ServerScoreboard scoreboard = cc.s.getServer().getScoreboard(); if(lv.size() == 0) return ListValue.wrap(scoreboard.getTeamNames().stream().map(StringValue::of).collect(Collectors.toList())); if (lv.size() != 1) return Value.NULL; @@ -264,7 +264,7 @@ public class Scoreboards { if(!(lv.size() < 3 && lv.size() > 0)) throw new InternalExpressionException("'team_add' requires one or two parameters"); CarpetContext cc = (CarpetContext)c; - ServerScoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard(); + ServerScoreboard scoreboard = cc.s.getServer().getScoreboard(); String teamName = lv.get(0).getString(); if(lv.size() == 1) @@ -287,7 +287,7 @@ public class Scoreboards { expression.addContextFunction("team_remove", 1, (c, t, lv) -> { CarpetContext cc = (CarpetContext)c; - ServerScoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard(); + ServerScoreboard scoreboard = cc.s.getServer().getScoreboard(); Value teamVal = lv.get(0); String team = teamVal.getString(); if(scoreboard.getTeam(team) == null) return Value.NULL; @@ -299,7 +299,7 @@ public class Scoreboards { expression.addContextFunction("team_leave", 1, (c, t, lv) -> { CarpetContext cc = (CarpetContext)c; - ServerScoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard(); + ServerScoreboard scoreboard = cc.s.getServer().getScoreboard(); Value playerVal = lv.get(0); String player = EntityValue.getPlayerNameByValue(playerVal); if(player == null) return Value.NULL; @@ -309,7 +309,7 @@ public class Scoreboards { expression.addContextFunction("team_property", -1, (c, t, lv) -> { CarpetContext cc = (CarpetContext)c; - ServerScoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard(); + ServerScoreboard scoreboard = cc.s.getServer().getScoreboard(); if(lv.size() < 2 || lv.size() > 3) throw new InternalExpressionException("'team_property' requires two or three arguments"); @@ -400,7 +400,7 @@ public class Scoreboards { expression.addContextFunction("bossbar", -1, (c, t, lv) -> { - BossBarManager bossBarManager = ((CarpetContext)c).s.getMinecraftServer().getBossBarManager(); + BossBarManager bossBarManager = ((CarpetContext)c).s.getServer().getBossBarManager(); if(lv.size() > 3) throw new InternalExpressionException("'bossbar' accepts max three arguments"); if(lv.size() == 0) return ListValue.wrap(bossBarManager.getAll().stream().map(CommandBossBar::getId).map(Identifier::toString).map(StringValue::of).collect(Collectors.toList())); @@ -457,13 +457,13 @@ public class Scoreboards { if(propertyValue instanceof ListValue) { ((ListValue) propertyValue).getItems().forEach((v)->{ - ServerPlayerEntity player = EntityValue.getPlayerByValue(((CarpetContext)c).s.getMinecraftServer(),propertyValue); + ServerPlayerEntity player = EntityValue.getPlayerByValue(((CarpetContext)c).s.getServer(),propertyValue); if(player != null) bossBar.addPlayer(player); }); return Value.TRUE; } - ServerPlayerEntity player = EntityValue.getPlayerByValue(((CarpetContext) c).s.getMinecraftServer(), propertyValue); + ServerPlayerEntity player = EntityValue.getPlayerByValue(((CarpetContext) c).s.getServer(), propertyValue); if(player != null) { bossBar.addPlayer(player); return Value.TRUE; @@ -475,14 +475,14 @@ public class Scoreboards { { bossBar.clearPlayers(); ((ListValue) propertyValue).getItems().forEach((v) -> { - ServerPlayerEntity p = EntityValue.getPlayerByValue(((CarpetContext) c).s.getMinecraftServer(), v); + ServerPlayerEntity p = EntityValue.getPlayerByValue(((CarpetContext) c).s.getServer(), v); if (p != null) bossBar.addPlayer(p); }); return Value.TRUE; } - ServerPlayerEntity p = EntityValue.getPlayerByValue(((CarpetContext) c).s.getMinecraftServer(), propertyValue); + ServerPlayerEntity p = EntityValue.getPlayerByValue(((CarpetContext) c).s.getServer(), propertyValue); bossBar.clearPlayers(); if (p != null) { bossBar.addPlayer(p); diff --git a/src/main/java/carpet/script/api/Threading.java b/src/main/java/carpet/script/api/Threading.java index baff04ab..257f4084 100644 --- a/src/main/java/carpet/script/api/Threading.java +++ b/src/main/java/carpet/script/api/Threading.java @@ -16,7 +16,7 @@ public class Threading { //"overidden" native call to cancel if on main thread expression.addContextFunction("task_join", 1, (c, t, lv) -> { - if (((CarpetContext)c).s.getMinecraftServer().isOnThread()) + if (((CarpetContext)c).s.getServer().isOnThread()) throw new InternalExpressionException("'task_join' cannot be called from main thread to avoid deadlocks"); Value v = lv.get(0); if (!(v instanceof ThreadValue)) @@ -27,13 +27,13 @@ public class Threading // has to be lazy due to deferred execution of the expression expression.addLazyFunctionWithDelegation("task_dock", 1, false,true, (c, t, expr, tok, lv) -> { CarpetContext cc = (CarpetContext)c; - MinecraftServer server = cc.s.getMinecraftServer(); + MinecraftServer server = cc.s.getServer(); if (server.isOnThread()) return lv.get(0); // pass through for on thread tasks Value[] result = new Value[]{Value.NULL}; RuntimeException[] internal = new RuntimeException[]{null}; try { - ((CarpetContext) c).s.getMinecraftServer().submitAndJoin(() -> + ((CarpetContext) c).s.getServer().submitAndJoin(() -> { try { diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index 4d199af3..17764cde 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -692,7 +692,7 @@ public class WorldAccess { boolean previous = CarpetSettings.impendingFillSkipUpdates.get(); if (previous) return lv.get(0); Value [] result = new Value[]{Value.NULL}; - ((CarpetContext)c).s.getMinecraftServer().submitAndJoin( () -> + ((CarpetContext)c).s.getServer().submitAndJoin( () -> { try { @@ -781,7 +781,7 @@ public class WorldAccess { BlockState finalSourceBlockState = sourceBlockState; BlockPos targetPos = targetLocator.block.getPos(); Boolean[] result = new Boolean[]{true}; - cc.s.getMinecraftServer().submitAndJoin( () -> + cc.s.getServer().submitAndJoin( () -> { Clearable.clear(world.getBlockEntity(targetPos)); boolean success = world.setBlockState(targetPos, finalSourceBlockState, 2); @@ -1135,7 +1135,7 @@ public class WorldAccess { if (lv.size() == 0) return ListValue.wrap(Registry.BLOCK.getIds().stream().map(ValueConversions::of).collect(Collectors.toList())); CarpetContext cc = (CarpetContext)c; - TagManager tagManager = cc.s.getMinecraftServer().getTagManager(); + TagManager tagManager = cc.s.getServer().getTagManager(); String tag = lv.get(0).getString(); net.minecraft.tag.Tag blockTag = tagManager.getOrCreateTagGroup(Registry.BLOCK_KEY).getTag(new Identifier(tag)); if (blockTag == null) return Value.NULL; @@ -1145,7 +1145,7 @@ public class WorldAccess { expression.addContextFunction("block_tags", -1, (c, t, lv) -> { CarpetContext cc = (CarpetContext)c; - TagManager tagManager = cc.s.getMinecraftServer().getTagManager(); + TagManager tagManager = cc.s.getServer().getTagManager(); if (lv.size() == 0) return ListValue.wrap(tagManager.getOrCreateTagGroup(Registry.BLOCK_KEY).getTagIds().stream().map(ValueConversions::of).collect(Collectors.toList())); BlockArgument blockLocator = BlockArgument.findIn(cc, lv, 0, true); @@ -1182,7 +1182,7 @@ public class WorldAccess { // in locatebiome if (locator.offset == lv.size()) { - Identifier biomeId = cc.s.getMinecraftServer().getRegistryManager().get(Registry.BIOME_KEY).getId(biome); + Identifier biomeId = cc.s.getServer().getRegistryManager().get(Registry.BIOME_KEY).getId(biome); return new StringValue(NBTSerializableValue.nameFromRegistryId(biomeId)); } String biomeFeature = lv.get(locator.offset).getString(); @@ -1199,7 +1199,7 @@ public class WorldAccess { throw new InternalExpressionException("'set_biome' needs a biome name as an argument"); String biomeName = lv.get(locator.offset+0).getString(); // from locatebiome command code - Biome biome = cc.s.getMinecraftServer().getRegistryManager().get(Registry.BIOME_KEY).getOrEmpty(new Identifier(biomeName)) + Biome biome = cc.s.getServer().getRegistryManager().get(Registry.BIOME_KEY).getOrEmpty(new Identifier(biomeName)) .orElseThrow(() -> new ThrowStatement(biomeName, Throwables.UNKNOWN_BIOME)); boolean doImmediateUpdate = true; if (lv.size() > locator.offset+1) @@ -1218,7 +1218,7 @@ public class WorldAccess { CarpetContext cc = (CarpetContext)c; BlockPos pos = BlockArgument.findIn(cc, lv, 0).block.getPos(); ServerWorld world = cc.s.getWorld(); - cc.s.getMinecraftServer().submitAndJoin( () -> WorldTools.forceChunkUpdate(pos, world)); + cc.s.getServer().submitAndJoin( () -> WorldTools.forceChunkUpdate(pos, world)); return Value.TRUE; }); @@ -1345,7 +1345,7 @@ public class WorldAccess { // good 'ol pointer Value[] result = new Value[]{Value.NULL}; // technically a world modification. Even if we could let it slide, we will still park it - ((CarpetContext) c).s.getMinecraftServer().submitAndJoin(() -> + ((CarpetContext) c).s.getServer().submitAndJoin(() -> { Map, StructureStart> structures = world.getChunk(pos).getStructureStarts(); if (lv.size() == locator.offset + 1) @@ -1407,7 +1407,7 @@ public class WorldAccess { } } - boolean success = WorldTools.createWorld(cc.s.getMinecraftServer(), worldKey, seed); + boolean success = WorldTools.createWorld(cc.s.getServer(), worldKey, seed); if (!success) return Value.FALSE; CarpetServer.settingsManager.notifyPlayersCommandsChanged(); return Value.TRUE; @@ -1466,7 +1466,7 @@ public class WorldAccess { Value [] result = new Value[]{Value.NULL}; - ((CarpetContext)c).s.getMinecraftServer().submitAndJoin( () -> + ((CarpetContext)c).s.getServer().submitAndJoin( () -> { Map report = ((ThreadedAnvilChunkStorageInterface) world.getChunkManager().threadedAnvilChunkStorage).regenerateChunkRegion(requestedChunks); /*for (ChunkPos chpos: requestedChunks) // needed in 1.16 only diff --git a/src/main/java/carpet/script/command/CommandArgument.java b/src/main/java/carpet/script/command/CommandArgument.java index b44671d2..92cc3392 100644 --- a/src/main/java/carpet/script/command/CommandArgument.java +++ b/src/main/java/carpet/script/command/CommandArgument.java @@ -132,7 +132,7 @@ public abstract class CommandArgument false ), new VanillaUnconfigurableArgument( "blockpredicate", BlockPredicateArgumentType::blockPredicate, - (c, p) -> ValueConversions.ofBlockPredicate(c.getSource().getMinecraftServer().getTagManager(), BlockPredicateArgumentType.getBlockPredicate(c, p)), false + (c, p) -> ValueConversions.ofBlockPredicate(c.getSource().getServer().getTagManager(), BlockPredicateArgumentType.getBlockPredicate(c, p)), false ), new VanillaUnconfigurableArgument("teamcolor", ColorArgumentType::color, (c, p) -> { @@ -199,13 +199,13 @@ public abstract class CommandArgument (c, p) -> ValueConversions.of( IdentifierArgumentType.getRecipeArgument(c, p).getId()), SuggestionProviders.ALL_RECIPES ), new VanillaUnconfigurableArgument("advancement", IdentifierArgumentType::identifier, - (c, p) -> ValueConversions.of( IdentifierArgumentType.getAdvancementArgument(c, p).getId()), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getMinecraftServer().getAdvancementLoader().getAdvancements().stream().map(Advancement::getId), builder) + (c, p) -> ValueConversions.of( IdentifierArgumentType.getAdvancementArgument(c, p).getId()), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getServer().getAdvancementLoader().getAdvancements().stream().map(Advancement::getId), builder) ), new VanillaUnconfigurableArgument("lootcondition", IdentifierArgumentType::identifier, - (c, p) -> ValueConversions.of( Registry.LOOT_CONDITION_TYPE.getId(IdentifierArgumentType.getPredicateArgument(c, p).getType())), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getMinecraftServer().getPredicateManager().getIds(), builder) + (c, p) -> ValueConversions.of( Registry.LOOT_CONDITION_TYPE.getId(IdentifierArgumentType.getPredicateArgument(c, p).getType())), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getServer().getPredicateManager().getIds(), builder) ), new VanillaUnconfigurableArgument("loottable", IdentifierArgumentType::identifier, - (c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getMinecraftServer().getLootManager().getTableIds(), builder) + (c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getServer().getLootManager().getTableIds(), builder) ), new VanillaUnconfigurableArgument("attribute", IdentifierArgumentType::identifier, (c, p) -> ValueConversions.of( Registry.ATTRIBUTE.getId(IdentifierArgumentType.getAttributeArgument(c, p))), (ctx, builder) -> CommandSource.suggestIdentifiers(Registry.ATTRIBUTE.getIds(), builder) @@ -220,7 +220,7 @@ public abstract class CommandArgument (c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), SuggestionProviders.AVAILABLE_SOUNDS ), new VanillaUnconfigurableArgument("storekey", IdentifierArgumentType::identifier, - (c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getMinecraftServer().getDataCommandStorage().getIds(), builder) + (c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getServer().getDataCommandStorage().getIds(), builder) ), // default diff --git a/src/main/java/carpet/script/utils/AppStoreManager.java b/src/main/java/carpet/script/utils/AppStoreManager.java index e418d0a3..27b89386 100644 --- a/src/main/java/carpet/script/utils/AppStoreManager.java +++ b/src/main/java/carpet/script/utils/AppStoreManager.java @@ -283,14 +283,14 @@ public class AppStoreManager public static boolean saveScriptToFile(ServerCommandSource source, String path, String appFileName, String code, boolean globalSavePath){ String scriptPath; String location; - if(globalSavePath && !source.getMinecraftServer().isDedicated()) + if(globalSavePath && !source.getServer().isDedicated()) { //cos config folder only is in clients scriptPath = FabricLoader.getInstance().getConfigDir().resolve("carpet/scripts/appstore").toAbsolutePath()+"/"+path; location = "global script config folder"; } else { - scriptPath = source.getMinecraftServer().getSavePath(WorldSavePath.ROOT).resolve("scripts").toAbsolutePath()+"/"+appFileName; + scriptPath = source.getServer().getSavePath(WorldSavePath.ROOT).resolve("scripts").toAbsolutePath()+"/"+appFileName; location = "world scripts folder"; } try diff --git a/src/main/java/carpet/script/utils/SnoopyCommandSource.java b/src/main/java/carpet/script/utils/SnoopyCommandSource.java index 25c3765d..bf48a730 100644 --- a/src/main/java/carpet/script/utils/SnoopyCommandSource.java +++ b/src/main/java/carpet/script/utils/SnoopyCommandSource.java @@ -40,7 +40,7 @@ public class SnoopyCommandSource extends ServerCommandSource public SnoopyCommandSource(ServerCommandSource original, Text[] error, List chatOutput) { super(CommandOutput.DUMMY, original.getPosition(), original.getRotation(), original.getWorld(), CarpetSettings.runPermissionLevel, - original.getName(), original.getDisplayName(), original.getMinecraftServer(), original.getEntity(), false, + original.getName(), original.getDisplayName(), original.getServer(), original.getEntity(), false, (ctx, succ, res) -> { }, EntityAnchorArgumentType.EntityAnchor.FEET); this.output = CommandOutput.DUMMY; this.position = original.getPosition(); @@ -48,7 +48,7 @@ public class SnoopyCommandSource extends ServerCommandSource this.level = CarpetSettings.runPermissionLevel; this.simpleName = original.getName(); this.name = original.getDisplayName(); - this.server = original.getMinecraftServer(); + this.server = original.getServer(); this.entity = original.getEntity(); this.resultConsumer = (ctx, succ, res) -> { }; this.entityAnchor = original.getEntityAnchor(); diff --git a/src/main/java/carpet/script/utils/SystemInfo.java b/src/main/java/carpet/script/utils/SystemInfo.java index 683371f1..dc7c3976 100644 --- a/src/main/java/carpet/script/utils/SystemInfo.java +++ b/src/main/java/carpet/script/utils/SystemInfo.java @@ -42,31 +42,31 @@ public class SystemInfo { put("app_scope", c -> StringValue.of((c.host).isPerUser()?"player":"global")); put("app_players", c -> ListValue.wrap(c.host.getUserList().stream().map(StringValue::new).collect(Collectors.toList()))); - put("world_name", c -> new StringValue(c.s.getMinecraftServer().getSaveProperties().getLevelName())); + put("world_name", c -> new StringValue(c.s.getServer().getSaveProperties().getLevelName())); put("world_seed", c -> new NumericValue(c.s.getWorld().getSeed())); - put("server_motd", c -> StringValue.of(c.s.getMinecraftServer().getServerMotd())); - put("world_path", c -> StringValue.of(c.s.getMinecraftServer().getSavePath(WorldSavePath.ROOT).toString())); + put("server_motd", c -> StringValue.of(c.s.getServer().getServerMotd())); + put("world_path", c -> StringValue.of(c.s.getServer().getSavePath(WorldSavePath.ROOT).toString())); put("world_folder", c -> { - Path serverPath = c.s.getMinecraftServer().getSavePath(WorldSavePath.ROOT); + Path serverPath = c.s.getServer().getSavePath(WorldSavePath.ROOT); int nodeCount = serverPath.getNameCount(); if (nodeCount < 2) return Value.NULL; String tlf = serverPath.getName(nodeCount-2).toString(); return StringValue.of(tlf); }); - put("world_dimensions", c -> ListValue.wrap(c.s.getMinecraftServer().getWorldRegistryKeys().stream().map(k -> ValueConversions.of(k.getValue())).collect(Collectors.toList()))); + put("world_dimensions", c -> ListValue.wrap(c.s.getServer().getWorldRegistryKeys().stream().map(k -> ValueConversions.of(k.getValue())).collect(Collectors.toList()))); put("world_spawn_point", c -> { - WorldProperties prop = c.s.getMinecraftServer().getOverworld().getLevelProperties(); + WorldProperties prop = c.s.getServer().getOverworld().getLevelProperties(); return ListValue.of(NumericValue.of(prop.getSpawnX()), NumericValue.of(prop.getSpawnY()), NumericValue.of(prop.getSpawnZ())); }); - put("game_difficulty", c -> StringValue.of(c.s.getMinecraftServer().getSaveProperties().getDifficulty().getName())); - put("game_hardcore", c -> BooleanValue.of(c.s.getMinecraftServer().getSaveProperties().isHardcore())); - put("game_storage_format", c -> StringValue.of(c.s.getMinecraftServer().getSaveProperties().getFormatName(c.s.getMinecraftServer().getSaveProperties().getVersion()))); - put("game_default_gamemode", c -> StringValue.of(c.s.getMinecraftServer().getDefaultGameMode().getName())); - put("game_max_players", c -> new NumericValue(c.s.getMinecraftServer().getMaxPlayerCount())); - put("game_view_distance", c -> new NumericValue(c.s.getMinecraftServer().getPlayerManager().getViewDistance())); - put("game_mod_name", c -> StringValue.of(c.s.getMinecraftServer().getServerModName())); - put("game_version", c -> StringValue.of(c.s.getMinecraftServer().getVersion())); + put("game_difficulty", c -> StringValue.of(c.s.getServer().getSaveProperties().getDifficulty().getName())); + put("game_hardcore", c -> BooleanValue.of(c.s.getServer().getSaveProperties().isHardcore())); + put("game_storage_format", c -> StringValue.of(c.s.getServer().getSaveProperties().getFormatName(c.s.getServer().getSaveProperties().getVersion()))); + put("game_default_gamemode", c -> StringValue.of(c.s.getServer().getDefaultGameMode().getName())); + put("game_max_players", c -> new NumericValue(c.s.getServer().getMaxPlayerCount())); + put("game_view_distance", c -> new NumericValue(c.s.getServer().getPlayerManager().getViewDistance())); + put("game_mod_name", c -> StringValue.of(c.s.getServer().getServerModName())); + put("game_version", c -> StringValue.of(c.s.getServer().getVersion())); put("game_target", c -> StringValue.of(SharedConstants.getGameVersion().getReleaseTarget())); put("game_protocol", c -> NumericValue.of(SharedConstants.getProtocolVersion())); put("game_major_target", c -> { @@ -81,11 +81,11 @@ public class SystemInfo { put("game_data_version", c->NumericValue.of(SharedConstants.getGameVersion().getWorldVersion())); put("game_pack_version", c->NumericValue.of(SharedConstants.getGameVersion().getPackVersion())); - put("server_ip", c -> StringValue.of(c.s.getMinecraftServer().getServerIp())); - put("server_whitelisted", c -> BooleanValue.of(c.s.getMinecraftServer().isEnforceWhitelist())); + put("server_ip", c -> StringValue.of(c.s.getServer().getServerIp())); + put("server_whitelisted", c -> BooleanValue.of(c.s.getServer().isEnforceWhitelist())); put("server_whitelist", c -> { MapValue whitelist = new MapValue(Collections.emptyList()); - for (String s: c.s.getMinecraftServer().getPlayerManager().getWhitelistedNames()) + for (String s: c.s.getServer().getPlayerManager().getWhitelistedNames()) { whitelist.append(StringValue.of(s)); } @@ -93,7 +93,7 @@ public class SystemInfo { }); put("server_banned_players", c -> { MapValue whitelist = new MapValue(Collections.emptyList()); - for (String s: c.s.getMinecraftServer().getPlayerManager().getUserBanList().getNames()) + for (String s: c.s.getServer().getPlayerManager().getUserBanList().getNames()) { whitelist.append(StringValue.of(s)); } @@ -101,7 +101,7 @@ public class SystemInfo { }); put("server_banned_ips", c -> { MapValue whitelist = new MapValue(Collections.emptyList()); - for (String s: c.s.getMinecraftServer().getPlayerManager().getIpBanList().getNames()) + for (String s: c.s.getServer().getPlayerManager().getIpBanList().getNames()) { whitelist.append(StringValue.of(s)); } diff --git a/src/main/java/carpet/script/value/NBTSerializableValue.java b/src/main/java/carpet/script/value/NBTSerializableValue.java index c92d0af0..4a3a7b00 100644 --- a/src/main/java/carpet/script/value/NBTSerializableValue.java +++ b/src/main/java/carpet/script/value/NBTSerializableValue.java @@ -207,7 +207,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa if (strVal.equals("enderchest")) { Value v2 = params.get(1 + offset); - ServerPlayerEntity player = EntityValue.getPlayerByValue(c.s.getMinecraftServer(), v2); + ServerPlayerEntity player = EntityValue.getPlayerByValue(c.s.getServer(), v2); if (player == null) throw new InternalExpressionException("enderchest inventory requires player argument"); return new InventoryLocator(player, player.getBlockPos(), player.getEnderChestInventory(), offset + 2, true); } @@ -221,7 +221,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa } boolean isEnder = strVal.startsWith("enderchest_"); if (isEnder) strVal = strVal.substring(11); // len("enderchest_") - ServerPlayerEntity player = c.s.getMinecraftServer().getPlayerManager().getPlayer(strVal); + ServerPlayerEntity player = c.s.getServer().getPlayerManager().getPlayer(strVal); if (player == null) throw new InternalExpressionException("String description of an inventory should either denote a player or player's enderchest"); return new InventoryLocator( player, diff --git a/src/main/java/carpet/utils/CarpetProfiler.java b/src/main/java/carpet/utils/CarpetProfiler.java index fd973229..a8889799 100644 --- a/src/main/java/carpet/utils/CarpetProfiler.java +++ b/src/main/java/carpet/utils/CarpetProfiler.java @@ -82,7 +82,7 @@ public class CarpetProfiler { SECTION_STATS.put(section, 0L); } - for (RegistryKey level : source.getMinecraftServer().getWorldRegistryKeys()) + for (RegistryKey level : source.getServer().getWorldRegistryKeys()) { for (String section : SECTIONS) { diff --git a/src/main/java/carpet/utils/Messenger.java b/src/main/java/carpet/utils/Messenger.java index 68270e10..e5a6c7f2 100644 --- a/src/main/java/carpet/utils/Messenger.java +++ b/src/main/java/carpet/utils/Messenger.java @@ -253,7 +253,7 @@ public class Messenger public static void m(ServerCommandSource source, Object ... fields) { if (source != null) - source.sendFeedback(Messenger.c(fields),source.getMinecraftServer() != null && source.getMinecraftServer().getWorld(World.OVERWORLD) != null); //OW + source.sendFeedback(Messenger.c(fields),source.getServer() != null && source.getServer().getWorld(World.OVERWORLD) != null); //OW } public static void m(PlayerEntity player, Object ... fields) { From fa43e54395ebfb2b859ba2fa33bbadb9901a9e86 Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 29 Jun 2021 17:41:18 -0300 Subject: [PATCH 109/115] 1.17.1-pre2 --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 9d76deec..e5029874 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.17.1-pre1 - yarn_mappings=1.17.1-pre1+build.19 + minecraft_version=1.17.1-pre2 + yarn_mappings=1.17.1-pre2+build.1 loader_version=0.11.6 fabric_version=0.36.0+1.17 From 92eb46e8adac210d131bb5ec5afa30dd5807645d Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 30 Jun 2021 14:15:26 -0300 Subject: [PATCH 110/115] 1.17.1-pre3 --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index e5029874..9fa7f22a 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.17.1-pre2 - yarn_mappings=1.17.1-pre2+build.1 + minecraft_version=1.17.1-pre3 + yarn_mappings=1.17.1-pre3+build.1 loader_version=0.11.6 fabric_version=0.36.0+1.17 From 702789cab56a602ed5812ddea2fcd7cca5d9f1eb Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 2 Jul 2021 00:28:49 -0300 Subject: [PATCH 111/115] 1.17.1-rc-1 --- gradle.properties | 4 ++-- src/main/java/carpet/commands/PlayerCommand.java | 2 +- .../mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java | 4 ++-- src/main/java/carpet/patches/EntityPlayerMPFake.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index 9fa7f22a..459b067d 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.17.1-pre3 - yarn_mappings=1.17.1-pre3+build.1 + minecraft_version=1.17.1-rc1 + yarn_mappings=1.17.1-rc1+build.1 loader_version=0.11.6 fabric_version=0.36.0+1.17 diff --git a/src/main/java/carpet/commands/PlayerCommand.java b/src/main/java/carpet/commands/PlayerCommand.java index 3e24e3c6..b849276b 100644 --- a/src/main/java/carpet/commands/PlayerCommand.java +++ b/src/main/java/carpet/commands/PlayerCommand.java @@ -189,7 +189,7 @@ public class PlayerCommand Messenger.m(context.getSource(), "r Player ", "rb " + playerName, "r is already logged on"); return true; } - GameProfile profile = server.getUserCache().findByName(playerName); + GameProfile profile = server.getUserCache().findByName(playerName).orElse(null); if (profile == null) { if (!CarpetSettings.allowSpawningOfflinePlayers) diff --git a/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java b/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java index 3811ddb2..812906b3 100644 --- a/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/ServerPlayNetworkHandler_scarpetEventsMixin.java @@ -62,7 +62,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin @Inject(method = "onPlayerAction", at = @At( value = "INVOKE", - target = "Lnet/minecraft/server/network/ServerPlayerEntity;method_37413(Z)Z", // dropSelectedItem + target = "Lnet/minecraft/server/network/ServerPlayerEntity;dropSelectedItem(Z)Z", // dropSelectedItem ordinal = 0, shift = At.Shift.BEFORE )) @@ -84,7 +84,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin @Inject(method = "onPlayerAction", at = @At( value = "INVOKE", - target = "Lnet/minecraft/server/network/ServerPlayerEntity;method_37413(Z)Z", // dropSelectedItem + target = "Lnet/minecraft/server/network/ServerPlayerEntity;dropSelectedItem(Z)Z", // dropSelectedItem ordinal = 1, shift = At.Shift.BEFORE )) diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index 9d811029..19dafed4 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -40,7 +40,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity UserCache.setUseRemote(false); GameProfile gameprofile; try { - gameprofile = server.getUserCache().findByName(username); + gameprofile = server.getUserCache().findByName(username).orElse(null); } finally { UserCache.setUseRemote(server.isDedicated() && server.isOnlineMode()); From 3affa8d5c8a5f70a96af3f3a995dfbc4da77173e Mon Sep 17 00:00:00 2001 From: gnembon Date: Mon, 5 Jul 2021 16:28:59 -0300 Subject: [PATCH 112/115] shulker stacks can now be moved in 1.17, fixes #976 --- gradle.properties | 2 +- src/main/java/carpet/CarpetSettings.java | 1 + .../mixins/Slot_stackableSBoxesMixin.java | 26 +++++++++++++++++++ src/main/resources/carpet.mixins.json | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/main/java/carpet/mixins/Slot_stackableSBoxesMixin.java diff --git a/gradle.properties b/gradle.properties index ddc34ac0..4ee04584 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=1.17.1-rc1 - yarn_mappings=1.17.1-rc1+build.1 + yarn_mappings=1.17.1-rc1+build.8 loader_version=0.11.6 fabric_version=0.36.0+1.17 diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 04ce1990..f7d33c75 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -196,6 +196,7 @@ public class CarpetSettings category = {SURVIVAL, FEATURE} ) public static boolean stackableShulkerBoxes = false; + public static final int SHULKER_STACK_SIZE = 64; @Rule( desc = "Explosions won't destroy blocks", category = {CREATIVE, TNT} ) public static boolean explosionNoBlockDamage = false; diff --git a/src/main/java/carpet/mixins/Slot_stackableSBoxesMixin.java b/src/main/java/carpet/mixins/Slot_stackableSBoxesMixin.java new file mode 100644 index 00000000..80fd8b79 --- /dev/null +++ b/src/main/java/carpet/mixins/Slot_stackableSBoxesMixin.java @@ -0,0 +1,26 @@ +package carpet.mixins; + +import carpet.CarpetSettings; +import net.minecraft.block.ShulkerBoxBlock; +import net.minecraft.item.BlockItem; +import net.minecraft.item.ItemStack; +import net.minecraft.screen.slot.Slot; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(Slot.class) +public class Slot_stackableSBoxesMixin { + @Redirect(method = "insertStack(Lnet/minecraft/item/ItemStack;I)Lnet/minecraft/item/ItemStack;", at = @At( + value = "INVOKE", + target = "Lnet/minecraft/screen/slot/Slot;getMaxItemCount(Lnet/minecraft/item/ItemStack;)I" + )) + private int getMaxCountForSboxes(Slot slot, ItemStack stack) + { + if (CarpetSettings.stackableShulkerBoxes && stack.getItem() instanceof BlockItem && ((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock) + { + return CarpetSettings.SHULKER_STACK_SIZE; + } + return slot.getMaxItemCount(stack); + } +} diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index 1f9f0c2a..e448a7e0 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -136,6 +136,7 @@ "ClientConnectionMixin", "CauldronBlock_stackableSBoxesMixin", "AbstractCauldronBlock_stackableSBoxesMixin", + "Slot_stackableSBoxesMixin", "ItemEntityMixin", "TntBlockMixin", "ExplosionMixin", From dabc6411a32ff8f5942ed4e6045b3437d647eb67 Mon Sep 17 00:00:00 2001 From: gnembon Date: Mon, 5 Jul 2021 16:58:33 -0300 Subject: [PATCH 113/115] rc2 --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 4ee04584..b73cb8a5 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.17.1-rc1 - yarn_mappings=1.17.1-rc1+build.8 + minecraft_version=1.17.1-rc2 + yarn_mappings=1.17.1-rc2+build.1 loader_version=0.11.6 fabric_version=0.36.0+1.17 From 59c8c208b361bd9e07cb4a28787257a680bfbe8f Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 6 Jul 2021 16:38:44 -0300 Subject: [PATCH 114/115] 1.17.1 --- gradle.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index b73cb8a5..412fd124 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=1.17.1-rc2 - yarn_mappings=1.17.1-rc2+build.1 + minecraft_version=1.17.1 + yarn_mappings=1.17.1+build.1 loader_version=0.11.6 - fabric_version=0.36.0+1.17 + fabric_version=0.36.1+1.17 # Mod Properties mod_version = 1.4.42 From 181bfb34bf6e269ebcfbb57ccf34f355959a3f5e Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 9 Jul 2021 02:22:53 -0300 Subject: [PATCH 115/115] tweaked stackable shulkerboxes for 1.17 fixes #989 --- src/main/java/carpet/CarpetSettings.java | 2 +- src/main/java/carpet/mixins/Slot_stackableSBoxesMixin.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 4581448d..0af1cea0 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -192,7 +192,7 @@ public class CarpetSettings @Rule( desc = "Empty shulker boxes can stack to 64 when dropped on the ground", - extra = "To move them around between inventories, use shift click to move entire stacks", + extra = ".. or when manipulated inside the inventories", category = {SURVIVAL, FEATURE} ) public static boolean stackableShulkerBoxes = false; diff --git a/src/main/java/carpet/mixins/Slot_stackableSBoxesMixin.java b/src/main/java/carpet/mixins/Slot_stackableSBoxesMixin.java index 80fd8b79..557ea506 100644 --- a/src/main/java/carpet/mixins/Slot_stackableSBoxesMixin.java +++ b/src/main/java/carpet/mixins/Slot_stackableSBoxesMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; +import carpet.helpers.InventoryHelper; import net.minecraft.block.ShulkerBoxBlock; import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; @@ -17,7 +18,11 @@ public class Slot_stackableSBoxesMixin { )) private int getMaxCountForSboxes(Slot slot, ItemStack stack) { - if (CarpetSettings.stackableShulkerBoxes && stack.getItem() instanceof BlockItem && ((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock) + if (CarpetSettings.stackableShulkerBoxes && + stack.getItem() instanceof BlockItem && + ((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock && + !InventoryHelper.shulkerBoxHasItems(stack) + ) { return CarpetSettings.SHULKER_STACK_SIZE; }