From d1d3d1b70900f85aec757e5130bb6305e91fa451 Mon Sep 17 00:00:00 2001 From: l_amp Date: Sun, 15 Dec 2019 16:13:09 +0100 Subject: [PATCH 1/3] Fix PrinterBypass --- .../matt/forgehax/mods/SchematicaPrinterBypass.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/matt/forgehax/mods/SchematicaPrinterBypass.java b/src/main/java/com/matt/forgehax/mods/SchematicaPrinterBypass.java index 2c9a6e165..2d6a33af9 100644 --- a/src/main/java/com/matt/forgehax/mods/SchematicaPrinterBypass.java +++ b/src/main/java/com/matt/forgehax/mods/SchematicaPrinterBypass.java @@ -10,6 +10,7 @@ import com.matt.forgehax.util.mod.ToggleMod; import com.matt.forgehax.util.mod.loader.RegisterMod; import net.minecraft.network.play.client.CPacketPlayer; +import net.minecraft.util.math.Vec3d; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; /** @@ -21,15 +22,10 @@ public class SchematicaPrinterBypass extends ToggleMod { public SchematicaPrinterBypass() { super(Category.MISC, "PrinterBypass", false, "Set silent angles for schematica printer"); } - - @Override - public boolean isHidden() { - return true; - } - + @SubscribeEvent public void onPrinterBlockPlace(SchematicaPlaceBlockEvent event) { - Angle lookAngle = Utils.getLookAtAngles(event.getVec()); + Angle lookAngle = Utils.getLookAtAngles(new Vec3d(event.getVec().x + 0.5, event.getVec().y + 0.5, event.getVec().z + 0.5)); getNetworkManager() .sendPacket( new CPacketPlayer.Rotation( From f4477f7207f11852b12a7aefb32b5e92668c569c Mon Sep 17 00:00:00 2001 From: l_amp Date: Sun, 15 Dec 2019 16:13:39 +0100 Subject: [PATCH 2/3] remove comment --- .../java/com/matt/forgehax/mods/SchematicaPrinterBypass.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/matt/forgehax/mods/SchematicaPrinterBypass.java b/src/main/java/com/matt/forgehax/mods/SchematicaPrinterBypass.java index 2d6a33af9..efe643526 100644 --- a/src/main/java/com/matt/forgehax/mods/SchematicaPrinterBypass.java +++ b/src/main/java/com/matt/forgehax/mods/SchematicaPrinterBypass.java @@ -18,7 +18,7 @@ */ @RegisterMod public class SchematicaPrinterBypass extends ToggleMod { - + public SchematicaPrinterBypass() { super(Category.MISC, "PrinterBypass", false, "Set silent angles for schematica printer"); } @@ -30,8 +30,5 @@ public void onPrinterBlockPlace(SchematicaPlaceBlockEvent event) { .sendPacket( new CPacketPlayer.Rotation( lookAngle.getYaw(), lookAngle.getPitch(), getLocalPlayer().onGround)); - // getLocalPlayer().rotationYaw = getLocalPlayer().prevRotationYaw = (float)lookAngle.getYaw(); - // getLocalPlayer().rotationPitch = getLocalPlayer().prevRotationPitch = - // (float)lookAngle.getPitch(); } } From 34d1ea5128fa1f5988366582948762a6ea886e51 Mon Sep 17 00:00:00 2001 From: l_amp Date: Mon, 16 Dec 2019 02:56:32 +0100 Subject: [PATCH 3/3] face new block instead of old block --- .../java/com/matt/forgehax/asm/ForgeHaxHooks.java | 4 ++-- src/main/java/com/matt/forgehax/asm/TypesHook.java | 1 + .../asm/events/SchematicaPlaceBlockEvent.java | 9 ++++++++- .../asm/patches/special/SchematicPrinterPatch.java | 1 + .../matt/forgehax/mods/SchematicaPrinterBypass.java | 11 +++++++---- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/matt/forgehax/asm/ForgeHaxHooks.java b/src/main/java/com/matt/forgehax/asm/ForgeHaxHooks.java index fbb793973..8ab808c12 100644 --- a/src/main/java/com/matt/forgehax/asm/ForgeHaxHooks.java +++ b/src/main/java/com/matt/forgehax/asm/ForgeHaxHooks.java @@ -165,9 +165,9 @@ public static float onRenderBoat(EntityBoat boat, float entityYaw) { .forgeEvent(SchematicaPlaceBlockEvent.class) .build(); - public static void onSchematicaPlaceBlock(ItemStack itemIn, BlockPos posIn, Vec3d vecIn) { + public static void onSchematicaPlaceBlock(ItemStack itemIn, BlockPos posIn, Vec3d vecIn, EnumFacing sideIn) { if (HOOK_onSchematicaPlaceBlock.reportHook()) { - MinecraftForge.EVENT_BUS.post(new SchematicaPlaceBlockEvent(itemIn, posIn, vecIn)); + MinecraftForge.EVENT_BUS.post(new SchematicaPlaceBlockEvent(itemIn, posIn, vecIn, sideIn)); } } diff --git a/src/main/java/com/matt/forgehax/asm/TypesHook.java b/src/main/java/com/matt/forgehax/asm/TypesHook.java index 1e610bbf0..651c3bc8f 100644 --- a/src/main/java/com/matt/forgehax/asm/TypesHook.java +++ b/src/main/java/com/matt/forgehax/asm/TypesHook.java @@ -356,6 +356,7 @@ interface Methods { .add(TypesMc.Classes.ItemStack) .add(TypesMc.Classes.BlockPos) .add(TypesMc.Classes.Vec3d) + .add(TypesMc.Classes.EnumFacing) .finish() .build(); diff --git a/src/main/java/com/matt/forgehax/asm/events/SchematicaPlaceBlockEvent.java b/src/main/java/com/matt/forgehax/asm/events/SchematicaPlaceBlockEvent.java index 2256f5371..c7d3110da 100644 --- a/src/main/java/com/matt/forgehax/asm/events/SchematicaPlaceBlockEvent.java +++ b/src/main/java/com/matt/forgehax/asm/events/SchematicaPlaceBlockEvent.java @@ -1,6 +1,7 @@ package com.matt.forgehax.asm.events; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraftforge.fml.common.eventhandler.Event; @@ -13,11 +14,13 @@ public class SchematicaPlaceBlockEvent extends Event { private ItemStack item; private BlockPos pos; private Vec3d vec; + private EnumFacing side; - public SchematicaPlaceBlockEvent(ItemStack itemIn, BlockPos posIn, Vec3d vecIn) { + public SchematicaPlaceBlockEvent(ItemStack itemIn, BlockPos posIn, Vec3d vecIn, EnumFacing sideIn) { this.item = itemIn; this.pos = posIn; this.vec = vecIn; + this.side = sideIn; } public ItemStack getItem() { @@ -31,4 +34,8 @@ public BlockPos getPos() { public Vec3d getVec() { return this.vec; } + + public EnumFacing getSide() { + return this.side; + } } diff --git a/src/main/java/com/matt/forgehax/asm/patches/special/SchematicPrinterPatch.java b/src/main/java/com/matt/forgehax/asm/patches/special/SchematicPrinterPatch.java index 709803dae..e891248f8 100644 --- a/src/main/java/com/matt/forgehax/asm/patches/special/SchematicPrinterPatch.java +++ b/src/main/java/com/matt/forgehax/asm/patches/special/SchematicPrinterPatch.java @@ -44,6 +44,7 @@ public void inject(MethodNode main) { insnList.add(new VarInsnNode(ALOAD, 3)); // load ItemStack insnList.add(new VarInsnNode(ALOAD, 4)); // load BlockPos insnList.add(new VarInsnNode(ALOAD, 6)); // load Vec + insnList.add(new VarInsnNode(ALOAD, 5)); // load EnumFacing insnList.add( ASMHelper.call(INVOKESTATIC, TypesHook.Methods.ForgeHaxHooks_onSchematicaPlaceBlock)); diff --git a/src/main/java/com/matt/forgehax/mods/SchematicaPrinterBypass.java b/src/main/java/com/matt/forgehax/mods/SchematicaPrinterBypass.java index efe643526..aa0371f29 100644 --- a/src/main/java/com/matt/forgehax/mods/SchematicaPrinterBypass.java +++ b/src/main/java/com/matt/forgehax/mods/SchematicaPrinterBypass.java @@ -1,8 +1,5 @@ package com.matt.forgehax.mods; -import static com.matt.forgehax.Helper.getLocalPlayer; -import static com.matt.forgehax.Helper.getNetworkManager; - import com.matt.forgehax.asm.events.SchematicaPlaceBlockEvent; import com.matt.forgehax.util.Utils; import com.matt.forgehax.util.math.Angle; @@ -10,9 +7,12 @@ import com.matt.forgehax.util.mod.ToggleMod; import com.matt.forgehax.util.mod.loader.RegisterMod; import net.minecraft.network.play.client.CPacketPlayer; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import static com.matt.forgehax.Helper.*; + /** * Created by Babbaj on 9/20/2017. */ @@ -25,7 +25,10 @@ public SchematicaPrinterBypass() { @SubscribeEvent public void onPrinterBlockPlace(SchematicaPlaceBlockEvent event) { - Angle lookAngle = Utils.getLookAtAngles(new Vec3d(event.getVec().x + 0.5, event.getVec().y + 0.5, event.getVec().z + 0.5)); + final BlockPos lookpos = event.getPos().offset(event.getSide()); + final Vec3d newvec = new Vec3d(lookpos.getX() + 0.5, lookpos.getY() + 0.5, lookpos.getZ() + 0.5); + + Angle lookAngle = Utils.getLookAtAngles(newvec); getNetworkManager() .sendPacket( new CPacketPlayer.Rotation(