Moar cleanups!

This commit is contained in:
Vincent Lee committed 2016-04-12 01:32:49 -05:00
1 parent b3ee6dcf7a
commit 649dffcf71
20 files changed
+156 -545

No files matched your search

@@ -20,54 +20,54 @@ import java.util.UUID;
*/
public interface IManaBurst {
public boolean isFake();
boolean isFake();
public void setMotion(double x, double y, double z);
void setMotion(double x, double y, double z);
public int getColor();
int getColor();
public void setColor(int color);
void setColor(int color);
public int getMana();
int getMana();
public void setMana(int mana);
void setMana(int mana);
public int getStartingMana();
int getStartingMana();
public void setStartingMana(int mana);
void setStartingMana(int mana);
public int getMinManaLoss();
int getMinManaLoss();
public void setMinManaLoss(int minManaLoss);
void setMinManaLoss(int minManaLoss);
public float getManaLossPerTick();
float getManaLossPerTick();
public void setManaLossPerTick(float mana);
void setManaLossPerTick(float mana);
public float getGravity();
float getGravity();
public void setGravity(float gravity);
void setGravity(float gravity);
public BlockPos getBurstSourceBlockPos();
BlockPos getBurstSourceBlockPos();
public void setBurstSourceCoords(BlockPos pos);
void setBurstSourceCoords(BlockPos pos);
public ItemStack getSourceLens();
ItemStack getSourceLens();
public void setSourceLens(ItemStack lens);
void setSourceLens(ItemStack lens);
public boolean hasAlreadyCollidedAt(BlockPos pos);
boolean hasAlreadyCollidedAt(BlockPos pos);
public void setCollidedAt(BlockPos pos);
void setCollidedAt(BlockPos pos);
public int getTicksExisted();
int getTicksExisted();
public void setFake(boolean fake);
void setFake(boolean fake);
public void setShooterUUID(UUID uuid);
void setShooterUUID(UUID uuid);
public UUID getShooterUIID();
UUID getShooterUUID();
public void ping();
void ping();
}
@@ -14,6 +14,7 @@ import java.util.ArrayDeque;
import java.util.Queue;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
@@ -25,12 +26,13 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.core.helper.ObfuscationHelper;
import vazkii.botania.common.lib.LibObfuscation;
public class FXSparkle extends EntityFX {
@@ -73,7 +75,7 @@ public class FXSparkle extends EntityFX {
ParticleRenderDispatcher.fakeSparkleFxCount = 0;
GlStateManager.color(1.0F, 1.0F, 1.0F, 0.75F);
Minecraft.getMinecraft().renderEngine.bindTexture(ConfigHandler.matrixMode ? ObfuscationHelper.getParticleTexture() : particles);
Minecraft.getMinecraft().renderEngine.bindTexture(ConfigHandler.matrixMode ? ReflectionHelper.getPrivateValue(EffectRenderer.class, null, LibObfuscation.PARTICLE_TEXTURES) : particles);
tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
for(FXSparkle sparkle : queuedRenders)
@@ -14,6 +14,7 @@ import java.util.ArrayDeque;
import java.util.Queue;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
@@ -23,12 +24,13 @@ import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.core.helper.ObfuscationHelper;
import net.minecraftforge.fml.client.FMLClientHandler;
import vazkii.botania.common.lib.LibObfuscation;
public class FXWisp extends EntityFX {
@@ -81,7 +83,7 @@ public class FXWisp extends EntityFX {
ParticleRenderDispatcher.depthIgnoringWispFxCount = 0;
GlStateManager.color(1.0F, 1.0F, 1.0F, 0.75F);
Minecraft.getMinecraft().renderEngine.bindTexture(ConfigHandler.matrixMode ? ObfuscationHelper.getParticleTexture() : particles);
Minecraft.getMinecraft().renderEngine.bindTexture(ConfigHandler.matrixMode ? ReflectionHelper.getPrivateValue(EffectRenderer.class, null, LibObfuscation.PARTICLE_TEXTURES) : particles);
if(!queuedRenders.isEmpty()) {
tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
@@ -42,9 +42,8 @@ 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.InventoryHelper2;
import vazkii.botania.common.core.helper.InventoryHelper;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibMisc;
public class SubTileHopperhock extends SubTileFunctional {
@@ -94,7 +93,7 @@ public class SubTileHopperhock extends SubTileFunctional {
for(EnumFacing dir : EnumFacing.VALUES) {
BlockPos pos_ = pos.offset(dir);
InvWithLocation inv = InventoryHelper2.getInventoryWithLocation(supertile.getWorld(), pos_, dir);
InvWithLocation inv = InventoryHelper.getInventoryWithLocation(supertile.getWorld(), pos_, dir);
if(inv != null) {
List<ItemStack> filter = getFilterForInventory(pos_, true);
boolean canAccept = canAcceptItem(stack, filter, filterType);
@@ -25,8 +25,6 @@ import vazkii.botania.api.corporea.CorporeaHelper;
import vazkii.botania.api.corporea.ICorporeaRequestor;
import vazkii.botania.api.corporea.ICorporeaSpark;
import vazkii.botania.common.core.helper.InventoryHelper;
import vazkii.botania.common.core.helper.InventoryHelper2;
import vazkii.botania.common.lib.LibMisc;
public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaRequestor {
@@ -99,16 +97,16 @@ public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaReq
private IItemHandler getInv() {
TileEntity te = worldObj.getTileEntity(pos.down());
IItemHandler ret = InventoryHelper2.getInventory(worldObj, pos.down(), EnumFacing.UP);
IItemHandler ret = InventoryHelper.getInventory(worldObj, pos.down(), EnumFacing.UP);
if(ret == null)
ret = InventoryHelper2.getInventory(worldObj, pos.down(), null);
ret = InventoryHelper.getInventory(worldObj, pos.down(), null);
if(ret != null && !(te instanceof TileCorporeaFunnel))
return ret;
te = worldObj.getTileEntity(pos.down(2));
ret = InventoryHelper2.getInventory(worldObj, pos.down(2), EnumFacing.UP);
ret = InventoryHelper.getInventory(worldObj, pos.down(2), EnumFacing.UP);
if(ret == null)
ret = InventoryHelper2.getInventory(worldObj, pos.down(2), null);
ret = InventoryHelper.getInventory(worldObj, pos.down(2), null);
if(ret != null && !(te instanceof TileCorporeaFunnel))
return ret;
@@ -225,7 +225,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
IManaBurst found = null;
UUID identity = getIdentifier();
for(IManaBurst burst : ((List<IManaBurst>) bursts))
if(burst != null && identity.equals(burst.getShooterUIID())) {
if(burst != null && identity.equals(burst.getShooterUUID())) {
found = burst;
break;
}
@@ -777,7 +777,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
return identity;
}
public UUID getIdentifierUnsafe() {
private UUID getIdentifierUnsafe() {
return identity;
}
@@ -23,27 +23,6 @@ public final class CommonTickHandler {
@SubscribeEvent
public void onTick(WorldTickEvent event) {
if(event.phase == Phase.END) {
/*List<Entity> entities = new ArrayList(event.world.loadedEntityList);
for(Entity entity : entities)
if(entity instanceof EntityItem)
TerrasteelCraftingHandler.onEntityUpdate((EntityItem) entity);*/
CorporeaHelper.clearCache();
}
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onTick(ClientTickEvent event) {
if(event.phase == Phase.END) {
/*World world = Minecraft.getMinecraft().theWorld;
if(world != null) {
List<Entity> entities = new ArrayList(world.loadedEntityList);
for(Entity entity : entities)
if(entity instanceof EntityItem)
TerrasteelCraftingHandler.onEntityUpdate((EntityItem) entity);
}*/
CorporeaHelper.clearCache();
}
}
@@ -30,8 +30,8 @@ public final class ManaNetworkHandler implements IManaNetwork {
public static final ManaNetworkHandler instance = new ManaNetworkHandler();
public WeakHashMap<World, List<TileSignature>> manaPools = new WeakHashMap<>();
public WeakHashMap<World, List<TileSignature>> manaCollectors = new WeakHashMap<>();
private final WeakHashMap<World, List<TileSignature>> manaPools = new WeakHashMap<>();
private final WeakHashMap<World, List<TileSignature>> manaCollectors = new WeakHashMap<>();
@SubscribeEvent
public void onNetworkEvent(ManaNetworkEvent event) {
@@ -19,6 +19,13 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class PixieHandler {
private static final Potion[] potions = {
MobEffects.blindness,
MobEffects.wither,
MobEffects.moveSlowdown,
MobEffects.weakness
};
@SubscribeEvent
public void onDamageTaken(LivingHurtEvent event) {
if(!event.getEntityLiving().worldObj.isRemote && event.getEntityLiving() instanceof EntityPlayer && event.getSource().getEntity() != null && event.getSource().getEntity() instanceof EntityLivingBase) {
@@ -38,12 +45,6 @@ public class PixieHandler {
pixie.setPosition(player.posX, player.posY + 2, player.posZ);
if(((ItemElementiumHelm) ModItems.elementiumHelm).hasArmorSet(player)) {
Potion[] potions = {
MobEffects.blindness,
MobEffects.wither,
MobEffects.moveSlowdown,
MobEffects.weakness
};
pixie.setApplyPotionEffect(new PotionEffect(potions[event.getEntityLiving().worldObj.rand.nextInt(potions.length)], 40, 0));
}
@@ -57,7 +58,7 @@ public class PixieHandler {
}
}
float getChance(ItemStack stack) {
private float getChance(ItemStack stack) {
if(stack == null || !(stack.getItem() instanceof IPixieSpawner))
return 0F;
else return ((IPixieSpawner) stack.getItem()).getPixieChance(stack);
@@ -38,8 +38,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public final class SheddingHandler {
public static final List<ShedPattern> patterns = new ArrayList<>();
public static final List<ShedPattern> defaultPatterns = new ArrayList<>();
private static final List<ShedPattern> patterns = new ArrayList<>();
private static final List<ShedPattern> defaultPatterns = new ArrayList<>();
@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event) {
@@ -54,7 +54,7 @@ public final class SheddingHandler {
}
}
public static ShedPattern getShedPattern(Entity entity) {
private static ShedPattern getShedPattern(Entity entity) {
for(ShedPattern pattern : patterns)
if(pattern.EntityClass.isInstance(entity))
return pattern;
@@ -103,7 +103,7 @@ public final class SheddingHandler {
}
}
public static void loadFromConfig(Configuration config, String key, ShedPattern defaultPattern) {
private static void loadFromConfig(Configuration config, String key, ShedPattern defaultPattern) {
String itemName = "";
int metadata = 0;
int rate = -1;
@@ -127,7 +127,7 @@ public final class SheddingHandler {
patterns.add(new ShedPattern(EntityList.stringToClassMapping.get(key), new ItemStack(Item.itemRegistry.getObject(new ResourceLocation(itemName)), 1, metadata), rate, lexiconSize));
}
public static class ShedPattern {
private static class ShedPattern {
private final Class EntityClass;
private final ItemStack itemStack;
@@ -12,6 +12,7 @@ package vazkii.botania.common.core.helper;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -32,94 +33,18 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.ILockableContainer;
import net.minecraft.world.World;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.VanillaDoubleChestItemHandler;
import vazkii.botania.api.corporea.InvWithLocation;
//From OpenBlocksLib: https://github.com/OpenMods/OpenModsLib
public class InventoryHelper {
public static void tryInsertStack(IInventory targetInventory, int slot, ItemStack stack, boolean canMerge) {
if(targetInventory.isItemValidForSlot(slot, stack)) {
ItemStack targetStack = targetInventory.getStackInSlot(slot);
if(targetStack == null) {
int space = targetInventory.getInventoryStackLimit();
int mergeAmount = Math.min(space, stack.stackSize);
ItemStack copy = stack.copy();
copy.stackSize = mergeAmount;
targetInventory.setInventorySlotContents(slot, copy);
stack.stackSize -= mergeAmount;
} else if(canMerge) {
if(targetInventory.isItemValidForSlot(slot, stack) && areMergeCandidates(stack, targetStack)) {
int space = Math.min(targetInventory.getInventoryStackLimit(), targetStack.getMaxStackSize()) - targetStack.stackSize;
int mergeAmount = Math.min(space, stack.stackSize);
ItemStack copy = targetStack.copy();
copy.stackSize += mergeAmount;
targetInventory.setInventorySlotContents(slot, copy);
stack.stackSize -= mergeAmount;
}
}
}
}
protected static boolean areMergeCandidates(ItemStack source, ItemStack target) {
return source.isItemEqual(target) && ItemStack.areItemStackTagsEqual(source, target) && target.stackSize < target.getMaxStackSize();
}
public static void insertItemIntoInventory(IInventory inventory, ItemStack stack) {
insertItemIntoInventory(inventory, stack, null, -1);
}
public static void insertItemIntoInventory(IInventory inventory, ItemStack stack, EnumFacing side, int intoSlot) {
insertItemIntoInventory(inventory, stack, side, intoSlot, true);
}
public static void insertItemIntoInventory(IInventory inventory, ItemStack stack, EnumFacing side, int intoSlot, boolean doMove) {
insertItemIntoInventory(inventory, stack, side, intoSlot, doMove, true);
}
public static void insertItemIntoInventory(IInventory inventory, ItemStack stack, EnumFacing side, int intoSlot, boolean doMove, boolean canStack) {
if(stack == null) return;
IInventory targetInventory = inventory;
if(!doMove) {
targetInventory = new GenericInventory("temporary.inventory", false, targetInventory.getSizeInventory());
((GenericInventory)targetInventory).copyFrom(inventory);
}
int i = 0;
int[] attemptSlots;
if(inventory instanceof ISidedInventory && side != null) {
attemptSlots = ((ISidedInventory)inventory).getSlotsForFace(side);
if(attemptSlots == null)
attemptSlots = new int[0];
} else {
attemptSlots = new int[inventory.getSizeInventory()];
for(int a = 0; a < inventory.getSizeInventory(); a++)
attemptSlots[a] = a;
}
if(intoSlot > -1) {
Set<Integer> x = new HashSet<>();
for(int attemptedSlot : attemptSlots)
x.add(attemptedSlot);
if(x.contains(intoSlot))
attemptSlots = new int[] { intoSlot };
else attemptSlots = new int[0];
}
while(stack.stackSize > 0 && i < attemptSlots.length) {
if(side != null && inventory instanceof ISidedInventory)
if(!((ISidedInventory)inventory).canInsertItem(attemptSlots[i], stack, side)) {
i++;
continue;
}
tryInsertStack(targetInventory, attemptSlots[i], stack, canStack);
i++;
}
}
public static int testInventoryInsertion(IInventory inventory, ItemStack item, EnumFacing side) {
if(item == null || item.stackSize == 0)
return 0;
@@ -167,38 +92,6 @@ public class InventoryHelper {
return 0;
}
public static IInventory getInventory(World world, BlockPos pos) {
TileEntity tileEntity = world.getTileEntity(pos);
if(tileEntity instanceof TileEntityChest) {
Block chestBlock = world.getBlockState(pos).getBlock();
if(world.getBlockState(pos.west()).getBlock() == chestBlock)
return new InventoryLargeChest("Large chest", (ILockableContainer) world.getTileEntity(pos.west()), (ILockableContainer) tileEntity);
if(world.getBlockState(pos.east()).getBlock() == chestBlock)
return new InventoryLargeChest("Large chest", (ILockableContainer) tileEntity, (ILockableContainer) world.getTileEntity(pos.east()));
if(world.getBlockState(pos.north()).getBlock() == chestBlock)
return new InventoryLargeChest("Large chest", (ILockableContainer) world.getTileEntity(pos.north()), (ILockableContainer) tileEntity);
if(world.getBlockState(pos.south()).getBlock() == chestBlock)
return new InventoryLargeChest("Large chest", (ILockableContainer) tileEntity, (ILockableContainer) world.getTileEntity(pos.south()));
}
return tileEntity instanceof IInventory ? (IInventory)tileEntity : null;
}
public static IInventory getInventory(World world, BlockPos pos, EnumFacing direction) {
if(direction != null) {
pos = pos.offset(direction);
}
return getInventory(world, pos);
}
public static IInventory getInventory(IInventory inventory) {
if(inventory instanceof TileEntityChest) {
TileEntity te = (TileEntity)inventory;
return getInventory(te.getWorld(), te.getPos());
}
return inventory;
}
public static int[] buildSlotsForLinearInventory(IInventory inv) {
int[] slots = new int[inv.getSizeInventory()];
for (int i = 0; i < slots.length; i++)
@@ -207,6 +100,45 @@ public class InventoryHelper {
return slots;
}
public static InvWithLocation getInventoryWithLocation(World world, BlockPos pos, EnumFacing side) {
IItemHandler ret = getInventory(world, pos, side);
if(ret == null)
return null;
else return new InvWithLocation(ret, world, pos);
}
public static IItemHandler getInventory(World world, BlockPos pos, EnumFacing side) {
TileEntity te = world.getTileEntity(pos);
if(te == null)
return null;
IItemHandler ret = te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) ?
te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) : null;
if(te instanceof TileEntityChest)
ret = VanillaDoubleChestItemHandler.get(((TileEntityChest) te));
if(ret == null && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
ret = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
return ret;
}
public static Iterable<ItemStack> toIterable(IItemHandler itemHandler) {
return () -> new Iterator<ItemStack>() {
int index = 0;
@Override
public boolean hasNext() {
return index < itemHandler.getSlots();
}
@Override
public ItemStack next() {
return itemHandler.getStackInSlot(index++);
}
};
}
public static class GenericInventory implements IInventory {
protected String inventoryTitle;
@@ -1,72 +0,0 @@
package vazkii.botania.common.core.helper;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.inventory.InventoryLargeChest;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.ILockableContainer;
import net.minecraft.world.World;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.InvWrapper;
import vazkii.botania.api.corporea.InvWithLocation;
import java.util.Iterator;
public final class InventoryHelper2 {
public static InvWithLocation getInventoryWithLocation(World world, BlockPos pos, EnumFacing side) {
IItemHandler ret = getInventory(world, pos, side);
if(ret == null)
return null;
else return new InvWithLocation(ret, world, pos);
}
public static IItemHandler getInventory(World world, BlockPos pos, EnumFacing side) {
TileEntity te = world.getTileEntity(pos);
if(te == null)
return null;
IItemHandler ret = te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) ?
te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) : null;
if(ret == null && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
ret = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if(te instanceof TileEntityChest) {
Block chestBlock = world.getBlockState(pos).getBlock();
if(world.getBlockState(pos.west()).getBlock() == chestBlock)
ret = new InvWrapper(new InventoryLargeChest("Large chest", (ILockableContainer) world.getTileEntity(pos.west()), (ILockableContainer) te));
if(world.getBlockState(pos.east()).getBlock() == chestBlock)
ret = new InvWrapper(new InventoryLargeChest("Large chest", (ILockableContainer) te, (ILockableContainer) world.getTileEntity(pos.east())));
if(world.getBlockState(pos.north()).getBlock() == chestBlock)
ret = new InvWrapper(new InventoryLargeChest("Large chest", (ILockableContainer) world.getTileEntity(pos.north()), (ILockableContainer) te));
if(world.getBlockState(pos.south()).getBlock() == chestBlock)
ret = new InvWrapper(new InventoryLargeChest("Large chest", (ILockableContainer) te, (ILockableContainer) world.getTileEntity(pos.south())));
}
return ret;
}
public static Iterable<ItemStack> toIterable(IItemHandler itemHandler) {
return () -> new Iterator<ItemStack>() {
int index = 0;
@Override
public boolean hasNext() {
return index < itemHandler.getSlots();
}
@Override
public ItemStack next() {
return itemHandler.getStackInSlot(index++);
}
};
}
private InventoryHelper2() {}
}
@@ -1,23 +0,0 @@
/**
* 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
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Jan 17, 2014, 4:52:37 PM (GMT)]
*/
package vazkii.botania.common.core.helper;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.util.ResourceLocation;
import vazkii.botania.common.lib.LibObfuscation;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
public class ObfuscationHelper {
public static ResourceLocation getParticleTexture() {
return ReflectionHelper.getPrivateValue(EffectRenderer.class, null, LibObfuscation.PARTICLE_TEXTURES);
}
}
@@ -18,7 +18,7 @@ import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
public final class AdaptorNotifier {
boolean triedToWarnPlayer;
private boolean triedToWarnPlayer;
@SubscribeEvent
public void onTick(ClientTickEvent event) {
@@ -28,14 +28,14 @@ import net.minecraft.util.text.translation.I18n;
public class ThreadDownloadMod extends Thread {
String fileName;
private String fileName;
byte[] buffer = new byte[10240];
private byte[] buffer = new byte[10240];
int totalBytesDownloaded;
int bytesJustDownloaded;
private int totalBytesDownloaded;
private int bytesJustDownloaded;
InputStream webReader;
private InputStream webReader;
public ThreadDownloadMod(String fileName) {
setName("Botania Download File Thread");
@@ -112,7 +112,7 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
motionY = 0;
motionZ = 0;
} else if (liveTime == delay && player != null) {
Vector3 playerLook = null;
Vector3 playerLook;
RayTraceResult lookat = ToolCommons.raytraceFromEntity(worldObj, player, true, 64);
if(lookat == null)
playerLook = new Vector3(player.getLookVec()).multiply(64).add(Vector3.fromEntity(player));
@@ -17,9 +17,7 @@ import com.google.common.base.Optional;
import com.google.common.base.Predicates;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
@@ -33,7 +31,7 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import vazkii.botania.api.corporea.ICorporeaSpark;
import vazkii.botania.api.corporea.InvWithLocation;
import vazkii.botania.common.core.helper.InventoryHelper2;
import vazkii.botania.common.core.helper.InventoryHelper;
import vazkii.botania.common.item.ModItems;
public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
@@ -195,7 +193,7 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
int x = MathHelper.floor_double(posX);
int y = MathHelper.floor_double(posY - 1);
int z = MathHelper.floor_double(posZ);
return InventoryHelper2.getInventoryWithLocation(worldObj, new BlockPos(x, y, z), EnumFacing.UP);
return InventoryHelper.getInventoryWithLocation(worldObj, new BlockPos(x, y, z), EnumFacing.UP);
}
@Override
@@ -49,7 +49,6 @@ import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.pathfinding.PathNavigateGround;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntityBeacon;
import net.minecraft.util.*;
@@ -65,7 +64,6 @@ import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.fml.common.registry.GameData;
import org.lwjgl.opengl.ARBShaderObjects;
import vazkii.botania.api.boss.IBotaniaBossWithShader;
@@ -281,7 +279,7 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
return dataManager.get(INVUL_TIME);
}
public boolean isAggored() {
public boolean isAggroed() {
return dataManager.get(AGGRO);
}
@@ -337,7 +335,7 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) {
super.writeEntityToNBT(par1nbtTagCompound);
par1nbtTagCompound.setInteger(TAG_INVUL_TIME, getInvulTime());
par1nbtTagCompound.setBoolean(TAG_AGGRO, isAggored());
par1nbtTagCompound.setBoolean(TAG_AGGRO, isAggroed());
par1nbtTagCompound.setInteger(TAG_MOB_SPAWN_TICKS, getMobSpawnTicks());
BlockPos source = getSource();
@@ -376,7 +374,6 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
if(!playersWhoAttacked.contains(player.getUniqueID()))
playersWhoAttacked.add(player.getUniqueID());
float dmg = par2;
boolean crit = false;
if(e instanceof EntityPlayer) {
EntityPlayer p = (EntityPlayer) e;
@@ -384,7 +381,7 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
}
int cap = crit ? 60 : 40;
return super.attackEntityFrom(par1DamageSource, Math.min(cap, dmg) * (isHardMode() ? 0.6F : 1F));
return super.attackEntityFrom(par1DamageSource, Math.min(cap, par2) * (isHardMode() ? 0.6F : 1F));
}
return false;
}
@@ -415,7 +412,7 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
motionY = 0.5;
motionZ = -motionVector.z;
setTPDelay(4);
spawnPixies = isAggored();
spawnPixies = isAggroed();
}
setAggroed(true);
@@ -651,7 +648,7 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
}
motionY = 0;
} else {
if(isAggored()) {
if(isAggroed()) {
boolean dying = getHealth() / getMaxHealth() < 0.2;
if(dying && mobTicks > 0) {
motionX = 0;
@@ -12,8 +12,11 @@ package vazkii.botania.common.entity;
import java.awt.Color;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import com.google.common.base.Optional;
@@ -86,9 +89,9 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
private static final DataParameter<BlockPos> SOURCE_COORDS = EntityDataManager.createKey(EntityManaBurst.class, DataSerializers.BLOCK_POS);
private static final DataParameter<Optional<ItemStack>> SOURCE_LENS = EntityDataManager.createKey(EntityManaBurst.class, DataSerializers.OPTIONAL_ITEM_STACK);
float accumulatedManaLoss = 0;
boolean fake = false;
List<String> alreadyCollidedAt = new ArrayList<>();
Set<BlockPos> alreadyCollidedAt = new HashSet<>();
boolean fullManaLastTick = true;
UUID shooterIdentity = null;
int _ticksExisted = 0;
@@ -150,225 +153,12 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
setMotion(mx, my, mz);
}
float accumulatedManaLoss = 0;
private int ticksInAir;
// Hacked code copied from super.onUpdate, to use Vector3 rather than the world vector pool
public void superUpdate() {
lastTickPosX = posX;
lastTickPosY = posY;
lastTickPosZ = posZ;
onEntityUpdate();
if(throwableShake > 0)
--throwableShake;
Vec3d vec3 = new Vector3(posX, posY, posZ).toVec3D();
Vec3d vec31 = new Vector3(posX + motionX, posY + motionY, posZ + motionZ).toVec3D();
RayTraceResult RayTraceResult = clip(vec3, vec31);
if(RayTraceResult != null)
vec31 = new Vector3(RayTraceResult.hitVec.xCoord, RayTraceResult.hitVec.yCoord, RayTraceResult.hitVec.zCoord).toVec3D();
if(!worldObj.isRemote) {
Entity entity = null;
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, getEntityBoundingBox().addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
EntityLivingBase entitylivingbase = getThrower();
for(int j = 0; j < list.size(); ++j) {
Entity entity1 = (Entity) list.get(j);
if(entity1.canBeCollidedWith() && (entity1 != entitylivingbase || ticksInAir >= 5)) {
float f = 0.3F;
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand(f, f, f);
RayTraceResult RayTraceResult1 = axisalignedbb.calculateIntercept(vec3, vec31);
if(RayTraceResult1 != null) {
double d1 = vec3.distanceTo(RayTraceResult1.hitVec);
if (d1 < d0 || d0 == 0.0D) {
entity = entity1;
d0 = d1;
}
}
}
}
if(entity != null)
RayTraceResult = new RayTraceResult(entity);
}
if(RayTraceResult != null)
onImpact(RayTraceResult);
posX += motionX;
posY += motionY;
posZ += motionZ;
float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
rotationYaw = (float)(Math.atan2(motionX, motionZ) * 180.0D / Math.PI);
for(rotationPitch = (float)(Math.atan2(motionY, f1) * 180.0D / Math.PI); rotationPitch - prevRotationPitch < -180.0F; prevRotationPitch -= 360.0F);
while(rotationPitch - prevRotationPitch >= 180.0F)
prevRotationPitch += 360.0F;
while(rotationYaw - prevRotationYaw < -180.0F)
prevRotationYaw -= 360.0F;
while(rotationYaw - prevRotationYaw >= 180.0F)
prevRotationYaw += 360.0F;
rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
float f3 = getGravityVelocity();
motionY -= f3;
setPosition(posX, posY, posZ);
}
public RayTraceResult clip(Vec3d par1Vec3, Vec3d par2Vec3) {
boolean par3 = false;
boolean par4 = false;
if (!Double.isNaN(par1Vec3.xCoord) && !Double.isNaN(par1Vec3.yCoord) && !Double.isNaN(par1Vec3.zCoord)) {
if (!Double.isNaN(par2Vec3.xCoord) && !Double.isNaN(par2Vec3.yCoord) && !Double.isNaN(par2Vec3.zCoord)) {
int i = MathHelper.floor_double(par2Vec3.xCoord);
int j = MathHelper.floor_double(par2Vec3.yCoord);
int k = MathHelper.floor_double(par2Vec3.zCoord);
int l = MathHelper.floor_double(par1Vec3.xCoord);
int i1 = MathHelper.floor_double(par1Vec3.yCoord);
int j1 = MathHelper.floor_double(par1Vec3.zCoord);
BlockPos pos = new BlockPos(l, i1, j1);
IBlockState state = worldObj.getBlockState(pos);
Block block = state.getBlock();
if (block != null && (!par4 || block == null || state.getCollisionBoundingBox(worldObj, pos) != null) && block != Blocks.air && block.canCollideCheck(state, par3)) {
RayTraceResult RayTraceResult = state.collisionRayTrace(worldObj, pos, par1Vec3, par2Vec3);
if (RayTraceResult != null)
return RayTraceResult;
}
int k1 = 200;
while (k1-- >= 0) {
if (Double.isNaN(par1Vec3.xCoord) || Double.isNaN(par1Vec3.yCoord) || Double.isNaN(par1Vec3.zCoord))
return null;
if (l == i && i1 == j && j1 == k)
return null;
boolean flag2 = true;
boolean flag3 = true;
boolean flag4 = true;
double d0 = 999.0D;
double d1 = 999.0D;
double d2 = 999.0D;
if (i > l)
d0 = l + 1.0D;
else if (i < l)
d0 = l + 0.0D;
else flag2 = false;
if (j > i1)
d1 = i1 + 1.0D;
else if (j < i1)
d1 = i1 + 0.0D;
else flag3 = false;
if (k > j1)
d2 = j1 + 1.0D;
else if (k < j1)
d2 = j1 + 0.0D;
else flag4 = false;
double d3 = 999.0D;
double d4 = 999.0D;
double d5 = 999.0D;
double d6 = par2Vec3.xCoord - par1Vec3.xCoord;
double d7 = par2Vec3.yCoord - par1Vec3.yCoord;
double d8 = par2Vec3.zCoord - par1Vec3.zCoord;
if (flag2)
d3 = (d0 - par1Vec3.xCoord) / d6;
if (flag3)
d4 = (d1 - par1Vec3.yCoord) / d7;
if (flag4)
d5 = (d2 - par1Vec3.zCoord) / d8;
byte b0;
if (d3 < d4 && d3 < d5) {
if (i > l)
b0 = 4;
else b0 = 5;
par1Vec3 = new Vec3d(d0, par1Vec3.yCoord + (d7 * d3), par1Vec3.zCoord + (d8 * d3));
} else if (d4 < d5) {
if (j > i1)
b0 = 0;
else b0 = 1;
par1Vec3 = new Vec3d(par1Vec3.xCoord + (d6 * d4), d1, par1Vec3.zCoord + (d8 * d4));
} else {
if (k > j1)
b0 = 2;
else b0 = 3;
par1Vec3 = new Vec3d(par1Vec3.xCoord + (d6 * d5), par1Vec3.yCoord + (d7 * d5), d2);
}
Vec3d vec32 = new Vector3(par1Vec3.xCoord, par1Vec3.yCoord, par1Vec3.zCoord).toVec3D();
vec32 = new Vec3d(MathHelper.floor_double(par1Vec3.xCoord), vec32.yCoord, vec32.zCoord);
l = ((int) vec32.xCoord);
if (b0 == 5) {
--l;
vec32 = vec32.addVector(1, 0, 0);
}
vec32 = new Vec3d(vec32.xCoord, MathHelper.floor_double(par1Vec3.yCoord), vec32.zCoord);
i1 = ((int) vec32.yCoord);
if (b0 == 1) {
--i1;
vec32 = vec32.addVector(0, 1, 0);
}
vec32 = new Vec3d(par1Vec3.xCoord, vec32.yCoord, MathHelper.floor_double(vec32.zCoord));
j1 = ((int) vec32.zCoord);
if (b0 == 3) {
--j1;
vec32 = vec32.addVector(0, 0, 1);
}
BlockPos pos1 = new BlockPos(l, i1, j1);
IBlockState state1 = worldObj.getBlockState(pos1);
Block block1 = state1.getBlock();
if ((!par4 || block1 == null || block1.getCollisionBoundingBox(state1, worldObj, pos1) != null) && block1 != Blocks.air && block1.canCollideCheck(state, par3)) {
RayTraceResult RayTraceResult1 = block1.collisionRayTrace(state1, worldObj, pos1, par1Vec3, par2Vec3);
if (RayTraceResult1 != null)
return RayTraceResult1;
}
}
return null;
}
else return null;
} else return null;
}
@Override
public void onUpdate() {
setTicksExisted(getTicksExisted() + 1);
superUpdate();
super.onUpdate();
// superUpdate(); todo 1.9 removed a ton of what appears to just be copied superclass code
// todo 1.9 if shit breaks revert this :P
if(!fake && !isDead)
ping();
@@ -418,8 +208,8 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
return false;
}
public TileEntity collidedTile = null;
public boolean noParticles = false;
private TileEntity collidedTile = null;
private boolean noParticles = false;
public TileEntity getCollidedTile(boolean noParticles) {
this.noParticles = noParticles;
@@ -459,7 +249,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
par1nbtTagCompound.setDouble(TAG_LAST_MOTION_Y, motionY);
par1nbtTagCompound.setDouble(TAG_LAST_MOTION_Z, motionZ);
UUID identity = getShooterUIID();
UUID identity = getShooterUUID();
boolean hasShooter = identity != null;
par1nbtTagCompound.setBoolean(TAG_HAS_SHOOTER, hasShooter);
if(hasShooter) {
@@ -501,7 +291,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
if(hasShooter) {
long most = par1nbtTagCompound.getLong(TAG_SHOOTER_UUID_MOST);
long least = par1nbtTagCompound.getLong(TAG_SHOOTER_UUID_LEAST);
UUID identity = getShooterUIID();
UUID identity = getShooterUUID();
if(identity == null || most != identity.getMostSignificantBits() || least != identity.getLeastSignificantBits())
shooterIdentity = new UUID(most, least);
}
@@ -629,7 +419,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
dead = lens.collideBurst(this, RayTraceResult, collidedTile != null && collidedTile instanceof IManaReceiver && ((IManaReceiver) collidedTile).canRecieveManaFromBursts(), dead, getSourceLens());
if(collided && !hasAlreadyCollidedAt(RayTraceResult.getBlockPos()))
alreadyCollidedAt.add(getCollisionLocString(RayTraceResult.getBlockPos()));
alreadyCollidedAt.add(RayTraceResult.getBlockPos());
if(dead && !isDead) {
if(!fake) {
@@ -652,7 +442,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
}
}
protected void onRecieverImpact(IManaReceiver tile, BlockPos pos) {
private void onRecieverImpact(IManaReceiver tile, BlockPos pos) {
int mana = getMana();
if(tile instanceof IManaCollector)
mana *= ((IManaCollector) tile).getManaYieldMultiplier(this);
@@ -674,7 +464,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
} else setDeathTicksForFakeParticle();
}
public TileEntity getShooter() {
private TileEntity getShooter() {
return worldObj.getTileEntity(getBurstSourceBlockPos());
}
@@ -789,7 +579,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
_ticksExisted = ticks;
}
public ILensEffect getLensInstance() {
private ILensEffect getLensInstance() {
ItemStack lens = getSourceLens();
if(lens != null && lens.getItem() instanceof ILensEffect)
return (ILensEffect) lens.getItem();
@@ -806,17 +596,13 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
@Override
public boolean hasAlreadyCollidedAt(BlockPos pos) {
return alreadyCollidedAt.contains(getCollisionLocString(pos));
return alreadyCollidedAt.contains(pos);
}
@Override
public void setCollidedAt(BlockPos pos) {
if(!hasAlreadyCollidedAt(pos))
alreadyCollidedAt.add(getCollisionLocString(pos));
}
private String getCollisionLocString(BlockPos pos) {
return pos.getX() + ":" + pos.getY() + ":" + pos.getZ();
alreadyCollidedAt.add(pos.toImmutable());
}
@Override
@@ -825,7 +611,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
}
@Override
public UUID getShooterUIID() {
public UUID getShooterUUID() {
return shooterIdentity;
}
@@ -833,20 +619,21 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
public void ping() {
TileEntity tile = getShooter();
if(tile != null && tile instanceof IPingable)
((IPingable) tile).pingback(this, getShooterUIID());
((IPingable) tile).pingback(this, getShooterUUID());
}
public boolean shouldDoFakeParticles() {
if(ConfigHandler.staticWandBeam)
protected boolean shouldDoFakeParticles() {
if (ConfigHandler.staticWandBeam)
return true;
TileEntity tile = getShooter();
if(tile != null && tile instanceof IManaSpreader)
return getMana() != getStartingMana() && fullManaLastTick || Math.abs(((IManaSpreader) tile).getBurstParticleTick() - getTicksExisted()) < 4;
return false;
return tile != null
&& tile instanceof IManaSpreader
&& (getMana() != getStartingMana() && fullManaLastTick
|| Math.abs(((IManaSpreader) tile).getBurstParticleTick() - getTicksExisted()) < 4);
}
public void incrementFakeParticleTick() {
private void incrementFakeParticleTick() {
TileEntity tile = getShooter();
if(tile != null && tile instanceof IManaSpreader) {
IManaSpreader spreader = (IManaSpreader) tile;
@@ -856,7 +643,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
}
}
public void setDeathTicksForFakeParticle() {
private void setDeathTicksForFakeParticle() {
BlockPos coords = getBurstSourceBlockPos();
TileEntity tile = worldObj.getTileEntity(coords);
if(tile != null && tile instanceof IManaSpreader)
@@ -890,6 +677,18 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
return world.getBlockState(coords) == this.state;
}
@Override
public int hashCode() {
return Objects.hash(coords, state);
}
@Override
public boolean equals(Object o) {
return o instanceof PositionProperties
&& ((PositionProperties) o).state == state
&& ((PositionProperties) o).coords.equals(coords);
}
}
}
@@ -41,6 +41,7 @@ import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.items.ItemHandlerHelper;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.handler.ClientMethodHandles;
@@ -208,9 +209,7 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
if(container == stackAt)
consume = false;
else {
InventoryHelper.insertItemIntoInventory(inv, container);
if(container.stackSize != 0 && player != null)
player.dropPlayerItemWithRandomChoice(container, false);
ItemHandlerHelper.giveItemToPlayer(player, container);
}
}