aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/features/puzzlesolvers/ArrowTerminalSolver.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/Danker/features/puzzlesolvers/ArrowTerminalSolver.java')
-rw-r--r--src/main/java/me/Danker/features/puzzlesolvers/ArrowTerminalSolver.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/main/java/me/Danker/features/puzzlesolvers/ArrowTerminalSolver.java b/src/main/java/me/Danker/features/puzzlesolvers/ArrowTerminalSolver.java
new file mode 100644
index 0000000..14870f2
--- /dev/null
+++ b/src/main/java/me/Danker/features/puzzlesolvers/ArrowTerminalSolver.java
@@ -0,0 +1,55 @@
+package me.Danker.features.puzzlesolvers;
+
+import me.Danker.commands.ToggleCommand;
+import me.Danker.events.PacketWriteEvent;
+import me.Danker.utils.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.EntityItemFrame;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraft.network.play.client.C02PacketUseEntity;
+import net.minecraft.util.BlockPos;
+import net.minecraftforge.event.entity.player.EntityInteractEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+
+public class ArrowTerminalSolver {
+
+ @SubscribeEvent
+ public void onEntityInteract(EntityInteractEvent event) {
+ Minecraft mc = Minecraft.getMinecraft();
+ if (mc.thePlayer != event.entityPlayer) return;
+
+ if (ToggleCommand.itemFrameOnSeaLanternsToggled && Utils.inDungeons && event.target instanceof EntityItemFrame) {
+ EntityItemFrame itemFrame = (EntityItemFrame) event.target;
+ ItemStack item = itemFrame.getDisplayedItem();
+ if (item == null || item.getItem() != Items.arrow) return;
+ BlockPos blockPos = Utils.getBlockUnderItemFrame(itemFrame);
+ if (mc.theWorld.getBlockState(blockPos).getBlock() == Blocks.sea_lantern) {
+ event.setCanceled(true);
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onPacket(PacketWriteEvent event) {
+ if (ToggleCommand.itemFrameOnSeaLanternsToggled && Utils.inDungeons && event.packet instanceof C02PacketUseEntity) {
+ Minecraft mc = Minecraft.getMinecraft();
+ C02PacketUseEntity packet = (C02PacketUseEntity) event.packet;
+ Entity entityHit = packet.getEntityFromWorld(mc.theWorld);
+ if (entityHit instanceof EntityItemFrame) {
+ EntityItemFrame itemFrame = (EntityItemFrame) entityHit;
+ ItemStack item = itemFrame.getDisplayedItem();
+ if (item != null && item.getItem() == Items.arrow) {
+ BlockPos blockPos = Utils.getBlockUnderItemFrame(itemFrame);
+ if (mc.theWorld.getBlockState(blockPos).getBlock() == Blocks.sea_lantern) {
+ event.setCanceled(true);
+ }
+ }
+ }
+ }
+
+ }
+
+}