Compare commits

...
Author SHA1 Message Date
Nikolay S. addd244ae9 Merge branch 'master' into fixLenses 2026-10-03 20:39:54 -05:00
Edgar Su 5a6b05f13c fix liquefaction focus not making lava (#147) 2026-10-03 20:23:20 -05:00
micvog 51763e0f80 Fix Synthskin draining Nutrition while the hunger bar is full (#148) 2026-09-30 14:03:11 +00:00
TheHoblit af4553527b missed an instancoef 2026-09-17 20:55:26 -07:00
TheHoblit e6b1e812e4 spotless 2026-09-17 20:43:44 -07:00
TheHoblit 13ef513606 enhanced instancoef in LensManager 2026-09-17 20:42:09 -07:00
TheHoblit e5e909a1d9 Actual baubles expanded compat 2026-09-17 20:42:09 -07:00
thehoblit bd81ed98c2 Merge branch 'master' into fixLenses 2026-09-17 19:08:27 -07:00
TheHoblit 6e171035e9 Baubles expanded compat 2026-09-17 19:07:26 -07:00
TheHoblit 3d42586e5a THKeyHandler early return 2026-09-17 18:55:11 -07:00
TheHoblit 89226ba3d3 RenderEventHandler early return 2026-09-17 18:55:02 -07:00
TheHoblit 96fca6c38f LensManager string check 2026-09-17 18:54:55 -07:00
Martin Robertz 21ab790045 update+gradle+bs+deps+gitignore
fix curse auto uploader
2026-09-18 00:28:41 +02:00
TheHoblit f3a80c9908 fix log message 2026-09-16 20:08:52 -07:00
TheHoblit 877647fea9 Use better map access 2026-09-16 19:46:10 -07:00
TheHoblit 8206d65215 Consolidate lens retrieval 2026-09-15 19:50:36 -07:00
TheHoblit aaa11bfa93 refactor RenderEventHandler maps in to data class 2026-09-15 19:32:52 -07:00
TheHoblit fb6a75a20a early returns in RenderEventHandler 2026-09-15 19:20:36 -07:00
TheHoblit 85a5336f39 clean ItemLensOrderEntropy 2026-09-15 19:16:39 -07:00
TheHoblit ebb6256c2c clean PacketFingersToServer 2026-09-13 17:50:17 -07:00
TheHoblit 03e99c835d spotless 2026-09-13 17:46:49 -07:00
TheHoblit e732515e4b remove unused variables from PacketToggleInvisibleToServer 2026-09-13 17:46:28 -07:00
TheHoblit 7634c7ca7e selfInfusionSecurityCheck cleanup 2026-09-13 17:44:59 -07:00
TheHoblit 49739affff clean PacketToggleClimbToServer 2026-09-13 17:39:58 -07:00
TheHoblit 11955a477c pouch assignment 2026-09-13 17:32:01 -07:00
TheHoblit f742e9315c spotless 2026-09-13 13:58:31 -07:00
TheHoblit af038f0b58 Improve mouse capture state on radial menu changing 2026-09-13 13:58:10 -07:00
github-actions[bot]andGitHub GTNH Actions 13d94d8098 Spotless apply for branch fixLenses for #127 (#145)
Co-authored-by: GitHub GTNH Actions <>
2026-09-13 21:42:21 +02:00
TheHoblit e8b7078a61 Revert intellij requireNonNull 2026-09-13 12:08:16 -07:00
TheHoblit 11d811ee8b Further clean up PacketLensChangeToServer 2026-09-13 12:05:01 -07:00
github-actions[bot]andGitHub GTNH Actions a605a162b9 Spotless apply for branch fixLenses for #127 (#144)
Co-authored-by: GitHub GTNH Actions <>
2026-09-12 17:49:12 -07:00
TheHoblit 8cacfdab7e More Intellij 2026-09-12 17:41:50 -07:00
TheHoblit b332fc8b1d Playing Intellij Wack-a-mole 2026-09-12 17:30:30 -07:00
TheHoblit c1d8e816cf refactor player entity checks in packetLensChangeToServer 2026-09-12 16:21:16 -07:00
TheHoblit 607d31b4f7 Remove unnecessary sideonly annotation 2026-09-12 16:09:15 -07:00
TheHoblit 6414c927d9 Remove redundant playerID check in packet 2026-09-12 16:08:34 -07:00
TheHoblit a67ba44d44 Add generic descriptors to maps 2026-09-12 16:08:14 -07:00
thehoblit 81a24dceca Merge branch 'master' into fixLenses 2026-09-10 15:25:47 -07:00
f42bcf230b Fix cloned mob item dupe (#122)
Co-authored-by: tiffit <10173431+tiffit@users.noreply.github.com>
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: Nikolay S. <nicksitnikov@gmail.com>
2026-09-07 19:33:28 +00:00
Martin Robertz e985a0c763 update+bs+deps 2026-09-06 19:21:48 +02:00
Mykhailo Balakerandkoolkrafter5 d9867a343e Fix Ethereal Shard ClassCastException upon being jared (#141)
Co-authored-by: koolkrafter5 <creepersrgreen@gmail.com>
2026-09-06 19:06:11 +02:00
thehoblit dd17915ad1 Merge branch 'master' into fixLenses 2026-08-29 22:21:04 -07:00
Ableytner ec0a44d6dd Display Warded Syringe with correct NBT data in NEI (#137) 2026-07-31 19:37:21 +02:00
thehoblit 3242e7c9eb Merge branch 'master' into fixLenses 2026-07-12 11:36:36 -07:00
tiffit b2186e92f9 Move pocket plane generation back to main server thread (#134) 2026-07-11 14:30:28 +02:00
thehoblit 0bf4829c16 Fix lens night vision removal 2026-06-10 21:20:56 -07:00
thehoblit 0f122cb17b refactor lens night vision 2026-06-10 20:50:21 -07:00
thehoblit 782efede83 one GUI per keyhold 2026-05-26 21:46:53 -07:00
thehoblit 08f6121791 spotless 2026-05-26 21:25:10 -07:00
thehoblit 7606d87e4d enhanced instanceof and intellij stuff 2026-05-26 21:22:55 -07:00
thehoblit e61cf0d79e prevent gui from instant-swapping randomly 2026-05-26 21:16:47 -07:00
thehoblit ed8d578720 skip duplicate lenses 2026-05-26 21:16:13 -07:00
thehoblit 53921befa3 early return before menu logic 2026-05-26 20:58:06 -07:00
thehoblit 31bf12189f Fix various menu bugs 2026-05-26 20:16:37 -07:00
thehoblit 7cd3fcf8b2 Many such fixes 2026-05-25 18:47:38 -07:00
36 changed files with 988 additions and 1083 deletions

No files matched your search

+1
View File
@@ -27,6 +27,7 @@ whitelist.json
*.iws
src/main/resources/mixins.*.json
*.bat
*.sh
*.DS_Store
!gradlew.bat
layout.json
+3 -3
View File
@@ -1,10 +1,10 @@
// Add your dependencies here
dependencies {
api('com.github.GTNewHorizons:Baubles-Expanded:2.2.21-GTNH:dev')
api('com.github.GTNewHorizons:Baubles-Expanded:2.2.24-GTNH:dev')
api('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.548:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.54.168:dev') {transitive = false}
runtimeOnlyNonPublishable('com.github.GTNewHorizons:AspectRecipeIndex:1.1.0:dev')
runtimeOnlyNonPublishable('com.github.GTNewHorizons:AspectRecipeIndex:1.1.5:dev')
}
+5
View File
@@ -186,6 +186,11 @@ modrinthRelations =
# Leave this empty if you don't want to publish on CurseForge.
curseForgeProjectId = 227914
# Comma-separated supported CurseForge environments: client, server (case-insensitive).
# Use client or server for mods that only support one environment. Defaults to client,server.
# These tags describe where the mod can run, not whether installation is required on both sides.
curseForgeEnvironments = client,server
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
# Syntax: type1:name1;type2:name2;...
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
+10 -10
View File
@@ -1,12 +1,12 @@
#This file is generated by updateDaemonJvm
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/cd495626d2ee49a75447e3fdc6afb287/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/cd495626d2ee49a75447e3fdc6afb287/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/d4fd992c9557644e637ebe98263e0ae7/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/faa12903720d410b387cc69ccafb1a74/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/cd495626d2ee49a75447e3fdc6afb287/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/8e1d9ee5d0f13e442218f6884a306da1/redirect
toolchainVendor=ADOPTIUM
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/539ea72837c6244075f8ee037babc29e/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/876dbbf00bf4ef6190f7da074cee903a/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/539ea72837c6244075f8ee037babc29e/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/876dbbf00bf4ef6190f7da074cee903a/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/9064f22734b42ac03e85df04b632e167/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/4d0277c49991306ac78048580fe34bcf/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/539ea72837c6244075f8ee037babc29e/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/876dbbf00bf4ef6190f7da074cee903a/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/a9fa3b809e484a1e1ac4308a5dda661a/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/aa99913fa6d767d899ffc96082da01ca/redirect
toolchainVersion=25
Binary file not shown.
+3 -1
View File
@@ -1,7 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+3 -3
View File
@@ -20,7 +20,7 @@
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
# gradlew start up script for POSIX generated by Gradle.
#
# Important for running:
#
@@ -29,7 +29,7 @@
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
# ksh gradlew
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
@@ -57,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Vendored
+12 -23
View File
@@ -19,12 +19,12 @@
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem gradlew startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Set local scope for the variables, and ensure extensions are enabled
setlocal EnableExtensions
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@@ -51,7 +51,7 @@ echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
"%COMSPEC%" /c exit 1
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
@@ -65,29 +65,18 @@ echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
"%COMSPEC%" /c exit 1
:execute
@rem Setup the command line
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
@rem Execute gradlew
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
@rem which allows us to clear the local environment before executing the java command
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
:exitWithErrorLevel
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
"%COMSPEC%" /c exit %ERRORLEVEL%
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.24'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.31'
}
@@ -283,7 +283,7 @@ public class ClientProxy extends CommonProxy {
return new GuiVat(player, (TileVat) world.getTileEntity(x, y, z));
}
case 8 -> {
return new GuiCase(player.inventory, world, x, y, z);
return new GuiCase(player.inventory, world);
}
case 9 -> {
return new GuiFingers(player.inventory);
@@ -21,9 +21,8 @@ public class GuiCase extends GuiContainer {
private final int blockSlot;
public GuiCase(final InventoryPlayer par1InventoryPlayer, final World world, final int x, final int y,
final int z) {
super(new ContainerCase(par1InventoryPlayer, world, x, y, z));
public GuiCase(final InventoryPlayer par1InventoryPlayer, final World world) {
super(new ContainerCase(par1InventoryPlayer, world));
this.blockSlot = par1InventoryPlayer.currentItem;
this.xSize = 176;
this.ySize = 233;
@@ -4,8 +4,9 @@
package com.kentington.thaumichorizons.client.lib;
import static com.kentington.thaumichorizons.common.items.lenses.LensPotionEffects.isNightVisionGrantedByLens;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.TreeMap;
import net.minecraft.block.Block;
@@ -36,7 +37,6 @@ import com.kentington.thaumichorizons.common.ThaumicHorizons;
import com.kentington.thaumichorizons.common.entities.EntityBoatThaumium;
import com.kentington.thaumichorizons.common.items.lenses.ILens;
import com.kentington.thaumichorizons.common.items.lenses.ItemLensCase;
import com.kentington.thaumichorizons.common.items.lenses.ItemLensFire;
import com.kentington.thaumichorizons.common.items.lenses.LensManager;
import com.kentington.thaumichorizons.common.lib.THKeyHandler;
import com.kentington.thaumichorizons.common.lib.networking.PacketHandler;
@@ -53,11 +53,23 @@ import thaumcraft.common.Thaumcraft;
public class RenderEventHandler {
static float radialHudScale;
TreeMap<String, Integer> foci;
HashMap<String, ItemStack> fociItem;
HashMap<String, Boolean> fociHover;
HashMap<String, Float> fociScale;
private static class FocusRenderInfo {
int slot;
ItemStack item;
float scale;
boolean hover;
FocusRenderInfo(final int slot, final ItemStack item) {
this.slot = slot;
this.item = item;
this.scale = 1.0f;
this.hover = false;
}
}
public static float radialHudScale;
TreeMap<String, FocusRenderInfo> foci;
long lastTime;
boolean lastState;
float breakProgress;
@@ -72,9 +84,6 @@ public class RenderEventHandler {
public RenderEventHandler() {
this.foci = new TreeMap<>();
this.fociItem = new HashMap<>();
this.fociHover = new HashMap<>();
this.fociScale = new HashMap<>();
this.lastTime = 0L;
this.lastState = false;
this.breakProgress = 0.0f;
@@ -92,159 +101,156 @@ public class RenderEventHandler {
public void renderOverlay(final RenderGameOverlayEvent event) {
final Minecraft mc = Minecraft.getMinecraft();
final long time = System.nanoTime() / 1000000L;
if (event.type == RenderGameOverlayEvent.ElementType.TEXT) {
this.handleFociRadial(mc, time, event);
final ItemStack goggles = mc.thePlayer.inventory.armorItemInSlot(3);
if (LensManager.nightVisionOffTime > 0L
&& (goggles == null || !(goggles.getItem() instanceof IRevealer)
|| goggles.stackTagCompound == null)
&& ItemLensFire.isEffectGrantedByLens(mc.thePlayer.getActivePotionEffect(Potion.nightVision))) {
mc.thePlayer.removePotionEffect(Potion.nightVision.id);
LensManager.nightVisionOffTime = 0L;
}
if (goggles != null && goggles.getItem() instanceof IRevealer
&& goggles.stackTagCompound != null
&& goggles.stackTagCompound.getString("Lens") != null
&& !goggles.stackTagCompound.getString("Lens").equals("")) {
final ILens theLens = (ILens) LensManager.getLens(goggles.stackTagCompound.getString("Lens"));
if (theLens != null) {
theLens.handleRender(mc, event.partialTicks);
}
}
if (event.type != RenderGameOverlayEvent.ElementType.TEXT) return;
final ItemStack goggles = mc.thePlayer.inventory.armorItemInSlot(3);
final boolean hasRevealerGoggles = goggles != null && goggles.getItem() instanceof IRevealer;
if (LensManager.nightVisionOffTime > 0L && (!hasRevealerGoggles || goggles.stackTagCompound == null)
&& isNightVisionGrantedByLens(mc.thePlayer.getActivePotionEffect(Potion.nightVision))) {
mc.thePlayer.removePotionEffect(Potion.nightVision.id);
LensManager.nightVisionOffTime = 0L;
}
if (!hasRevealerGoggles) return;
this.handleFociRadial(mc, time, event, goggles);
final ILens theLens = LensManager.getLensFromItem(goggles);
if (theLens != null) {
theLens.handleRender(mc, event.partialTicks);
}
}
@SideOnly(Side.CLIENT)
public void handleFociRadial(final Minecraft mc, final long time, final RenderGameOverlayEvent event) {
if (THKeyHandler.radialActive || RenderEventHandler.radialHudScale > 0.0f) {
final long timeDiff = System.currentTimeMillis() - THKeyHandler.lastPressV;
if (THKeyHandler.radialActive) {
if (mc.currentScreen != null) {
THKeyHandler.radialActive = false;
THKeyHandler.radialLock = true;
mc.setIngameFocus();
mc.setIngameNotInFocus();
return;
}
if (RenderEventHandler.radialHudScale == 0.0f) {
this.foci.clear();
this.fociItem.clear();
this.fociHover.clear();
this.fociScale.clear();
int pouchcount = 0;
ItemStack item = null;
final IInventory baubles = BaublesApi.getBaubles(mc.thePlayer);
for (int a = 0; a < 4; ++a) {
if (baubles.getStackInSlot(a) != null
&& baubles.getStackInSlot(a).getItem() instanceof ItemLensCase) {
++pouchcount;
item = baubles.getStackInSlot(a);
final ItemStack[] inv = ((ItemLensCase) item.getItem()).getInventory(item);
for (int q = 0; q < inv.length; ++q) {
item = inv[q];
if (item != null && item.getItem() instanceof ILens) {
this.foci.put(((ILens) item.getItem()).lensName(), q + pouchcount * 1000);
this.fociItem.put(((ILens) item.getItem()).lensName(), item.copy());
this.fociScale.put(((ILens) item.getItem()).lensName(), 1.0f);
this.fociHover.put(((ILens) item.getItem()).lensName(), false);
}
public void handleFociRadial(final Minecraft mc, final long time, final RenderGameOverlayEvent event,
final ItemStack goggles) {
if (!THKeyHandler.radialActive && RenderEventHandler.radialHudScale <= 0.0f) return;
if (THKeyHandler.radialActive) {
if (mc.currentScreen != null) {
THKeyHandler.radialActive = false;
THKeyHandler.radialLock = true;
THKeyHandler.radialSelectionMade = true;
mc.setIngameFocus();
mc.setIngameNotInFocus();
return;
}
if (RenderEventHandler.radialHudScale == 0.0f && !THKeyHandler.radialLock) {
this.foci.clear();
THKeyHandler.radialLock = true;
int pouchcount = 0;
ItemStack item;
final String currentLensName = goggles.stackTagCompound != null
? goggles.stackTagCompound.getString("Lens")
: null;
final IInventory baubles = BaublesApi.getBaubles(mc.thePlayer);
for (int a = 0; a < baubles.getSizeInventory(); ++a) {
if (baubles.getStackInSlot(a) != null
&& baubles.getStackInSlot(a).getItem() instanceof ItemLensCase lensCase) {
++pouchcount;
item = baubles.getStackInSlot(a);
final ItemStack[] inv = lensCase.getInventory(item);
for (int q = 0; q < inv.length; ++q) {
item = inv[q];
if (item != null && item.getItem() instanceof ILens lens) {
final String lensName = lens.lensName();
if (lensName.equals(currentLensName) || this.foci.containsKey(lensName)) continue;
this.foci.put(lensName, new FocusRenderInfo(q + pouchcount * 1000, item.copy()));
}
}
}
for (int a = 0; a < 36; ++a) {
item = mc.thePlayer.inventory.mainInventory[a];
if (item != null && item.getItem() instanceof ILens) {
this.foci.put(((ILens) item.getItem()).lensName(), a);
this.fociItem.put(((ILens) item.getItem()).lensName(), item.copy());
this.fociScale.put(((ILens) item.getItem()).lensName(), 1.0f);
this.fociHover.put(((ILens) item.getItem()).lensName(), false);
}
for (int a = 0; a < 36; ++a) {
item = mc.thePlayer.inventory.mainInventory[a];
if (item != null && item.getItem() instanceof ILens lens) {
final String lensName = lens.lensName();
if (!lensName.equals(currentLensName) && !this.foci.containsKey(lensName)) {
this.foci.put(lensName, new FocusRenderInfo(a, item.copy()));
}
if (item != null && item.getItem() instanceof ItemLensCase) {
++pouchcount;
final ItemStack[] inv = ((ItemLensCase) item.getItem()).getInventory(item);
for (int q = 0; q < inv.length; ++q) {
item = inv[q];
if (item != null && item.getItem() instanceof ILens) {
this.foci.put(((ILens) item.getItem()).lensName(), q + pouchcount * 1000);
this.fociItem.put(((ILens) item.getItem()).lensName(), item.copy());
this.fociScale.put(((ILens) item.getItem()).lensName(), 1.0f);
this.fociHover.put(((ILens) item.getItem()).lensName(), false);
}
}
if (item != null && item.getItem() instanceof ItemLensCase lensCase) {
++pouchcount;
final ItemStack[] inv = lensCase.getInventory(item);
for (int q = 0; q < inv.length; ++q) {
item = inv[q];
if (item != null && item.getItem() instanceof ILens lens) {
final String lensName = lens.lensName();
if (lensName.equals(currentLensName) || this.foci.containsKey(lensName)) continue;
this.foci.put(lensName, new FocusRenderInfo(q + pouchcount * 1000, item.copy()));
}
}
}
if (this.foci.size() > 0 && mc.inGameHasFocus) {
mc.inGameHasFocus = false;
mc.mouseHelper.ungrabMouseCursor();
}
}
} else if (mc.currentScreen == null && this.lastState) {
if (Display.isActive() && !mc.inGameHasFocus) {
mc.inGameHasFocus = true;
mc.mouseHelper.grabMouseCursor();
if (!this.foci.isEmpty() && mc.inGameHasFocus) {
mc.inGameHasFocus = false;
mc.mouseHelper.ungrabMouseCursor();
}
this.lastState = false;
}
this.renderFocusRadialHUD(
event.resolution.getScaledWidth_double(),
event.resolution.getScaledHeight_double(),
time,
event.partialTicks);
if (time > this.lastTime) {
for (final String key : this.fociHover.keySet()) {
if (this.fociHover.get(key)) {
if (!THKeyHandler.radialActive && !THKeyHandler.radialLock) {
PacketHandler.INSTANCE.sendToServer(new PacketLensChangeToServer(mc.thePlayer, key));
THKeyHandler.radialLock = true;
}
if (this.fociScale.get(key) >= 1.3f) {
continue;
}
this.fociScale.put(key, this.fociScale.get(key) + 0.025f);
} else {
if (this.fociScale.get(key) <= 1.0f) {
continue;
}
this.fociScale.put(key, this.fociScale.get(key) - 0.025f);
}
}
if (!THKeyHandler.radialActive) {
RenderEventHandler.radialHudScale -= 0.05f;
} else if (THKeyHandler.radialActive && RenderEventHandler.radialHudScale < 1.0f) {
RenderEventHandler.radialHudScale += 0.05f;
}
if (RenderEventHandler.radialHudScale > 1.0f) {
RenderEventHandler.radialHudScale = 1.0f;
}
if (RenderEventHandler.radialHudScale < 0.0f) {
RenderEventHandler.radialHudScale = 0.0f;
THKeyHandler.radialLock = false;
}
this.lastTime = time + 5L;
this.lastState = THKeyHandler.radialActive;
} else if (mc.currentScreen == null && this.lastState) {
if (Display.isActive() && !mc.inGameHasFocus) {
mc.inGameHasFocus = true;
mc.mouseHelper.grabMouseCursor();
}
this.lastState = false;
}
this.renderFocusRadialHUD(
event.resolution.getScaledWidth_double(),
event.resolution.getScaledHeight_double(),
event.partialTicks,
goggles);
if (time > this.lastTime) {
for (final var entry : this.foci.entrySet()) {
FocusRenderInfo renderInfo = entry.getValue();
if (renderInfo.hover) {
if (!THKeyHandler.radialActive && !THKeyHandler.radialLock) {
PacketHandler.INSTANCE.sendToServer(new PacketLensChangeToServer(entry.getKey()));
THKeyHandler.radialLock = true;
if (Display.isActive() && !mc.inGameHasFocus) {
mc.inGameHasFocus = true;
mc.mouseHelper.grabMouseCursor();
}
}
if (renderInfo.scale >= 1.3f) {
continue;
}
renderInfo.scale += 0.025f;
} else {
if (renderInfo.scale <= 1.0f) {
continue;
}
renderInfo.scale -= 0.025f;
}
}
if (!THKeyHandler.radialActive) {
RenderEventHandler.radialHudScale -= 0.05f;
} else if (RenderEventHandler.radialHudScale < 1.0f) {
RenderEventHandler.radialHudScale += 0.05f;
}
if (RenderEventHandler.radialHudScale > 1.0f) {
RenderEventHandler.radialHudScale = 1.0f;
THKeyHandler.radialLock = false;
}
if (RenderEventHandler.radialHudScale < 0.0f) {
RenderEventHandler.radialHudScale = 0.0f;
THKeyHandler.radialLock = false;
}
this.lastTime = time + 5L;
this.lastState = THKeyHandler.radialActive;
}
}
@SideOnly(Side.CLIENT)
private void renderFocusRadialHUD(final double sw, final double sh, final long time, final float partialTicks) {
private void renderFocusRadialHUD(final double sw, final double sh, final float partialTicks,
final ItemStack goggles) {
final RenderItem ri = new RenderItem();
final Minecraft mc = Minecraft.getMinecraft();
if (mc.thePlayer.inventory.armorItemInSlot(3) == null
|| !(mc.thePlayer.inventory.armorItemInSlot(3).getItem() instanceof IRevealer)) {
return;
}
final ItemStack goggles = mc.thePlayer.inventory.armorItemInSlot(3);
ILens lens = null;
if (goggles.stackTagCompound != null) {
lens = (ILens) LensManager.getLens(goggles.stackTagCompound.getString("Lens"));
}
final int i = (int) (Mouse.getEventX() * sw / mc.displayWidth);
final int j = (int) (sh - Mouse.getEventY() * sh / mc.displayHeight - 1.0);
final ILens lens = LensManager.getLensFromItem(goggles);
final int i = (int) (Mouse.getX() * sw / mc.displayWidth);
final int j = (int) (sh - Mouse.getY() * sh / mc.displayHeight - 1.0);
final int k = Mouse.getEventButton();
if (this.fociItem.size() == 0) {
return;
}
if (this.foci.isEmpty()) return;
GL11.glPushMatrix();
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
GL11.glMatrixMode(GL11.GL_PROJECTION);
@@ -258,7 +264,7 @@ public class RenderEventHandler {
GL11.glPushMatrix();
GL11.glTranslated(sw / 2.0, sh / 2.0, 0.0);
ItemStack tt = null;
final float width = 16.0f + this.fociItem.size() * 2.5f;
final float width = 16.0f + this.foci.size() * 2.5f;
UtilsFX.bindTexture("textures/misc/radial.png");
GL11.glPushMatrix();
GL11.glRotatef(partialTicks + mc.thePlayer.ticksExisted % 720 / 2.0f, 0.0f, 0.0f, 1.0f);
@@ -314,37 +320,45 @@ public class RenderEventHandler {
RenderEventHandler.radialHudScale,
RenderEventHandler.radialHudScale);
float currentRot = -90.0f * RenderEventHandler.radialHudScale;
final float pieSlice = 360.0f / this.fociItem.size();
final float pieSlice = 360.0f / this.foci.size();
String key = this.foci.firstKey();
for (int a = 0; a < this.fociItem.size(); ++a) {
for (int a = 0; a < this.foci.size(); ++a) {
final FocusRenderInfo renderInfo = this.foci.get(key);
final double xx = MathHelper.cos(currentRot / 180.0f * (float) Math.PI) * width;
final double yy = MathHelper.sin(currentRot / 180.0f * (float) Math.PI) * width;
currentRot += pieSlice;
GL11.glPushMatrix();
GL11.glTranslated(xx, yy, 100.0);
GL11.glScalef(this.fociScale.get(key), this.fociScale.get(key), this.fociScale.get(key));
GL11.glScalef(renderInfo.scale, renderInfo.scale, renderInfo.scale);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
final ItemStack item2 = this.fociItem.get(key).copy();
final ItemStack item2 = renderInfo.item.copy();
item2.stackTagCompound = null;
ri.renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, item2, -8, -8);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
if (!THKeyHandler.radialLock && THKeyHandler.radialActive) {
final int mx2 = (int) (i - sw / 2.0 - xx);
final int my2 = (int) (j - sh / 2.0 - yy);
if (!THKeyHandler.radialLock && THKeyHandler.radialActive && RenderEventHandler.radialHudScale >= 1.0f) {
final double scaledXX = xx * RenderEventHandler.radialHudScale;
final double scaledYY = yy * RenderEventHandler.radialHudScale;
final int mx2 = (int) (i - sw / 2.0 - scaledXX);
final int my2 = (int) (j - sh / 2.0 - scaledYY);
if (mx2 >= -10 && mx2 <= 10 && my2 >= -10 && my2 <= 10) {
this.fociHover.put(key, true);
tt = this.fociItem.get(key);
renderInfo.hover = true;
tt = renderInfo.item;
if (k == 0) {
THKeyHandler.radialActive = false;
THKeyHandler.radialLock = true;
PacketHandler.INSTANCE.sendToServer(new PacketLensChangeToServer(mc.thePlayer, key));
THKeyHandler.radialSelectionMade = true;
PacketHandler.INSTANCE.sendToServer(new PacketLensChangeToServer(key));
if (Display.isActive() && !mc.inGameHasFocus) {
mc.inGameHasFocus = true;
mc.mouseHelper.grabMouseCursor();
}
break;
}
} else {
this.fociHover.put(key, false);
renderInfo.hover = false;
}
}
key = this.foci.higherKey(key);
@@ -372,28 +386,19 @@ public class RenderEventHandler {
public void blockHighlight(final DrawBlockHighlightEvent event) {
final Minecraft mc = Minecraft.getMinecraft();
final ItemStack goggles = mc.thePlayer.inventory.armorItemInSlot(3);
if (goggles != null && goggles.getItem() instanceof IRevealer && goggles.stackTagCompound != null) {
if (goggles.stackTagCompound.getString("Lens") != null
&& !goggles.stackTagCompound.getString("Lens").equals("")) {
final ILens theLens = (ILens) LensManager.getLens(goggles.stackTagCompound.getString("Lens"));
if (theLens == ThaumicHorizons.itemLensEarth) {
if (this.cacheX != event.target.blockX || this.cacheY != event.target.blockY
|| this.cacheZ != event.target.blockZ
|| this.tempDir != ForgeDirection.getOrientation(event.target.sideHit)) {
this.resetBlocks(mc.thePlayer);
}
if (event.player.worldObj.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ)
.getMaterial() != Material.air) {
this.cacheX = event.target.blockX;
this.cacheY = event.target.blockY;
this.cacheZ = event.target.blockZ;
this.tempDir = ForgeDirection.getOrientation(event.target.sideHit);
} else {
this.resetBlocks(mc.thePlayer);
}
} else {
this.resetBlocks(mc.thePlayer);
}
final ILens theLens = LensManager.getLensFromItem(goggles);
if (theLens != null && theLens == ThaumicHorizons.itemLensEarth) {
if (this.cacheX != event.target.blockX || this.cacheY != event.target.blockY
|| this.cacheZ != event.target.blockZ
|| this.tempDir != ForgeDirection.getOrientation(event.target.sideHit)) {
this.resetBlocks(mc.thePlayer);
}
if (event.player.worldObj.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ)
.getMaterial() != Material.air) {
this.cacheX = event.target.blockX;
this.cacheY = event.target.blockY;
this.cacheZ = event.target.blockZ;
this.tempDir = ForgeDirection.getOrientation(event.target.sideHit);
} else {
this.resetBlocks(mc.thePlayer);
}
@@ -544,18 +549,12 @@ public class RenderEventHandler {
@SubscribeEvent
public void renderTick(final TickEvent.RenderTickEvent event) {
final Minecraft mc = Minecraft.getMinecraft();
if (mc.thePlayer == null) {
return;
}
if (mc.thePlayer == null) return;
final ItemStack goggles = mc.thePlayer.inventory.armorItemInSlot(3);
if (goggles != null && goggles.getItem() instanceof IRevealer
&& goggles.stackTagCompound != null
&& goggles.stackTagCompound.getString("Lens") != null
&& !goggles.stackTagCompound.getString("Lens").equals("")) {
final ILens theLens = (ILens) LensManager.getLens(goggles.stackTagCompound.getString("Lens"));
if (theLens == ThaumicHorizons.itemLensEarth) {
this.setBlocksEvanescent(mc.thePlayer);
}
final ILens theLens = LensManager.getLensFromItem(goggles);
if (theLens != null && theLens == ThaumicHorizons.itemLensEarth) {
this.setBlocksEvanescent(mc.thePlayer);
}
}
@@ -587,15 +586,11 @@ public class RenderEventHandler {
public void clearWater(final RenderBlockOverlayEvent event) {
final Minecraft mc = Minecraft.getMinecraft();
final ItemStack goggles = mc.thePlayer.inventory.armorItemInSlot(3);
if (goggles != null && goggles.getItem() instanceof IRevealer
&& goggles.stackTagCompound != null
&& goggles.stackTagCompound.getString("Lens") != null
&& !goggles.stackTagCompound.getString("Lens").equals("")) {
final ILens theLens = (ILens) LensManager.getLens(goggles.stackTagCompound.getString("Lens"));
if (theLens == ThaumicHorizons.itemLensWater) {
event.setCanceled(true);
}
final ILens theLens = LensManager.getLensFromItem(goggles);
if (theLens != null && theLens == ThaumicHorizons.itemLensWater) {
event.setCanceled(true);
}
if (event.overlayType == RenderBlockOverlayEvent.OverlayType.FIRE
&& mc.thePlayer.ridingEntity instanceof EntityBoatThaumium) {
event.setCanceled(true);
@@ -92,7 +92,7 @@ public class CommonProxy implements IGuiHandler {
return new ContainerVat(player, (TileVat) world.getTileEntity(x, y, z));
}
case 8 -> {
return new ContainerCase(player.inventory, world, x, y, z);
return new ContainerCase(player.inventory, world);
}
case 9 -> {
return new ContainerFingers(player.inventory);
@@ -82,20 +82,19 @@ public class BlockSyntheticNode extends BlockContainer {
return false;
}
public void breakBlock(final World p_149749_1_, final int p_149749_2_, final int p_149749_3_, final int p_149749_4_,
final Block p_149749_5_, final int p_149749_6_) {
final TileSyntheticNode tile = (TileSyntheticNode) p_149749_1_
.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
if (tile != null) {
for (final Aspect asp : tile.getMaxAspects().getAspects()) {
final ItemStack essence = new ItemStack(
ConfigItems.itemWispEssence,
tile.getMaxAspects().getAmount(asp) / 4);
((ItemWispEssence) ConfigItems.itemWispEssence).setAspects(essence, new AspectList().add(asp, 2));
p_149749_1_.spawnEntityInWorld(
new EntityItem(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, essence));
}
public void breakBlock(final World world, final int x, final int y, final int z, final Block block,
final int meta) {
if (!(world.getTileEntity(x, y, z) instanceof TileSyntheticNode tile)) {
super.breakBlock(world, x, y, z, block, meta);
return;
}
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
for (final Aspect asp : tile.getMaxAspects().getAspects()) {
final ItemStack essence = new ItemStack(
ConfigItems.itemWispEssence,
tile.getMaxAspects().getAmount(asp) / 4);
((ItemWispEssence) ConfigItems.itemWispEssence).setAspects(essence, new AspectList().add(asp, 2));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, essence));
}
super.breakBlock(world, x, y, z, block, meta);
}
}
@@ -20,31 +20,22 @@ import thaumcraft.common.container.SlotLimitedByClass;
public class ContainerCase extends Container {
private final World worldObj;
private int posX;
private int posY;
private int posZ;
private int blockSlot;
private final int blockSlot;
public IInventory input;
ItemStack pouch;
EntityPlayer player;
public ContainerCase(final InventoryPlayer iinventory, final World par2World, final int par3, final int par4,
final int par5) {
public ContainerCase(final InventoryPlayer inventory, final World par2World) {
this.input = new InventoryCase(this);
this.pouch = null;
this.player = null;
this.worldObj = par2World;
this.posX = par3;
this.posY = par4;
this.posZ = par5;
this.player = iinventory.player;
this.pouch = iinventory.getCurrentItem();
this.blockSlot = iinventory.currentItem + 45;
this.player = inventory.player;
this.pouch = inventory.getCurrentItem();
this.blockSlot = inventory.currentItem + 45;
for (int a = 0; a < 18; ++a) {
this.addSlotToContainer(
new SlotLimitedByClass(ILens.class, this.input, a, 37 + a % 6 * 18, 51 + a / 6 * 18));
}
this.bindPlayerInventory(iinventory);
this.bindPlayerInventory(inventory);
if (!par2World.isRemote && this.pouch != null
&& this.pouch.getItem() instanceof ItemLensCase lensCase
&& this.input instanceof InventoryCase inv) {
@@ -69,7 +60,7 @@ public class ContainerCase extends Container {
return null;
}
ItemStack stack = null;
final Slot slotObject = (Slot) this.inventorySlots.get(slot);
final Slot slotObject = this.inventorySlots.get(slot);
if (slotObject != null && slotObject.getHasStack()) {
final ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
@@ -87,6 +78,7 @@ public class ContainerCase extends Container {
} else {
slotObject.onSlotChanged();
}
this.detectAndSendChanges();
}
return stack;
}
@@ -401,7 +401,27 @@ public class ItemFocusLiquefaction extends ItemFocusBasic {
final int meltable = this.isMeltableBlock(bi, md);
final boolean flammable = bi.isFlammable(p.worldObj, x, y, z, ForgeDirection.UNKNOWN);
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(bi, 1, md));
if (result != null && wand.consumeAllVis(stack, p, this.getVisCost(stack), true, true)) {
// Meltable blocks (e.g. stone) take priority over any furnace smelting recipe they may have,
// otherwise mods that add a smelting recipe for stone (such as Et Futurum Requiem's smooth
// stone) would prevent the stone -> lava transmutation.
if (meltable > 0 && wand.consumeAllVis(stack, p, this.getVisCost(stack), true, true)) {
if (meltable == 1) {
p.worldObj.setBlockToAir(x, y, z);
} else if (meltable == 2) {
if (p.worldObj.provider.dimensionId != -1) {
p.worldObj.setBlock(x, y, z, Blocks.water, 0, 3);
} else {
p.worldObj.setBlockToAir(x, y, z);
}
} else if (meltable == 3) {
p.worldObj.setBlock(x, y, z, Blocks.dirt, 0, 3);
} else if (meltable == 4) {
Blocks.tnt.onBlockDestroyedByPlayer(p.worldObj, x, y, z, 1);
p.worldObj.setBlockToAir(x, y, z);
} else if (meltable == 6) {
p.worldObj.setBlock(x, y, z, Blocks.lava, 0, 3);
}
} else if (result != null && wand.consumeAllVis(stack, p, this.getVisCost(stack), true, true)) {
if (this.getUpgradeLevel(wand.getFocusItem(stack), ItemFocusLiquefaction.purity) > 0
&& Utils.findSpecialMiningResult(new ItemStack(bi, 1, md), 9999.0f, p.worldObj.rand) != null) {
final ItemStack pure = Utils
@@ -433,23 +453,6 @@ public class ItemFocusLiquefaction extends ItemFocusBasic {
theItem.setEntityItemStack(result.copy());
p.worldObj.spawnEntityInWorld(theItem);
}
} else if (meltable > 0 && wand.consumeAllVis(stack, p, this.getVisCost(stack), true, true)) {
if (meltable == 1) {
p.worldObj.setBlockToAir(x, y, z);
} else if (meltable == 2) {
if (p.worldObj.provider.dimensionId != -1) {
p.worldObj.setBlock(x, y, z, Blocks.water, 0, 3);
} else {
p.worldObj.setBlockToAir(x, y, z);
}
} else if (meltable == 3) {
p.worldObj.setBlock(x, y, z, Blocks.dirt, 0, 3);
} else if (meltable == 4) {
Blocks.tnt.onBlockDestroyedByPlayer(p.worldObj, x, y, z, 1);
p.worldObj.setBlockToAir(x, y, z);
} else if (meltable == 6) {
p.worldObj.setBlock(x, y, z, Blocks.lava, 0, 3);
}
} else if (flammable && wand.consumeAllVis(stack, p, this.getVisCost(stack), true, true)) {
p.worldObj.setBlock(x, y, z, Blocks.fire);
}
@@ -4,7 +4,10 @@
package com.kentington.thaumichorizons.common.items;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
@@ -43,6 +46,11 @@ public class ItemSyringeEmpty extends Item {
return this.icon;
}
@SideOnly(Side.CLIENT)
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List par3List) {
par3List.add(new ItemStack(this, 1, 2));
}
public String getUnlocalizedName(final ItemStack par1ItemStack) {
return "item.syringeEmpty";
}
@@ -60,6 +68,11 @@ public class ItemSyringeEmpty extends Item {
final NBTTagCompound critterTag = new NBTTagCompound();
critter.writeToNBT(critterTag);
critterTag.setString("id", EntityList.getEntityString(ent));
// Strip inventory-related tags - a blood sample should only carry genetic data
critterTag.removeTag("Items");
critterTag.removeTag("ArmorItem");
critterTag.removeTag("SaddleItem");
critterTag.removeTag("ChestedHorse");
bloodSample.stackTagCompound.setString("critterName", ent.getCommandSenderName());
bloodSample.stackTagCompound.setTag("critter", critterTag);
if (p.inventory.addItemStackToInventory(bloodSample)) {
@@ -45,13 +45,18 @@ public class ItemLensAir extends Item implements ILens {
return "LensAir";
}
@Override
public int getItemStackLimit(ItemStack stack) {
return 1;
}
@SideOnly(Side.CLIENT)
public void handleRender(final Minecraft mc, final float partialTicks) {
if (mc.gameSettings.thirdPersonView > 0) {
return;
}
final EntityPlayer player = mc.thePlayer;
final List<Entity> critters = (List<Entity>) player.worldObj.getEntitiesWithinAABBExcludingEntity(
final List<Entity> critters = player.worldObj.getEntitiesWithinAABBExcludingEntity(
mc.thePlayer,
AxisAlignedBB.getBoundingBox(
player.posX - 24.0,
@@ -121,7 +126,8 @@ public class ItemLensAir extends Item implements ILens {
numRipples = 4;
}
for (int i = 0; i < numRipples; ++i) {
final double ripSize = size * ((i * 16 / (numRipples + 1) + sizeOffset) % 16.0f) / 12.0;
final double ripSize = size * (((double) (i * 16) / (numRipples + 1) + sizeOffset) % 16.0f)
/ 12.0;
t.startDrawingQuads();
t.addVertexWithUV(xCenter - ripSize, yCenter + ripSize, 1.0, 0.0, 1.0);
t.addVertexWithUV(xCenter + ripSize, yCenter + ripSize, 1.0, 1.0, 1.0);
@@ -28,6 +28,11 @@ public class ItemLensEarth extends Item implements ILens {
return "LensEarth";
}
@Override
public int getItemStackLimit(ItemStack stack) {
return 1;
}
public void handleRender(final Minecraft mc, final float partialTicks) {}
public String getUnlocalizedName(final ItemStack par1ItemStack) {
@@ -4,6 +4,8 @@
package com.kentington.thaumichorizons.common.items.lenses;
import static com.kentington.thaumichorizons.common.items.lenses.LensPotionEffects.isNightVisionGrantedByLens;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -17,7 +19,7 @@ import net.minecraft.util.IIcon;
import com.kentington.thaumichorizons.common.ThaumicHorizons;
import com.kentington.thaumichorizons.common.lib.networking.PacketHandler;
import com.kentington.thaumichorizons.common.lib.networking.PacketRemoveNightvision;
import com.kentington.thaumichorizons.common.lib.networking.PacketRemoveLensNightvision;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -34,20 +36,26 @@ public class ItemLensFire extends Item implements ILens {
return "LensFire";
}
@Override
public int getItemStackLimit(ItemStack stack) {
return 1;
}
public void handleRender(final Minecraft mc, final float partialTicks) {
final boolean inWater = mc.thePlayer.isInsideOfMaterial(Material.water);
final PotionEffect effect = mc.thePlayer.getActivePotionEffect(Potion.nightVision);
if (!inWater) {
// Apply effect.
if ((effect == null || (isEffectGrantedByLens(effect) && effect.getDuration() < 242))
if ((effect == null || (isNightVisionGrantedByLens(effect) && effect.getDuration() < 242))
&& Minecraft.getSystemTime() > LensManager.nightVisionOffTime) {
LensManager.nightVisionOffTime = Minecraft.getSystemTime();
mc.thePlayer.addPotionEffect(new IlluminePotionEffect(Potion.nightVision.id, 255, -1, true));
mc.thePlayer
.addPotionEffect(new LensPotionEffects.LensNightVision(Potion.nightVision.id, 255, -1, true));
}
} else {
// Remove effect.
if (isEffectGrantedByLens(effect)) {
if (isNightVisionGrantedByLens(effect)) {
mc.thePlayer.removePotionEffect(Potion.nightVision.id);
}
}
@@ -68,30 +76,6 @@ public class ItemLensFire extends Item implements ILens {
}
public void handleRemoval(final EntityPlayer p) {
if (isEffectGrantedByLens(p.getActivePotionEffect(Potion.nightVision))) {
p.removePotionEffect(Potion.nightVision.id);
PacketHandler.INSTANCE.sendTo(new PacketRemoveNightvision(), (EntityPlayerMP) p);
}
}
public static boolean isEffectGrantedByLens(PotionEffect effect) {
return effect instanceof IlluminePotionEffect illumineEffect && illumineEffect.isGrantedByLens;
}
private static class IlluminePotionEffect extends PotionEffect {
public boolean isGrantedByLens;
public IlluminePotionEffect(int potionID, int duration, int amplifier, boolean isAmbient) {
super(potionID, duration, amplifier, isAmbient);
isGrantedByLens = true;
}
public void combine(PotionEffect effect) {
// If this is replaced by another night vision effect, for example from drinking a potion, it should not be
// turned off by the lens.
super.combine(effect);
isGrantedByLens = effect instanceof IlluminePotionEffect;
}
PacketHandler.INSTANCE.sendTo(new PacketRemoveLensNightvision(), (EntityPlayerMP) p);
}
}
@@ -7,6 +7,8 @@ package com.kentington.thaumichorizons.common.items.lenses;
import java.awt.Color;
import java.text.DecimalFormat;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
@@ -63,24 +65,25 @@ public class ItemLensOrderEntropy extends Item implements ILens {
return "LensOrderEntropy";
}
@Override
public int getItemStackLimit(ItemStack stack) {
return 1;
}
@SideOnly(Side.CLIENT)
public void handleRender(final Minecraft mc, final float partialTicks) {
if (Minecraft.getMinecraft().thePlayer.worldObj.isRemote) {
double x = 0.0;
double y = 0.0;
double z = 0.0;
final EntityPlayer p = Minecraft.getMinecraft().thePlayer;
this.isNew = false;
String text = "?";
final ScanResult scan = this.doScan(new ItemStack(ConfigItems.itemThaumometer), p.worldObj, p, this.count);
final ScanResult scan = this.doScan(new ItemStack(ConfigItems.itemThaumometer), p.worldObj, p);
if (scan != null) {
AspectList aspects = null;
if (!this.isNew) {
aspects = ScanManager.getScanAspects(scan, p.worldObj);
}
ItemStack stack = null;
if (scan.id > 0) {
stack = new ItemStack(Item.getItemById(scan.id), 1, scan.meta);
ItemStack stack = new ItemStack(Item.getItemById(scan.id), 1, scan.meta);
if (stack.getItem() != null) {
try {
text = stack.getDisplayName();
@@ -93,15 +96,9 @@ public class ItemLensOrderEntropy extends Item implements ILens {
} else {
text = ((EntityItem) scan.entity).getEntityItem().getDisplayName();
}
x = scan.entity.posX;
y = scan.entity.posY;
z = scan.entity.posZ;
} else {
final MovingObjectPosition mop = EntityUtils.getMovingObjectPositionFromPlayer(p.worldObj, p, true);
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
x = mop.blockX;
y = mop.blockY;
z = mop.blockZ;
final TileEntity tile = p.worldObj.getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
if (scan.type == 3 && scan.phenomena.startsWith("NODE") && tile instanceof INode) {
if (!this.isNew) {
@@ -129,7 +126,7 @@ public class ItemLensOrderEntropy extends Item implements ILens {
}
}
}
if (aspects != null || text.length() > 0) {
if (aspects != null || !text.isEmpty()) {
this.renderNameAndAspects(aspects, text);
}
}
@@ -169,24 +166,21 @@ public class ItemLensOrderEntropy extends Item implements ILens {
final int h = sr.getScaledHeight();
if (aspects != null && aspects.size() > 0) {
int num = 0;
int yOff = 0;
int thisRow = 0;
final int size = 18;
thisRow = Math.min(aspects.size() - num, 5);
int thisRow = Math.min(aspects.size() - num, 5);
for (final Aspect asp : aspects.getAspects()) {
yOff = num / 5 * size;
int yOff = num / 5 * size;
this.drawAspectTag(
asp,
aspects.getAmount(asp),
w / 2 - size * thisRow / 2 + size * (num % 5),
h / 2 + 16 + yOff,
w);
h / 2 + 16 + yOff);
if (++num % 5 == 0) {
thisRow = Math.min(aspects.size() - num, 5);
}
}
}
if (text.length() > 0) {
if (!text.isEmpty()) {
Minecraft.getMinecraft().ingameGUI.drawString(
Minecraft.getMinecraft().fontRenderer,
text,
@@ -196,34 +190,21 @@ public class ItemLensOrderEntropy extends Item implements ILens {
}
}
private ScanResult doScan(final ItemStack stack, final World world, final EntityPlayer p, final int count) {
final Entity pointedEntity = EntityUtils.getPointedEntity(p.worldObj, p, 0.5, 10.0, 0.0f, true);
private ScanResult doScan(final ItemStack stack, final World world, final EntityPlayer player) {
final Entity pointedEntity = EntityUtils.getPointedEntity(player.worldObj, player, 0.5, 10.0, 0.0f, true);
if (pointedEntity == null) {
final MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(p.worldObj, p, true);
final MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(player.worldObj, player, true);
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
final TileEntity tile = world.getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
if (tile instanceof INode) {
final ScanResult sr = new ScanResult((byte) 3, 0, 0, null, "NODE" + ((INode) tile).getId());
if (ScanManager.isValidScanTarget(p, sr, "@")) {
Thaumcraft.proxy.blockRunes(
world,
mop.blockX,
mop.blockY + 0.25,
mop.blockZ,
0.3f + world.rand.nextFloat() * 0.7f,
0.0f,
0.3f + world.rand.nextFloat() * 0.7f,
15,
0.03f);
this.isNew = true;
return sr;
}
return sr;
return getScanResult(world, player, mop, sr);
} else {
final Block bi = world.getBlock(mop.blockX, mop.blockY, mop.blockZ);
if (bi != Blocks.air) {
final int md = bi.getDamageValue(world, mop.blockX, mop.blockY, mop.blockZ);
ItemStack is = bi.getPickBlock(mop, p.worldObj, mop.blockX, mop.blockY, mop.blockZ);
ItemStack is = bi
.getPickBlock(mop, player.worldObj, mop.blockX, mop.blockY, mop.blockZ, player);
ScanResult sr2 = null;
try {
if (is == null) {
@@ -242,26 +223,12 @@ public class ItemLensOrderEntropy extends Item implements ILens {
"");
}
} catch (Exception ignored) {}
if (ScanManager.isValidScanTarget(p, sr2, "@")) {
Thaumcraft.proxy.blockRunes(
world,
mop.blockX,
mop.blockY + 0.25,
mop.blockZ,
0.3f + world.rand.nextFloat() * 0.7f,
0.0f,
0.3f + world.rand.nextFloat() * 0.7f,
15,
0.03f);
this.isNew = true;
return sr2;
}
return sr2;
return getScanResult(world, player, mop, sr2);
}
}
}
for (final IScanEventHandler seh : ThaumcraftApi.scanEventhandlers) {
final ScanResult scan = seh.scanPhenomena(stack, world, p);
final ScanResult scan = seh.scanPhenomena(stack, world, player);
if (scan != null) {
return scan;
}
@@ -269,7 +236,7 @@ public class ItemLensOrderEntropy extends Item implements ILens {
return null;
}
final ScanResult sr3 = new ScanResult((byte) 2, 0, 0, pointedEntity, "");
if (ScanManager.isValidScanTarget(p, sr3, "@")) {
if (ScanManager.isValidScanTarget(player, sr3, "@")) {
Thaumcraft.proxy.blockRunes(
world,
pointedEntity.posX - 0.5,
@@ -286,11 +253,30 @@ public class ItemLensOrderEntropy extends Item implements ILens {
return sr3;
}
@Nullable
private ScanResult getScanResult(World world, EntityPlayer player, MovingObjectPosition mop, ScanResult sr) {
if (ScanManager.isValidScanTarget(player, sr, "@")) {
Thaumcraft.proxy.blockRunes(
world,
mop.blockX,
mop.blockY + 0.25,
mop.blockZ,
0.3f + world.rand.nextFloat() * 0.7f,
0.0f,
0.3f + world.rand.nextFloat() * 0.7f,
15,
0.03f);
this.isNew = true;
}
return sr;
}
public String getUnlocalizedName(final ItemStack par1ItemStack) {
return "item.LensOrderEntropy";
}
public void drawAspectTag(final Aspect aspect, final int amount, final int x, final int y, final int sw) {
public void drawAspectTag(final Aspect aspect, final int amount, final int x, final int y) {
GL11.glPushMatrix();
GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569f);
GL11.glEnable(GL11.GL_BLEND);
@@ -4,6 +4,8 @@
package com.kentington.thaumichorizons.common.items.lenses;
import static com.kentington.thaumichorizons.common.items.lenses.LensPotionEffects.isNightVisionGrantedByLens;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -17,7 +19,7 @@ import net.minecraft.util.IIcon;
import com.kentington.thaumichorizons.common.ThaumicHorizons;
import com.kentington.thaumichorizons.common.lib.networking.PacketHandler;
import com.kentington.thaumichorizons.common.lib.networking.PacketRemoveNightvision;
import com.kentington.thaumichorizons.common.lib.networking.PacketRemoveLensNightvision;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -34,16 +36,28 @@ public class ItemLensWater extends Item implements ILens {
return "LensWater";
}
@Override
public int getItemStackLimit(ItemStack stack) {
return 1;
}
public void handleRender(final Minecraft mc, final float partialTicks) {
final boolean inWater = mc.thePlayer.isInsideOfMaterial(Material.water);
if (inWater
&& (mc.thePlayer.getActivePotionEffect(Potion.nightVision) == null
|| mc.thePlayer.getActivePotionEffect(Potion.nightVision).getDuration() < 242)
&& Minecraft.getSystemTime() > LensManager.nightVisionOffTime) {
LensManager.nightVisionOffTime = Minecraft.getSystemTime();
mc.thePlayer.addPotionEffect(new PotionEffect(Potion.nightVision.id, 255, 0, true));
} else if (!inWater) {
mc.thePlayer.removePotionEffect(Potion.nightVision.id);
final PotionEffect effect = mc.thePlayer.getActivePotionEffect(Potion.nightVision);
if (inWater) {
// Apply effect.
if ((effect == null || (isNightVisionGrantedByLens(effect) && effect.getDuration() < 242))
&& Minecraft.getSystemTime() > LensManager.nightVisionOffTime) {
LensManager.nightVisionOffTime = Minecraft.getSystemTime();
mc.thePlayer
.addPotionEffect(new LensPotionEffects.LensNightVision(Potion.nightVision.id, 255, -1, true));
}
} else {
// Remove effect.
if (isNightVisionGrantedByLens(effect)) {
mc.thePlayer.removePotionEffect(Potion.nightVision.id);
}
}
}
@@ -62,7 +76,6 @@ public class ItemLensWater extends Item implements ILens {
}
public void handleRemoval(final EntityPlayer p) {
p.removePotionEffect(Potion.nightVision.id);
PacketHandler.INSTANCE.sendTo(new PacketRemoveNightvision(), (EntityPlayerMP) p);
PacketHandler.INSTANCE.sendTo(new PacketRemoveLensNightvision(), (EntityPlayerMP) p);
}
}
@@ -27,89 +27,88 @@ public class LensManager {
public static long nightVisionOffTime;
public static void changeLens(final ItemStack is, final World w, final EntityPlayer player, final String lens) {
final IRevealer goggles = (IRevealer) is.getItem();
final TreeMap lenses = new TreeMap<>();
final HashMap pouches = new HashMap<>();
final TreeMap<String, Integer> lenses = new TreeMap<>();
final HashMap<Integer, Integer> pouches = new HashMap<>();
int pouchcount = 0;
ItemStack item = null;
final IInventory baubles = BaublesApi.getBaubles(player);
for (int a = 0; a < 4; ++a) {
if (baubles.getStackInSlot(a) != null && baubles.getStackInSlot(a).getItem() instanceof ItemLensCase) {
final int baubleSlots = baubles.getSizeInventory();
for (int a = 0; a < baubleSlots; ++a) {
if (baubles.getStackInSlot(a) != null
&& baubles.getStackInSlot(a).getItem() instanceof ItemLensCase lensCase) {
++pouchcount;
item = baubles.getStackInSlot(a);
pouches.put(pouchcount, a - 4);
final ItemStack[] inv = ((ItemLensCase) item.getItem()).getInventory(item);
pouches.put(pouchcount, a - baubleSlots);
final ItemStack[] inv = lensCase.getInventory(item);
for (int q = 0; q < inv.length; ++q) {
item = inv[q];
if (item != null && item.getItem() instanceof ILens) {
lenses.put(((ILens) item.getItem()).lensName(), q + pouchcount * 1000);
if (item != null && item.getItem() instanceof ILens newLens) {
lenses.put(newLens.lensName(), q + pouchcount * 1000);
}
}
}
}
for (int newkey = 0; newkey < 36; ++newkey) {
item = player.inventory.mainInventory[newkey];
if (item != null && item.getItem() instanceof ILens) {
lenses.put(((ILens) item.getItem()).lensName(), newkey);
if (item != null && item.getItem() instanceof ILens newLens) {
lenses.put(newLens.lensName(), newkey);
}
if (item != null && item.getItem() instanceof ItemLensCase) {
if (item != null && item.getItem() instanceof ItemLensCase lensCase) {
++pouchcount;
pouches.put(pouchcount, newkey);
final ItemStack[] pid = ((ItemLensCase) item.getItem()).getInventory(item);
final ItemStack[] pid = lensCase.getInventory(item);
for (int pouchslot = 0; pouchslot < pid.length; ++pouchslot) {
item = pid[pouchslot];
if (item != null && item.getItem() instanceof ILens) {
lenses.put(((ILens) item.getItem()).lensName(), pouchslot + pouchcount * 1000);
if (item != null && item.getItem() instanceof ILens newLens) {
lenses.put(newLens.lensName(), pouchslot + pouchcount * 1000);
}
}
}
}
ItemStack oldLens = null;
if (!lens.equals("REMOVE") && lenses.size() != 0) {
if (lenses != null && lenses.size() > 0 && lens != null) {
String var13 = lens;
if (lenses.get(lens) == null) {
var13 = (String) lenses.higherKey(lens);
}
if (var13 == null || lenses.get(var13) == null) {
var13 = (String) lenses.firstKey();
}
if ((Integer) lenses.get(var13) < 1000) {
item = player.inventory.mainInventory[(Integer) lenses.get(var13)].copy();
} else {
final int var14 = (Integer) lenses.get(var13) / 1000;
if (pouches.containsKey(var14)) {
final int pouchslot = (Integer) pouches.get(var14);
final int lensSlot = (Integer) lenses.get(var13) - (var14 * 1000);
ItemStack tmp;
if (pouchslot >= 0) {
tmp = player.inventory.mainInventory[pouchslot].copy();
} else {
tmp = baubles.getStackInSlot(pouchslot + 4).copy();
}
item = fetchLensFromPouch(player, lensSlot, tmp, pouchslot);
ItemStack oldLens;
if (!lens.equals("REMOVE") && !lenses.isEmpty()) {
String var13 = lens;
if (lenses.get(lens) == null) {
var13 = lenses.higherKey(lens);
}
if (var13 == null || lenses.get(var13) == null) {
var13 = lenses.firstKey();
}
if (lenses.get(var13) < 1000) {
item = player.inventory.mainInventory[lenses.get(var13)].copy();
} else {
final int var14 = lenses.get(var13) / 1000;
if (pouches.containsKey(var14)) {
final int pouchSlot = pouches.get(var14);
final int lensSlot = lenses.get(var13) - (var14 * 1000);
ItemStack tmp;
if (pouchSlot >= 0) {
tmp = player.inventory.mainInventory[pouchSlot].copy();
} else {
tmp = baubles.getStackInSlot(pouchSlot + baubleSlots).copy();
}
item = fetchLensFromPouch(player, lensSlot, tmp, pouchSlot);
}
if (item == null) {
return;
}
if ((Integer) lenses.get(var13) < 1000) {
player.inventory.setInventorySlotContents((Integer) lenses.get(var13), null);
}
w.playSoundAtEntity(player, "thaumcraft:cameraticks", 0.3f, 1.0f);
String currentLens = "";
if (is.stackTagCompound != null) {
currentLens = is.stackTagCompound.getString("Lens");
}
oldLens = getLensItem(currentLens);
if (!currentLens.equals("") && (addLensToPouch(player, oldLens, pouches)
|| player.inventory.addItemStackToInventory(oldLens))) {
setLensItem(is, item);
} else if (currentLens.equals("")) {
setLensItem(is, item);
} else if (!addLensToPouch(player, item, pouches)) {
player.inventory.addItemStackToInventory(item);
}
}
if (item == null) {
return;
}
if (lenses.get(var13) < 1000) {
player.inventory.decrStackSize(lenses.get(var13), 1);
}
w.playSoundAtEntity(player, "thaumcraft:cameraticks", 0.3f, 1.0f);
String currentLens = "";
if (is.stackTagCompound != null) {
currentLens = is.stackTagCompound.getString("Lens");
}
oldLens = getLensItem(currentLens);
if (!currentLens.isEmpty() && (addLensToPouch(player, oldLens, pouches)
|| player.inventory.addItemStackToInventory(oldLens))) {
setLensItem(is, item);
} else if (currentLens.isEmpty()) {
setLensItem(is, item);
} else if (!addLensToPouch(player, item, pouches)) {
player.inventory.addItemStackToInventory(item);
}
} else {
String currentLens2 = "";
@@ -117,7 +116,7 @@ public class LensManager {
currentLens2 = is.stackTagCompound.getString("Lens");
}
oldLens = getLensItem(currentLens2);
if (!currentLens2.equals("") && (addLensToPouch(player, oldLens, pouches)
if (!currentLens2.isEmpty() && (addLensToPouch(player, oldLens, pouches)
|| player.inventory.addItemStackToInventory(oldLens))) {
setLensItem(is, null);
w.playSoundAtEntity(player, "thaumcraft:cameraticks", 0.3f, 0.9f);
@@ -128,21 +127,25 @@ public class LensManager {
}
}
private static ItemStack fetchLensFromPouch(final EntityPlayer player, final int lensid, final ItemStack pouch,
final int pouchslot) {
private static ItemStack fetchLensFromPouch(final EntityPlayer player, final int lensId, final ItemStack pouch,
final int pouchSlot) {
ItemStack lens = null;
final ItemStack[] inv = ((ItemLensCase) pouch.getItem()).getInventory(pouch);
final ItemStack contents = inv[lensid];
final ItemStack contents = inv[lensId];
if (contents != null && contents.getItem() instanceof ILens) {
lens = contents.copy();
inv[lensid] = null;
if (contents.stackSize <= 1) {
inv[lensId] = null;
} else {
contents.stackSize--;
}
((ItemLensCase) pouch.getItem()).setInventory(pouch, inv);
if (pouchslot >= 0) {
player.inventory.setInventorySlotContents(pouchslot, pouch);
if (pouchSlot >= 0) {
player.inventory.setInventorySlotContents(pouchSlot, pouch);
player.inventory.markDirty();
} else {
final IInventory baubles = BaublesApi.getBaubles(player);
baubles.setInventorySlotContents(pouchslot + 4, pouch);
baubles.setInventorySlotContents(pouchSlot + baubles.getSizeInventory(), pouch);
baubles.markDirty();
}
}
@@ -151,14 +154,13 @@ public class LensManager {
private static boolean addLensToPouch(final EntityPlayer player, final ItemStack lens,
final HashMap<Integer, Integer> pouches) {
for (int value : pouches.values()) {
for (int pouchSlot : pouches.values()) {
final IInventory baubles = BaublesApi.getBaubles(player);
final int pouchslot = value;
ItemStack pouch;
if (pouchslot >= 0) {
pouch = player.inventory.mainInventory[pouchslot];
if (pouchSlot >= 0) {
pouch = player.inventory.mainInventory[pouchSlot];
} else {
pouch = baubles.getStackInSlot(pouchslot + 4);
pouch = baubles.getStackInSlot(pouchSlot + baubles.getSizeInventory());
}
final ItemStack[] inv = ((ItemLensCase) pouch.getItem()).getInventory(pouch);
for (int q = 0; q < inv.length; ++q) {
@@ -166,11 +168,11 @@ public class LensManager {
if (contents == null) {
inv[q] = lens.copy();
((ItemLensCase) pouch.getItem()).setInventory(pouch, inv);
if (pouchslot >= 0) {
player.inventory.setInventorySlotContents(pouchslot, pouch);
if (pouchSlot >= 0) {
player.inventory.setInventorySlotContents(pouchSlot, pouch);
player.inventory.markDirty();
} else {
baubles.setInventorySlotContents(pouchslot + 4, pouch);
baubles.setInventorySlotContents(pouchSlot + baubles.getSizeInventory(), pouch);
baubles.markDirty();
}
player.inventory.markDirty();
@@ -188,23 +190,27 @@ public class LensManager {
return null;
}
public static ILens getLensFromItem(final ItemStack stack) {
if (stack == null || !(stack.getItem() instanceof IRevealer) || stack.stackTagCompound == null) {
return null;
}
final String lensName = stack.stackTagCompound.getString("Lens");
if (lensName.isEmpty()) {
return null;
}
final Item lensItem = getLens(lensName);
return lensItem instanceof ILens ? (ILens) lensItem : null;
}
public static Item getLens(final String lens) {
if (lens.equals("LensFire")) {
return ThaumicHorizons.itemLensFire;
}
if (lens.equals("LensWater")) {
return ThaumicHorizons.itemLensWater;
}
if (lens.equals("LensEarth")) {
return ThaumicHorizons.itemLensEarth;
}
if (lens.equals("LensAir")) {
return ThaumicHorizons.itemLensAir;
}
if (lens.equals("LensOrderEntropy")) {
return ThaumicHorizons.itemLensOrderEntropy;
}
return null;
return switch (lens) {
case "LensFire" -> ThaumicHorizons.itemLensFire;
case "LensWater" -> ThaumicHorizons.itemLensWater;
case "LensEarth" -> ThaumicHorizons.itemLensEarth;
case "LensAir" -> ThaumicHorizons.itemLensAir;
case "LensOrderEntropy" -> ThaumicHorizons.itemLensOrderEntropy;
default -> null;
};
}
public static void setLensItem(final ItemStack goggles, final ItemStack lens) {
@@ -0,0 +1,27 @@
package com.kentington.thaumichorizons.common.items.lenses;
import net.minecraft.potion.PotionEffect;
public class LensPotionEffects {
public static boolean isNightVisionGrantedByLens(PotionEffect effect) {
return effect instanceof LensNightVision lensNightvision && lensNightvision.isGrantedByLens;
}
static class LensNightVision extends PotionEffect {
public boolean isGrantedByLens;
public LensNightVision(int potionID, int duration, int amplifier, boolean isAmbient) {
super(potionID, duration, amplifier, isAmbient);
isGrantedByLens = true;
}
public void combine(PotionEffect effect) {
// If this is replaced by another night vision effect, for example from drinking a potion, it should not be
// turned off by the lens.
super.combine(effect);
isGrantedByLens = effect instanceof LensNightVision;
}
}
}
@@ -339,6 +339,7 @@ public class EventHandlerEntity {
}
}
if (prop.hasPlayerInfusion(6) && event.entity.ticksExisted % 200 == 0
&& player.getFoodStats().needFood()
&& player.worldObj.isDaytime()
&& player.worldObj.canBlockSeeTheSky(
MathHelper.floor_double(player.posX),
@@ -35,7 +35,9 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.NoiseGeneratorOctaves;
import com.kentington.thaumichorizons.common.ThaumicHorizons;
@@ -78,6 +80,17 @@ public class PocketPlaneData {
return a.intValue() > a.floatValue() ? a.intValue() - 1 : a.intValue();
}
/**
* Sets the block directly in the chunk for significant performance boost
*/
private static void setBlock(World world, int x, int y, int z, Block blockIn, int metadataIn) {
WorldServer server = (WorldServer) world;
Chunk chunk = server.theChunkProviderServer.loadChunk(x >> 4, z >> 4);
chunk.func_150807_a(x & 15, y, z & 15, blockIn, metadataIn);
chunk.setChunkModified();
}
// TODO: Make pocket planes generate chunk-by-chunk using normal chunk generation
public static void generatePocketPlane(final AspectList aspects, final PocketPlaneData data, final World world,
final int vortexX, final int vortexY, final int vortexZ, final int returnID) {
if (!world.isRemote) {
@@ -106,12 +119,12 @@ public class PocketPlaneData {
drawSphere(xCenter, yCenter, zCenter, data.radius, ThaumicHorizons.blockVoid, 0, world);
for (int x = -2; x <= 2; ++x) {
for (int z = -2; z <= 2; ++z) {
world.setBlock(xCenter + x, yCenter, zCenter + z, ConfigBlocks.blockCosmeticSolid, 6, 0);
setBlock(world, xCenter + x, yCenter, zCenter + z, ConfigBlocks.blockCosmeticSolid, 6);
world.setBlockToAir(xCenter + x, yCenter + 1, zCenter + z);
world.setBlockToAir(xCenter + x, yCenter + 2, zCenter + z);
}
}
world.setBlock(xCenter, yCenter + 1, zCenter, ThaumicHorizons.blockVortex);
setBlock(world, xCenter, yCenter + 1, zCenter, ThaumicHorizons.blockVortex, 0);
TileEntity te = world.getTileEntity(xCenter, yCenter + 1, zCenter);
if (!(te instanceof TileVortex)) {
te = new TileVortex();
@@ -332,6 +345,7 @@ public class PocketPlaneData {
level -= fastFloor((aspectFraction(Aspect.CLOTH, aspects) * data.radius));
drewAnything = true;
}
if (aspects.getAmount(Aspect.EARTH) > 0) {
if (bio == BiomeGenBase.desert) {
drawLayer(xCenter, yCenter, zCenter, data, world, Blocks.sand, 0, level, noise, bio, life, aspects);
@@ -427,13 +441,13 @@ public class PocketPlaneData {
if (top != bottom && level + y > 0) {
if (y == top) {
if (block != null) {
world.setBlock(x + xCenter, y + level, z + zCenter, block, md, 0);
setBlock(world, x + xCenter, y + level, z + zCenter, block, md);
}
if (block == Blocks.water) {
if (bio != null && bio.getTempCategory() == BiomeGenBase.TempCategory.COLD) {
world.setBlock(x + xCenter, y + level, z + zCenter, Blocks.ice, 0, 0);
setBlock(world, x + xCenter, y + level, z + zCenter, Blocks.ice, 0);
} else {
world.setBlock(x + xCenter, y + level, z + zCenter, block, 0, 0);
setBlock(world, x + xCenter, y + level, z + zCenter, block, 0);
if ((life > 40 || aspects.getAmount(Aspect.BEAST) > 0)
&& world.rand.nextInt(100) > 98
&& creatures < MAX_CREATURES) {
@@ -444,199 +458,199 @@ public class PocketPlaneData {
++creatures;
}
if (life > 0 && world.rand.nextInt(100) > 98) {
world.setBlock(x + xCenter, y + level + 1, z + zCenter, Blocks.waterlily, 0, 0);
setBlock(world, x + xCenter, y + level + 1, z + zCenter, Blocks.waterlily, 0);
}
}
} else if (block == Blocks.dirt) {
if (life > 0 && world.isAirBlock(x + xCenter, y + level + 1, z + zCenter)) {
world.setBlock(x + xCenter, y + level, z + zCenter, Blocks.grass, 0, 0);
setBlock(world, x + xCenter, y + level, z + zCenter, Blocks.grass, 0);
if (life >= 10) {
if ((life >= 20 || aspects.getAmount(Aspect.CROP) > 0
|| aspects.getAmount(Aspect.HARVEST) > 0)
&& world.rand.nextInt(100) > 97) {
switch (world.rand.nextInt(10)) {
case 0 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level,
z + zCenter,
Blocks.farmland,
0,
0);
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.carrots,
0,
0);
}
case 1 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level,
z + zCenter,
Blocks.farmland,
0,
0);
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.potatoes,
0,
0);
}
case 2 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level,
z + zCenter,
Blocks.farmland,
0,
0);
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.wheat,
0,
0);
}
case 3 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.melon_block,
0,
0);
}
case 4 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.pumpkin,
0,
0);
}
case 5 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.reeds,
0,
0);
}
case 6 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level,
z + zCenter,
Blocks.mycelium,
0,
0);
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.red_mushroom,
0,
0);
}
case 7 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level,
z + zCenter,
Blocks.mycelium,
0,
0);
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.brown_mushroom,
0,
0);
}
case 8 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
ConfigBlocks.blockCustomPlant,
2,
0);
2);
}
case 9 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
ConfigBlocks.blockCustomPlant,
5,
0);
5);
}
}
} else if ((life >= 15 || aspects.getAmount(Aspect.TREE) > 0)
&& world.rand.nextInt(100) > 97) {
switch (world.rand.nextInt(10)) {
case 0 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.sapling,
0,
0);
}
case 1 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.sapling,
1,
0);
1);
}
case 2 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.sapling,
2,
0);
2);
}
case 3 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.sapling,
3,
0);
3);
}
case 4 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.sapling,
4,
0);
4);
}
case 5 -> {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.sapling,
5,
0);
5);
}
case 6 -> {
if (((bio != null
@@ -644,24 +658,24 @@ public class PocketPlaneData {
|| aspects.getAmount(Aspect.MAGIC) > 10
|| aspects.getAmount(Aspect.AURA) > 5)
&& world.rand.nextInt(4) == 0) {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
ConfigBlocks.blockCustomPlant,
1,
0);
1);
break;
}
}
case 7 -> {
if (world.rand.nextInt(3) == 0) {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
ConfigBlocks.blockCustomPlant,
0,
0);
break;
}
@@ -672,40 +686,40 @@ public class PocketPlaneData {
&& world.rand.nextInt(100) > 94) {
final int random = world.rand.nextInt(18);
if (random <= 15) {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.red_flower,
random,
0);
random);
} else {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
Blocks.tallgrass,
random - 16,
0);
random - 16);
}
}
}
} else {
world.setBlock(x + xCenter, y + level, z + zCenter, block, 0, 0);
setBlock(world, x + xCenter, y + level, z + zCenter, block, 0);
}
} else if (block == Blocks.sand) {
world.setBlock(x + xCenter, y + level, z + zCenter, block, 0, 0);
setBlock(world, x + xCenter, y + level, z + zCenter, block, 0);
if (life > 10) {
if (life >= 20 && world.rand.nextInt(100) > 98) {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
ConfigBlocks.blockCustomPlant,
3,
0);
3);
} else if (world.rand.nextInt(100) > 97) {
world.setBlock(x + xCenter, y + level + 1, z + zCenter, Blocks.cactus, 0, 0);
setBlock(world, x + xCenter, y + level + 1, z + zCenter, Blocks.cactus, 0);
}
}
} else if (block == ConfigBlocks.blockTaint && md == 2 && world.rand.nextInt(300) > 298) {
@@ -713,12 +727,12 @@ public class PocketPlaneData {
for (int ecks = 0; ecks < 3; ++ecks) {
for (int zee = 0; zee < 2; ++zee) {
for (int why = 0; why < 2; ++why) {
world.setBlock(
setBlock(
world,
x + xCenter + ecks,
y + level + why,
z + zCenter + zee,
ThaumicHorizons.blockBrain,
0,
0);
}
}
@@ -727,12 +741,12 @@ public class PocketPlaneData {
for (int ecks = 0; ecks < 2; ++ecks) {
for (int zee = 0; zee < 3; ++zee) {
for (int why = 0; why < 2; ++why) {
world.setBlock(
setBlock(
world,
x + xCenter + ecks,
y + level + why,
z + zCenter + zee,
ThaumicHorizons.blockBrain,
0,
0);
}
}
@@ -741,7 +755,7 @@ public class PocketPlaneData {
}
if (bio != null && block.isNormalCube()
&& bio.getTempCategory() == BiomeGenBase.TempCategory.COLD) {
world.setBlock(x + xCenter, y + level + 1, z + zCenter, Blocks.snow_layer, 1, 0);
setBlock(world, x + xCenter, y + level + 1, z + zCenter, Blocks.snow_layer, 1);
}
if ((life >= 50 || aspects.getAmount(Aspect.BEAST) > 0) && world.rand.nextInt(100) > 98) {
EntityLiving critter = null;
@@ -799,52 +813,46 @@ public class PocketPlaneData {
++creatures;
}
if (aspects.getAmount(Aspect.ELDRITCH) > 0 && world.rand.nextInt(200) > 198) {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level,
z + zCenter,
ConfigBlocks.blockCosmeticSolid,
1,
0);
world.setBlock(
1);
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
ConfigBlocks.blockCosmeticSolid,
0,
0);
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 2,
z + zCenter,
ConfigBlocks.blockCosmeticSolid,
0,
0);
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 3,
z + zCenter,
ConfigBlocks.blockCosmeticSolid,
0,
0);
}
if (aspects.getAmount(Aspect.CRAFT) > 0 && world.rand.nextInt(200) > 198) {
world.setBlock(
setBlock(
world,
x + xCenter,
y + level + 1,
z + zCenter,
ConfigBlocks.blockStoneDevice,
1,
0);
1);
}
if (aspects.getAmount(Aspect.TAINT) > 0 && world.rand.nextInt(100) > 98) {
world.setBlock(
x + xCenter,
y + level,
z + zCenter,
ConfigBlocks.blockTaintFibres,
0,
0);
setBlock(world, x + xCenter, y + level, z + zCenter, ConfigBlocks.blockTaintFibres, 0);
}
if (aspects.getAmount(Aspect.TAINT) > 0 && world.rand.nextInt(200) > 198
&& creatures < MAX_CREATURES) {
@@ -861,7 +869,7 @@ public class PocketPlaneData {
++creatures;
}
} else if (block != null) {
world.setBlock(x + xCenter, y + level, z + zCenter, block, md, 0);
setBlock(world, x + xCenter, y + level, z + zCenter, block, md);
}
}
}
@@ -988,114 +996,114 @@ public class PocketPlaneData {
yCenter + yOffset + y,
zCenter - zSize + zOffset + z) != Blocks.water) {
if (whichAspect == Aspect.EARTH) {
world.setBlock(
setBlock(
world,
xCenter - xSize + xOffset + x,
yCenter + yOffset + y,
zCenter - zSize + zOffset + z,
ConfigBlocks.blockCrystal,
3,
0);
3);
} else if (whichAspect == Aspect.AIR) {
world.setBlock(
setBlock(
world,
xCenter - xSize + xOffset + x,
yCenter + yOffset + y,
zCenter - zSize + zOffset + z,
ConfigBlocks.blockCrystal,
0,
0);
} else if (whichAspect == Aspect.WATER) {
world.setBlock(
setBlock(
world,
xCenter - xSize + xOffset + x,
yCenter + yOffset + y,
zCenter - zSize + zOffset + z,
ConfigBlocks.blockCrystal,
2,
0);
2);
} else if (whichAspect == Aspect.FIRE) {
world.setBlock(
setBlock(
world,
xCenter - xSize + xOffset + x,
yCenter + yOffset + y,
zCenter - zSize + zOffset + z,
ConfigBlocks.blockCrystal,
1,
0);
1);
} else if (whichAspect == Aspect.ORDER) {
world.setBlock(
setBlock(
world,
xCenter - xSize + xOffset + x,
yCenter + yOffset + y,
zCenter - zSize + zOffset + z,
ConfigBlocks.blockCrystal,
4,
0);
4);
} else if (whichAspect == Aspect.ENTROPY) {
world.setBlock(
setBlock(
world,
xCenter - xSize + xOffset + x,
yCenter + yOffset + y,
zCenter - zSize + zOffset + z,
ConfigBlocks.blockCrystal,
5,
0);
5);
} else if (whichAspect == Aspect.DEATH || whichAspect == Aspect.UNDEAD) {
world.setBlock(
setBlock(
world,
xCenter - xSize + xOffset + x,
yCenter + yOffset + y,
zCenter - zSize + zOffset + z,
Blocks.skull,
0,
0);
} else if (whichAspect == Aspect.SENSES) {
world.setBlock(
setBlock(
world,
xCenter - xSize + xOffset + x,
yCenter + yOffset + y,
zCenter - zSize + zOffset + z,
Blocks.lapis_block,
0,
0);
} else if (whichAspect == Aspect.GREED) {
if (world.rand.nextBoolean()) {
world.setBlock(
setBlock(
world,
xCenter - xSize + xOffset + x,
yCenter + yOffset + y,
zCenter - zSize + zOffset + z,
Blocks.gold_block,
0,
0);
} else {
world.setBlock(
setBlock(
world,
xCenter - xSize + xOffset + x,
yCenter + yOffset + y,
zCenter - zSize + zOffset + z,
Blocks.emerald_block,
0,
0);
}
} else if (whichAspect == Aspect.METAL) {
if (world.rand.nextBoolean()) {
world.setBlock(
setBlock(
world,
xCenter - xSize + xOffset + x,
yCenter + yOffset + y,
zCenter - zSize + zOffset + z,
Blocks.gold_block,
0,
0);
} else {
world.setBlock(
setBlock(
world,
xCenter - xSize + xOffset + x,
yCenter + yOffset + y,
zCenter - zSize + zOffset + z,
Blocks.iron_block,
0,
0);
}
}
}
} else {
world.setBlock(
setBlock(
world,
xCenter - xSize + xOffset + x,
yCenter + yOffset + y,
zCenter - zSize + zOffset + z,
Blocks.air,
0,
0);
}
}
@@ -1395,13 +1403,13 @@ public class PocketPlaneData {
xCenter - xSize + xOffset + x,
yCenter + yOffset + y,
zCenter - zSize + zOffset + z) != Blocks.water) {
world.setBlock(
setBlock(
world,
xCenter - xSize + xOffset + x,
yCenter + yOffset + y,
zCenter - zSize + zOffset + z,
block,
md,
0);
md);
}
}
}
@@ -1478,38 +1486,38 @@ public class PocketPlaneData {
int z = 0;
int radiusError = error0;
while (x >= z) {
world.setBlock(x0 + x, y0 + y1, z0 + z, block, md, 0);
world.setBlock(x0 + z, y0 + y1, z0 + x, block, md, 0);
world.setBlock(x0 - x, y0 + y1, z0 + z, block, md, 0);
world.setBlock(x0 - z, y0 + y1, z0 + x, block, md, 0);
world.setBlock(x0 - x, y0 + y1, z0 - z, block, md, 0);
world.setBlock(x0 - z, y0 + y1, z0 - x, block, md, 0);
world.setBlock(x0 + x, y0 + y1, z0 - z, block, md, 0);
world.setBlock(x0 + z, y0 + y1, z0 - x, block, md, 0);
world.setBlock(x0 + x, y0 - y1, z0 + z, block, md, 0);
world.setBlock(x0 + z, y0 - y1, z0 + x, block, md, 0);
world.setBlock(x0 - x, y0 - y1, z0 + z, block, md, 0);
world.setBlock(x0 - z, y0 - y1, z0 + x, block, md, 0);
world.setBlock(x0 - x, y0 - y1, z0 - z, block, md, 0);
world.setBlock(x0 - z, y0 - y1, z0 - x, block, md, 0);
world.setBlock(x0 + x, y0 - y1, z0 - z, block, md, 0);
world.setBlock(x0 + z, y0 - y1, z0 - x, block, md, 0);
world.setBlock(x0 + y1, y0 + x, z0 + z, block, md, 0);
world.setBlock(x0 + z, y0 + x, z0 + y1, block, md, 0);
world.setBlock(x0 - y1, y0 + x, z0 + z, block, md, 0);
world.setBlock(x0 - z, y0 + x, z0 + y1, block, md, 0);
world.setBlock(x0 + y1, y0 + x, z0 - z, block, md, 0);
world.setBlock(x0 + z, y0 + x, z0 - y1, block, md, 0);
world.setBlock(x0 - y1, y0 + x, z0 - z, block, md, 0);
world.setBlock(x0 - z, y0 + x, z0 - y1, block, md, 0);
world.setBlock(x0 + y1, y0 - x, z0 + z, block, md, 0);
world.setBlock(x0 + z, y0 - x, z0 + y1, block, md, 0);
world.setBlock(x0 - y1, y0 - x, z0 + z, block, md, 0);
world.setBlock(x0 - z, y0 - x, z0 + y1, block, md, 0);
world.setBlock(x0 + y1, y0 - x, z0 - z, block, md, 0);
world.setBlock(x0 + z, y0 - x, z0 - y1, block, md, 0);
world.setBlock(x0 - y1, y0 - x, z0 - z, block, md, 0);
world.setBlock(x0 - z, y0 - x, z0 - y1, block, md, 0);
setBlock(world, x0 + x, y0 + y1, z0 + z, block, md);
setBlock(world, x0 + z, y0 + y1, z0 + x, block, md);
setBlock(world, x0 - x, y0 + y1, z0 + z, block, md);
setBlock(world, x0 - z, y0 + y1, z0 + x, block, md);
setBlock(world, x0 - x, y0 + y1, z0 - z, block, md);
setBlock(world, x0 - z, y0 + y1, z0 - x, block, md);
setBlock(world, x0 + x, y0 + y1, z0 - z, block, md);
setBlock(world, x0 + z, y0 + y1, z0 - x, block, md);
setBlock(world, x0 + x, y0 - y1, z0 + z, block, md);
setBlock(world, x0 + z, y0 - y1, z0 + x, block, md);
setBlock(world, x0 - x, y0 - y1, z0 + z, block, md);
setBlock(world, x0 - z, y0 - y1, z0 + x, block, md);
setBlock(world, x0 - x, y0 - y1, z0 - z, block, md);
setBlock(world, x0 - z, y0 - y1, z0 - x, block, md);
setBlock(world, x0 + x, y0 - y1, z0 - z, block, md);
setBlock(world, x0 + z, y0 - y1, z0 - x, block, md);
setBlock(world, x0 + y1, y0 + x, z0 + z, block, md);
setBlock(world, x0 + z, y0 + x, z0 + y1, block, md);
setBlock(world, x0 - y1, y0 + x, z0 + z, block, md);
setBlock(world, x0 - z, y0 + x, z0 + y1, block, md);
setBlock(world, x0 + y1, y0 + x, z0 - z, block, md);
setBlock(world, x0 + z, y0 + x, z0 - y1, block, md);
setBlock(world, x0 - y1, y0 + x, z0 - z, block, md);
setBlock(world, x0 - z, y0 + x, z0 - y1, block, md);
setBlock(world, x0 + y1, y0 - x, z0 + z, block, md);
setBlock(world, x0 + z, y0 - x, z0 + y1, block, md);
setBlock(world, x0 - y1, y0 - x, z0 + z, block, md);
setBlock(world, x0 - z, y0 - x, z0 + y1, block, md);
setBlock(world, x0 + y1, y0 - x, z0 - z, block, md);
setBlock(world, x0 + z, y0 - x, z0 - y1, block, md);
setBlock(world, x0 - y1, y0 - x, z0 - z, block, md);
setBlock(world, x0 - z, y0 - x, z0 - y1, block, md);
++z;
if (radiusError < 0) {
radiusError += 2 * z + 1;
@@ -1636,7 +1644,7 @@ public class PocketPlaneData {
if (which == 1) {
for (int x = -1; x <= 1; ++x) {
for (int y = 126; y <= 128; ++y) {
world.setBlock(x, y, 256 * id + data.radius, ThaumicHorizons.blockVoid);
setBlock(world, x, y, 256 * id + data.radius, ThaumicHorizons.blockVoid, 0);
}
}
data.portalA[0] = 0;
@@ -1645,7 +1653,7 @@ public class PocketPlaneData {
} else if (which == 2) {
for (int x = -1; x <= 1; ++x) {
for (int y = 126; y <= 128; ++y) {
world.setBlock(x, y, 256 * id - data.radius, ThaumicHorizons.blockVoid);
setBlock(world, x, y, 256 * id - data.radius, ThaumicHorizons.blockVoid, 0);
}
}
data.portalB[0] = 0;
@@ -1654,7 +1662,7 @@ public class PocketPlaneData {
} else if (which == 3) {
for (int z = -1; z <= 1; ++z) {
for (int y = 126; y <= 128; ++y) {
world.setBlock(data.radius, y, 256 * id + z, ThaumicHorizons.blockVoid);
setBlock(world, data.radius, y, 256 * id + z, ThaumicHorizons.blockVoid, 0);
}
}
data.portalC[0] = 0;
@@ -1663,7 +1671,7 @@ public class PocketPlaneData {
} else if (which == 4) {
for (int z = -1; z <= 1; ++z) {
for (int y = 126; y <= 128; ++y) {
world.setBlock(-data.radius, y, 256 * id + z, ThaumicHorizons.blockVoid);
setBlock(world, -data.radius, y, 256 * id + z, ThaumicHorizons.blockVoid, 0);
}
}
data.portalD[0] = 0;
@@ -1678,8 +1686,8 @@ public class PocketPlaneData {
if (which == 1) {
for (int x = -1; x <= 1; ++x) {
for (int y = 126; y <= 128; ++y) {
world.setBlock(x, y, 256 * id + data.radius, ThaumicHorizons.blockPortal, 0, 3);
world.setBlock(x, y, 256 * id + data.radius + 1, ThaumicHorizons.blockVoid);
setBlock(world, x, y, 256 * id + data.radius, ThaumicHorizons.blockPortal, 0);
setBlock(world, x, y, 256 * id + data.radius + 1, ThaumicHorizons.blockVoid, 0);
}
}
data.portalA[0] = xCoord;
@@ -1688,8 +1696,8 @@ public class PocketPlaneData {
} else if (which == 2) {
for (int x = -1; x <= 1; ++x) {
for (int y = 126; y <= 128; ++y) {
world.setBlock(x, y, 256 * id - data.radius, ThaumicHorizons.blockPortal, 2, 3);
world.setBlock(x, y, 256 * id - data.radius - 1, ThaumicHorizons.blockVoid);
setBlock(world, x, y, 256 * id - data.radius, ThaumicHorizons.blockPortal, 2);
setBlock(world, x, y, 256 * id - data.radius - 1, ThaumicHorizons.blockVoid, 0);
}
}
data.portalB[0] = xCoord;
@@ -1698,8 +1706,8 @@ public class PocketPlaneData {
} else if (which == 3) {
for (int z = -1; z <= 1; ++z) {
for (int y = 126; y <= 128; ++y) {
world.setBlock(data.radius, y, 256 * id + z, ThaumicHorizons.blockPortal, 1, 3);
world.setBlock(data.radius + 1, y, 256 * id + z, ThaumicHorizons.blockVoid);
setBlock(world, data.radius, y, 256 * id + z, ThaumicHorizons.blockPortal, 1);
setBlock(world, data.radius + 1, y, 256 * id + z, ThaumicHorizons.blockVoid, 0);
}
}
data.portalC[0] = xCoord;
@@ -1708,8 +1716,8 @@ public class PocketPlaneData {
} else if (which == 4) {
for (int z = -1; z <= 1; ++z) {
for (int y = 126; y <= 128; ++y) {
world.setBlock(-data.radius, y, 256 * id + z, ThaumicHorizons.blockPortal, 3, 3);
world.setBlock(-data.radius - 1, y, 256 * id + z, ThaumicHorizons.blockVoid);
setBlock(world, -data.radius, y, 256 * id + z, ThaumicHorizons.blockPortal, 3);
setBlock(world, -data.radius - 1, y, 256 * id + z, ThaumicHorizons.blockVoid, 0);
}
}
data.portalD[0] = xCoord;
@@ -1,36 +0,0 @@
//
// Decompiled by Procyon v0.5.30
//
package com.kentington.thaumichorizons.common.lib;
import net.minecraft.world.World;
import thaumcraft.api.aspects.AspectList;
public class PocketPlaneThread implements Runnable {
PocketPlaneData data;
AspectList aspects;
World world;
int x;
int y;
int z;
int returnID;
public PocketPlaneThread(final PocketPlaneData data, final AspectList aspects, final World world, final int x,
final int y, final int z, final int returnID) {
this.data = data;
this.aspects = aspects;
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.returnID = returnID;
}
@Override
public void run() {
PocketPlaneData.generatePocketPlane(this.aspects, this.data, this.world, this.x, this.y, this.z, this.returnID);
}
}
@@ -15,6 +15,7 @@ import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.input.Keyboard;
import com.kentington.thaumichorizons.client.lib.RenderEventHandler;
import com.kentington.thaumichorizons.common.ThaumicHorizons;
import com.kentington.thaumichorizons.common.lib.networking.PacketFingersToServer;
import com.kentington.thaumichorizons.common.lib.networking.PacketHandler;
@@ -43,9 +44,10 @@ public class THKeyHandler {
private boolean keyPressedX;
public static long lastPressX;
private boolean keyPressedV;
public static long lastPressV;
public static boolean radialActive;
public static boolean radialLock;
public static long lastPressV;
public static boolean radialSelectionMade;
public THKeyHandler() {
this.keyV = new KeyBinding("Change Arcane Lens", Keyboard.KEY_NONE, "Thaumcraft");
@@ -65,149 +67,147 @@ public class THKeyHandler {
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void playerTick(final TickEvent.PlayerTickEvent event) {
if (event.side == Side.SERVER) {
return;
if (event.side == Side.SERVER) return;
if (event.phase != TickEvent.Phase.START) return;
if (this.keyV.getIsKeyPressed()) {
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
final EntityPlayer player = event.player;
if (player != null) {
if (!this.keyPressedV) {
THKeyHandler.lastPressV = System.currentTimeMillis();
THKeyHandler.radialLock = false;
THKeyHandler.radialSelectionMade = false;
}
if (!THKeyHandler.radialLock && !THKeyHandler.radialSelectionMade
&& player.inventory.armorItemInSlot(3) != null
&& player.inventory.armorItemInSlot(3).getItem() instanceof IRevealer) {
if (player.isSneaking()) {
PacketHandler.INSTANCE.sendToServer(new PacketLensChangeToServer("REMOVE"));
} else if (RenderEventHandler.radialHudScale <= 0.0f) {
THKeyHandler.radialActive = true;
}
}
}
this.keyPressedV = true;
}
} else {
THKeyHandler.radialActive = false;
THKeyHandler.radialSelectionMade = false;
if (this.keyPressedV) {
THKeyHandler.lastPressV = System.currentTimeMillis();
}
this.keyPressedV = false;
}
if (event.phase == TickEvent.Phase.START) {
if (this.keyV.getIsKeyPressed()) {
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
final EntityPlayer player = event.player;
if (player != null) {
if (!this.keyPressedV) {
THKeyHandler.lastPressV = System.currentTimeMillis();
THKeyHandler.radialLock = false;
}
if (!THKeyHandler.radialLock && player.inventory.armorItemInSlot(3) != null
&& player.inventory.armorItemInSlot(3).getItem() instanceof IRevealer) {
if (player.isSneaking()) {
PacketHandler.INSTANCE.sendToServer(new PacketLensChangeToServer(player, "REMOVE"));
} else {
THKeyHandler.radialActive = true;
}
}
if (this.keyM.getIsKeyPressed()) {
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
final EntityPlayer player = event.player;
if (player != null) {
if (!this.keyPressedM) {
THKeyHandler.lastPressM = System.currentTimeMillis();
}
this.keyPressedV = true;
}
} else {
THKeyHandler.radialActive = false;
if (this.keyPressedV) {
THKeyHandler.lastPressV = System.currentTimeMillis();
}
this.keyPressedV = false;
}
if (this.keyM.getIsKeyPressed()) {
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
final EntityPlayer player = event.player;
if (player != null) {
if (!this.keyPressedM) {
THKeyHandler.lastPressM = System.currentTimeMillis();
}
if (((EntityInfusionProperties) player.getExtendedProperties("CreatureInfusion"))
.hasPlayerInfusion(2) && !this.keyPressedM) {
player.openGui(
ThaumicHorizons.instance,
9,
player.worldObj,
(int) player.posX,
(int) player.posY,
(int) player.posZ);
PacketHandler.INSTANCE.sendToServer(new PacketFingersToServer(player, player.dimension));
}
if (((EntityInfusionProperties) player.getExtendedProperties("CreatureInfusion"))
.hasPlayerInfusion(2) && !this.keyPressedM) {
player.openGui(
ThaumicHorizons.instance,
9,
player.worldObj,
(int) player.posX,
(int) player.posY,
(int) player.posZ);
PacketHandler.INSTANCE.sendToServer(new PacketFingersToServer());
}
this.keyPressedM = true;
}
} else {
if (this.keyPressedM) {
THKeyHandler.lastPressM = System.currentTimeMillis();
}
this.keyPressedM = false;
this.keyPressedM = true;
}
if (this.keyC.getIsKeyPressed()) {
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
final EntityPlayer player = event.player;
if (player != null) {
if (!this.keyPressedC) {
THKeyHandler.lastPressC = System.currentTimeMillis();
}
if (((EntityInfusionProperties) player.getExtendedProperties("CreatureInfusion"))
.hasPlayerInfusion(9) && !this.keyPressedC) {
((EntityInfusionProperties) player.getExtendedProperties(
"CreatureInfusion")).toggleClimb = !((EntityInfusionProperties) player
.getExtendedProperties("CreatureInfusion")).toggleClimb;
if (((EntityInfusionProperties) player
.getExtendedProperties("CreatureInfusion")).toggleClimb) {
player.addChatMessage(
new ChatComponentText(
EnumChatFormatting.ITALIC + ""
+ EnumChatFormatting.GRAY
+ "Spider Climb disabled."));
} else {
player.addChatMessage(
new ChatComponentText(
EnumChatFormatting.ITALIC + ""
+ EnumChatFormatting.GRAY
+ "Spider Climb enabled."));
}
PacketHandler.INSTANCE
.sendToServer(new PacketToggleClimbToServer(player, player.dimension));
}
} else {
if (this.keyPressedM) {
THKeyHandler.lastPressM = System.currentTimeMillis();
}
this.keyPressedM = false;
}
if (this.keyC.getIsKeyPressed()) {
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
final EntityPlayer player = event.player;
if (player != null) {
if (!this.keyPressedC) {
THKeyHandler.lastPressC = System.currentTimeMillis();
}
this.keyPressedC = true;
}
} else {
if (this.keyPressedC) {
THKeyHandler.lastPressC = System.currentTimeMillis();
}
this.keyPressedC = false;
}
if (this.keyX.getIsKeyPressed()) {
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
final EntityPlayer player = event.player;
if (player != null) {
if (!this.keyPressedX) {
THKeyHandler.lastPressX = System.currentTimeMillis();
}
if (((EntityInfusionProperties) player.getExtendedProperties("CreatureInfusion"))
.hasPlayerInfusion(10) && !this.keyPressedX) {
((EntityInfusionProperties) player.getExtendedProperties(
"CreatureInfusion")).toggleInvisible = !((EntityInfusionProperties) player
.getExtendedProperties("CreatureInfusion")).toggleInvisible;
if (((EntityInfusionProperties) player
.getExtendedProperties("CreatureInfusion")).toggleInvisible) {
player.removePotionEffectClient(Potion.invisibility.id);
player.setInvisible(false);
player.addChatMessage(
new ChatComponentText(
EnumChatFormatting.ITALIC + ""
+ EnumChatFormatting.GRAY
+ "Chameleon Skin disabled."));
} else {
final PotionEffect effect = new PotionEffect(
Potion.invisibility.id,
Integer.MAX_VALUE,
0,
true);
effect.setCurativeItems(new ArrayList<>());
player.addPotionEffect(effect);
player.setInvisible(true);
player.addChatMessage(
new ChatComponentText(
EnumChatFormatting.ITALIC + ""
+ EnumChatFormatting.GRAY
+ "Chameleon Skin enabled."));
}
PacketHandler.INSTANCE
.sendToServer(new PacketToggleInvisibleToServer(player, player.dimension));
if (((EntityInfusionProperties) player.getExtendedProperties("CreatureInfusion"))
.hasPlayerInfusion(9) && !this.keyPressedC) {
((EntityInfusionProperties) player.getExtendedProperties(
"CreatureInfusion")).toggleClimb = !((EntityInfusionProperties) player
.getExtendedProperties("CreatureInfusion")).toggleClimb;
if (((EntityInfusionProperties) player.getExtendedProperties("CreatureInfusion")).toggleClimb) {
player.addChatMessage(
new ChatComponentText(
EnumChatFormatting.ITALIC + ""
+ EnumChatFormatting.GRAY
+ "Spider Climb disabled."));
} else {
player.addChatMessage(
new ChatComponentText(
EnumChatFormatting.ITALIC + ""
+ EnumChatFormatting.GRAY
+ "Spider Climb enabled."));
}
PacketHandler.INSTANCE.sendToServer(new PacketToggleClimbToServer());
}
this.keyPressedX = true;
}
} else {
if (this.keyPressedX) {
THKeyHandler.lastPressX = System.currentTimeMillis();
}
this.keyPressedX = false;
this.keyPressedC = true;
}
} else {
if (this.keyPressedC) {
THKeyHandler.lastPressC = System.currentTimeMillis();
}
this.keyPressedC = false;
}
if (this.keyX.getIsKeyPressed()) {
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
final EntityPlayer player = event.player;
if (player != null) {
if (!this.keyPressedX) {
THKeyHandler.lastPressX = System.currentTimeMillis();
}
if (((EntityInfusionProperties) player.getExtendedProperties("CreatureInfusion"))
.hasPlayerInfusion(10) && !this.keyPressedX) {
((EntityInfusionProperties) player.getExtendedProperties(
"CreatureInfusion")).toggleInvisible = !((EntityInfusionProperties) player
.getExtendedProperties("CreatureInfusion")).toggleInvisible;
if (((EntityInfusionProperties) player
.getExtendedProperties("CreatureInfusion")).toggleInvisible) {
player.removePotionEffectClient(Potion.invisibility.id);
player.setInvisible(false);
player.addChatMessage(
new ChatComponentText(
EnumChatFormatting.ITALIC + ""
+ EnumChatFormatting.GRAY
+ "Chameleon Skin disabled."));
} else {
final PotionEffect effect = new PotionEffect(
Potion.invisibility.id,
Integer.MAX_VALUE,
0,
true);
effect.setCurativeItems(new ArrayList<>());
player.addPotionEffect(effect);
player.setInvisible(true);
player.addChatMessage(
new ChatComponentText(
EnumChatFormatting.ITALIC + ""
+ EnumChatFormatting.GRAY
+ "Chameleon Skin enabled."));
}
PacketHandler.INSTANCE.sendToServer(new PacketToggleInvisibleToServer());
}
}
this.keyPressedX = true;
}
} else {
if (this.keyPressedX) {
THKeyHandler.lastPressX = System.currentTimeMillis();
}
this.keyPressedX = false;
}
}
@@ -215,8 +215,9 @@ public class THKeyHandler {
THKeyHandler.lastPressM = 0L;
THKeyHandler.lastPressC = 0L;
THKeyHandler.lastPressX = 0L;
THKeyHandler.lastPressV = 0L;
THKeyHandler.radialActive = false;
THKeyHandler.radialLock = false;
THKeyHandler.lastPressV = 0L;
THKeyHandler.radialSelectionMade = false;
}
}
@@ -5,8 +5,6 @@
package com.kentington.thaumichorizons.common.lib.networking;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import com.kentington.thaumichorizons.common.ThaumicHorizons;
@@ -17,32 +15,17 @@ import io.netty.buffer.ByteBuf;
public class PacketFingersToServer implements IMessage, IMessageHandler<PacketFingersToServer, IMessage> {
private int playerid;
private int dim;
public PacketFingersToServer() {}
public PacketFingersToServer(final EntityPlayer player, final int dim) {
this.playerid = player.getEntityId();
this.dim = dim;
}
public void toBytes(final ByteBuf buffer) {}
public void toBytes(final ByteBuf buffer) {
buffer.writeInt(this.playerid);
buffer.writeInt(this.dim);
}
public void fromBytes(final ByteBuf buffer) {
this.playerid = buffer.readInt();
this.dim = buffer.readInt();
}
public void fromBytes(final ByteBuf buffer) {}
public IMessage onMessage(final PacketFingersToServer message, final MessageContext ctx) {
if (!PacketHandler.selfInfusionSecurityCheck(ctx, "open workbench", message.playerid, 2)) {
if (PacketHandler.selfInfusionSecurityCheck(ctx, "open workbench", 2)) {
return null;
}
final World world = DimensionManager.getWorld(message.dim);
final EntityPlayer player = (EntityPlayer) world.getEntityByID(message.playerid);
final EntityPlayer player = ctx.getServerHandler().playerEntity;
player.openGui(
ThaumicHorizons.instance,
9,
@@ -38,8 +38,11 @@ public class PacketHandler {
PacketHandler.INSTANCE.registerMessage(PacketNoMoreItems.class, PacketNoMoreItems.class, idx++, Side.CLIENT);
PacketHandler.INSTANCE
.registerMessage(PacketFXBlocksplosion.class, PacketFXBlocksplosion.class, idx++, Side.CLIENT);
PacketHandler.INSTANCE
.registerMessage(PacketRemoveNightvision.class, PacketRemoveNightvision.class, idx++, Side.CLIENT);
PacketHandler.INSTANCE.registerMessage(
PacketRemoveLensNightvision.class,
PacketRemoveLensNightvision.class,
idx++,
Side.CLIENT);
PacketHandler.INSTANCE
.registerMessage(PacketFingersToServer.class, PacketFingersToServer.class, idx++, Side.SERVER);
PacketHandler.INSTANCE
@@ -53,32 +56,24 @@ public class PacketHandler {
PacketToggleInvisibleToServer.class,
idx++,
Side.SERVER);
PacketHandler.INSTANCE.registerMessage(PacketRainState.class, PacketRainState.class, idx++, Side.CLIENT);
PacketHandler.INSTANCE.registerMessage(PacketRainState.class, PacketRainState.class, idx, Side.CLIENT);
}
static {
INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel("ThaumicHorizons".toLowerCase());
}
private static void securityWarn(String message, Object... args) {
ThaumicHorizons.log.warn(SECURITY_MARKER, message, args);
}
static boolean selfInfusionSecurityCheck(final MessageContext ctx, String action, int sentPlayerID,
int requiredInfusion) {
static boolean selfInfusionSecurityCheck(final MessageContext ctx, String action, int requiredInfusion) {
final EntityPlayerMP player = ctx.getServerHandler().playerEntity;
if (player.getEntityId() != sentPlayerID) {
PacketHandler.securityWarn("Player {} tried to {} for other people!", player.getGameProfile(), action);
return false;
}
EntityInfusionProperties ieep = (EntityInfusionProperties) player.getExtendedProperties("CreatureInfusion");
if (!ieep.hasInfusion(requiredInfusion)) {
PacketHandler.securityWarn(
"Player {} tried to {} getting the ability legitimately",
ThaumicHorizons.log.warn(
SECURITY_MARKER,
"Player {} tried to {} without getting the ability legitimately",
player.getGameProfile(),
action);
return false;
return true;
}
return true;
return false;
}
}
@@ -4,10 +4,7 @@
package com.kentington.thaumichorizons.common.lib.networking;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import net.minecraft.entity.player.EntityPlayerMP;
import com.kentington.thaumichorizons.common.items.lenses.LensManager;
@@ -20,44 +17,30 @@ import thaumcraft.api.nodes.IRevealer;
public class PacketLensChangeToServer implements IMessage, IMessageHandler<PacketLensChangeToServer, IMessage> {
private int dim;
private int playerid;
private String lens;
public PacketLensChangeToServer() {}
public PacketLensChangeToServer(final EntityPlayer player, final String lens) {
this.dim = player.worldObj.provider.dimensionId;
this.playerid = player.getEntityId();
public PacketLensChangeToServer(final String lens) {
this.lens = lens;
}
public void toBytes(final ByteBuf buffer) {
buffer.writeInt(this.dim);
buffer.writeInt(this.playerid);
ByteBufUtils.writeUTF8String(buffer, this.lens);
}
public void fromBytes(final ByteBuf buffer) {
this.dim = buffer.readInt();
this.playerid = buffer.readInt();
this.lens = ByteBufUtils.readUTF8String(buffer);
}
public IMessage onMessage(final PacketLensChangeToServer message, final MessageContext ctx) {
final World world = DimensionManager.getWorld(message.dim);
if (world == null || (ctx.getServerHandler().playerEntity != null
&& ctx.getServerHandler().playerEntity.getEntityId() != message.playerid)) {
final EntityPlayerMP player = ctx.getServerHandler().playerEntity;
if (player.worldObj == null) {
return null;
}
final Entity player = world.getEntityByID(message.playerid);
if (player instanceof EntityPlayer && ((EntityPlayer) player).inventory.armorItemInSlot(3) != null
&& ((EntityPlayer) player).inventory.armorItemInSlot(3).getItem() instanceof IRevealer) {
LensManager.changeLens(
((EntityPlayer) player).inventory.armorItemInSlot(3),
world,
(EntityPlayer) player,
message.lens);
if (player.inventory.armorItemInSlot(3) != null
&& player.inventory.armorItemInSlot(3).getItem() instanceof IRevealer) {
LensManager.changeLens(player.inventory.armorItemInSlot(3), player.worldObj, player, message.lens);
}
return null;
}
@@ -0,0 +1,34 @@
//
// Decompiled by Procyon v0.5.30
//
package com.kentington.thaumichorizons.common.lib.networking;
import static com.kentington.thaumichorizons.common.items.lenses.LensPotionEffects.isNightVisionGrantedByLens;
import net.minecraft.client.Minecraft;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import com.kentington.thaumichorizons.common.items.lenses.LensManager;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
public class PacketRemoveLensNightvision implements IMessage, IMessageHandler<PacketRemoveLensNightvision, IMessage> {
public IMessage onMessage(final PacketRemoveLensNightvision message, final MessageContext ctx) {
final PotionEffect effect = Minecraft.getMinecraft().thePlayer.getActivePotionEffect(Potion.nightVision);
if (isNightVisionGrantedByLens(effect)) {
Minecraft.getMinecraft().thePlayer.removePotionEffect(Potion.nightVision.id);
LensManager.nightVisionOffTime = Minecraft.getSystemTime() + 100L;
}
return null;
}
public void fromBytes(final ByteBuf buf) {}
public void toBytes(final ByteBuf buf) {}
}
@@ -1,32 +0,0 @@
//
// Decompiled by Procyon v0.5.30
//
package com.kentington.thaumichorizons.common.lib.networking;
import net.minecraft.client.Minecraft;
import net.minecraft.potion.Potion;
import com.kentington.thaumichorizons.common.items.lenses.LensManager;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
public class PacketRemoveNightvision implements IMessage, IMessageHandler<PacketRemoveNightvision, IMessage> {
@SideOnly(Side.CLIENT)
public IMessage onMessage(final PacketRemoveNightvision message, final MessageContext ctx) {
Minecraft.getMinecraft().thePlayer.removePotionEffect(Potion.nightVision.id);
Minecraft.getMinecraft();
LensManager.nightVisionOffTime = Minecraft.getSystemTime() + 100L;
return null;
}
public void fromBytes(final ByteBuf buf) {}
public void toBytes(final ByteBuf buf) {}
}
@@ -5,8 +5,6 @@
package com.kentington.thaumichorizons.common.lib.networking;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import com.kentington.thaumichorizons.common.lib.EntityInfusionProperties;
@@ -17,32 +15,17 @@ import io.netty.buffer.ByteBuf;
public class PacketToggleClimbToServer implements IMessage, IMessageHandler<PacketToggleClimbToServer, IMessage> {
private int playerid;
private int dim;
public PacketToggleClimbToServer() {}
public PacketToggleClimbToServer(final EntityPlayer player, final int dim) {
this.playerid = player.getEntityId();
this.dim = dim;
}
public void toBytes(final ByteBuf buffer) {}
public void toBytes(final ByteBuf buffer) {
buffer.writeInt(this.playerid);
buffer.writeInt(this.dim);
}
public void fromBytes(final ByteBuf buffer) {
this.playerid = buffer.readInt();
this.dim = buffer.readInt();
}
public void fromBytes(final ByteBuf buffer) {}
public IMessage onMessage(final PacketToggleClimbToServer message, final MessageContext ctx) {
if (!PacketHandler.selfInfusionSecurityCheck(ctx, "toggle spider climb", message.playerid, 9)) {
if (PacketHandler.selfInfusionSecurityCheck(ctx, "toggle spider climb", 9)) {
return null;
}
final World world = DimensionManager.getWorld(message.dim);
final EntityPlayer player = (EntityPlayer) world.getEntityByID(message.playerid);
final EntityPlayer player = ctx.getServerHandler().playerEntity;
((EntityInfusionProperties) player
.getExtendedProperties("CreatureInfusion")).toggleClimb = !((EntityInfusionProperties) player
.getExtendedProperties("CreatureInfusion")).toggleClimb;
@@ -6,7 +6,6 @@ package com.kentington.thaumichorizons.common.lib.networking;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
@@ -21,29 +20,14 @@ import io.netty.buffer.ByteBuf;
public class PacketToggleInvisibleToServer
implements IMessage, IMessageHandler<PacketToggleInvisibleToServer, IMessage> {
private int playerid;
private int dim;
public PacketToggleInvisibleToServer() {}
public PacketToggleInvisibleToServer(final EntityPlayer player, final int dim) {
this.playerid = player.getEntityId();
this.dim = dim;
}
public void toBytes(final ByteBuf buffer) {}
public void toBytes(final ByteBuf buffer) {
buffer.writeInt(this.playerid);
buffer.writeInt(this.dim);
}
public void fromBytes(final ByteBuf buffer) {
this.playerid = buffer.readInt();
this.dim = buffer.readInt();
}
public void fromBytes(final ByteBuf buffer) {}
public IMessage onMessage(final PacketToggleInvisibleToServer message, final MessageContext ctx) {
if (!PacketHandler
.selfInfusionSecurityCheck(ctx, "toggle chamelon skin (i.e. invisible)", message.playerid, 10)) {
if (PacketHandler.selfInfusionSecurityCheck(ctx, "toggle chamelon skin (i.e. invisible)", 10)) {
return null;
}
final EntityPlayerMP player = ctx.getServerHandler().playerEntity;
@@ -33,7 +33,6 @@ import net.minecraftforge.common.DimensionManager;
import com.kentington.thaumichorizons.common.ThaumicHorizons;
import com.kentington.thaumichorizons.common.entities.EntityGolemTH;
import com.kentington.thaumichorizons.common.lib.PocketPlaneData;
import com.kentington.thaumichorizons.common.lib.PocketPlaneThread;
import com.kentington.thaumichorizons.common.lib.VortexTeleporter;
import cpw.mods.fml.common.FMLCommonHandler;
@@ -60,10 +59,8 @@ public class TileVortex extends TileThaumcraft implements IWandable, IAspectCont
boolean ateDevices;
public boolean collapsing;
public boolean createdDimension;
public boolean generating;
public boolean cheat;
public ArrayList<ItemStack> items;
Thread ppThread;
private boolean soundStarted = false;
// true once the first S35 description packet has been received on the client
public boolean clientSynced = false;
@@ -74,10 +71,8 @@ public class TileVortex extends TileThaumcraft implements IWandable, IAspectCont
this.ateDevices = false;
this.collapsing = false;
this.createdDimension = false;
this.generating = false;
this.cheat = false;
this.items = new ArrayList<ItemStack>();
this.ppThread = null;
this.items = new ArrayList<>();
}
public void updateEntity() {
@@ -95,114 +90,91 @@ public class TileVortex extends TileThaumcraft implements IWandable, IAspectCont
soundStarted = true;
}
if (this.generating) {
this.worldObj.createExplosion(
null,
this.xCoord + this.worldObj.rand.nextFloat(),
this.yCoord + this.worldObj.rand.nextFloat(),
this.zCoord + this.worldObj.rand.nextFloat(),
1.0f,
false);
if (this.ppThread == null) {
this.createDimension(null);
return;
}
if (!this.ppThread.isAlive()) {
this.generating = false;
this.createdDimension = true;
this.markDirty();
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
} else {
if (this.collapsing) {
++this.count;
if (this.count > 25) {
if (this.createdDimension) {
WorldServer wsd = DimensionManager.getWorld(ThaumicHorizons.dimensionPocketId);
if (wsd != null) {
wsd.setBlockToAir(0, 129, this.dimensionID * 256);
}
if (this.collapsing) {
++this.count;
if (this.count > 25) {
if (this.createdDimension) {
WorldServer wsd = DimensionManager.getWorld(ThaumicHorizons.dimensionPocketId);
if (wsd != null) {
wsd.setBlockToAir(0, 129, this.dimensionID * 256);
}
this.worldObj.setBlockToAir(this.xCoord, this.yCoord, this.zCoord);
if (worldObj.isRemote)
Thaumcraft.proxy.burst(this.worldObj, this.xCoord, this.yCoord, this.zCoord, 4.0f);
BlockAiry.explodify(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
return;
this.worldObj.setBlockToAir(this.xCoord, this.yCoord, this.zCoord);
if (worldObj.isRemote)
Thaumcraft.proxy.burst(this.worldObj, this.xCoord, this.yCoord, this.zCoord, 4.0f);
BlockAiry.explodify(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
if (this.count < 50) {
++this.count;
} else {
if (!this.ateDevices) {
if (!this.cheat && this.worldObj.provider.dimensionId != ThaumicHorizons.dimensionPocketId) {
for (int dx = -2; dx <= 2; ++dx) {
for (int dy = -2; dy <= 2; ++dy) {
for (int dz = -2; dz <= 2; ++dz) {
if (dx != 0 || dy != 0 || dz != 0) {
this.worldObj
.setBlockToAir(this.xCoord + dx, this.yCoord + dy, this.zCoord + dz);
if (worldObj.isRemote) Thaumcraft.proxy.burst(
this.worldObj,
this.xCoord + dx,
this.yCoord + dy,
this.zCoord + dz,
4.0f);
}
return;
}
if (this.count < 50) {
++this.count;
} else {
if (!this.ateDevices) {
if (!this.cheat && this.worldObj.provider.dimensionId != ThaumicHorizons.dimensionPocketId) {
for (int dx = -2; dx <= 2; ++dx) {
for (int dy = -2; dy <= 2; ++dy) {
for (int dz = -2; dz <= 2; ++dz) {
if (dx != 0 || dy != 0 || dz != 0) {
this.worldObj.setBlockToAir(this.xCoord + dx, this.yCoord + dy, this.zCoord + dz);
if (worldObj.isRemote) Thaumcraft.proxy.burst(
this.worldObj,
this.xCoord + dx,
this.yCoord + dy,
this.zCoord + dz,
4.0f);
}
}
}
}
this.ateDevices = true;
}
if (this.beams < 6 && !this.cheat
&& this.worldObj.provider.dimensionId != ThaumicHorizons.dimensionPocketId) {
this.handleHungryNode();
} else if (!this.createdDimension && !this.generating) {
this.handlePocketPlaneStuff();
}
if (!this.cheat) {
this.count += Math.max(0, 6 - this.beams);
}
if (this.count > MAX_COUNT && !this.cheat
&& this.worldObj.provider.dimensionId != ThaumicHorizons.dimensionPocketId) {
this.collapsing = true;
this.count = 0;
}
if (this.createdDimension) {
final List ents = this.worldObj.getEntitiesWithinAABB(
EntityPlayerMP.class,
AxisAlignedBB.getBoundingBox(
this.xCoord,
this.yCoord,
this.zCoord,
this.xCoord + 1,
this.yCoord + 1,
this.zCoord + 1));
if (ents.size() > 0) {
for (final Object e : ents) {
final EntityPlayerMP player = (EntityPlayerMP) e;
if (player.ridingEntity == null && player.riddenByEntity == null) {
final MinecraftServer mServer = FMLCommonHandler.instance()
.getMinecraftServerInstance();
if (player.timeUntilPortal > 0) {
player.timeUntilPortal = 10;
} else if (player.dimension != ThaumicHorizons.dimensionPocketId) {
player.timeUntilPortal = 200;
player.mcServer.getConfigurationManager().transferPlayerToDimension(
player,
ThaumicHorizons.dimensionPocketId,
new VortexTeleporter(
mServer.worldServerForDimension(ThaumicHorizons.dimensionPocketId),
this.dimensionID));
} else {
player.timeUntilPortal = 200;
player.mcServer.getConfigurationManager().transferPlayerToDimension(
player,
this.returnID,
new VortexTeleporter(
mServer.worldServerForDimension(this.returnID),
this.dimensionID));
}
this.ateDevices = true;
}
if (this.beams < 6 && !this.cheat
&& this.worldObj.provider.dimensionId != ThaumicHorizons.dimensionPocketId) {
this.handleHungryNode();
} else if (!this.createdDimension) {
this.handlePocketPlaneStuff();
}
if (!this.cheat) {
this.count += Math.max(0, 6 - this.beams);
}
if (this.count > MAX_COUNT && !this.cheat
&& this.worldObj.provider.dimensionId != ThaumicHorizons.dimensionPocketId) {
this.collapsing = true;
this.count = 0;
}
if (this.createdDimension) {
final List<EntityPlayerMP> ents = this.worldObj.getEntitiesWithinAABB(
EntityPlayerMP.class,
AxisAlignedBB.getBoundingBox(
this.xCoord,
this.yCoord,
this.zCoord,
this.xCoord + 1,
this.yCoord + 1,
this.zCoord + 1));
if (!ents.isEmpty()) {
for (final EntityPlayerMP player : ents) {
if (player.ridingEntity == null && player.riddenByEntity == null) {
final MinecraftServer mServer = FMLCommonHandler.instance().getMinecraftServerInstance();
if (player.timeUntilPortal > 0) {
player.timeUntilPortal = 10;
} else if (player.dimension != ThaumicHorizons.dimensionPocketId) {
player.timeUntilPortal = 200;
player.mcServer.getConfigurationManager().transferPlayerToDimension(
player,
ThaumicHorizons.dimensionPocketId,
new VortexTeleporter(
mServer.worldServerForDimension(ThaumicHorizons.dimensionPocketId),
this.dimensionID));
} else {
player.timeUntilPortal = 200;
player.mcServer.getConfigurationManager().transferPlayerToDimension(
player,
this.returnID,
new VortexTeleporter(
mServer.worldServerForDimension(this.returnID),
this.dimensionID));
}
}
}
@@ -212,7 +184,7 @@ public class TileVortex extends TileThaumcraft implements IWandable, IAspectCont
}
void handlePocketPlaneStuff() {
final List ents = this.worldObj.getEntitiesWithinAABB(
final List<Entity> ents = this.worldObj.getEntitiesWithinAABB(
Entity.class,
AxisAlignedBB.getBoundingBox(
this.xCoord,
@@ -221,12 +193,18 @@ public class TileVortex extends TileThaumcraft implements IWandable, IAspectCont
this.xCoord + 1,
this.yCoord + 1,
this.zCoord + 1).expand(1.0, 1.0, 1.0));
if (ents != null && ents.size() > 0) {
for (final Object ent : ents) {
final Entity eo = (Entity) ent;
if (ents != null && !ents.isEmpty()) {
for (final Entity eo : ents) {
if (eo instanceof final EntityItem item) {
if (ThaumicHorizons.enablePocket && item.getEntityItem().getItem() == ConfigItems.itemEldritchObject
&& item.getEntityItem().getItemDamage() == 3) {
this.worldObj.createExplosion(
null,
this.xCoord + this.worldObj.rand.nextFloat(),
this.yCoord + this.worldObj.rand.nextFloat(),
this.zCoord + this.worldObj.rand.nextFloat(),
1.0f,
false);
this.createDimension(item);
item.setDead();
} else {
@@ -322,19 +300,19 @@ public class TileVortex extends TileThaumcraft implements IWandable, IAspectCont
if (DimensionManager.getWorld(ThaumicHorizons.dimensionPocketId) == null) {
DimensionManager.initDimension(ThaumicHorizons.dimensionPocketId);
}
this.generating = true;
if (!this.worldObj.isRemote) {
this.returnID = this.worldObj.provider.dimensionId;
(this.ppThread = new Thread(
new PocketPlaneThread(
data,
this.aspects,
(World) MinecraftServer.getServer()
.worldServerForDimension(ThaumicHorizons.dimensionPocketId),
this.xCoord,
this.yCoord,
this.zCoord,
this.returnID))).start();
World world = server.worldServerForDimension(ThaumicHorizons.dimensionPocketId);
PocketPlaneData.generatePocketPlane(
this.aspects,
data,
world,
this.xCoord,
this.yCoord,
this.zCoord,
this.returnID);
this.createdDimension = true;
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
this.markDirty();
}
@@ -451,7 +429,6 @@ public class TileVortex extends TileThaumcraft implements IWandable, IAspectCont
nbttagcompound.setBoolean("ateDevices", this.ateDevices);
nbttagcompound.setBoolean("collapsing", this.collapsing);
nbttagcompound.setBoolean("createdDimension", this.createdDimension);
nbttagcompound.setBoolean("isGenerating", this.generating);
nbttagcompound.setBoolean("cheat", this.cheat);
final NBTTagList tlist = new NBTTagList();
nbttagcompound.setTag("aspects", tlist);
@@ -482,7 +459,6 @@ public class TileVortex extends TileThaumcraft implements IWandable, IAspectCont
this.ateDevices = nbttagcompound.getBoolean("ateDevices");
this.collapsing = nbttagcompound.getBoolean("collapsing");
this.createdDimension = nbttagcompound.getBoolean("createdDimension");
this.generating = nbttagcompound.getBoolean("isGenerating");
this.cheat = nbttagcompound.getBoolean("cheat");
final AspectList al = new AspectList();
final NBTTagList tlist = nbttagcompound.getTagList("aspects", 10);
@@ -504,7 +480,7 @@ public class TileVortex extends TileThaumcraft implements IWandable, IAspectCont
@Override
public int onWandRightClick(final World world, final ItemStack wandstack, final EntityPlayer player, final int x,
final int y, final int z, final int side, final int md) {
if (!this.worldObj.isRemote && this.items.size() > 0) {
if (!this.worldObj.isRemote && !this.items.isEmpty()) {
final ItemStack item = this.items.get(0);
final EntityItem key = new EntityItem(this.worldObj);
key.setEntityItemStack(item);