Merge branch 'master' into 1.17

This commit is contained in:
gnembon committed 2021-01-26 05:42:20 -04:00
commit 71a8dcc31e
14 files changed
+239 -15

No files matched your search

@@ -15,7 +15,7 @@ public class ClientPlayerEntity_clientCommandMixin
@Inject(method = "sendChatMessage", at = @At("HEAD"))
private void inspectMessage(String string, CallbackInfo ci)
{
if (string.startsWith("/call"))
if (string.startsWith("/call "))
{
String command = string.substring(6);
CarpetClient.sendClientCommand(command);
@@ -32,4 +32,4 @@ public abstract class StructureBlockBlockEntity_fillUpdatesMixin
CarpetSettings.impendingFillSkipUpdates = false;
}
}
}
}
@@ -0,0 +1,53 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.Block;
import net.minecraft.block.entity.StructureBlockBlockEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(StructureBlockBlockEntity.class)
public abstract class StructureBlockBlockEntity_limitsMixin
{
@ModifyConstant(
method = "fromTag",
constant = @Constant(intValue = 48)
)
private int positiveLimit(int original) {
return CarpetSettings.structureBlockLimit;
}
@ModifyConstant(
method = "fromTag",
constant = @Constant(intValue = -48)
)
private int negativeLimit(int original) {
return -CarpetSettings.structureBlockLimit;
}
@ModifyArg(
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"
),
index = 4
)
private Block ignoredBlock(Block original) {
return CarpetSettings.structureBlockIgnoredBlock;
}
@Environment(EnvType.CLIENT)
@ModifyConstant(
method = "getSquaredRenderDistance",
constant = @Constant(doubleValue = 96d)
)
private double outlineRenderDistanceLimit(double original) {
return CarpetSettings.structureBlockOutlineDistance;
}
}
@@ -0,0 +1,45 @@
package carpet.mixins;
import carpet.CarpetSettings;
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 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(UpdateStructureBlockC2SPacket.class)
public class UpdateStructureBlockC2SPacketMixin {
@Shadow
private BlockPos offset;
@Shadow
private BlockPos size;
@Inject(
method = "read",
at = @At("TAIL")
)
private void structureBlockLimitsRead(PacketByteBuf buf, CallbackInfo ci) {
if (buf.readableBytes() > 0) {
// 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));
}
}
@Inject(
method = "write",
at = @At("TAIL")
)
private void structureBlockLimitsWrite(PacketByteBuf buf, CallbackInfo ci) {
buf.writeInt(this.offset.getX());
buf.writeInt(this.offset.getY());
buf.writeInt(this.offset.getZ());
buf.writeInt(this.size.getX());
buf.writeInt(this.size.getY());
buf.writeInt(this.size.getZ());
}
}
@@ -2,6 +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.render.BufferBuilderStorage;
@@ -28,7 +29,7 @@ public class WorldRenderer_scarpetRenderMixin
@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"))
private void renderScarpetThings(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, CallbackInfo ci)
{
if (CarpetClient.shapes != null)
if (!FabricAPIHooks.WORLD_RENDER_EVENTS && CarpetClient.shapes != null)
{
RenderSystem.pushMatrix();
CarpetClient.shapes.render(camera, tickDelta);