mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 03:15:07 +00:00
Change a bunch of heavy reflection to use methodhandles
This commit is contained in:
1 parent
b6427bcae9
commit
7967f25c1c
25 files changed
+252
-107
No files matched your search
@@ -36,6 +36,7 @@ import vazkii.botania.api.item.IWireframeCoordinateListProvider;
|
||||
import vazkii.botania.api.wand.ICoordBoundItem;
|
||||
import vazkii.botania.api.wand.IWireframeAABBProvider;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import vazkii.botania.common.core.handler.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
public final class BoundTileRenderer {
|
||||
@@ -98,21 +99,19 @@ public final class BoundTileRenderer {
|
||||
renderBlockOutlineAt(pos, color, 1F);
|
||||
}
|
||||
|
||||
private double getRenderPosX() { // todo 1.8
|
||||
return ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, Minecraft.getMinecraft().getRenderManager(), LibObfuscation.RENDERPOSX);
|
||||
}
|
||||
|
||||
private double getRenderPosY() {
|
||||
return ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, Minecraft.getMinecraft().getRenderManager(), LibObfuscation.RENDERPOSY);
|
||||
}
|
||||
|
||||
private double getRenderPosZ() {
|
||||
return ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, Minecraft.getMinecraft().getRenderManager(), LibObfuscation.RENDERPOSZ);
|
||||
}
|
||||
|
||||
private void renderBlockOutlineAt(BlockPos pos, int color, float thickness) {
|
||||
double renderPosX, renderPosY, renderPosZ;
|
||||
|
||||
try {
|
||||
renderPosX = (double) BotaniaMethodHandles.GETRENDERPOSX.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosY = (double) BotaniaMethodHandles.GETRENDERPOSY.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosZ = (double) BotaniaMethodHandles.GETRENDERPOSZ.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
} catch (Throwable t) {
|
||||
return;
|
||||
}
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(pos.getX() - getRenderPosX(), pos.getY() - getRenderPosY(), pos.getZ() - getRenderPosZ() + 1);
|
||||
GlStateManager.translate(pos.getX() - renderPosX, pos.getY() - renderPosY, pos.getZ() - renderPosZ + 1);
|
||||
Color colorRGB = new Color(color);
|
||||
GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 255);
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import vazkii.botania.api.lexicon.multiblock.MultiblockSet;
|
||||
import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.handler.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
public final class MultiblockRenderHandler {
|
||||
@@ -140,26 +141,24 @@ public final class MultiblockRenderHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private double getRenderPosX() { // todo 1.8
|
||||
return ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, Minecraft.getMinecraft().getRenderManager(), LibObfuscation.RENDERPOSX);
|
||||
}
|
||||
|
||||
private double getRenderPosY() {
|
||||
return ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, Minecraft.getMinecraft().getRenderManager(), LibObfuscation.RENDERPOSY);
|
||||
}
|
||||
|
||||
private double getRenderPosZ() {
|
||||
return ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, Minecraft.getMinecraft().getRenderManager(), LibObfuscation.RENDERPOSZ);
|
||||
}
|
||||
|
||||
private boolean renderComponentInWorld(World world, Multiblock mb, MultiblockComponent comp, BlockPos anchorPos) {
|
||||
double renderPosX, renderPosY, renderPosZ;
|
||||
|
||||
try {
|
||||
renderPosX = (double) BotaniaMethodHandles.GETRENDERPOSX.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosY = (double) BotaniaMethodHandles.GETRENDERPOSY.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosZ = (double) BotaniaMethodHandles.GETRENDERPOSZ.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
} catch (Throwable t) {
|
||||
return true;
|
||||
}
|
||||
|
||||
BlockPos pos = comp.getRelativePosition();
|
||||
BlockPos pos_ = pos.add(anchorPos);
|
||||
if(anchor != null && comp.matches(world, pos_))
|
||||
return false;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(-getRenderPosX(), -getRenderPosY(), -getRenderPosZ());
|
||||
GlStateManager.translate(-renderPosX, -renderPosY, -renderPosZ);
|
||||
GlStateManager.disableDepth();
|
||||
doRenderComponent(mb, comp, pos_, 0.4F);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
@@ -27,6 +27,7 @@ import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.common.block.tile.string.TileRedString;
|
||||
import vazkii.botania.common.core.handler.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
@@ -68,25 +69,23 @@ public final class RedStringRenderer {
|
||||
sizeAlpha += 0.1F;
|
||||
}
|
||||
|
||||
private static double getRenderPosX() { // todo 1.8
|
||||
return ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, Minecraft.getMinecraft().getRenderManager(), LibObfuscation.RENDERPOSX);
|
||||
}
|
||||
|
||||
private static double getRenderPosY() {
|
||||
return ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, Minecraft.getMinecraft().getRenderManager(), LibObfuscation.RENDERPOSY);
|
||||
}
|
||||
|
||||
private static double getRenderPosZ() {
|
||||
return ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, Minecraft.getMinecraft().getRenderManager(), LibObfuscation.RENDERPOSZ);
|
||||
}
|
||||
|
||||
private static void renderTile(TileRedString tile) {
|
||||
double renderPosX, renderPosY, renderPosZ;
|
||||
|
||||
try {
|
||||
renderPosX = (double) BotaniaMethodHandles.GETRENDERPOSX.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosY = (double) BotaniaMethodHandles.GETRENDERPOSY.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosZ = (double) BotaniaMethodHandles.GETRENDERPOSZ.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
} catch (Throwable t) {
|
||||
return;
|
||||
}
|
||||
|
||||
EnumFacing dir = tile.getOrientation();
|
||||
BlockPos bind = tile.getBinding();
|
||||
|
||||
if(bind != null) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(tile.getPos().getX() + 0.5 - getRenderPosX(), tile.getPos().getY() + 0.5 - getRenderPosY(), tile.getPos().getZ() + 0.5 - getRenderPosZ());
|
||||
GlStateManager.translate(tile.getPos().getX() + 0.5 - renderPosX, tile.getPos().getY() + 0.5 - renderPosY, tile.getPos().getZ() + 0.5 - renderPosZ);
|
||||
Vector3 vecOrig = new Vector3(bind.getX() - tile.getPos().getX(), bind.getY() - tile.getPos().getY(), bind.getZ() - tile.getPos().getZ());
|
||||
Vector3 vecNorm = vecOrig.copy().normalize();
|
||||
Vector3 vecMag = vecNorm.copy().multiply(0.025);
|
||||
|
||||
@@ -31,6 +31,7 @@ import vazkii.botania.api.subtile.ISubTileContainer;
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.SubTileEntity;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.handler.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.item.ItemTwigWand;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
@@ -84,21 +85,19 @@ public final class SubTileRadiusRenderHandler {
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
private double getRenderPosX() { // todo 1.8
|
||||
return ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, Minecraft.getMinecraft().getRenderManager(), LibObfuscation.RENDERPOSX);
|
||||
}
|
||||
|
||||
private double getRenderPosY() {
|
||||
return ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, Minecraft.getMinecraft().getRenderManager(), LibObfuscation.RENDERPOSY);
|
||||
}
|
||||
|
||||
private double getRenderPosZ() {
|
||||
return ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, Minecraft.getMinecraft().getRenderManager(), LibObfuscation.RENDERPOSZ);
|
||||
}
|
||||
|
||||
public void renderRectangle(AxisAlignedBB aabb) {
|
||||
double renderPosX, renderPosY, renderPosZ;
|
||||
|
||||
try {
|
||||
renderPosX = (double) BotaniaMethodHandles.GETRENDERPOSX.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosY = (double) BotaniaMethodHandles.GETRENDERPOSY.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosZ = (double) BotaniaMethodHandles.GETRENDERPOSZ.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
} catch (Throwable t) {
|
||||
return;
|
||||
}
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(aabb.minX - getRenderPosX(), aabb.minY - getRenderPosY(), aabb.minZ - getRenderPosZ());
|
||||
GlStateManager.translate(aabb.minX - renderPosX, aabb.minY - renderPosY, aabb.minZ - renderPosZ);
|
||||
int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F);
|
||||
|
||||
Color colorRGB = new Color(color);
|
||||
@@ -132,11 +131,21 @@ public final class SubTileRadiusRenderHandler {
|
||||
}
|
||||
|
||||
public void renderCircle(BlockPos center, double radius) {
|
||||
double renderPosX, renderPosY, renderPosZ;
|
||||
|
||||
try {
|
||||
renderPosX = (double) BotaniaMethodHandles.GETRENDERPOSX.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosY = (double) BotaniaMethodHandles.GETRENDERPOSY.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosZ = (double) BotaniaMethodHandles.GETRENDERPOSZ.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
} catch (Throwable t) {
|
||||
return;
|
||||
}
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
double x = center.getX() + 0.5;
|
||||
double y = center.getY();
|
||||
double z = center.getZ() + 0.5;
|
||||
GlStateManager.translate(x - getRenderPosX(), y - getRenderPosY(), z - getRenderPosZ());
|
||||
GlStateManager.translate(x - renderPosX, y - renderPosY, z - renderPosZ);
|
||||
int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F);
|
||||
|
||||
Color colorRGB = new Color(color);
|
||||
|
||||
@@ -48,6 +48,7 @@ import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.client.model.ModelCrystalCube;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaCrystalCube;
|
||||
import vazkii.botania.common.core.handler.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -65,7 +66,10 @@ public class RenderTileCorporeaCrystalCube extends TileEntitySpecialRenderer<Til
|
||||
if(entity == null)
|
||||
entity = new EntityItem(cube.getWorld(), cube.getPos().getX(), cube.getPos().getY(), cube.getPos().getZ(), new ItemStack(Blocks.stone));
|
||||
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, entity, ClientTickHandler.ticksInGame, LibObfuscation.AGE);
|
||||
try {
|
||||
BotaniaMethodHandles.SETITEMAGE.invokeExact(entity, ClientTickHandler.ticksInGame);
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
stack = cube.getRequestTarget();
|
||||
entity.setEntityItemStack(stack);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.handler.MiscellaneousIcons;
|
||||
import vazkii.botania.client.core.helper.ShaderHelper;
|
||||
import vazkii.botania.common.block.tile.TileEnchanter;
|
||||
import vazkii.botania.common.core.handler.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
public class RenderTileEnchanter extends TileEntitySpecialRenderer<TileEnchanter> {
|
||||
@@ -49,7 +50,10 @@ 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);
|
||||
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, item, ClientTickHandler.ticksInGame, LibObfuscation.AGE);
|
||||
try {
|
||||
BotaniaMethodHandles.SETITEMAGE.invokeExact(item, ClientTickHandler.ticksInGame);
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
item.setEntityItemStack(enchanter.itemToEnchant);
|
||||
|
||||
GlStateManager.color(1F, 1F, 1F, 1F);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class BlockTerraPlate extends BlockModContainer implements ILexiconable {
|
||||
ItemStack target = stack.copy();
|
||||
target.stackSize = 1;
|
||||
EntityItem item = new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, target);
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, item, 40, LibObfuscation.PICKUP_DELAY);
|
||||
item.setPickupDelay(40);
|
||||
item.motionX = item.motionY = item.motionZ = 0;
|
||||
if(!worldObj.isRemote)
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
|
||||
@@ -23,6 +23,7 @@ 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.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
@@ -52,12 +53,20 @@ public class SubTileDaffomill extends SubTileFunctional {
|
||||
if(axis != null) {
|
||||
List<EntityItem> items = supertile.getWorld().getEntitiesWithinAABB(EntityItem.class, axis);
|
||||
int slowdown = getSlowdownFactor();
|
||||
for(EntityItem item : items)
|
||||
if(!item.isDead && ((Integer) ObfuscationReflectionHelper.getPrivateValue(EntityItem.class, item, LibObfuscation.AGE)) >= slowdown) {
|
||||
for(EntityItem item : items) {
|
||||
int age;
|
||||
try {
|
||||
age = (int) BotaniaMethodHandles.GETITEMAGE.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!item.isDead && age >= slowdown) {
|
||||
item.motionX += orientation.getFrontOffsetX() * 0.05;
|
||||
item.motionY += orientation.getFrontOffsetY() * 0.05;
|
||||
item.motionZ += orientation.getFrontOffsetZ() * 0.05;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
windTicks--;
|
||||
|
||||
@@ -40,6 +40,7 @@ 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.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.core.helper.InventoryHelper;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
@@ -74,7 +75,13 @@ public class SubTileHopperhock extends SubTileFunctional {
|
||||
int slowdown = getSlowdownFactor();
|
||||
|
||||
for(EntityItem item : items) {
|
||||
int age = ObfuscationReflectionHelper.getPrivateValue(EntityItem.class, item, LibObfuscation.AGE);
|
||||
int age;
|
||||
try {
|
||||
age = (int) BotaniaMethodHandles.GETITEMAGE.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(age < (60 + slowdown) || age >= 105 && age < 110 || item.isDead)
|
||||
continue;
|
||||
|
||||
|
||||
+9
-1
@@ -20,6 +20,7 @@ import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.SubTileFunctional;
|
||||
import vazkii.botania.common.core.handler.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
@@ -46,7 +47,14 @@ public class SubTilePollidisiac extends SubTileFunctional {
|
||||
int love = ReflectionHelper.getPrivateValue(EntityAnimal.class, animal, LibObfuscation.IN_LOVE);
|
||||
if(animal.getGrowingAge() == 0 && love <= 0) {
|
||||
for(EntityItem item : items) {
|
||||
if(((Integer) ObfuscationReflectionHelper.getPrivateValue(EntityItem.class, item, LibObfuscation.AGE)) < (60 + slowdown) || item.isDead)
|
||||
int age;
|
||||
try {
|
||||
age = (int) BotaniaMethodHandles.GETITEMAGE.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(age < (60 + slowdown) || item.isDead)
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getEntityItem();
|
||||
|
||||
+9
-1
@@ -41,6 +41,7 @@ import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.SubTileEntity;
|
||||
import vazkii.botania.api.subtile.SubTileFunctional;
|
||||
import vazkii.botania.api.item.IFloatingFlower;
|
||||
import vazkii.botania.common.core.handler.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
@@ -80,7 +81,14 @@ 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) {
|
||||
if(((Integer) ObfuscationReflectionHelper.getPrivateValue(EntityItem.class, item, LibObfuscation.AGE)) < (60 + slowdown) || item.isDead)
|
||||
int age;
|
||||
try {
|
||||
age = (int) BotaniaMethodHandles.GETITEMAGE.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(age < (60 + slowdown) || item.isDead)
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getEntityItem();
|
||||
|
||||
+9
-1
@@ -24,6 +24,7 @@ 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.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.core.helper.MathHelper;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -57,7 +58,14 @@ public class SubTileSpectranthemum extends SubTileFunctional {
|
||||
int slowdown = getSlowdownFactor();
|
||||
|
||||
for(EntityItem item : items) {
|
||||
if(((Integer) ObfuscationReflectionHelper.getPrivateValue(EntityItem.class, item, LibObfuscation.AGE)) < (60 + slowdown) || item.isDead || item.getEntityData().getBoolean(TAG_TELEPORTED))
|
||||
int age;
|
||||
try {
|
||||
age = (int) BotaniaMethodHandles.GETITEMAGE.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(age < (60 + slowdown) || item.isDead || item.getEntityData().getBoolean(TAG_TELEPORTED))
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getEntityItem();
|
||||
|
||||
@@ -24,6 +24,7 @@ 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.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
@@ -46,9 +47,16 @@ public class SubTileEndoflame extends SubTileGenerating {
|
||||
|
||||
int slowdown = getSlowdownFactor();
|
||||
|
||||
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)));
|
||||
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) {
|
||||
if(((Integer) ObfuscationReflectionHelper.getPrivateValue(EntityItem.class, item, LibObfuscation.AGE)) >= (59 + slowdown) && !item.isDead) {
|
||||
int age;
|
||||
try {
|
||||
age = (int) BotaniaMethodHandles.GETITEMAGE.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(age >= (59 + slowdown) && !item.isDead) {
|
||||
ItemStack stack = item.getEntityItem();
|
||||
if(stack.getItem().hasContainerItem(stack))
|
||||
continue;
|
||||
|
||||
+10
-1
@@ -24,6 +24,7 @@ import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.SubTileGenerating;
|
||||
import vazkii.botania.common.core.handler.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
@@ -56,7 +57,15 @@ public class SubTileGourmaryllis extends SubTileGenerating {
|
||||
|
||||
for(EntityItem item : items) {
|
||||
ItemStack stack = item.getEntityItem();
|
||||
if(stack != null && stack.getItem() instanceof ItemFood && !item.isDead && ((Integer) ObfuscationReflectionHelper.getPrivateValue(EntityItem.class, item, LibObfuscation.AGE)) >= slowdown) {
|
||||
|
||||
int age;
|
||||
try {
|
||||
age = (int) BotaniaMethodHandles.GETITEMAGE.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(stack != null && stack.getItem() instanceof ItemFood && !item.isDead && age >= slowdown) {
|
||||
if(cooldown <= 0) {
|
||||
int val = ((ItemFood) stack.getItem()).getHealAmount(stack);
|
||||
storedMana = val * val * 64;
|
||||
|
||||
+10
-1
@@ -31,6 +31,7 @@ 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.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
@@ -54,7 +55,15 @@ public class SubTileSpectrolus extends SubTileGenerating {
|
||||
|
||||
for(EntityItem item : items) {
|
||||
ItemStack stack = item.getEntityItem();
|
||||
if(stack != null && stack.getItem() == wool && !item.isDead && ((Integer) ObfuscationReflectionHelper.getPrivateValue(EntityItem.class, item, LibObfuscation.AGE)) >= slowdown) {
|
||||
|
||||
int age;
|
||||
try {
|
||||
age = (int) BotaniaMethodHandles.GETITEMAGE.invokeExact(item);
|
||||
} catch (Throwable t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(stack != null && stack.getItem() == wool && !item.isDead && age >= slowdown) {
|
||||
int meta = stack.getItemDamage();
|
||||
if(meta == nextColor) {
|
||||
if(!remote) {
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import vazkii.botania.common.core.handler.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
@@ -71,8 +72,12 @@ public class TileOpenCrate extends TileSimpleInventory {
|
||||
item.motionY = 0;
|
||||
item.motionZ = 0;
|
||||
|
||||
if(redstone)
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, item, -200, LibObfuscation.AGE);
|
||||
if(redstone) {
|
||||
try {
|
||||
BotaniaMethodHandles.SETITEMAGE.invokeExact(item, -200);
|
||||
} catch (Throwable ignored) {}
|
||||
}
|
||||
|
||||
|
||||
setInventorySlotContents(0, null);
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class TileRuneAltar extends TileSimpleInventory implements ISidedInventor
|
||||
}
|
||||
|
||||
EntityItem item = new EntityItem(worldObj, getPos().getX() + 0.5, getPos().getY() + 1, getPos().getZ() + 0.5, new ItemStack(ModBlocks.livingrock));
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, item, 40, LibObfuscation.PICKUP_DELAY);
|
||||
item.setPickupDelay(40);
|
||||
item.motionX = item.motionY = item.motionZ = 0;
|
||||
if(!worldObj.isRemote)
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
|
||||
@@ -58,6 +58,7 @@ import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
import vazkii.botania.common.core.handler.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.core.handler.ManaNetworkHandler;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
@@ -150,7 +151,11 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
item.setDead();
|
||||
}
|
||||
|
||||
int age = ObfuscationReflectionHelper.getPrivateValue(EntityItem.class, item, LibObfuscation.AGE);
|
||||
int age;
|
||||
try {
|
||||
age = ((int) BotaniaMethodHandles.GETITEMAGE.invokeExact(item));
|
||||
} catch (Throwable throwable) { return false; }
|
||||
|
||||
if(age > 100 && age < 130 || !catalystsRegistered)
|
||||
return false;
|
||||
|
||||
@@ -167,7 +172,9 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
|
||||
ItemStack output = recipe.getOutput().copy();
|
||||
EntityItem outputItem = new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, output);
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, outputItem, 105, LibObfuscation.AGE);
|
||||
try {
|
||||
BotaniaMethodHandles.SETITEMAGE.invokeExact(outputItem, 105);
|
||||
} catch (Throwable ignored) {}
|
||||
worldObj.spawnEntityInWorld(outputItem);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package vazkii.botania.common.core.handler;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public final class BotaniaMethodHandles {
|
||||
|
||||
public static final MethodHandle
|
||||
GETRENDERPOSX, GETRENDERPOSY, GETRENDERPOSZ,
|
||||
GETITEMAGE, SETITEMAGE,
|
||||
GETPICKUPDELAY; // Already has setter in vanilla
|
||||
|
||||
static {
|
||||
try {
|
||||
Field f = ReflectionHelper.findField(RenderManager.class, LibObfuscation.RENDERPOSX);
|
||||
f.setAccessible(true);
|
||||
GETRENDERPOSX = MethodHandles.publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(RenderManager.class, LibObfuscation.RENDERPOSY);
|
||||
f.setAccessible(true);
|
||||
GETRENDERPOSY = MethodHandles.publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(RenderManager.class, LibObfuscation.RENDERPOSZ);
|
||||
f.setAccessible(true);
|
||||
GETRENDERPOSZ = MethodHandles.publicLookup().unreflectGetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(EntityItem.class, LibObfuscation.AGE);
|
||||
f.setAccessible(true);
|
||||
GETITEMAGE = MethodHandles.publicLookup().unreflectGetter(f);
|
||||
SETITEMAGE = MethodHandles.publicLookup().unreflectSetter(f);
|
||||
|
||||
f = ReflectionHelper.findField(EntityItem.class, LibObfuscation.PICKUP_DELAY);
|
||||
f.setAccessible(true);
|
||||
GETPICKUPDELAY = MethodHandles.publicLookup().unreflectGetter(f);
|
||||
} catch (Throwable t) {
|
||||
throw Throwables.propagate(t);
|
||||
}
|
||||
}
|
||||
|
||||
private BotaniaMethodHandles() {}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import vazkii.botania.common.core.handler.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
@@ -35,12 +36,12 @@ public class EntityThrownItem extends EntityItem {
|
||||
double p_i1710_4_, double p_i1710_6_, EntityItem item) {
|
||||
super(p_i1710_1_, p_i1710_2_, p_i1710_4_, p_i1710_6_, item.getEntityItem());
|
||||
|
||||
ObfuscationReflectionHelper.setPrivateValue(
|
||||
EntityItem.class,
|
||||
this,
|
||||
ObfuscationReflectionHelper.getPrivateValue(EntityItem.class, item, LibObfuscation.PICKUP_DELAY),
|
||||
LibObfuscation.PICKUP_DELAY
|
||||
);
|
||||
int pickupDelay = 0;
|
||||
try {
|
||||
pickupDelay = (int) BotaniaMethodHandles.GETPICKUPDELAY.invokeExact(item);
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
item.setPickupDelay(pickupDelay);
|
||||
motionX = item.motionX;
|
||||
motionY = item.motionY;
|
||||
motionZ = item.motionZ;
|
||||
@@ -70,7 +71,12 @@ public class EntityThrownItem extends EntityItem {
|
||||
{
|
||||
Entity entity1 = (Entity)list.get(j);
|
||||
|
||||
if (entity1.canBeCollidedWith() && (!(entity1 instanceof EntityPlayer) || ((Integer) ObfuscationReflectionHelper.getPrivateValue(EntityItem.class, this, LibObfuscation.PICKUP_DELAY)) == 0))
|
||||
int pickupDelay;
|
||||
try {
|
||||
pickupDelay = (int) BotaniaMethodHandles.GETPICKUPDELAY.invokeExact(this);
|
||||
} catch (Throwable ignored) { continue; }
|
||||
|
||||
if (entity1.canBeCollidedWith() && (!(entity1 instanceof EntityPlayer) || pickupDelay == 0))
|
||||
{
|
||||
float f = 1.0F;
|
||||
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand(f, f, f);
|
||||
|
||||
@@ -46,6 +46,7 @@ import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.achievement.ICraftAchievement;
|
||||
import vazkii.botania.common.achievement.ModAchievements;
|
||||
import vazkii.botania.common.core.handler.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.core.helper.InventoryHelper;
|
||||
import vazkii.botania.common.core.helper.InventoryHelper.GenericInventory;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
@@ -391,24 +392,22 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
|
||||
render(stack, player, event.partialTicks);
|
||||
}
|
||||
|
||||
private double getRenderPosX() { // todo 1.8
|
||||
return ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, Minecraft.getMinecraft().getRenderManager(), LibObfuscation.RENDERPOSX);
|
||||
}
|
||||
|
||||
private double getRenderPosY() {
|
||||
return ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, Minecraft.getMinecraft().getRenderManager(), LibObfuscation.RENDERPOSY);
|
||||
}
|
||||
|
||||
private double getRenderPosZ() {
|
||||
return ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, Minecraft.getMinecraft().getRenderManager(), LibObfuscation.RENDERPOSZ);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(ItemStack stack, EntityPlayer player, float partialTicks) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
Tessellator tess = Tessellator.getInstance();
|
||||
// todo 1.8.8 Tessellator.renderingWorldRenderer = false;
|
||||
|
||||
double renderPosX, renderPosY, renderPosZ;
|
||||
|
||||
try {
|
||||
renderPosX = (double) BotaniaMethodHandles.GETRENDERPOSX.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosY = (double) BotaniaMethodHandles.GETRENDERPOSY.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
renderPosZ = (double) BotaniaMethodHandles.GETRENDERPOSZ.invokeExact(Minecraft.getMinecraft().getRenderManager());
|
||||
} catch (Throwable t) {
|
||||
return;
|
||||
}
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -418,7 +417,7 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
|
||||
double posY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks;
|
||||
double posZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks;
|
||||
|
||||
GlStateManager.translate(posX - getRenderPosX(), posY - getRenderPosY() + player.getDefaultEyeHeight(), posZ - getRenderPosZ());
|
||||
GlStateManager.translate(posX - renderPosX, posY - renderPosY + player.getDefaultEyeHeight(), posZ - renderPosZ);
|
||||
|
||||
|
||||
float base = getRotationBase(stack);
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class ItemElementiumAxe extends ItemManasteelAxe {
|
||||
|
||||
private void addDrop(LivingDropsEvent event, ItemStack drop) {
|
||||
EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, drop);
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, entityitem, 10, LibObfuscation.PICKUP_DELAY);
|
||||
entityitem.setPickupDelay(10);
|
||||
event.drops.add(entityitem);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ public class ItemManasteelShears extends ItemShears implements IManaUsingItem {
|
||||
double d2 = rand.nextFloat() * f + (1D - f) * 0.5;
|
||||
|
||||
EntityItem entityitem = new EntityItem(player.worldObj, pos.getX() + d, pos.getY() + d1, pos.getZ() + d2, stack);
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, entityitem, 10, LibObfuscation.PICKUP_DELAY);
|
||||
entityitem.setPickupDelay(10);
|
||||
player.worldObj.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import vazkii.botania.api.item.IExtendedWireframeCoordinateListProvider;
|
||||
import vazkii.botania.api.item.IWireframeCoordinateListProvider;
|
||||
import vazkii.botania.common.achievement.ICraftAchievement;
|
||||
import vazkii.botania.common.achievement.ModAchievements;
|
||||
import vazkii.botania.common.core.handler.BotaniaMethodHandles;
|
||||
import vazkii.botania.common.crafting.recipe.AesirRingRecipe;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
@@ -69,18 +70,17 @@ public class ItemAesirRing extends ItemRelicBauble implements IExtendedWireframe
|
||||
entity.motionX = event.entityItem.motionX;
|
||||
entity.motionY = event.entityItem.motionY;
|
||||
entity.motionZ = event.entityItem.motionZ;
|
||||
ObfuscationReflectionHelper.setPrivateValue(
|
||||
EntityItem.class,
|
||||
entity,
|
||||
ObfuscationReflectionHelper.getPrivateValue(EntityItem.class, event.entityItem, LibObfuscation.AGE),
|
||||
LibObfuscation.AGE
|
||||
);
|
||||
ObfuscationReflectionHelper.setPrivateValue(
|
||||
EntityItem.class,
|
||||
entity,
|
||||
ObfuscationReflectionHelper.getPrivateValue(EntityItem.class, event.entityItem, LibObfuscation.PICKUP_DELAY),
|
||||
LibObfuscation.PICKUP_DELAY
|
||||
);
|
||||
|
||||
try {
|
||||
BotaniaMethodHandles.SETITEMAGE.invokeExact(entity, BotaniaMethodHandles.GETITEMAGE.invokeExact(entity));
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
int pickupDelay = 0;
|
||||
try {
|
||||
pickupDelay = (int) BotaniaMethodHandles.GETPICKUPDELAY.invokeExact(event.entityItem);
|
||||
} catch (Throwable ignored) {}
|
||||
entity.setPickupDelay(pickupDelay);
|
||||
|
||||
entity.worldObj.spawnEntityInWorld(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
|
||||
|
||||
if(ManaItemHandler.requestManaExactForTool(stack, player, COST, true)) {
|
||||
if(item instanceof EntityItem)
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, ((EntityItem) item), 5, LibObfuscation.PICKUP_DELAY);
|
||||
((EntityItem) item).setPickupDelay(5);
|
||||
|
||||
if(item instanceof EntityLivingBase) {
|
||||
EntityLivingBase targetEntity = (EntityLivingBase)item;
|
||||
@@ -224,7 +224,7 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
|
||||
ItemNBTHelper.setDouble(stack, TAG_DIST, -1);
|
||||
Vector3 moveVector = new Vector3(player.getLookVec().normalize());
|
||||
if(item instanceof EntityItem) {
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, ((EntityItem) item), 20, LibObfuscation.PICKUP_DELAY);
|
||||
((EntityItem) item).setPickupDelay(20);
|
||||
float mot = IManaProficiencyArmor.Helper.hasProficiency(player) ? 2.25F : 1.5F;
|
||||
item.motionX = moveVector.x * mot;
|
||||
item.motionY = moveVector.y;
|
||||
|
||||
Reference in new issue
Block a user