mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 12:19:46 +00:00
Move things to AT so we know when they break immediately
This commit is contained in:
1 parent
37098050cc
commit
789a380e7d
37 files changed
+188
-568
No files matched your search
@@ -75,15 +75,9 @@ public final class AstrolabePreviewHandler {
|
||||
private static void renderBlockAt(Block block, int meta, BlockPos pos) {
|
||||
IBlockState state = block.getStateFromMeta(meta);
|
||||
|
||||
double renderPosX, renderPosY, renderPosZ;
|
||||
|
||||
try {
|
||||
renderPosX = (double) ClientMethodHandles.renderPosX_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosY = (double) ClientMethodHandles.renderPosY_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosZ = (double) ClientMethodHandles.renderPosZ_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
} catch (Throwable t) {
|
||||
return;
|
||||
}
|
||||
double renderPosX = Minecraft.getMinecraft().getRenderManager().renderPosX;
|
||||
double renderPosY = Minecraft.getMinecraft().getRenderManager().renderPosY;
|
||||
double renderPosZ = Minecraft.getMinecraft().getRenderManager().renderPosZ;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(-renderPosX, -renderPosY, -renderPosZ);
|
||||
|
||||
@@ -107,15 +107,9 @@ public final class BlockHighlightRenderHandler {
|
||||
}
|
||||
|
||||
private static void renderRectangle(AxisAlignedBB aabb, boolean inner, Color color, byte alpha) {
|
||||
double renderPosX, renderPosY, renderPosZ;
|
||||
|
||||
try {
|
||||
renderPosX = (double) ClientMethodHandles.renderPosX_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosY = (double) ClientMethodHandles.renderPosY_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosZ = (double) ClientMethodHandles.renderPosZ_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
} catch (Throwable t) {
|
||||
return;
|
||||
}
|
||||
double renderPosX = Minecraft.getMinecraft().getRenderManager().renderPosX;
|
||||
double renderPosY = Minecraft.getMinecraft().getRenderManager().renderPosY;
|
||||
double renderPosZ = Minecraft.getMinecraft().getRenderManager().renderPosZ;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(aabb.minX - renderPosX, aabb.minY - renderPosY, aabb.minZ - renderPosZ);
|
||||
@@ -154,15 +148,9 @@ public final class BlockHighlightRenderHandler {
|
||||
}
|
||||
|
||||
private static void renderCircle(BlockPos center, double radius) {
|
||||
double renderPosX, renderPosY, renderPosZ;
|
||||
|
||||
try {
|
||||
renderPosX = (double) ClientMethodHandles.renderPosX_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosY = (double) ClientMethodHandles.renderPosY_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosZ = (double) ClientMethodHandles.renderPosZ_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
} catch (Throwable t) {
|
||||
return;
|
||||
}
|
||||
double renderPosX = Minecraft.getMinecraft().getRenderManager().renderPosX;
|
||||
double renderPosY = Minecraft.getMinecraft().getRenderManager().renderPosY;
|
||||
double renderPosZ = Minecraft.getMinecraft().getRenderManager().renderPosZ;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
double x = center.getX() + 0.5;
|
||||
|
||||
@@ -95,15 +95,9 @@ public final class BoundTileRenderer {
|
||||
}
|
||||
|
||||
private static void renderBlockOutlineAt(BlockPos pos, int color, float thickness) {
|
||||
double renderPosX, renderPosY, renderPosZ;
|
||||
|
||||
try {
|
||||
renderPosX = (double) ClientMethodHandles.renderPosX_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosY = (double) ClientMethodHandles.renderPosY_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosZ = (double) ClientMethodHandles.renderPosZ_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
} catch (Throwable t) {
|
||||
return;
|
||||
}
|
||||
double renderPosX = Minecraft.getMinecraft().getRenderManager().renderPosX;
|
||||
double renderPosY = Minecraft.getMinecraft().getRenderManager().renderPosY;
|
||||
double renderPosZ = Minecraft.getMinecraft().getRenderManager().renderPosZ;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(pos.getX() - renderPosX, pos.getY() - renderPosY, pos.getZ() - renderPosZ + 1);
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
package vazkii.botania.client.core.handler;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public final class ClientMethodHandles {
|
||||
|
||||
public static final MethodHandle
|
||||
renderPosX_getter, renderPosY_getter, renderPosZ_getter, // RenderManager
|
||||
starGLCallList_getter, starVBO_getter, glSkyList_getter, skyVBO_getter; // RenderGlobal
|
||||
|
||||
static {
|
||||
try {
|
||||
Field f = ReflectionHelper.findField(RenderManager.class, LibObfuscation.RENDERPOSX);
|
||||
f.setAccessible(true);
|
||||
renderPosX_getter = MethodHandles.publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(RenderManager.class, LibObfuscation.RENDERPOSY);
|
||||
f.setAccessible(true);
|
||||
renderPosY_getter = MethodHandles.publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(RenderManager.class, LibObfuscation.RENDERPOSZ);
|
||||
f.setAccessible(true);
|
||||
renderPosZ_getter = MethodHandles.publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(RenderGlobal.class, LibObfuscation.STAR_GL_CALL_LIST);
|
||||
f.setAccessible(true);
|
||||
starGLCallList_getter = MethodHandles.publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(RenderGlobal.class, LibObfuscation.STAR_VBO);
|
||||
f.setAccessible(true);
|
||||
starVBO_getter = MethodHandles.publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(RenderGlobal.class, LibObfuscation.GL_SKY_LIST);
|
||||
f.setAccessible(true);
|
||||
glSkyList_getter = MethodHandles.publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(RenderGlobal.class, LibObfuscation.SKY_VBO);
|
||||
f.setAccessible(true);
|
||||
skyVBO_getter = MethodHandles.publicLookup().unreflectGetter(f);
|
||||
} catch (IllegalAccessException e) {
|
||||
Botania.LOGGER.fatal("Couldn't initialize client methodhandles! Things will be broken!");
|
||||
e.printStackTrace();
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
private ClientMethodHandles() {}
|
||||
}
|
||||
@@ -92,11 +92,10 @@ public class CorporeaAutoCompleteHandler {
|
||||
if(!CorporeaHelper.shouldAutoComplete())
|
||||
return;
|
||||
|
||||
GuiTextField inputField = ReflectionHelper.getPrivateValue(GuiChat.class, chat, LibObfuscation.INPUT_FIELD);
|
||||
if(!isAutoCompleted)
|
||||
buildAutoCompletes(inputField, chat);
|
||||
buildAutoCompletes(chat.inputField, chat);
|
||||
if(isAutoCompleted && !completions.isEmpty())
|
||||
advanceAutoComplete(inputField, chat);
|
||||
advanceAutoComplete(chat.inputField, chat);
|
||||
}
|
||||
|
||||
private void advanceAutoComplete(GuiTextField inputField, GuiChat chat) {
|
||||
|
||||
@@ -264,7 +264,7 @@ public final class HUDHandler {
|
||||
Profiler profiler = mc.mcProfiler;
|
||||
|
||||
profiler.startSection("wandMode");
|
||||
int ticks = ReflectionHelper.getPrivateValue(GuiIngame.class, mc.ingameGUI, LibObfuscation.REMAINING_HIGHLIGHT_TICKS);
|
||||
int ticks = mc.ingameGUI.remainingHighlightTicks;
|
||||
ticks -= 15;
|
||||
if(ticks > 0) {
|
||||
int alpha = Math.min(255, (int) (ticks * 256.0F / 10.0F));
|
||||
|
||||
@@ -138,15 +138,9 @@ public final class MultiblockRenderHandler {
|
||||
}
|
||||
|
||||
private static boolean renderComponentInWorld(World world, Multiblock mb, MultiblockComponent comp, BlockPos anchorPos) {
|
||||
double renderPosX, renderPosY, renderPosZ;
|
||||
|
||||
try {
|
||||
renderPosX = (double) ClientMethodHandles.renderPosX_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosY = (double) ClientMethodHandles.renderPosY_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosZ = (double) ClientMethodHandles.renderPosZ_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
} catch (Throwable t) {
|
||||
return true;
|
||||
}
|
||||
double renderPosX = Minecraft.getMinecraft().getRenderManager().renderPosX;
|
||||
double renderPosY = Minecraft.getMinecraft().getRenderManager().renderPosY;
|
||||
double renderPosZ = Minecraft.getMinecraft().getRenderManager().renderPosZ;
|
||||
|
||||
BlockPos pos = comp.getRelativePosition();
|
||||
BlockPos pos_ = pos.add(anchorPos);
|
||||
|
||||
@@ -64,15 +64,9 @@ public final class RedStringRenderer {
|
||||
}
|
||||
|
||||
private static void renderTile(TileRedString tile) {
|
||||
double renderPosX, renderPosY, renderPosZ;
|
||||
|
||||
try {
|
||||
renderPosX = (double) ClientMethodHandles.renderPosX_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosY = (double) ClientMethodHandles.renderPosY_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosZ = (double) ClientMethodHandles.renderPosZ_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
} catch (Throwable t) {
|
||||
return;
|
||||
}
|
||||
double renderPosX = Minecraft.getMinecraft().getRenderManager().renderPosX;
|
||||
double renderPosY = Minecraft.getMinecraft().getRenderManager().renderPosY;
|
||||
double renderPosZ = Minecraft.getMinecraft().getRenderManager().renderPosZ;
|
||||
|
||||
EnumFacing dir = tile.getOrientation();
|
||||
BlockPos bind = tile.getBinding();
|
||||
|
||||
@@ -12,6 +12,7 @@ package vazkii.botania.client.core.proxy;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
@@ -298,10 +299,10 @@ public class ClientProxy implements IProxy {
|
||||
@Override
|
||||
public void setExtraReach(EntityLivingBase entity, float reach) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
EntityPlayer player = mc.player;
|
||||
EntityPlayerSP player = mc.player;
|
||||
if(entity == player) {
|
||||
if(!(mc.playerController instanceof IExtendedPlayerController)) {
|
||||
NetHandlerPlayClient net = ReflectionHelper.getPrivateValue(PlayerControllerMP.class, mc.playerController, LibObfuscation.NET_CLIENT_HANDLER);
|
||||
NetHandlerPlayClient net = player.connection;
|
||||
BotaniaPlayerController controller = new BotaniaPlayerController(mc, net);
|
||||
boolean isFlying = player.capabilities.isFlying;
|
||||
boolean allowFlying = player.capabilities.allowFlying;
|
||||
|
||||
@@ -39,7 +39,6 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaCrystalCube;
|
||||
import vazkii.botania.common.core.handler.MethodHandles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -63,12 +62,8 @@ public class RenderTileCorporeaCrystalCube extends TileEntitySpecialRenderer<Til
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
MethodHandles.itemAge_setter.invokeExact(entity, ClientTickHandler.ticksInGame);
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
stack = cube.getRequestTarget();
|
||||
entity.setItem(stack);
|
||||
entity.age = ClientTickHandler.ticksInGame;
|
||||
entity.setItem(cube.getRequestTarget());
|
||||
}
|
||||
|
||||
double time = ClientTickHandler.ticksInGame + f;
|
||||
|
||||
@@ -25,7 +25,6 @@ import vazkii.botania.client.core.handler.MiscellaneousIcons;
|
||||
import vazkii.botania.client.core.helper.ShaderHelper;
|
||||
import vazkii.botania.client.core.proxy.ClientProxy;
|
||||
import vazkii.botania.common.block.tile.TileEnchanter;
|
||||
import vazkii.botania.common.core.handler.MethodHandles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -48,10 +47,7 @@ public class RenderTileEnchanter extends TileEntitySpecialRenderer<TileEnchanter
|
||||
if(item == null)
|
||||
item = new EntityItem(enchanter.getWorld(), enchanter.getPos().getX(), enchanter.getPos().getY() + 1, enchanter.getPos().getZ(), enchanter.itemToEnchant);
|
||||
|
||||
try {
|
||||
MethodHandles.itemAge_setter.invokeExact(item, ClientTickHandler.ticksInGame);
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
item.age = ClientTickHandler.ticksInGame;
|
||||
item.setItem(enchanter.itemToEnchant);
|
||||
|
||||
GlStateManager.color(1F, 1F, 1F, 1F);
|
||||
|
||||
@@ -23,7 +23,6 @@ import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.client.IRenderHandler;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.client.core.handler.ClientMethodHandles;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
|
||||
@@ -48,13 +47,8 @@ public class SkyblockSkyRenderer extends IRenderHandler {
|
||||
@Override
|
||||
public void render(float partialTicks, WorldClient world, Minecraft mc) {
|
||||
// Environment setup
|
||||
int glSkyList;
|
||||
net.minecraft.client.renderer.vertex.VertexBuffer skyVBO;
|
||||
|
||||
try {
|
||||
glSkyList = (int) ClientMethodHandles.glSkyList_getter.invokeExact(mc.renderGlobal);
|
||||
skyVBO = (net.minecraft.client.renderer.vertex.VertexBuffer) ClientMethodHandles.skyVBO_getter.invokeExact(mc.renderGlobal);
|
||||
} catch (Throwable t) { return; }
|
||||
int glSkyList = mc.renderGlobal.glSkyList;
|
||||
net.minecraft.client.renderer.vertex.VertexBuffer skyVBO = mc.renderGlobal.skyVBO;
|
||||
|
||||
// Begin
|
||||
GlStateManager.disableTexture2D();
|
||||
@@ -441,13 +435,8 @@ public class SkyblockSkyRenderer extends IRenderHandler {
|
||||
}
|
||||
|
||||
private void renderStars(Minecraft mc, float alpha, float partialTicks) {
|
||||
int starGLCallList;
|
||||
net.minecraft.client.renderer.vertex.VertexBuffer starVBO;
|
||||
|
||||
try {
|
||||
starGLCallList = (int) ClientMethodHandles.starGLCallList_getter.invokeExact(mc.renderGlobal);
|
||||
starVBO = (net.minecraft.client.renderer.vertex.VertexBuffer) ClientMethodHandles.starVBO_getter.invokeExact(mc.renderGlobal);
|
||||
} catch (Throwable t) { return; }
|
||||
int starGLCallList = mc.renderGlobal.starGLCallList;
|
||||
net.minecraft.client.renderer.vertex.VertexBuffer starVBO = mc.renderGlobal.starVBO;
|
||||
|
||||
float t = (ClientTickHandler.ticksInGame + partialTicks + 2000) * 0.005F;
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
@@ -20,7 +20,6 @@ import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.SubTileFunctional;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.handler.MethodHandles;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
|
||||
import java.util.List;
|
||||
@@ -52,14 +51,7 @@ public class SubTileDaffomill extends SubTileFunctional {
|
||||
List<EntityItem> items = supertile.getWorld().getEntitiesWithinAABB(EntityItem.class, axis);
|
||||
int slowdown = getSlowdownFactor();
|
||||
for(EntityItem item : items) {
|
||||
int age;
|
||||
try {
|
||||
age = (int) MethodHandles.itemAge_getter.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!item.isDead && age >= slowdown) {
|
||||
if(!item.isDead && item.age >= slowdown) {
|
||||
item.motionX += orientation.getFrontOffsetX() * 0.05;
|
||||
item.motionY += orientation.getFrontOffsetY() * 0.05;
|
||||
item.motionZ += orientation.getFrontOffsetZ() * 0.05;
|
||||
|
||||
+2
-2
@@ -88,8 +88,8 @@ public class SubTileHeiseiDream extends SubTileFunctional {
|
||||
}
|
||||
|
||||
private static void messWithGetTargetAI(EntityAINearestAttackableTarget aiEntry, EntityLivingBase target) {
|
||||
ReflectionHelper.setPrivateValue(EntityAINearestAttackableTarget.class, aiEntry, Entity.class, LibObfuscation.TARGET_CLASS);
|
||||
ReflectionHelper.setPrivateValue(EntityAINearestAttackableTarget.class, aiEntry, Predicates.equalTo(target), LibObfuscation.TARGET_ENTITY_SELECTOR); // todo 1.8 will this leak `target`?
|
||||
aiEntry.targetClass = Entity.class;
|
||||
aiEntry.targetEntitySelector = e -> e == target; // todo will this leak target?
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,7 +35,6 @@ import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.mana.IManaItem;
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.SubTileFunctional;
|
||||
import vazkii.botania.common.core.handler.MethodHandles;
|
||||
import vazkii.botania.common.core.helper.InventoryHelper;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
|
||||
@@ -69,14 +68,7 @@ public class SubTileHopperhock extends SubTileFunctional {
|
||||
int slowdown = getSlowdownFactor();
|
||||
|
||||
for(EntityItem item : items) {
|
||||
int age;
|
||||
try {
|
||||
age = (int) MethodHandles.itemAge_getter.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(age < 60 + slowdown || age >= 105 && age < 110 || item.isDead || item.getItem().isEmpty())
|
||||
if(item.age < 60 + slowdown || item.age >= 105 && item.age < 110 || item.isDead || item.getItem().isEmpty())
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getItem();
|
||||
|
||||
+2
-10
@@ -18,7 +18,6 @@ import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.SubTileFunctional;
|
||||
import vazkii.botania.common.core.handler.MethodHandles;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
@@ -45,14 +44,7 @@ public class SubTilePollidisiac extends SubTileFunctional {
|
||||
|
||||
if(animal.getGrowingAge() == 0 && !animal.isInLove()) {
|
||||
for(EntityItem item : items) {
|
||||
int age;
|
||||
try {
|
||||
age = (int) MethodHandles.itemAge_getter.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(age < 60 + slowdown || item.isDead)
|
||||
if(item.age < 60 + slowdown || item.isDead)
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getItem();
|
||||
@@ -61,7 +53,7 @@ public class SubTilePollidisiac extends SubTileFunctional {
|
||||
|
||||
mana -= manaCost;
|
||||
|
||||
ReflectionHelper.setPrivateValue(EntityAnimal.class, animal, 1200, LibObfuscation.IN_LOVE);
|
||||
animal.inLove = 1200;
|
||||
supertile.getWorld().setEntityState(animal, (byte)18);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-10
@@ -39,7 +39,6 @@ import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.SubTileEntity;
|
||||
import vazkii.botania.api.subtile.SubTileFunctional;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.core.handler.MethodHandles;
|
||||
import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
@@ -80,14 +79,7 @@ public class SubTileRannuncarpus extends SubTileFunctional {
|
||||
List<EntityItem> items = supertile.getWorld().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE_Y, -RANGE), supertile.getPos().add(RANGE + 1, RANGE_Y + 1, RANGE + 1)));
|
||||
int slowdown = getSlowdownFactor();
|
||||
for(EntityItem item : items) {
|
||||
int age;
|
||||
try {
|
||||
age = (int) MethodHandles.itemAge_getter.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(age < 60 + slowdown || item.isDead || item.getItem().isEmpty())
|
||||
if(item.age < 60 + slowdown || item.isDead || item.getItem().isEmpty())
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getItem();
|
||||
@@ -123,7 +115,7 @@ public class SubTileRannuncarpus extends SubTileFunctional {
|
||||
stateToPlace = ((ItemBlock) stackItem).getBlock().getStateFromMeta(blockMeta);
|
||||
}
|
||||
else if(stackItem instanceof ItemBlockSpecial)
|
||||
stateToPlace = ((Block) ReflectionHelper.getPrivateValue(ItemBlockSpecial.class, (ItemBlockSpecial) stackItem, LibObfuscation.REED_ITEM)).getDefaultState();
|
||||
stateToPlace = ((ItemBlockSpecial) stackItem).getBlock().getDefaultState();
|
||||
else if(stackItem instanceof ItemRedstone)
|
||||
stateToPlace = Blocks.REDSTONE_WIRE.getDefaultState();
|
||||
|
||||
|
||||
+1
-9
@@ -26,7 +26,6 @@ import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.mana.IManaItem;
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.SubTileFunctional;
|
||||
import vazkii.botania.common.core.handler.MethodHandles;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.network.PacketBotaniaEffect;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
@@ -60,14 +59,7 @@ public class SubTileSpectranthemum extends SubTileFunctional {
|
||||
int slowdown = getSlowdownFactor();
|
||||
|
||||
for(EntityItem item : items) {
|
||||
int age;
|
||||
try {
|
||||
age = (int) MethodHandles.itemAge_getter.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(age < 60 + slowdown || item.isDead || item.getEntityData().getBoolean(TAG_TELEPORTED))
|
||||
if(item.age < 60 + slowdown || item.isDead || item.getEntityData().getBoolean(TAG_TELEPORTED))
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getItem();
|
||||
|
||||
@@ -62,7 +62,7 @@ public class SubTileTigerseye extends SubTileFunctional {
|
||||
}
|
||||
|
||||
if(entity instanceof EntityCreeper) {
|
||||
ReflectionHelper.setPrivateValue(EntityCreeper.class, (EntityCreeper) entity, 2, LibObfuscation.TIME_SINCE_IGNITED);
|
||||
((EntityCreeper) entity).timeSinceIgnited = 2;
|
||||
entity.setAttackTarget(null);
|
||||
}
|
||||
|
||||
@@ -75,16 +75,16 @@ public class SubTileTigerseye extends SubTileFunctional {
|
||||
}
|
||||
|
||||
private boolean messWithRunAwayAI(EntityAIAvoidEntity aiEntry) {
|
||||
if(ReflectionHelper.getPrivateValue(EntityAIAvoidEntity.class, aiEntry, LibObfuscation.TARGET_ENTITY_CLASS) == EntityOcelot.class) {
|
||||
ReflectionHelper.setPrivateValue(EntityAIAvoidEntity.class, aiEntry, EntityPlayer.class, LibObfuscation.TARGET_ENTITY_CLASS);
|
||||
if(aiEntry.classToAvoid == EntityOcelot.class) {
|
||||
aiEntry.classToAvoid = EntityPlayer.class;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void messWithGetTargetAI(EntityAINearestAttackableTarget aiEntry) {
|
||||
if(ReflectionHelper.getPrivateValue(EntityAINearestAttackableTarget.class, aiEntry, LibObfuscation.TARGET_CLASS) == EntityPlayer.class)
|
||||
ReflectionHelper.setPrivateValue(EntityAINearestAttackableTarget.class, aiEntry, EntityEnderCrystal.class, LibObfuscation.TARGET_CLASS); // Something random that won't be around
|
||||
if(aiEntry.targetClass == EntityPlayer.class)
|
||||
aiEntry.targetClass = EntityEnderCrystal.class; // Something random that won't be around
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,6 @@ import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.SubTileGenerating;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.handler.MethodHandles;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
|
||||
@@ -49,14 +48,7 @@ public class SubTileEndoflame extends SubTileGenerating {
|
||||
|
||||
List<EntityItem> items = supertile.getWorld().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
|
||||
for(EntityItem item : items) {
|
||||
int age;
|
||||
try {
|
||||
age = (int) MethodHandles.itemAge_getter.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(age >= 59 + slowdown && !item.isDead) {
|
||||
if(item.age >= 59 + slowdown && !item.isDead) {
|
||||
ItemStack stack = item.getItem();
|
||||
if(stack.isEmpty() || stack.getItem().hasContainerItem(stack))
|
||||
continue;
|
||||
|
||||
+1
-9
@@ -23,7 +23,6 @@ import net.minecraft.world.WorldServer;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.SubTileGenerating;
|
||||
import vazkii.botania.common.core.handler.MethodHandles;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
|
||||
import java.util.List;
|
||||
@@ -59,14 +58,7 @@ public class SubTileGourmaryllis extends SubTileGenerating {
|
||||
for(EntityItem item : items) {
|
||||
ItemStack stack = item.getItem();
|
||||
|
||||
int age;
|
||||
try {
|
||||
age = (int) MethodHandles.itemAge_getter.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!stack.isEmpty() && stack.getItem() instanceof ItemFood && !item.isDead && age >= slowdown) {
|
||||
if(!stack.isEmpty() && stack.getItem() instanceof ItemFood && !item.isDead && item.age >= slowdown) {
|
||||
if(cooldown <= 0) {
|
||||
int val = Math.min(12, ((ItemFood) stack.getItem()).getHealAmount(stack));
|
||||
storedMana = val * val * 64;
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.SubTileGenerating;
|
||||
import vazkii.botania.common.core.handler.MethodHandles;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
|
||||
import java.awt.Color;
|
||||
@@ -57,14 +56,7 @@ public class SubTileSpectrolus extends SubTileGenerating {
|
||||
for(EntityItem item : items) {
|
||||
ItemStack stack = item.getItem();
|
||||
|
||||
int age;
|
||||
try {
|
||||
age = (int) MethodHandles.itemAge_getter.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!stack.isEmpty() && stack.getItem() == wool && !item.isDead && age >= slowdown) {
|
||||
if(!stack.isEmpty() && stack.getItem() == wool && !item.isDead && item.age >= slowdown) {
|
||||
int meta = stack.getItemDamage();
|
||||
if(meta == nextColor) {
|
||||
mana = Math.min(getMaxMana(), mana + 300);
|
||||
|
||||
@@ -20,7 +20,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.handler.MethodHandles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -72,13 +71,7 @@ public class TileOpenCrate extends TileSimpleInventory {
|
||||
item.motionX = 0;
|
||||
item.motionY = 0;
|
||||
item.motionZ = 0;
|
||||
|
||||
if(redstone) {
|
||||
try {
|
||||
MethodHandles.itemAge_setter.invokeExact(item, -200);
|
||||
} catch (Throwable ignored) {}
|
||||
}
|
||||
|
||||
item.age = -200;
|
||||
|
||||
itemHandler.setStackInSlot(0, ItemStack.EMPTY);
|
||||
world.spawnEntity(item);
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* <p>
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* <p>
|
||||
* File Created @ [Jul 23, 2014, 5:32:11 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.IEntityLivingData;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.MobSpawnerBaseLogic;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||
import net.minecraft.util.WeightedRandom;
|
||||
import net.minecraft.util.WeightedSpawnerEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -25,9 +25,6 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||
import vazkii.botania.api.mana.IManaReceiver;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.handler.MethodHandles;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileSpawnerClaw extends TileMod implements IManaReceiver {
|
||||
|
||||
@@ -42,119 +39,84 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver {
|
||||
TileEntityMobSpawner spawner = (TileEntityMobSpawner) tileBelow;
|
||||
MobSpawnerBaseLogic logic = spawner.getSpawnerBaseLogic();
|
||||
|
||||
try {
|
||||
// Directly drawn from MobSpawnerBaseLogic, with inverted isActivated check and mana consumption
|
||||
if(!((boolean) MethodHandles.isActivated.invokeExact(logic))) {
|
||||
if(!world.isRemote)
|
||||
mana -= 6;
|
||||
BlockPos blockpos = logic.getSpawnerPosition();
|
||||
|
||||
if(logic.getSpawnerWorld().isRemote) {
|
||||
int delay = (int) MethodHandles.spawnDelay_getter.invokeExact(logic);
|
||||
if(delay > 0)
|
||||
MethodHandles.spawnDelay_setter.invokeExact(logic, delay - 1);
|
||||
// Directly drawn from MobSpawnerBaseLogic, with inverted isActivated check and mana consumption
|
||||
if(!logic.isActivated()) {
|
||||
if(!world.isRemote)
|
||||
mana -= 6;
|
||||
|
||||
if(Math.random() > 0.5)
|
||||
Botania.proxy.wispFX(getPos().getX() + 0.3 + Math.random() * 0.5, getPos().getY() - 0.3 + Math.random() * 0.25, getPos().getZ() + Math.random(), 0.6F - (float) Math.random() * 0.3F, 0.1F, 0.6F - (float) Math.random() * 0.3F, (float) Math.random() / 3F, -0.025F - 0.005F * (float) Math.random(), 2F);
|
||||
|
||||
MethodHandles.prevMobRotation_setter.invokeExact(logic, logic.getMobRotation());
|
||||
MethodHandles.mobRotation_setter.invokeExact(logic, (logic.getMobRotation() + 1000.0F / ((int) MethodHandles.spawnDelay_getter.invokeExact(logic) + 200.0F)) % 360.0D);
|
||||
} else {
|
||||
if((int) MethodHandles.spawnDelay_getter.invokeExact(logic) == -1)
|
||||
resetTimer(logic);
|
||||
int delay = (int) MethodHandles.spawnDelay_getter.invokeExact(logic);
|
||||
if(delay > 0) {
|
||||
MethodHandles.spawnDelay_setter.invokeExact(logic, delay - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if(logic.getSpawnerWorld().isRemote)
|
||||
return;
|
||||
|
||||
boolean flag = false;
|
||||
|
||||
int spawnCount = (int) MethodHandles.spawnCount_getter.invokeExact(logic);
|
||||
int spawnRange = (int) MethodHandles.spawnRange_getter.invokeExact(logic);
|
||||
int maxNearbyEntities = (int) MethodHandles.maxNearbyEntities_getter.invokeExact(logic);
|
||||
WeightedSpawnerEntity randomEntity = (WeightedSpawnerEntity) MethodHandles.randomEntity_getter.invokeExact(logic);
|
||||
|
||||
BlockPos blockpos = logic.getSpawnerPosition();
|
||||
for(int i = 0; i < spawnCount; ++i) {
|
||||
NBTTagCompound nbttagcompound = randomEntity.getNbt();
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("Pos", 6);
|
||||
World world = logic.getSpawnerWorld();
|
||||
int j = nbttaglist.tagCount();
|
||||
double d0 = j >= 1 ? nbttaglist.getDoubleAt(0) : blockpos.getX() + (world.rand.nextDouble() - world.rand.nextDouble()) * spawnRange + 0.5D;
|
||||
double d1 = j >= 2 ? nbttaglist.getDoubleAt(1) : (double)(blockpos.getY() + world.rand.nextInt(3) - 1);
|
||||
double d2 = j >= 3 ? nbttaglist.getDoubleAt(2) : blockpos.getZ() + (world.rand.nextDouble() - world.rand.nextDouble()) * spawnRange + 0.5D;
|
||||
Entity entity = AnvilChunkLoader.readWorldEntityPos(nbttagcompound, world, d0, d1, d2, false);
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int k = world.getEntitiesWithinAABB(entity.getClass(), new AxisAlignedBB(blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockpos.getX() + 1, blockpos.getY() + 1, blockpos.getZ() + 1).grow(spawnRange)).size();
|
||||
|
||||
if (k >= maxNearbyEntities)
|
||||
{
|
||||
resetTimer(logic);
|
||||
return;
|
||||
}
|
||||
|
||||
EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving)entity : null;
|
||||
entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, world.rand.nextFloat() * 360.0F, 0.0F);
|
||||
|
||||
if (entityliving == null || net.minecraftforge.event.ForgeEventFactory.canEntitySpawnSpawner(entityliving, logic.getSpawnerWorld(), (float)entity.posX, (float)entity.posY, (float)entity.posZ))
|
||||
{
|
||||
if (randomEntity.getNbt().getSize() == 1 && randomEntity.getNbt().hasKey("id", 8) && entity instanceof EntityLiving)
|
||||
{
|
||||
if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(entityliving, logic.getSpawnerWorld(), (float)entity.posX, (float)entity.posY, (float)entity.posZ))
|
||||
((EntityLiving)entity).onInitialSpawn(world.getDifficultyForLocation(new BlockPos(entity)), null);
|
||||
}
|
||||
|
||||
AnvilChunkLoader.spawnEntity(entity, world);
|
||||
world.playEvent(2004, blockpos, 0);
|
||||
|
||||
if (entityliving != null)
|
||||
{
|
||||
entityliving.spawnExplosionParticle();
|
||||
}
|
||||
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag)
|
||||
resetTimer(logic);
|
||||
if(logic.getSpawnerWorld().isRemote) {
|
||||
if(logic.spawnDelay > 0) {
|
||||
--logic.spawnDelay;
|
||||
}
|
||||
|
||||
if(Math.random() > 0.5)
|
||||
Botania.proxy.wispFX(getPos().getX() + 0.3 + Math.random() * 0.5, getPos().getY() - 0.3 + Math.random() * 0.25, getPos().getZ() + Math.random(), 0.6F - (float) Math.random() * 0.3F, 0.1F, 0.6F - (float) Math.random() * 0.3F, (float) Math.random() / 3F, -0.025F - 0.005F * (float) Math.random(), 2F);
|
||||
|
||||
logic.prevMobRotation = logic.mobRotation;
|
||||
logic.mobRotation = (logic.mobRotation + (double) (1000.0F / ((float) logic.spawnDelay + 200.0F))) % 360.0D;
|
||||
} else {
|
||||
if(logic.spawnDelay == -1) {
|
||||
logic.resetTimer();
|
||||
}
|
||||
|
||||
if(logic.spawnDelay > 0) {
|
||||
--logic.spawnDelay;
|
||||
return;
|
||||
}
|
||||
|
||||
boolean flag = false;
|
||||
|
||||
for(int i = 0; i < logic.spawnCount; ++i) {
|
||||
NBTTagCompound nbttagcompound = logic.spawnData.getNbt();
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("Pos", 6);
|
||||
World world = logic.getSpawnerWorld();
|
||||
int j = nbttaglist.tagCount();
|
||||
double d0 = j >= 1 ? nbttaglist.getDoubleAt(0) : (double) blockpos.getX() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double) logic.spawnRange + 0.5D;
|
||||
double d1 = j >= 2 ? nbttaglist.getDoubleAt(1) : (double) (blockpos.getY() + world.rand.nextInt(3) - 1);
|
||||
double d2 = j >= 3 ? nbttaglist.getDoubleAt(2) : (double) blockpos.getZ() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double) logic.spawnRange + 0.5D;
|
||||
Entity entity = AnvilChunkLoader.readWorldEntityPos(nbttagcompound, world, d0, d1, d2, false);
|
||||
|
||||
if(entity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int k = world.getEntitiesWithinAABB(entity.getClass(), (new AxisAlignedBB((double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ(), (double) (blockpos.getX() + 1), (double) (blockpos.getY() + 1), (double) (blockpos.getZ() + 1))).grow((double) logic.spawnRange)).size();
|
||||
|
||||
if(k >= logic.maxNearbyEntities) {
|
||||
logic.resetTimer();
|
||||
return;
|
||||
}
|
||||
|
||||
EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving) entity : null;
|
||||
entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, world.rand.nextFloat() * 360.0F, 0.0F);
|
||||
|
||||
if(entityliving == null || net.minecraftforge.event.ForgeEventFactory.canEntitySpawnSpawner(entityliving, world, (float) entity.posX, (float) entity.posY, (float) entity.posZ)) {
|
||||
if(logic.spawnData.getNbt().getSize() == 1 && logic.spawnData.getNbt().hasKey("id", 8) && entity instanceof EntityLiving) {
|
||||
if(!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(entityliving, logic.getSpawnerWorld(), (float) entity.posX, (float) entity.posY, (float) entity.posZ))
|
||||
((EntityLiving) entity).onInitialSpawn(world.getDifficultyForLocation(new BlockPos(entity)), (IEntityLivingData) null);
|
||||
}
|
||||
|
||||
AnvilChunkLoader.spawnEntity(entity, world);
|
||||
world.playEvent(2004, blockpos, 0);
|
||||
|
||||
if(entityliving != null) {
|
||||
entityliving.spawnExplosionParticle();
|
||||
}
|
||||
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(flag) {
|
||||
logic.resetTimer();
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Direct copy of MobSpawnerBaseLogic.resetTimer()
|
||||
private void resetTimer(MobSpawnerBaseLogic logic) throws Throwable {
|
||||
int maxSpawnDelay = (int) MethodHandles.maxSpawnDelay_getter.invokeExact(logic);
|
||||
int minSpawnDelay = (int) MethodHandles.minSpawnDelay_getter.invokeExact(logic);
|
||||
List potentialEntitySpawns = (List) MethodHandles.potentialSpawns_getter.invokeExact(logic);
|
||||
|
||||
if(maxSpawnDelay <= minSpawnDelay)
|
||||
MethodHandles.spawnDelay_setter.invokeExact(logic, minSpawnDelay);
|
||||
else {
|
||||
int i = maxSpawnDelay - minSpawnDelay;
|
||||
MethodHandles.spawnDelay_setter.invokeExact(logic, minSpawnDelay + logic.getSpawnerWorld().rand.nextInt(i));
|
||||
}
|
||||
|
||||
if(potentialEntitySpawns != null && potentialEntitySpawns.size() > 0)
|
||||
logic.setNextSpawnData((WeightedSpawnerEntity)WeightedRandom.getRandomItem(logic.getSpawnerWorld().rand, potentialEntitySpawns));
|
||||
|
||||
logic.broadcastEvent(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(NBTTagCompound cmp) {
|
||||
cmp.setInteger(TAG_MANA, mana);
|
||||
|
||||
@@ -55,7 +55,6 @@ import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.core.handler.ManaNetworkHandler;
|
||||
import vazkii.botania.common.core.handler.MethodHandles;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.item.ItemManaTablet;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
@@ -167,12 +166,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
((IManaDissolvable) stack.getItem()).onDissolveTick(this, stack, item);
|
||||
}
|
||||
|
||||
int age;
|
||||
try {
|
||||
age = (int) MethodHandles.itemAge_getter.invokeExact(item);
|
||||
} catch (Throwable throwable) { return false; }
|
||||
|
||||
if(age > 100 && age < 130)
|
||||
if(item.age > 100 && item.age < 130)
|
||||
return false;
|
||||
|
||||
RecipeManaInfusion recipe = getMatchingRecipe(stack, world.getBlockState(pos.down()));
|
||||
@@ -186,9 +180,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
|
||||
ItemStack output = recipe.getOutput().copy();
|
||||
EntityItem outputItem = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, output);
|
||||
try {
|
||||
MethodHandles.itemAge_setter.invokeExact(outputItem, 105);
|
||||
} catch (Throwable ignored) {}
|
||||
outputItem.age = 105;
|
||||
world.spawnEntity(outputItem);
|
||||
|
||||
craftingFanciness();
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
package vazkii.botania.common.core.handler;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.tileentity.MobSpawnerBaseLogic;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import static java.lang.invoke.MethodHandles.publicLookup;
|
||||
|
||||
// MethodHandles for frequently reflected fields and methods.
|
||||
// Handles suffixed with _getter and _setter are for fields, while those without suffixes are normal methods.
|
||||
public final class MethodHandles {
|
||||
|
||||
public static final MethodHandle
|
||||
itemAge_getter, itemAge_setter, pickupDelay_getter, // EntityItem, pickup delay already has setter in vanilla
|
||||
spawnRange_getter, spawnCount_getter, maxNearbyEntities_getter,
|
||||
maxSpawnDelay_getter, minSpawnDelay_getter,
|
||||
spawnDelay_getter, spawnDelay_setter, prevMobRotation_setter, mobRotation_setter, potentialSpawns_getter,
|
||||
randomEntity_getter, isActivated; // MobSpawnerBaseLogic
|
||||
|
||||
|
||||
static {
|
||||
try {
|
||||
Field f = ReflectionHelper.findField(EntityItem.class, LibObfuscation.AGE);
|
||||
f.setAccessible(true);
|
||||
itemAge_getter = publicLookup().unreflectGetter(f);
|
||||
itemAge_setter = publicLookup().unreflectSetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(EntityItem.class, LibObfuscation.PICKUP_DELAY);
|
||||
f.setAccessible(true);
|
||||
pickupDelay_getter = publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(MobSpawnerBaseLogic.class, LibObfuscation.SPAWN_RANGE);
|
||||
f.setAccessible(true);
|
||||
spawnRange_getter = publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(MobSpawnerBaseLogic.class, LibObfuscation.SPAWN_COUNT);
|
||||
f.setAccessible(true);
|
||||
spawnCount_getter = publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(MobSpawnerBaseLogic.class, LibObfuscation.MAX_NEARBY_ENTITIES);
|
||||
f.setAccessible(true);
|
||||
maxNearbyEntities_getter = publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(MobSpawnerBaseLogic.class, LibObfuscation.MAX_SPAWN_DELAY);
|
||||
f.setAccessible(true);
|
||||
maxSpawnDelay_getter = publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(MobSpawnerBaseLogic.class, LibObfuscation.MIN_SPAWN_DELAY);
|
||||
f.setAccessible(true);
|
||||
minSpawnDelay_getter = publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(MobSpawnerBaseLogic.class, LibObfuscation.SPAWN_DELAY);
|
||||
f.setAccessible(true);
|
||||
spawnDelay_getter = publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(MobSpawnerBaseLogic.class, LibObfuscation.SPAWN_DELAY);
|
||||
f.setAccessible(true);
|
||||
spawnDelay_setter = publicLookup().unreflectSetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(MobSpawnerBaseLogic.class, LibObfuscation.PREV_MOB_ROTATION);
|
||||
f.setAccessible(true);
|
||||
prevMobRotation_setter = publicLookup().unreflectSetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(MobSpawnerBaseLogic.class, LibObfuscation.MOB_ROTATION);
|
||||
f.setAccessible(true);
|
||||
mobRotation_setter = publicLookup().unreflectSetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(MobSpawnerBaseLogic.class, LibObfuscation.POTENTIAL_ENTITY_SPAWNS);
|
||||
f.setAccessible(true);
|
||||
potentialSpawns_getter = publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(MobSpawnerBaseLogic.class, LibObfuscation.RANDOM_ENTITY);
|
||||
f.setAccessible(true);
|
||||
randomEntity_getter = publicLookup().unreflectGetter(f);
|
||||
|
||||
Method m = ReflectionHelper.findMethod(MobSpawnerBaseLogic.class, null, LibObfuscation.IS_ACTIVATED);
|
||||
m.setAccessible(true);
|
||||
isActivated = publicLookup().unreflect(m);
|
||||
} catch (Throwable t) {
|
||||
Botania.LOGGER.fatal("Couldn't initialize methodhandles! Things will be broken!");
|
||||
t.printStackTrace();
|
||||
throw Throwables.propagate(t);
|
||||
}
|
||||
}
|
||||
|
||||
private MethodHandles() {}
|
||||
}
|
||||
@@ -50,8 +50,8 @@ public class EntityMagicMissile extends EntityThrowable {
|
||||
}
|
||||
|
||||
public EntityMagicMissile(EntityLivingBase thrower, boolean evil) {
|
||||
this(thrower.world);
|
||||
ReflectionHelper.setPrivateValue(EntityThrowable.class, this, thrower, LibObfuscation.THROWER);
|
||||
super(thrower.world, thrower);
|
||||
setSize(0F, 0F);
|
||||
setEvil(evil);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.common.core.handler.MethodHandles;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -34,13 +33,7 @@ public class EntityThrownItem extends EntityItem {
|
||||
public EntityThrownItem(World world, double x,
|
||||
double y, double z, EntityItem item) {
|
||||
super(world, x, y, z, item.getItem());
|
||||
|
||||
int pickupDelay = 0;
|
||||
try {
|
||||
pickupDelay = (int) MethodHandles.pickupDelay_getter.invokeExact(item);
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
setPickupDelay(pickupDelay);
|
||||
setPickupDelay(item.delayBeforeCanPickup);
|
||||
motionX = item.motionX;
|
||||
motionY = item.motionY;
|
||||
motionZ = item.motionZ;
|
||||
@@ -67,14 +60,7 @@ public class EntityThrownItem extends EntityItem {
|
||||
double d0 = 0.0D;
|
||||
|
||||
for (Entity entity1 : list) {
|
||||
int pickupDelay;
|
||||
try {
|
||||
pickupDelay = (int) MethodHandles.pickupDelay_getter.invokeExact(this);
|
||||
} catch (Throwable ignored) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entity1.canBeCollidedWith() && (!(entity1 instanceof EntityPlayer) || pickupDelay == 0)) {
|
||||
if (entity1.canBeCollidedWith() && (!(entity1 instanceof EntityPlayer) || delayBeforeCanPickup == 0)) {
|
||||
float f = 1.0F;
|
||||
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand(f, f, f);
|
||||
RayTraceResult RayTraceResult1 = axisalignedbb.calculateIntercept(vec3, vec31);
|
||||
|
||||
@@ -50,7 +50,6 @@ import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.client.core.handler.ClientMethodHandles;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.gui.crafting.InventoryCraftingHalo;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
@@ -411,16 +410,9 @@ public class ItemCraftingHalo extends ItemMod {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
Tessellator tess = Tessellator.getInstance();
|
||||
|
||||
double renderPosX, renderPosY, renderPosZ;
|
||||
|
||||
try {
|
||||
renderPosX = (double) ClientMethodHandles.renderPosX_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosY = (double) ClientMethodHandles.renderPosY_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosZ = (double) ClientMethodHandles.renderPosZ_getter.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return;
|
||||
}
|
||||
double renderPosX = mc.getRenderManager().renderPosX;
|
||||
double renderPosY = mc.getRenderManager().renderPosY;
|
||||
double renderPosZ = mc.getRenderManager().renderPosZ;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
|
||||
@@ -95,7 +95,7 @@ public class ItemVirus extends ItemMod {
|
||||
IAttributeInstance health = attributes.getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH);
|
||||
health.applyModifier(new AttributeModifier("Ermergerd Virus D:", health.getBaseValue(), 0));
|
||||
|
||||
IAttributeInstance jumpHeight = attributes.getAttributeInstance(ReflectionHelper.getPrivateValue(AbstractHorse.class, null, LibObfuscation.HORSE_JUMP_STRENGTH));
|
||||
IAttributeInstance jumpHeight = attributes.getAttributeInstance(AbstractHorse.JUMP_STRENGTH);
|
||||
jumpHeight.applyModifier(new AttributeModifier("Ermergerd Virus D:", jumpHeight.getBaseValue() * 0.5, 0));
|
||||
|
||||
newHorse.playSound(SoundEvents.ENTITY_ZOMBIE_VILLAGER_CURE, 1.0F + living.world.rand.nextFloat(), living.world.rand.nextFloat() * 0.7F + 1.3F);
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem, IBauble
|
||||
if(mobs.size() > 1) {
|
||||
if(SubTileHeiseiDream.brainwashEntity((EntityLiving) event.getEntityLiving(), (List<IMob>) mobs)) {
|
||||
if(event.getEntityLiving() instanceof EntityCreeper)
|
||||
ReflectionHelper.setPrivateValue(EntityCreeper.class, (EntityCreeper) event.getEntityLiving(), 2, LibObfuscation.TIME_SINCE_IGNITED);
|
||||
((EntityCreeper) event.getEntityLiving()).timeSinceIgnited = 2;
|
||||
event.getEntityLiving().heal(event.getEntityLiving().getMaxHealth());
|
||||
if(event.getEntityLiving().isDead)
|
||||
event.getEntityLiving().isDead = false;
|
||||
|
||||
+4
-10
@@ -21,14 +21,12 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import vazkii.botania.api.item.IBaubleRender;
|
||||
import vazkii.botania.client.core.handler.MiscellaneousIcons;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
public class ItemSuperLavaPendant extends ItemBauble implements IBaubleRender {
|
||||
|
||||
@@ -37,17 +35,13 @@ public class ItemSuperLavaPendant extends ItemBauble implements IBaubleRender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack stack, EntityLivingBase player) {
|
||||
setImmunity(player, true);
|
||||
public void onWornTick(ItemStack stack, EntityLivingBase living) {
|
||||
living.isImmuneToFire = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnequipped(ItemStack stack, EntityLivingBase player) {
|
||||
setImmunity(player, false);
|
||||
}
|
||||
|
||||
private void setImmunity(Entity entity, boolean immune) {
|
||||
ReflectionHelper.setPrivateValue(Entity.class, entity, immune, LibObfuscation.IS_IMMUNE_TO_FIRE);
|
||||
public void onUnequipped(ItemStack stack, EntityLivingBase living) {
|
||||
living.isImmuneToFire = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.item.ItemTossEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import vazkii.botania.api.item.IWireframeCoordinateListProvider;
|
||||
import vazkii.botania.common.core.handler.MethodHandles;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
@@ -56,17 +55,8 @@ public class ItemAesirRing extends ItemRelicBauble implements IWireframeCoordina
|
||||
entity.motionX = event.getEntityItem().motionX;
|
||||
entity.motionY = event.getEntityItem().motionY;
|
||||
entity.motionZ = event.getEntityItem().motionZ;
|
||||
|
||||
try {
|
||||
MethodHandles.itemAge_setter.invokeExact(entity, MethodHandles.itemAge_getter.invokeExact(entity));
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
int pickupDelay = 0;
|
||||
try {
|
||||
pickupDelay = (int) MethodHandles.pickupDelay_getter.invokeExact(event.getEntityItem());
|
||||
} catch (Throwable ignored) {}
|
||||
entity.setPickupDelay(pickupDelay);
|
||||
|
||||
entity.age = event.getEntityItem().age;
|
||||
entity.setPickupDelay(event.getEntityItem().delayBeforeCanPickup);
|
||||
entity.world.spawnEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ItemInfiniteFruit extends ItemRelic implements IManaUsingItem {
|
||||
|
||||
if(count == 5)
|
||||
if(player.canEat(false))
|
||||
ReflectionHelper.setPrivateValue(EntityLivingBase.class, player, 20, LibObfuscation.ITEM_IN_USE_COUNT);
|
||||
player.activeItemStackUseCount = 20;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,74 +11,6 @@
|
||||
package vazkii.botania.common.lib;
|
||||
|
||||
public final class LibObfuscation {
|
||||
|
||||
// RenderManager
|
||||
public static final String[] RENDERPOSX = { "renderPosX", "field_78725_b", "o" };
|
||||
public static final String[] RENDERPOSY = { "renderPosY", "field_78726_c", "p" };
|
||||
public static final String[] RENDERPOSZ = { "renderPosZ", "field_78723_d", "q" };
|
||||
|
||||
// EntityItem
|
||||
public static final String[] AGE = { "age", "field_70292_b", "d" };
|
||||
public static final String[] PICKUP_DELAY = { "delayBeforeCanPickup", "field_145804_b", "e" };
|
||||
|
||||
// EntityAINearestAttackableTarget
|
||||
public static final String[] TARGET_CLASS = { "targetClass", "field_75307_b", "a" };
|
||||
public static final String[] TARGET_ENTITY_SELECTOR = { "targetEntitySelector", "field_82643_g", "c" };
|
||||
|
||||
// EntityAIAvoidEntity
|
||||
public static final String[] TARGET_ENTITY_CLASS = { "classToAvoid", "field_181064_i", "i" };
|
||||
|
||||
// EntityCreeper
|
||||
public static final String[] TIME_SINCE_IGNITED = { "timeSinceIgnited", "field_70833_d", "bw" };
|
||||
|
||||
// Entity
|
||||
public static final String[] IS_IMMUNE_TO_FIRE = { "isImmuneToFire", "field_70178_ae", "Y" };
|
||||
|
||||
// ItemBlockSpecial
|
||||
public static final String[] REED_ITEM = { "block", "field_150935_a", "a" };
|
||||
|
||||
// EntityAnimal
|
||||
public static final String[] IN_LOVE = { "inLove", "field_70881_d", "bv" };
|
||||
|
||||
// EntityLivingBase
|
||||
public static final String[] ITEM_IN_USE_COUNT = { "activeItemStackUseCount", "field_184628_bn", "bn" };
|
||||
|
||||
// AbstractHorse
|
||||
public static final String[] HORSE_JUMP_STRENGTH = { "JUMP_STRENGTH", "field_110271_bv", "bw" };
|
||||
|
||||
// PlayerControllerMP
|
||||
public static final String[] NET_CLIENT_HANDLER = { "connection", "field_78774_b", "b" };
|
||||
|
||||
// MobSpawnerBaseLogic
|
||||
public static final String[] IS_ACTIVATED = { "isActivated" ,"func_98279_f", "h" };
|
||||
public static final String[] SPAWN_RANGE = { "spawnRange", "field_98290_m", "l" };
|
||||
public static final String[] SPAWN_COUNT = { "spawnCount", "field_98294_i", "h" };
|
||||
public static final String[] MAX_NEARBY_ENTITIES = { "maxNearbyEntities", "field_98292_k", "j" };
|
||||
public static final String[] MAX_SPAWN_DELAY = { "maxSpawnDelay", "field_98293_h", "g" };
|
||||
public static final String[] MIN_SPAWN_DELAY = { "minSpawnDelay", "field_98283_g", "f" };
|
||||
public static final String[] POTENTIAL_ENTITY_SPAWNS = { "potentialSpawns", "field_98285_e", "b" };
|
||||
public static final String[] SPAWN_DELAY = { "spawnDelay", "field_98286_b", "a" };
|
||||
public static final String[] PREV_MOB_ROTATION = { "prevMobRotation", "field_98284_d", "e" };
|
||||
public static final String[] MOB_ROTATION = { "mobRotation", "field_98287_c", "d" };
|
||||
public static final String[] RANDOM_ENTITY = { "randomEntity", "field_98282_f", "c" };
|
||||
|
||||
// GuiIngame
|
||||
public static final String[] REMAINING_HIGHLIGHT_TICKS = { "remainingHighlightTicks", "field_92017_k", "q" };
|
||||
|
||||
// EntityThrowable
|
||||
public static final String[] THROWER = { "thrower", "field_70192_c", "h" };
|
||||
|
||||
// GuiChat
|
||||
public static final String[] INPUT_FIELD = { "inputField", "field_146415_a", "a" };
|
||||
// todo 1.9+ public static final String[] COMPLETE_FLAG = { "waitingOnAutocomplete", "field_146414_r", "r" };
|
||||
|
||||
// Entityliving
|
||||
public static final String[] GET_LIVING_SOUND = { "getAmbientSound", "func_184639_G", "G" };
|
||||
|
||||
// RenderGlobal
|
||||
public static final String[] STAR_GL_CALL_LIST = { "starGLCallList", "field_72772_v", "p" };
|
||||
public static final String[] STAR_VBO = { "starVBO", "field_175013_s", "t" };
|
||||
public static final String[] GL_SKY_LIST = { "glSkyList", "field_72771_w", "q" };
|
||||
public static final String[] SKY_VBO = { "skyVBO", "field_175012_t", "u" };
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user