Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PrinterBypass #155

Merged
merged 3 commits into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/com/matt/forgehax/asm/ForgeHaxHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/matt/forgehax/asm/TypesHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ interface Methods {
.add(TypesMc.Classes.ItemStack)
.add(TypesMc.Classes.BlockPos)
.add(TypesMc.Classes.Vec3d)
.add(TypesMc.Classes.EnumFacing)
.finish()
.build();

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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() {
Expand All @@ -31,4 +34,8 @@ public BlockPos getPos() {
public Vec3d getVec() {
return this.vec;
}

public EnumFacing getSide() {
return this.side;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
24 changes: 10 additions & 14 deletions src/main/java/com/matt/forgehax/mods/SchematicaPrinterBypass.java
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
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;
import com.matt.forgehax.util.mod.Category;
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.
*/
@RegisterMod
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());
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(
lookAngle.getYaw(), lookAngle.getPitch(), getLocalPlayer().onGround));
// getLocalPlayer().rotationYaw = getLocalPlayer().prevRotationYaw = (float)lookAngle.getYaw();
// getLocalPlayer().rotationPitch = getLocalPlayer().prevRotationPitch =
// (float)lookAngle.getPitch();
}
}