From 50dc2122462642a0c3a00b3a3ae6389825dc04df Mon Sep 17 00:00:00 2001
From: IRONM00N <64110067+IRONM00N@users.noreply.github.com>
Date: Thu, 9 Jun 2022 18:04:22 -0400
Subject: Re-license project as LGPL (#157)
* add licence files & a few misc chores
* add license notices & run auto formatter
---
.../miscfeatures/CustomItemEffects.java | 41 ++++++++++++++++++++--
1 file changed, 38 insertions(+), 3 deletions(-)
(limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java')
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
index e621cf78..ca9a92cb 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
@@ -1,3 +1,22 @@
+/*
+ * Copyright (C) 2022 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see .
+ */
+
package io.github.moulberry.notenoughupdates.miscfeatures;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
@@ -11,7 +30,11 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.multiplayer.WorldClient;
-import net.minecraft.client.renderer.*;
+import net.minecraft.client.renderer.BlockRendererDispatcher;
+import net.minecraft.client.renderer.EntityRenderer;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
@@ -24,7 +47,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
-import net.minecraft.util.*;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.EnumFacing;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.Vec3;
+import net.minecraft.util.Vec3i;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
@@ -36,8 +65,14 @@ import org.lwjgl.util.vector.Vector3f;
import java.awt.*;
import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
-import java.util.*;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
--
cgit
From 74ae776a74bd6d0b24df7354e49287a42600011a Mon Sep 17 00:00:00 2001
From: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Date: Thu, 11 Aug 2022 13:05:46 +0200
Subject: Etherwarp (#216)
---
.../miscfeatures/CustomItemEffects.java | 98 +++++++++++++---------
1 file changed, 60 insertions(+), 38 deletions(-)
(limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java')
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
index ca9a92cb..c77a4b39 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
@@ -273,6 +273,7 @@ public class CustomItemEffects {
private boolean usingEtherwarp = false;
private RaycastResult etherwarpRaycast = null;
private int lastEtherwarpUse = 0;
+ private String denyTpReason = null;
@SubscribeEvent
public void onOverlayDrawn(RenderGameOverlayEvent.Post event) {
@@ -281,40 +282,50 @@ public class CustomItemEffects {
ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
- if (usingEtherwarp && NotEnoughUpdates.INSTANCE.config.itemOverlays.enableEtherwarpHelperOverlay) {
- String denyTpReason = null;
+ WorldClient world = Minecraft.getMinecraft().theWorld;
+ if (usingEtherwarp) {
+ denyTpReason = null;
if (etherwarpRaycast == null) {
denyTpReason = "Too far!";
} else {
BlockPos pos = etherwarpRaycast.pos;
- if (!etherwarpRaycast.state.getBlock().isCollidable() ||
- etherwarpRaycast.state.getBlock().getCollisionBoundingBox(
- Minecraft.getMinecraft().theWorld,
- etherwarpRaycast.pos,
- etherwarpRaycast.state
- ) == null) {
+ Block block = etherwarpRaycast.state.getBlock();
+ if (!block.isCollidable() ||
+ //Don't allow teleport at this block
+ block == Blocks.carpet || block == Blocks.skull ||
+ block.getCollisionBoundingBox(world, etherwarpRaycast.pos, etherwarpRaycast.state) == null &&
+ //Allow teleport at this block
+ block != Blocks.wall_sign && block != Blocks.standing_sign) {
denyTpReason = "Not solid!";
} else {
- WorldClient world = Minecraft.getMinecraft().theWorld;
- Block above = world.getBlockState(pos.add(0, 1, 0)).getBlock();
- if (above != Blocks.air && above.isCollidable() &&
- above.getCollisionBoundingBox(Minecraft.getMinecraft().theWorld, pos.add(0, 1, 0),
- world.getBlockState(pos.add(0, 1, 0))
- ) != null ||
- world.getBlockState(pos.add(0, 2, 0)).getBlock() != Blocks.air) {
+ BlockPos blockPosAbove = pos.add(0, 1, 0);
+ Block blockAbove = world.getBlockState(blockPosAbove).getBlock();
+
+ Block twoBlockAbove = world.getBlockState(pos.add(0, 2, 0)).getBlock();
+ if (blockAbove != Blocks.air &&
+ //Allow teleport to the block below this block
+ blockAbove != Blocks.carpet && blockAbove != Blocks.skull && blockAbove.isCollidable() &&
+ blockAbove.getCollisionBoundingBox(world, blockPosAbove, world.getBlockState(blockPosAbove)) != null ||
+ //Don't allow teleport to the block below this block
+ blockAbove == Blocks.wall_sign || block == Blocks.standing_sign ||
+ //Allow teleport to the block 2 blocks below this block
+ twoBlockAbove != Blocks.air && twoBlockAbove != Blocks.double_plant && twoBlockAbove != Blocks.carpet &&
+ blockAbove != Blocks.skull) {
denyTpReason = "No air above!";
}
}
}
- if (denyTpReason != null) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- Utils.drawStringCentered(EnumChatFormatting.RED + "Can't TP: " + denyTpReason,
- Minecraft.getMinecraft().fontRendererObj,
- scaledResolution.getScaledWidth() / 2f, scaledResolution.getScaledHeight() / 2f + 10, true, 0
- );
- GlStateManager.color(1, 1, 1, 1);
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.enableEtherwarpHelperOverlay) {
+ if (denyTpReason != null) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ Utils.drawStringCentered(EnumChatFormatting.RED + "Can't TP: " + denyTpReason,
+ Minecraft.getMinecraft().fontRendererObj,
+ scaledResolution.getScaledWidth() / 2f, scaledResolution.getScaledHeight() / 2f + 10, true, 0
+ );
+ GlStateManager.color(1, 1, 1, 1);
+ }
}
}
@@ -326,7 +337,7 @@ public class CustomItemEffects {
Minecraft.getMinecraft().objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK &&
onPrivateIsland) {
- IBlockState hover = Minecraft.getMinecraft().theWorld.getBlockState(
+ IBlockState hover = world.getBlockState(
Minecraft.getMinecraft().objectMouseOver.getBlockPos().offset(
Minecraft.getMinecraft().objectMouseOver.sideHit, 1));
if (hover.getBlock() == Blocks.air) {
@@ -338,14 +349,14 @@ public class CustomItemEffects {
TreeMap> candidatesOldSorted = new TreeMap<>();
IBlockState match =
- Minecraft.getMinecraft().theWorld.getBlockState(Minecraft.getMinecraft().objectMouseOver.getBlockPos());
+ world.getBlockState(Minecraft.getMinecraft().objectMouseOver.getBlockPos());
Item matchItem = Item.getItemFromBlock(match.getBlock());
if (matchItem != null) {
ItemStack matchStack = new ItemStack(matchItem, 1,
match
.getBlock()
.getDamageValue(
- Minecraft.getMinecraft().theWorld,
+ world,
Minecraft.getMinecraft().objectMouseOver.getBlockPos()
)
);
@@ -603,7 +614,8 @@ public class CustomItemEffects {
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) event.partialTicks;
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) event.partialTicks;
- if (tick - lastEtherwarpUse > 10) {
+ //Don't need to wait 10 ticks when zoom is disabled
+ if (tick - lastEtherwarpUse > 10 || !NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpZoom) {
boolean aotv = Minecraft.getMinecraft().thePlayer.isSneaking() &&
(heldInternal.equals("ASPECT_OF_THE_VOID") || heldInternal.equals("ASPECT_OF_THE_END"));
if (aotv || heldInternal.equals("ETHERWARP_CONDUIT")) {
@@ -632,20 +644,30 @@ public class CustomItemEffects {
if (etherwarpRaycast != null &&
NotEnoughUpdates.INSTANCE.config.itemOverlays.enableEtherwarpBlockOverlay) {
- AxisAlignedBB bb = etherwarpRaycast.state.getBlock().getSelectedBoundingBox(
- Minecraft.getMinecraft().theWorld,
- etherwarpRaycast.pos
- )
- .expand(0.01D, 0.01D, 0.01D).offset(-d0, -d1, -d2);
- drawFilledBoundingBox(bb, 1f, NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpHighlightColour);
+ if (denyTpReason == null || !NotEnoughUpdates.INSTANCE.config.itemOverlays.disableOverlayWhenFailed) {
+ AxisAlignedBB box = etherwarpRaycast.state.getBlock().getSelectedBoundingBox(
+ Minecraft.getMinecraft().theWorld,
+ etherwarpRaycast.pos
+ );
+ AxisAlignedBB bb = box.expand(0.01D, 0.01D, 0.01D).offset(-d0, -d1, -d2);
+ drawFilledBoundingBox(
+ bb,
+ 1f,
+ NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpHighlightColour
+ );
- GlStateManager.disableDepth();
- drawOutlineBoundingBox(bb, 2f, NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpHighlightColour);
- GlStateManager.enableDepth();
+ GlStateManager.disableDepth();
+ drawOutlineBoundingBox(
+ bb,
+ 2f,
+ NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpHighlightColour
+ );
+ GlStateManager.enableDepth();
- GlStateManager.depthMask(true);
- GlStateManager.enableTexture2D();
- GlStateManager.disableBlend();
+ GlStateManager.depthMask(true);
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
+ }
if (NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpZoom) {
float distFactor = 1 -
--
cgit
From c1e711d270693e198781f3b6591f95c14eb5a6d1 Mon Sep 17 00:00:00 2001
From: hannibal2 <24389977+hannibal002@users.noreply.github.com>
Date: Thu, 13 Oct 2022 22:21:01 +0200
Subject: NPE Fix (#364)
prevent an npe
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
---
.../notenoughupdates/miscfeatures/CustomItemEffects.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
(limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java')
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
index c77a4b39..452f8a9b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
@@ -213,12 +213,14 @@ public class CustomItemEffects {
@SubscribeEvent
public void onGameTick(TickEvent.ClientTickEvent event) {
if (event.phase != TickEvent.Phase.END) return;
+ EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ if (player == null) return;
if (!usingEtherwarp && wasUsingEtherwarp) {
- if (Minecraft.getMinecraft().thePlayer.rotationYaw > 0) {
- Minecraft.getMinecraft().thePlayer.rotationYaw -= 0.000001;
+ if (player.rotationYaw > 0) {
+ player.rotationYaw -= 0.000001;
} else {
- Minecraft.getMinecraft().thePlayer.rotationYaw += 0.000001;
+ player.rotationYaw += 0.000001;
}
}
wasUsingEtherwarp = usingEtherwarp;
--
cgit