diff --git a/src/main/java/buildcraft/api/core/SafeTimeTracker.java b/src/main/java/buildcraft/api/core/SafeTimeTracker.java
new file mode 100644
index 00000000..44e1531e
--- /dev/null
+++ b/src/main/java/buildcraft/api/core/SafeTimeTracker.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public License
+ * 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.api.core;
+
+import net.minecraft.world.World;
+
+public class SafeTimeTracker {
+
+ private long lastMark = Long.MIN_VALUE;
+ private long duration = -1;
+
+ /**
+ * Return true if a given delay has passed since last time marked was called
+ * successfully.
+ */
+ public boolean markTimeIfDelay(World world, long delay) {
+ if (world == null)
+ return false;
+
+ long currentTime = world.getTotalWorldTime();
+
+ if (currentTime < lastMark) {
+ lastMark = currentTime;
+ return false;
+ } else if (lastMark + delay <= currentTime) {
+ duration = currentTime - lastMark;
+ lastMark = currentTime;
+ return true;
+ } else
+ return false;
+
+ }
+
+ public long durationOfLastDelay() {
+ return duration > 0 ? duration : 0;
+ }
+
+ public void markTime(World world) {
+ lastMark = world.getTotalWorldTime();
+ }
+}
diff --git a/src/main/java/buildcraft/api/power/IPowerReceptor.java b/src/main/java/buildcraft/api/power/IPowerReceptor.java
new file mode 100644
index 00000000..7af53607
--- /dev/null
+++ b/src/main/java/buildcraft/api/power/IPowerReceptor.java
@@ -0,0 +1,47 @@
+/**
+ * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public License
+ * 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.api.power;
+
+import net.minecraft.world.World;
+import net.minecraftforge.common.ForgeDirection;
+import buildcraft.api.power.PowerHandler.PowerReceiver;
+
+/**
+ * This interface should be implemented by any Tile Entity that wishes to be
+ * able to receive power.
+ *
+ * @author CovertJaguar
+ */
+public interface IPowerReceptor {
+
+ /**
+ * Get the PowerReceiver for this side of the block. You can return the same
+ * PowerReceiver for all sides or one for each side.
+ *
+ * You should NOT return null to this method unless you mean to NEVER
+ * receive power from that side. Returning null, after previous returning a
+ * PowerReceiver, will most likely cause pipe connections to derp out and
+ * engines to eventually explode.
+ *
+ * @param side
+ * @return
+ */
+ public PowerReceiver getPowerReceiver(ForgeDirection side);
+
+ /**
+ * Call back from the PowerHandler that is called when the stored power
+ * exceeds the activation power.
+ *
+ * It can be triggered by update() calls or power modification calls.
+ *
+ * @param workProvider
+ */
+ public void doWork(PowerHandler workProvider);
+
+ public World getWorld();
+}
diff --git a/src/main/java/buildcraft/api/power/PowerHandler.java b/src/main/java/buildcraft/api/power/PowerHandler.java
new file mode 100644
index 00000000..7073bee9
--- /dev/null
+++ b/src/main/java/buildcraft/api/power/PowerHandler.java
@@ -0,0 +1,390 @@
+/**
+ * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public License
+ * 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.api.power;
+
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.common.ForgeDirection;
+import buildcraft.api.core.SafeTimeTracker;
+
+public final class PowerHandler {
+
+ public static enum Type {
+
+ ENGINE, GATE, MACHINE, PIPE, STORAGE;
+
+ public boolean canReceiveFromPipes() {
+ switch (this) {
+ case MACHINE:
+ case STORAGE:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ public boolean eatsEngineExcess() {
+ switch (this) {
+ case MACHINE:
+ case STORAGE:
+ return true;
+ default:
+ return false;
+ }
+ }
+ }
+
+ public static class PerditionCalculator {
+
+ public static final float DEFAULT_POWERLOSS = 1F;
+ public static final float MIN_POWERLOSS = 0.01F;
+ private final float powerLoss;
+
+ public PerditionCalculator() {
+ powerLoss = DEFAULT_POWERLOSS;
+ }
+
+ public PerditionCalculator(float powerLoss) {
+ if (powerLoss < MIN_POWERLOSS) {
+ powerLoss = MIN_POWERLOSS;
+ }
+ this.powerLoss = powerLoss;
+ }
+
+ /**
+ * Apply the perdition algorithm to the current stored energy. This
+ * function can only be called once per tick, but it might not be called
+ * every tick. It is triggered by any manipulation of the stored energy.
+ *
+ * @param powerHandler the PowerHandler requesting the perdition update
+ * @param current the current stored energy
+ * @param ticksPassed ticks since the last time this function was called
+ * @return
+ */
+ public float applyPerdition(PowerHandler powerHandler, float current, long ticksPassed) {
+ current -= powerLoss * ticksPassed;
+ if (current < 0) {
+ current = 0;
+ }
+ return current;
+ }
+ }
+ public static final PerditionCalculator DEFAULT_PERDITION = new PerditionCalculator();
+ private float minEnergyReceived;
+ private float maxEnergyReceived;
+ private float maxEnergyStored;
+ private float activationEnergy;
+ private float energyStored = 0;
+ private final SafeTimeTracker doWorkTracker = new SafeTimeTracker();
+ private final SafeTimeTracker sourcesTracker = new SafeTimeTracker();
+ private final SafeTimeTracker perditionTracker = new SafeTimeTracker();
+ public final int[] powerSources = new int[6];
+ public final IPowerReceptor receptor;
+ private PerditionCalculator perdition;
+ private final PowerReceiver receiver;
+ private final Type type;
+
+ public PowerHandler(IPowerReceptor receptor, Type type) {
+ this.receptor = receptor;
+ this.type = type;
+ receiver = new PowerReceiver();
+ perdition = DEFAULT_PERDITION;
+ }
+
+ public PowerReceiver getPowerReceiver() {
+ return receiver;
+ }
+
+ public float getMinEnergyReceived() {
+ return minEnergyReceived;
+ }
+
+ public float getMaxEnergyReceived() {
+ return maxEnergyReceived;
+ }
+
+ public float getMaxEnergyStored() {
+ return maxEnergyStored;
+ }
+
+ public float getActivationEnergy() {
+ return activationEnergy;
+ }
+
+ public float getEnergyStored() {
+ return energyStored;
+ }
+
+ /**
+ * Setup your PowerHandler's settings.
+ *
+ * @param minEnergyReceived This is the minimum about of power that will be
+ * accepted by the PowerHandler. This should generally be greater than the
+ * activationEnergy if you plan to use the doWork() callback. Anything
+ * greater than 1 will prevent Redstone Engines from powering this Provider.
+ * @param maxEnergyReceived The maximum amount of power accepted by the
+ * PowerHandler. This should generally be less than 500. Too low and larger
+ * engines will overheat while trying to power the machine. Too high, and
+ * the engines will never warm up. Greater values also place greater strain
+ * on the power net.
+ * @param activationEnergy If the stored energy is greater than this value,
+ * the doWork() callback is called (once per tick).
+ * @param maxStoredEnergy The maximum amount of power this PowerHandler can
+ * store. Values tend to range between 100 and 5000. With 1000 and 1500
+ * being common.
+ */
+ public void configure(float minEnergyReceived, float maxEnergyReceived, float activationEnergy, float maxStoredEnergy) {
+ if (minEnergyReceived > maxEnergyReceived) {
+ maxEnergyReceived = minEnergyReceived;
+ }
+ this.minEnergyReceived = minEnergyReceived;
+ this.maxEnergyReceived = maxEnergyReceived;
+ maxEnergyStored = maxStoredEnergy;
+ this.activationEnergy = activationEnergy;
+ }
+
+ public void configurePowerPerdition(int powerLoss, int powerLossRegularity) {
+ if (powerLoss == 0 || powerLossRegularity == 0) {
+ perdition = new PerditionCalculator(0);
+ return;
+ }
+ perdition = new PerditionCalculator((float) powerLoss / (float) powerLossRegularity);
+ }
+
+ /**
+ * Allows you to define a new PerditionCalculator class to handler perdition
+ * calculations.
+ *
+ * For example if you want exponentially increasing loss based on amount
+ * stored.
+ *
+ * @param perdition
+ */
+ public void setPerdition(PerditionCalculator perdition) {
+ if (perdition == null)
+ perdition = DEFAULT_PERDITION;
+ this.perdition = perdition;
+ }
+
+ public PerditionCalculator getPerdition() {
+ if (perdition == null)
+ return DEFAULT_PERDITION;
+ return perdition;
+ }
+
+ /**
+ * Ticks the power handler. You should call this if you can, but its not
+ * required.
+ *
+ * If you don't call it, the possibility exists for some weirdness with the
+ * perdition algorithm and work callback as its possible they will not be
+ * called on every tick they otherwise would be. You should be able to
+ * design around this though if you are aware of the limitations.
+ */
+ public void update() {
+ applyPerdition();
+ applyWork();
+ validateEnergy();
+ }
+
+ private void applyPerdition() {
+ if (perditionTracker.markTimeIfDelay(receptor.getWorld(), 1) && energyStored > 0) {
+ float newEnergy = getPerdition().applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
+ if (newEnergy == 0 || newEnergy < energyStored)
+ energyStored = newEnergy;
+ else
+ energyStored = DEFAULT_PERDITION.applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
+ validateEnergy();
+ }
+ }
+
+ private void applyWork() {
+ if (energyStored >= activationEnergy) {
+ if (doWorkTracker.markTimeIfDelay(receptor.getWorld(), 1)) {
+ receptor.doWork(this);
+ }
+ }
+ }
+
+ private void updateSources(ForgeDirection source) {
+ if (sourcesTracker.markTimeIfDelay(receptor.getWorld(), 1)) {
+ for (int i = 0; i < 6; ++i) {
+ powerSources[i] -= sourcesTracker.durationOfLastDelay();
+ if (powerSources[i] < 0) {
+ powerSources[i] = 0;
+ }
+ }
+ }
+
+ if (source != null)
+ powerSources[source.ordinal()] = 10;
+ }
+
+ /**
+ * Extract energy from the PowerHandler. You must call this even if doWork()
+ * triggers.
+ *
+ * @param min
+ * @param max
+ * @param doUse
+ * @return amount used
+ */
+ public float useEnergy(float min, float max, boolean doUse) {
+ applyPerdition();
+
+ float result = 0;
+
+ if (energyStored >= min) {
+ if (energyStored <= max) {
+ result = energyStored;
+ if (doUse) {
+ energyStored = 0;
+ }
+ } else {
+ result = max;
+ if (doUse) {
+ energyStored -= max;
+ }
+ }
+ }
+
+ validateEnergy();
+
+ return result;
+ }
+
+ public void readFromNBT(NBTTagCompound data) {
+ readFromNBT(data, "powerProvider");
+ }
+
+ public void readFromNBT(NBTTagCompound data, String tag) {
+ NBTTagCompound nbt = data.getCompoundTag(tag);
+ energyStored = nbt.getFloat("storedEnergy");
+ }
+
+ public void writeToNBT(NBTTagCompound data) {
+ writeToNBT(data, "powerProvider");
+ }
+
+ public void writeToNBT(NBTTagCompound data, String tag) {
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setFloat("storedEnergy", energyStored);
+ data.setCompoundTag(tag, nbt);
+ }
+
+ public final class PowerReceiver {
+
+ private PowerReceiver() {
+ }
+
+ public float getMinEnergyReceived() {
+ return minEnergyReceived;
+ }
+
+ public float getMaxEnergyReceived() {
+ return maxEnergyReceived;
+ }
+
+ public float getMaxEnergyStored() {
+ return maxEnergyStored;
+ }
+
+ public float getActivationEnergy() {
+ return activationEnergy;
+ }
+
+ public float getEnergyStored() {
+ return energyStored;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public void update() {
+ PowerHandler.this.update();
+ }
+
+ /**
+ * The amount of power that this PowerHandler currently needs.
+ *
+ * @return
+ */
+ public float powerRequest() {
+ update();
+ return Math.min(maxEnergyReceived, maxEnergyStored - energyStored);
+ }
+
+ /**
+ * Add power to the PowerReceiver from an external source.
+ *
+ * @param quantity
+ * @param from
+ * @return the amount of power used
+ */
+ public float receiveEnergy(Type source, final float quantity, ForgeDirection from) {
+ float used = quantity;
+ if (source == Type.ENGINE) {
+ if (used < minEnergyReceived) {
+ return 0;
+ } else if (used > maxEnergyReceived) {
+ used = maxEnergyReceived;
+ }
+ }
+
+ updateSources(from);
+
+ used = addEnergy(used);
+
+ applyWork();
+
+ if (source == Type.ENGINE && type.eatsEngineExcess()) {
+ return Math.min(quantity, maxEnergyReceived);
+ }
+
+ return used;
+ }
+ }
+
+ /**
+ *
+ * @return the amount the power changed by
+ */
+ public float addEnergy(float quantity) {
+ energyStored += quantity;
+
+ if (energyStored > maxEnergyStored) {
+ quantity -= energyStored - maxEnergyStored;
+ energyStored = maxEnergyStored;
+ } else if (energyStored < 0) {
+ quantity -= energyStored;
+ energyStored = 0;
+ }
+
+ applyPerdition();
+
+ return quantity;
+ }
+
+ public void setEnergy(float quantity) {
+ energyStored = quantity;
+ validateEnergy();
+ }
+
+ public boolean isPowerSource(ForgeDirection from) {
+ return powerSources[from.ordinal()] != 0;
+ }
+
+ private void validateEnergy() {
+ if (energyStored < 0) {
+ energyStored = 0;
+ }
+ if (energyStored > maxEnergyStored) {
+ energyStored = maxEnergyStored;
+ }
+ }
+}
diff --git a/src/main/java/cofh/api/energy/IEnergyHandler.java b/src/main/java/cofh/api/energy/IEnergyHandler.java
new file mode 100644
index 00000000..07a37782
--- /dev/null
+++ b/src/main/java/cofh/api/energy/IEnergyHandler.java
@@ -0,0 +1,56 @@
+package cofh.api.energy;
+
+import net.minecraftforge.common.ForgeDirection;
+
+/**
+ * Implement this interface on TileEntities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
+ *
+ * A reference implementation is provided {@link TileEnergyHandler}.
+ *
+ * @author King Lemming
+ *
+ */
+public interface IEnergyHandler {
+
+ /**
+ * Add energy to an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
+ *
+ * @param from
+ * Orientation the energy is received from.
+ * @param maxReceive
+ * Maximum amount of energy to received.
+ * @param simulate
+ * If TRUE, the charge will only be simulated.
+ * @return Amount of energy that was (or would have been, if simulated) received.
+ */
+ int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate);
+
+ /**
+ * Remove energy from an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
+ *
+ * @param from
+ * Orientation the energy is extracted to.
+ * @param maxExtract
+ * Maximum amount of energy to extract.
+ * @param simulate
+ * If TRUE, the discharge will only be simulated.
+ * @return Amount of energy that was (or would have been, if simulated) extracted.
+ */
+ int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate);
+
+ /**
+ * Returns true if the Handler functions on a given side - if a Tile Entity can receive and/or send energy from a given side, this should return true.
+ */
+ boolean canInterface(ForgeDirection from);
+
+ /**
+ * Returns the amount of energy currently stored.
+ */
+ int getEnergyStored(ForgeDirection from);
+
+ /**
+ * Returns the maximum amount of energy that can be stored.
+ */
+ int getMaxEnergyStored(ForgeDirection from);
+
+}
diff --git a/src/main/java/dan200/computer/api/ComputerCraftAPI.java b/src/main/java/dan200/computer/api/ComputerCraftAPI.java
new file mode 100644
index 00000000..f0403079
--- /dev/null
+++ b/src/main/java/dan200/computer/api/ComputerCraftAPI.java
@@ -0,0 +1,164 @@
+/**
+ * This file is part of the public ComputerCraft API - http://www.computercraft.info
+ * Copyright Daniel Ratcliffe, 2011-2013. This API may be redistributed unmodified and in full only.
+ * For help using the API, and posting your mods, visit the forums at computercraft.info.
+ */
+
+package dan200.computer.api;
+import java.lang.reflect.Method;
+
+import net.minecraft.world.World;
+
+/**
+ * The static entry point to the ComputerCraft API.
+ * Members in this class must be called after mod_ComputerCraft has been initialised,
+ * but may be called before it is fully loaded.
+ */
+public class ComputerCraftAPI
+{
+ /**
+ * Creates a numbered directory in a subfolder of the save directory for a given world, and returns that number.
+ * Use in conjuction with createSaveDirMount() to create a unique place for your peripherals or media items to store files.
+ * @param world The world for which the save dir should be created. This should be the serverside world object.
+ * @param parentSubPath The folder path within the save directory where the new directory should be created. eg: "computer/disk"
+ * @return The numerical value of the name of the new folder, or -1 if the folder could not be created for some reason.
+ * eg: if createUniqueNumberedSaveDir( world, "computer/disk" ) was called returns 42, then "computer/disk/42" is now available for writing.
+ * @see #createSaveDirMount(World, String)
+ */
+ public static int createUniqueNumberedSaveDir( World world, String parentSubPath )
+ {
+ findCC();
+ if( computerCraft_createUniqueNumberedSaveDir != null )
+ {
+ try {
+ return ((Integer)computerCraft_createUniqueNumberedSaveDir.invoke( null, world, parentSubPath )).intValue();
+ } catch (Exception e){
+ // It failed
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Creates a file system mount that maps to a subfolder of the save directory for a given world, and returns it.
+ * Use in conjuction with IComputerAccess.mount() or IComputerAccess.mountWritable() to mount a folder from the
+ * users save directory onto a computers file system.
+ * @param world The world for which the save dir can be found. This should be the serverside world object.
+ * @param subPath The folder path within the save directory that the mount should map to. eg: "computer/disk/42".
+ * Use createUniqueNumberedSaveDir() to create a new numbered folder to use.
+ * @param capacity The ammount of data that can be stored in the directory before it fills up, in bytes.
+ * @return The mount, or null if it could be created for some reason. Use IComputerAccess.mount() or IComputerAccess.mountWritable()
+ * to mount this on a Computers' file system.
+ * @see #createUniqueNumberedSaveDir(World, String)
+ * @see IComputerAccess#mount(String, IMount)
+ * @see IComputerAccess#mountWritable(String, IWritableMount)
+ * @see IMount
+ * @see IMountWritable
+ */
+ public static IWritableMount createSaveDirMount( World world, String subPath, long capacity )
+ {
+ findCC();
+ if( computerCraft_createSaveDirMount != null )
+ {
+ try {
+ return (IWritableMount)computerCraft_createSaveDirMount.invoke( null, world, subPath, capacity );
+ } catch (Exception e){
+ // It failed
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Creates a file system mount to a resource folder, and returns it.
+ * Use in conjuction with IComputerAccess.mount() or IComputerAccess.mountWritable() to mount a resource folder onto a computers file system.
+ * The files in this mount will be a combination of files in the specified mod jar, and resource packs that contain resources with the same domain and path.
+ * @param class A class in whose jar to look first for the resources to mount. Using your main mod class is recommended. eg: MyMod.class
+ * @param domain The domain under which to look for resources. eg: "mymod"
+ * @param subPath The domain under which to look for resources. eg: "mymod/lua/myfiles"
+ * @return The mount, or null if it could be created for some reason. Use IComputerAccess.mount() or IComputerAccess.mountWritable()
+ * to mount this on a Computers' file system.
+ * @see IComputerAccess#mount(String, IMount)
+ * @see IComputerAccess#mountWritable(String, IMountWritable)
+ * @see IMount
+ */
+ public static IMount createResourceMount( Class modClass, String domain, String subPath )
+ {
+ findCC();
+ if( computerCraft_createResourceMount != null )
+ {
+ try {
+ return (IMount)computerCraft_createResourceMount.invoke( null, modClass, domain, subPath );
+ } catch (Exception e){
+ // It failed
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Registers a peripheral handler for a TileEntity that you do not have access to. Only
+ * use this if you want to expose IPeripheral on a TileEntity from another mod. For your own
+ * mod, just implement IPeripheral on the TileEntity directly.
+ * @see IPeripheral
+ * @see IPeripheralHandler
+ */
+ public static void registerExternalPeripheral( Class extends net.minecraft.tileentity.TileEntity> clazz, IPeripheralHandler handler )
+ {
+ findCC();
+ if (computerCraft_registerExternalPeripheral != null)
+ {
+ try {
+ computerCraft_registerExternalPeripheral.invoke(null, clazz, handler);
+ } catch (Exception e){
+ // It failed
+ }
+ }
+ }
+
+ // The functions below here are private, and are used to interface with the non-API ComputerCraft classes.
+ // Reflection is used here so you can develop your mod in MCP without decompiling ComputerCraft and including
+ // it in your solution.
+
+ private static void findCC()
+ {
+ if( !ccSearched ) {
+ try {
+ computerCraft = Class.forName( "dan200.ComputerCraft" );
+ computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class[] {
+ World.class, String.class
+ } );
+ computerCraft_createSaveDirMount = findCCMethod( "createSaveDirMount", new Class[] {
+ World.class, String.class, Long.TYPE
+ } );
+ computerCraft_createResourceMount = findCCMethod( "createResourceMount", new Class[] {
+ Class.class, String.class, String.class
+ } );
+ computerCraft_registerExternalPeripheral = findCCMethod( "registerExternalPeripheral", new Class[] {
+ Class.class, IPeripheralHandler.class
+ } );
+ } catch( Exception e ) {
+ net.minecraft.server.MinecraftServer.getServer().logInfo( "ComputerCraftAPI: ComputerCraft not found." );
+ } finally {
+ ccSearched = true;
+ }
+ }
+ }
+
+ private static Method findCCMethod( String name, Class[] args )
+ {
+ try {
+ return computerCraft.getMethod( name, args );
+ } catch( NoSuchMethodException e ) {
+ net.minecraft.server.MinecraftServer.getServer().logInfo( "ComputerCraftAPI: ComputerCraft method " + name + " not found." );
+ return null;
+ }
+ }
+
+ private static boolean ccSearched = false;
+ private static Class computerCraft = null;
+ private static Method computerCraft_createUniqueNumberedSaveDir = null;
+ private static Method computerCraft_createSaveDirMount = null;
+ private static Method computerCraft_createResourceMount = null;
+ private static Method computerCraft_registerExternalPeripheral = null;
+}
diff --git a/src/main/java/dan200/computer/api/IComputerAccess.java b/src/main/java/dan200/computer/api/IComputerAccess.java
new file mode 100644
index 00000000..2eac5d0b
--- /dev/null
+++ b/src/main/java/dan200/computer/api/IComputerAccess.java
@@ -0,0 +1,91 @@
+/**
+ * This file is part of the public ComputerCraft API - http://www.computercraft.info
+ * Copyright Daniel Ratcliffe, 2011-2013. This API may be redistributed unmodified and in full only.
+ * For help using the API, and posting your mods, visit the forums at computercraft.info.
+ */
+
+package dan200.computer.api;
+
+import net.minecraft.world.World;
+
+/**
+ * The interface passed to peripherals by computers or turtles, providing methods
+ * that they can call. This should not be implemented by your classes. Do not interact
+ * with computers except via this interface.
+ */
+public interface IComputerAccess
+{
+ /**
+ * Mount a mount onto the computers' file system in a read only mode.
+ * @param desiredLoction The location on the computer's file system where you would like the mount to be mounted.
+ * @param mount The mount object to mount on the computer. These can be obtained by calling ComputerCraftAPI.createSaveDirMount(), ComputerCraftAPI.createResourceMount() or by creating your own objects that implement the IMount interface.
+ * @return The location on the computer's file system where you the mount mounted, or null if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
+ * @see ComputerCraftAPI#createSaveDirMount(World, String)
+ * @see ComputerCraftAPI#createResourceMount(Class, String, String)
+ * @see #mountWritable(String, IWritableMount)
+ * @see #unmount(String)
+ * @see IMount
+ */
+ public String mount( String desiredLocation, IMount mount );
+
+ /**
+ * Mount a mount onto the computers' file system in a writable mode.
+ * @param desiredLoction The location on the computer's file system where you would like the mount to be mounted.
+ * @param mount The mount object to mount on the computer. These can be obtained by calling ComputerCraftAPI.createSaveDirMount() or by creating your own objects that implement the IWritableMount interface.
+ * @return The location on the computer's file system where you the mount mounted, or null if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
+ * @see ComputerCraftAPI#createSaveDirMount(World, String)
+ * @see ComputerCraftAPI#createResourceMount(Class, String, String)
+ * @see #mount(String, IMount)
+ * @see #unmount(String)
+ * @see IMount
+ */
+ public String mountWritable( String desiredLocation, IWritableMount mount );
+
+ /**
+ * Unmounts a directory previously mounted onto the computers file system by mount() or mountWritable().
+ * When a directory is unmounted, it will disappear from the computers file system, and the user will no longer be able to
+ * access it. All directories mounted by a mount or mountWritable are automatically unmounted when the peripheral
+ * is attached if they have not been explicitly unmounted.
+ * @param location The desired location in the computers file system of the directory to unmount.
+ * This must be the location of a directory previously mounted by mount() or mountWritable(), as
+ * indicated by their return value.
+ * @see #mount(String, IMount)
+ * @see #mountWritable(String, IWritableMount)
+ */
+ public void unmount( String location );
+
+ /**
+ * Returns the numerical ID of this computer.
+ * This is the same number obtained by calling os.getComputerID() or running the "id" program from lua,
+ * and is guarunteed unique. This number will be positive.
+ * @return The identifier.
+ */
+ public int getID();
+
+ /**
+ * Causes an event to be raised on this computer, which the computer can respond to by calling
+ * os.pullEvent(). This can be used to notify the computer when things happen in the world or to
+ * this peripheral.
+ * @param event A string identifying the type of event that has occurred, this will be
+ * returned as the first value from os.pullEvent(). It is recommended that you
+ * you choose a name that is unique, and recognisable as originating from your
+ * peripheral. eg: If your peripheral type is "button", a suitable event would be
+ * "button_pressed".
+ * @param arguments In addition to a name, you may pass an array of extra arguments to the event, that will
+ * be supplied as extra return values to os.pullEvent(). Objects in the array will be converted
+ * to lua data types in the same fashion as the return values of IPeripheral.callMethod().
+ * You may supply null to indicate that no arguments are to be supplied.
+ * @see IPeripheral#callMethod
+ */
+ public void queueEvent( String event, Object[] arguments );
+
+ /**
+ * Get a string, unique to the computer, by which the computer refers to this peripheral.
+ * For directly attached peripherals this will be "left","right","front","back",etc, but
+ * for peripherals attached remotely it will be different. It is good practice to supply
+ * this string when raising events to the computer, so that the computer knows from
+ * which peripheral the event came.
+ * @return A string unique to the computer, but not globally.
+ */
+ public String getAttachmentName();
+}
diff --git a/src/main/java/dan200/computer/api/IHostedPeripheral.java b/src/main/java/dan200/computer/api/IHostedPeripheral.java
new file mode 100644
index 00000000..89902a65
--- /dev/null
+++ b/src/main/java/dan200/computer/api/IHostedPeripheral.java
@@ -0,0 +1,43 @@
+/**
+ * This file is part of the public ComputerCraft API - http://www.computercraft.info
+ * Copyright Daniel Ratcliffe, 2011-2013. This API may be redistributed unmodified and in full only.
+ * For help using the API, and posting your mods, visit the forums at computercraft.info.
+ */
+
+package dan200.computer.api;
+
+/**
+ * A subclass of IPeripheral specifically for peripherals
+ * created by ITurtleUpgrade's of type Peripheral. When an
+ * IHostedPeripheral is created, its IPeripheral methods will be called
+ * just as if the peripheral was a seperate adjacent block in the world,
+ * and update() will be called once per tick.
+ * @see ITurtleUpgrade
+ */
+public interface IHostedPeripheral extends IPeripheral
+{
+ /**
+ * A method called on each hosted peripheral once per tick, on the main thread
+ * over the lifetime of the turtle or block. May be used to update the state
+ * of the peripheral, and may interact with IComputerAccess or ITurtleAccess
+ * however it likes at this time.
+ */
+ public void update();
+
+ /**
+ * A method called whenever data is read from the Turtle's NBTTag,
+ * over the lifetime of the turtle. You should only use this for
+ * reading data you want to stay with the peripheral.
+ * @param nbttagcompound The peripheral's NBTTag
+ */
+ public void readFromNBT( net.minecraft.nbt.NBTTagCompound nbttagcompound );
+
+ /**
+ * A method called whenever data is written to the Turtle's NBTTag,
+ * over the lifetime of the turtle. You should only use this for
+ * writing data you want to stay with the peripheral.
+ * @param nbttagcompound The peripheral's NBTTag.
+ * @param ID The turtle's ID.
+ */
+ public void writeToNBT( net.minecraft.nbt.NBTTagCompound nbttagcompound );
+}
diff --git a/src/main/java/dan200/computer/api/ILuaContext.java b/src/main/java/dan200/computer/api/ILuaContext.java
new file mode 100644
index 00000000..2bda0260
--- /dev/null
+++ b/src/main/java/dan200/computer/api/ILuaContext.java
@@ -0,0 +1,45 @@
+/**
+ * This file is part of the public ComputerCraft API - http://www.computercraft.info
+ * Copyright Daniel Ratcliffe, 2011-2013. This API may be redistributed unmodified and in full only.
+ * For help using the API, and posting your mods, visit the forums at computercraft.info.
+ */
+
+package dan200.computer.api;
+
+/**
+ * An interface passed to peripherals and ILuaObjects' by computers or turtles, providing methods
+ * that allow the peripheral call to wait for events before returning, just like in lua.
+ * This is very useful if you need to signal work to be performed on the main thread, and don't want to return
+ * until the work has been completed.
+ */
+public interface ILuaContext
+{
+ /**
+ * Wait for an event to occur on the computer, suspending the thread until it arises. This method is exactly equivalent to os.pullEvent() in lua.
+ * @param filter A specific event to wait for, or null to wait for any event
+ * @return An object array containing the name of the event that occurred, and any event parameters
+ * @throws Exception If the user presses CTRL+T to terminate the current program while pullEvent() is waiting for an event, a "Terminated" exception will be thrown here.
+ * Do not attempt to block this exception, unless you wish to prevent termination, which is not recommended.
+ * @throws InterruptedException If the user shuts down or reboots the computer while pullEvent() is waiting for an event, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computer will leak memory and end up in a broken state.
+ */
+ public Object[] pullEvent( String filter ) throws Exception, InterruptedException;
+
+ /**
+ * The same as pullEvent(), except "terminated" events are ignored. Only use this if you want to prevent program termination, which is not recommended. This method is exactly equivalent to os.pullEventRaw() in lua.
+ * @param filter A specific event to wait for, or null to wait for any event
+ * @return An object array containing the name of the event that occurred, and any event parameters
+ * @throws InterruptedException If the user shuts down or reboots the computer while pullEventRaw() is waiting for an event, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computer will leak memory and end up in a broken state.
+ * @see #pullEvent(String)
+ */
+ public Object[] pullEventRaw( String filter ) throws InterruptedException;
+
+
+ /**
+ * Yield the current coroutine with some arguments until it is resumed. This method is exactly equivalent to coroutine.yield() in lua. Use pullEvent() if you wish to wait for events.
+ * @param arguments An object array containing the arguments to pass to coroutine.yield()
+ * @return An object array containing the return values from coroutine.yield()
+ * @throws InterruptedException If the user shuts down or reboots the computer the coroutine is suspended, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computer will leak memory and end up in a broken state.
+ * @see #pullEvent(String)
+ */
+ public Object[] yield( Object[] arguments ) throws InterruptedException;
+}
diff --git a/src/main/java/dan200/computer/api/ILuaObject.java b/src/main/java/dan200/computer/api/ILuaObject.java
new file mode 100644
index 00000000..a063fa5b
--- /dev/null
+++ b/src/main/java/dan200/computer/api/ILuaObject.java
@@ -0,0 +1,26 @@
+/**
+ * This file is part of the public ComputerCraft API - http://www.computercraft.info
+ * Copyright Daniel Ratcliffe, 2011-2013. This API may be redistributed unmodified and in full only.
+ * For help using the API, and posting your mods, visit the forums at computercraft.info.
+ */
+
+package dan200.computer.api;
+
+/**
+ * An interface for representing custom objects returned by IPeripheral.callMethod() calls.
+ * Return objects implementing this interface to expose objects with methods to lua.
+ */
+public interface ILuaObject
+{
+ /**
+ * Get the names of the methods that this object implements. This works the same as IPeripheral.getMethodNames(). See that method for detailed documentation.
+ * @see IPeripheral#getMethodNames()
+ */
+ public String[] getMethodNames();
+
+ /**
+ * Called when a user calls one of the methods that this object implements. This works the same as IPeripheral.callMethod(). See that method for detailed documentation.
+ * @see IPeripheral#callMethod(IComputerAccess, ILuaContext, int, Object[])
+ */
+ public Object[] callMethod( ILuaContext context, int method, Object[] arguments ) throws Exception;
+}
diff --git a/src/main/java/dan200/computer/api/IMount.java b/src/main/java/dan200/computer/api/IMount.java
new file mode 100644
index 00000000..74f9bdeb
--- /dev/null
+++ b/src/main/java/dan200/computer/api/IMount.java
@@ -0,0 +1,59 @@
+/**
+ * This file is part of the public ComputerCraft API - http://www.computercraft.info
+ * Copyright Daniel Ratcliffe, 2011-2013. This API may be redistributed unmodified and in full only.
+ * For help using the API, and posting your mods, visit the forums at computercraft.info.
+ */
+
+package dan200.computer.api;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+import net.minecraft.world.World;
+
+/**
+ * Represents a read only part of a virtual filesystem that can be mounted onto a computer using IComputerAccess.mount().
+ * Ready made implementations of this interface can be created using ComputerCraftAPI.createSaveDirMount() or ComputerCraftAPI.createResourceMount(), or you're free to implement it yourselves!
+ * @see ComputerCraftAPI#createSaveDirMount(World, String)
+ * @see ComputerCraftAPI#createResourceMount(Class, String, String)
+ * @see IComputerAccess#mount(String, IMount)
+ * @see IWritableMount
+ */
+public interface IMount
+{
+ /**
+ * Returns whether a file with a given path exists or not.
+ * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
+ * @return true if the file exists, false otherwise
+ */
+ public boolean exists( String path ) throws IOException;
+
+ /**
+ * Returns whether a file with a given path is a directory or not.
+ * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
+ * @return true if the file exists and is a directory, false otherwise
+ */
+ public boolean isDirectory( String path ) throws IOException;
+
+ /**
+ * Returns the file names of all the files in a directory.
+ * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
+ * @param contents A list of strings. Add all the file names to this list
+ */
+ public void list( String path, List contents ) throws IOException;
+
+ /**
+ * Returns the size of a file with a given path, in bytes
+ * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
+ * @return the size of the file, in bytes
+ */
+ public long getSize( String path ) throws IOException;
+
+ /**
+ * Opens a file with a given path, and returns an inputstream representing it's contents.
+ * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
+ * @return a stream representing the contents of the file
+ */
+ public InputStream openForRead( String path ) throws IOException;
+}
diff --git a/src/main/java/dan200/computer/api/IPeripheral.java b/src/main/java/dan200/computer/api/IPeripheral.java
new file mode 100644
index 00000000..76d5a38f
--- /dev/null
+++ b/src/main/java/dan200/computer/api/IPeripheral.java
@@ -0,0 +1,106 @@
+/**
+ * This file is part of the public ComputerCraft API - http://www.computercraft.info
+ * Copyright Daniel Ratcliffe, 2011-2013. This API may be redistributed unmodified and in full only.
+ * For help using the API, and posting your mods, visit the forums at computercraft.info.
+ */
+
+package dan200.computer.api;
+
+/**
+ * The interface that defines a peripheral. This should be implemented by the
+ * TileEntity of any block that you wish to be interacted with by
+ * computer or turtle.
+ */
+public interface IPeripheral
+{
+ /**
+ * Should return a string that uniquely identifies this type of peripheral.
+ * This can be queried from lua by calling peripheral.getType()
+ * @return A string identifying the type of peripheral.
+ */
+ public String getType();
+
+ /**
+ * Should return an array of strings that identify the methods that this
+ * peripheral exposes to Lua. This will be called once before each attachment,
+ * and should not change when called multiple times.
+ * @return An array of strings representing method names.
+ * @see #callMethod
+ */
+ public String[] getMethodNames();
+
+ /**
+ * This is called when a lua program on an attached computer calls peripheral.call() with
+ * one of the methods exposed by getMethodNames().
+ *
+ * Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
+ * when interacting with minecraft objects.
+ * @param computer The interface to the computer that is making the call. Remember that multiple
+ * computers can be attached to a peripheral at once.
+ * @param context The context of the currently running lua thread. This can be used to wait for events
+ * or otherwise yield.
+ * @param method An integer identifying which of the methods from getMethodNames() the computer
+ * wishes to call. The integer indicates the index into the getMethodNames() table
+ * that corresponds to the string passed into peripheral.call()
+ * @param arguments An array of objects, representing the arguments passed into peripheral.call().
+ * Lua values of type "string" will be represented by Object type String.
+ * Lua values of type "number" will be represented by Object type Double.
+ * Lua values of type "boolean" will be represented by Object type Boolean.
+ * Lua values of any other type will be represented by a null object.
+ * This array will be empty if no arguments are passed.
+ * @return An array of objects, representing values you wish to return to the lua program.
+ * Integers, Doubles, Floats, Strings, Booleans and null be converted to their corresponding lua type.
+ * All other types will be converted to nil.
+ * You may return null to indicate no values should be returned.
+ * @throws Exception If you throw any exception from this function, a lua error will be raised with the
+ * same message as your exception. Use this to throw appropriate errors if the wrong
+ * arguments are supplied to your method.
+ * @see #getMethodNames
+ */
+ public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws Exception;
+
+ /**
+ * Is called before the computer attempts to attach to the peripheral, and should return whether to allow
+ * the attachment. Use this to restrict the number of computers that can attach, or to limit attachments to
+ * certain world directions.
+ * If true is returned, attach() will be called shortly afterwards, and the computer will be able to make method calls.
+ * If false is returned, attach() will not be called, and the peripheral will be invisible to the computer.
+ * @param side The world direction (0=bottom, 1=top, etc) that the computer lies relative to the peripheral.
+ * @return Whether to allow the attachment, as a boolean.
+ * @see #attach
+ */
+ public boolean canAttachToSide( int side );
+
+ /**
+ * Is called when canAttachToSide has returned true, and a computer is attaching to the peripheral.
+ * This will occur when a peripheral is placed next to an active computer, when a computer is turned on next to a peripheral,
+ * or when a turtle travels into a square next to a peripheral.
+ * Between calls to attach() and detach(), the attached computer can make method calls on the peripheral using peripheral.call().
+ * This method can be used to keep track of which computers are attached to the peripheral, or to take action when attachment
+ * occurs.
+ *
+ * Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
+ * when interacting with minecraft objects.
+ * @param computer The interface to the computer that is being attached. Remember that multiple
+ * computers can be attached to a peripheral at once.
+ * @see #canAttachToSide
+ * @see #detach
+ */
+ public void attach( IComputerAccess computer );
+
+ /**
+ * Is called when a computer is detaching from the peripheral.
+ * This will occur when a computer shuts down, when the peripheral is removed while attached to computers,
+ * or when a turtle moves away from a square attached to a peripheral.
+ * This method can be used to keep track of which computers are attached to the peripheral, or to take action when detachment
+ * occurs.
+ *
+ * Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
+ * when interacting with minecraft objects.
+ * @param computer The interface to the computer that is being detached. Remember that multiple
+ * computers can be attached to a peripheral at once.
+ * @see #canAttachToSide
+ * @see #detach
+ */
+ public void detach( IComputerAccess computer );
+}
diff --git a/src/main/java/dan200/computer/api/IPeripheralHandler.java b/src/main/java/dan200/computer/api/IPeripheralHandler.java
new file mode 100644
index 00000000..363ae2ea
--- /dev/null
+++ b/src/main/java/dan200/computer/api/IPeripheralHandler.java
@@ -0,0 +1,17 @@
+/**
+ * This file is part of the public ComputerCraft API - http://www.computercraft.info
+ * Copyright Daniel Ratcliffe, 2011-2013. This API may be redistributed unmodified and in full only.
+ * For help using the API, and posting your mods, visit the forums at computercraft.info.
+ */
+
+package dan200.computer.api;
+
+import net.minecraft.tileentity.TileEntity;
+
+/**
+ * TODO: Document me
+ */
+public interface IPeripheralHandler
+{
+ public IHostedPeripheral getPeripheral( TileEntity tile );
+}
diff --git a/src/main/java/dan200/computer/api/IWritableMount.java b/src/main/java/dan200/computer/api/IWritableMount.java
new file mode 100644
index 00000000..05d3c01d
--- /dev/null
+++ b/src/main/java/dan200/computer/api/IWritableMount.java
@@ -0,0 +1,54 @@
+/**
+ * This file is part of the public ComputerCraft API - http://www.computercraft.info
+ * Copyright Daniel Ratcliffe, 2011-2013. This API may be redistributed unmodified and in full only.
+ * For help using the API, and posting your mods, visit the forums at computercraft.info.
+ */
+
+package dan200.computer.api;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.minecraft.world.World;
+
+/**
+ * Represents a part of a virtual filesystem that can be mounted onto a computer using IComputerAccess.mount() or IComputerAccess.mountWritable(), that can also be written to.
+ * Ready made implementations of this interface can be created using ComputerCraftAPI.createSaveDirMount(), or you're free to implement it yourselves!
+ * @see ComputerCraftAPI#createSaveDirMount(World, String)
+ * @see IComputerAccess#mountWritable(String, IMount)
+ * @see IMount
+ */
+public interface IWritableMount extends IMount
+{
+ /**
+ * Creates a directory at a given path inside the virtual file system.
+ * @param path A file path in normalised format, relative to the mount location. ie: "programs/mynewprograms"
+ */
+ public void makeDirectory( String path ) throws IOException;
+
+ /**
+ * Deletes a directory at a given path inside the virtual file system.
+ * @param path A file path in normalised format, relative to the mount location. ie: "programs/myoldprograms"
+ */
+ public void delete( String path ) throws IOException;
+
+ /**
+ * Opens a file with a given path, and returns an outputstream for writing to it.
+ * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
+ * @return a stream for writing to
+ */
+ public OutputStream openForWrite( String path ) throws IOException;
+
+ /**
+ * Opens a file with a given path, and returns an outputstream for appending to it.
+ * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
+ * @return a stream for writing to
+ */
+ public OutputStream openForAppend( String path ) throws IOException;
+
+ /**
+ * Get the ammount of free space on the mount, in bytes. You should decrease this value as the user writes to the mount, and write operations should fail once it reaches zero.
+ * @return The ammount of free space, in bytes.
+ */
+ public long getRemainingSpace() throws IOException;
+}
diff --git a/src/main/java/ic2/api/energy/event/EnergyTileEvent.java b/src/main/java/ic2/api/energy/event/EnergyTileEvent.java
new file mode 100644
index 00000000..0c9d9c1d
--- /dev/null
+++ b/src/main/java/ic2/api/energy/event/EnergyTileEvent.java
@@ -0,0 +1,21 @@
+package ic2.api.energy.event;
+
+import ic2.api.energy.tile.IEnergyTile;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.event.world.WorldEvent;
+
+/**
+ * Base class for energy net events, don't use it directly.
+ *
+ * See ic2/api/energy/usage.txt for an overall description of the energy net api.
+ */
+public class EnergyTileEvent extends WorldEvent {
+ public final IEnergyTile energyTile;
+
+ public EnergyTileEvent(IEnergyTile energyTile) {
+ super(((TileEntity) energyTile).worldObj);
+
+ this.energyTile = energyTile;
+ }
+}
+
diff --git a/src/main/java/ic2/api/energy/event/EnergyTileLoadEvent.java b/src/main/java/ic2/api/energy/event/EnergyTileLoadEvent.java
new file mode 100644
index 00000000..6974e39b
--- /dev/null
+++ b/src/main/java/ic2/api/energy/event/EnergyTileLoadEvent.java
@@ -0,0 +1,26 @@
+package ic2.api.energy.event;
+
+import ic2.api.energy.tile.IEnergyTile;
+
+/**
+ * Event announcing new energy tiles.
+ *
+ * This event notifies subscribers of loaded energy tiles, e.g. after getting
+ * loaded through the chunk they are in or after being placed down by the
+ * player or another deployer mechanism.
+ *
+ * Every energy tile which wants to get connected to the IC2 Energy Network has
+ * to either post this event or alternatively call EnergyNet.addTileEntity().
+ *
+ * You may use this event to build a static representation of energy tiles for
+ * your own energy grid implementation if you need to. It's not required if you
+ * always lookup energy paths on demand.
+ *
+ * See ic2/api/energy/usage.txt for an overall description of the energy net api.
+ */
+public class EnergyTileLoadEvent extends EnergyTileEvent {
+ public EnergyTileLoadEvent(IEnergyTile energyTile) {
+ super(energyTile);
+ }
+}
+
diff --git a/src/main/java/ic2/api/energy/event/EnergyTileUnloadEvent.java b/src/main/java/ic2/api/energy/event/EnergyTileUnloadEvent.java
new file mode 100644
index 00000000..63b3bd08
--- /dev/null
+++ b/src/main/java/ic2/api/energy/event/EnergyTileUnloadEvent.java
@@ -0,0 +1,27 @@
+package ic2.api.energy.event;
+
+import ic2.api.energy.tile.IEnergyTile;
+
+/**
+ * Event announcing terminated energy tiles.
+ *
+ * This event notifies subscribers of unloaded energy tiles, e.g. after getting
+ * unloaded through the chunk they are in or after being destroyed by the
+ * player or another block pick/destruction mechanism.
+ *
+ * Every energy tile which wants to get disconnected from the IC2 Energy
+ * Network has to either post this event or alternatively call
+ * EnergyNet.removeTileEntity().
+ *
+ * You may use this event to build a static representation of energy tiles for
+ * your own energy grid implementation if you need to. It's not required if you
+ * always lookup energy paths on demand.
+ *
+ * See ic2/api/energy/usage.txt for an overall description of the energy net api.
+ */
+public class EnergyTileUnloadEvent extends EnergyTileEvent {
+ public EnergyTileUnloadEvent(IEnergyTile energyTile) {
+ super(energyTile);
+ }
+}
+
diff --git a/src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java b/src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java
new file mode 100644
index 00000000..56e2092b
--- /dev/null
+++ b/src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java
@@ -0,0 +1,26 @@
+package ic2.api.energy.tile;
+
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.ForgeDirection;
+
+/**
+ * For internal/multi-block usage only.
+ *
+ * @see IEnergySink
+ * @see IEnergyConductor
+ *
+ * See ic2/api/energy/usage.txt for an overall description of the energy net api.
+ */
+public interface IEnergyAcceptor extends IEnergyTile {
+ /**
+ * Determine if this acceptor can accept current from an adjacent emitter in a direction.
+ *
+ * The TileEntity in the emitter parameter is what was originally added to the energy net,
+ * which may be normal in-world TileEntity, a delegate or an IMetaDelegate.
+ *
+ * @param emitter energy emitter
+ * @param direction direction the energy is being received from
+ */
+ boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction);
+}
+
diff --git a/src/main/java/ic2/api/energy/tile/IEnergySink.java b/src/main/java/ic2/api/energy/tile/IEnergySink.java
new file mode 100644
index 00000000..fcaebbe7
--- /dev/null
+++ b/src/main/java/ic2/api/energy/tile/IEnergySink.java
@@ -0,0 +1,46 @@
+package ic2.api.energy.tile;
+
+import net.minecraftforge.common.ForgeDirection;
+
+/**
+ * Allows a tile entity (mostly a machine) to receive energy.
+ *
+ * See ic2/api/energy/usage.txt for an overall description of the energy net api.
+ */
+public interface IEnergySink extends IEnergyAcceptor {
+ /**
+ * Determine how much energy the sink accepts.
+ *
+ * This value is unrelated to getMaxSafeInput().
+ *
+ * Make sure that injectEnergy() does accepts energy if demandsEnergy() returns anything > 0.
+ *
+ * @return max accepted input in eu
+ */
+ double demandedEnergyUnits();
+
+ /**
+ * Transfer energy to the sink.
+ *
+ * It's highly recommended to accept all energy by letting the internal buffer overflow to
+ * increase the performance and accuracy of the distribution simulation.
+ *
+ * @param directionFrom direction from which the energy comes from
+ * @param amount energy to be transferred
+ * @return Energy not consumed (leftover)
+ */
+ double injectEnergyUnits(ForgeDirection directionFrom, double amount);
+
+ /**
+ * Determine the amount of eu which can be safely injected into the specific energy sink without exploding.
+ *
+ * Typical values are 32 for LV, 128 for MV, 512 for HV and 2048 for EV. A value of Integer.MAX_VALUE indicates no
+ * limit.
+ *
+ * This value is unrelated to demandsEnergy().
+ *
+ * @return max safe input in eu
+ */
+ int getMaxSafeInput();
+}
+
diff --git a/src/main/java/ic2/api/energy/tile/IEnergyTile.java b/src/main/java/ic2/api/energy/tile/IEnergyTile.java
new file mode 100644
index 00000000..655a14f0
--- /dev/null
+++ b/src/main/java/ic2/api/energy/tile/IEnergyTile.java
@@ -0,0 +1,14 @@
+package ic2.api.energy.tile;
+
+/**
+ * For internal usage only, base class for all energy tiles.
+ *
+ * @see IEnergySink
+ * @see IEnergySource
+ * @see IEnergyConductor
+ *
+ * See ic2/api/energy/usage.txt for an overall description of the energy net api.
+ */
+public interface IEnergyTile {
+}
+
diff --git a/src/main/java/vazkii/tinkerer/client/core/handler/ClientTickHandler.java b/src/main/java/vazkii/tinkerer/client/core/handler/ClientTickHandler.java
new file mode 100644
index 00000000..3164a3d2
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/core/handler/ClientTickHandler.java
@@ -0,0 +1,68 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [13 Sep 2013, 15:00:40 (GMT)]
+ */
+package vazkii.tinkerer.client.core.handler;
+
+import java.util.EnumSet;
+
+import net.minecraft.client.Minecraft;
+import thaumcraft.api.research.ResearchItem;
+import thaumcraft.client.gui.GuiResearchRecipe;
+import vazkii.tinkerer.client.core.handler.kami.ToolModeHUDHandler;
+import vazkii.tinkerer.client.core.helper.ClientHelper;
+import vazkii.tinkerer.client.gui.GuiResearchPeripheral;
+import vazkii.tinkerer.common.core.handler.ConfigHandler;
+import vazkii.tinkerer.common.core.handler.EasymodeResearchHandler;
+import vazkii.tinkerer.common.lib.LibMisc;
+import vazkii.tinkerer.common.lib.LibResearch;
+import cpw.mods.fml.common.ITickHandler;
+import cpw.mods.fml.common.TickType;
+import cpw.mods.fml.relauncher.ReflectionHelper;
+
+public class ClientTickHandler implements ITickHandler {
+
+ public static int elapsedTicks;
+
+ @Override
+ public void tickStart(EnumSet type, Object... tickData) {
+ }
+
+ @Override
+ public void tickEnd(EnumSet type, Object... tickData) {
+ Minecraft mc = ClientHelper.minecraft();
+ if(mc.currentScreen != null && mc.currentScreen instanceof GuiResearchRecipe && !(mc.currentScreen instanceof GuiResearchPeripheral)) {
+ ResearchItem research = ReflectionHelper.getPrivateValue(GuiResearchRecipe.class, (GuiResearchRecipe) mc.currentScreen, 9);
+ if(research.key.equals(LibResearch.KEY_PERIPHERALS))
+ mc.displayGuiScreen(new GuiResearchPeripheral(research));
+ }
+
+ if(ConfigHandler.enableEasymodeResearch)
+ EasymodeResearchHandler.onPlayerTick(mc.thePlayer);
+
+ ToolModeHUDHandler.clientTick();
+
+ ++elapsedTicks;
+ }
+
+ @Override
+ public EnumSet ticks() {
+ return EnumSet.of(TickType.CLIENT);
+ }
+
+ @Override
+ public String getLabel() {
+ return LibMisc.MOD_NAME;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/core/handler/HUDHandler.java b/src/main/java/vazkii/tinkerer/client/core/handler/HUDHandler.java
new file mode 100644
index 00000000..49946ba8
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/core/handler/HUDHandler.java
@@ -0,0 +1,81 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [10 Sep 2013, 12:16:36 (GMT)]
+ */
+package vazkii.tinkerer.client.core.handler;
+
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.renderer.entity.RenderItem;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.client.event.RenderGameOverlayEvent;
+import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
+import net.minecraftforge.event.ForgeSubscribe;
+import thaumcraft.api.wands.IWandFocus;
+import thaumcraft.common.config.Config;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import vazkii.tinkerer.client.core.helper.ClientHelper;
+import vazkii.tinkerer.common.item.foci.ItemFocusDislocation;
+
+public final class HUDHandler {
+
+ RenderItem renderItem = new RenderItem();
+
+ @ForgeSubscribe
+ public void drawDislocationFocusHUD(RenderGameOverlayEvent.Post event) {
+ if(event.type == ElementType.HOTBAR && ClientHelper.minecraft().currentScreen == null) {
+ boolean up = !Config.dialBottom;
+ int xpos = 4;
+ int ypos = up ? 50 : event.resolution.getScaledHeight() - 70;
+
+ ItemStack item = ClientHelper.clientPlayer().getCurrentEquippedItem();
+ if(item != null && item.getItem() instanceof ItemWandCasting) {
+ ItemWandCasting wand = (ItemWandCasting) item.getItem();
+ wand.getFocusItem(item);
+ IWandFocus focus = wand.getFocus(item);
+
+ if(focus != null && focus instanceof ItemFocusDislocation) {
+ ItemStack pickedBlock = ((ItemFocusDislocation) focus).getPickedBlock(item);
+ if(pickedBlock != null) {
+ Gui.drawRect(xpos - 1, ypos - 1, xpos + 18, ypos + 18, 0x66000000);
+
+ FontRenderer font = ClientHelper.fontRenderer();
+ boolean unicode = font.getUnicodeFlag();
+ font.setUnicodeFlag(true);
+ String name = StatCollector.translateToLocal("ttmisc.focusDislocation.tooltip");
+ int strLength = font.getStringWidth(name);
+
+ Gui.drawRect(xpos + 18, ypos, xpos + 18 + strLength + 4, ypos + 9, 0x66000000);
+ font.drawStringWithShadow(name, xpos + 20, ypos, 0xFFAA00);
+
+ NBTTagCompound cmp = ((ItemFocusDislocation) focus).getStackTileEntity(item);
+ if(cmp != null && !cmp.hasNoTags()) {
+ String content = StatCollector.translateToLocal("ttmisc.focusDislocation.tooltipExtra");
+ font.getStringWidth(content);
+
+ Gui.drawRect(xpos + 18, ypos + 9, xpos + 18 + strLength + 4, ypos + 18, 0x66000000);
+ font.drawStringWithShadow(content, xpos + 20, ypos + 9, 0xFFAA00);
+ }
+
+ if(pickedBlock.getItem() != null)
+ renderItem.renderItemIntoGUI(font, ClientHelper.minecraft().renderEngine, pickedBlock, xpos, ypos);
+ font.setUnicodeFlag(unicode);
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/core/handler/LocalizationHandler.java b/src/main/java/vazkii/tinkerer/client/core/handler/LocalizationHandler.java
new file mode 100644
index 00000000..00345f7a
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/core/handler/LocalizationHandler.java
@@ -0,0 +1,27 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [4 Sep 2013, 17:03:43 (GMT)]
+ */
+package vazkii.tinkerer.client.core.handler;
+
+import vazkii.tinkerer.client.lib.LibResources;
+import cpw.mods.fml.common.registry.LanguageRegistry;
+
+public final class LocalizationHandler {
+
+ public static void loadLocalizations() {
+ for(String locale : LibResources.LANGS)
+ LanguageRegistry.instance().loadLocalization(LibResources.PREFIX_LANG + locale + ".lang", locale, false);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/core/handler/kami/PlacementMirrorPredictionRenderer.java b/src/main/java/vazkii/tinkerer/client/core/handler/kami/PlacementMirrorPredictionRenderer.java
new file mode 100644
index 00000000..df445b04
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/core/handler/kami/PlacementMirrorPredictionRenderer.java
@@ -0,0 +1,67 @@
+package vazkii.tinkerer.client.core.handler.kami;
+
+import java.util.List;
+
+import net.minecraft.block.Block;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ChunkCoordinates;
+import net.minecraft.world.World;
+import net.minecraftforge.client.event.RenderWorldLastEvent;
+import net.minecraftforge.event.ForgeSubscribe;
+
+import org.lwjgl.opengl.GL11;
+
+import vazkii.tinkerer.common.item.ModItems;
+import vazkii.tinkerer.common.item.kami.ItemPlacementMirror;
+
+public final class PlacementMirrorPredictionRenderer {
+
+ RenderBlocks blockRender = new RenderBlocks();
+
+ @ForgeSubscribe
+ public void onWorldRenderLast(RenderWorldLastEvent event) {
+ World world = Minecraft.getMinecraft().theWorld;
+ List playerEntities = world.playerEntities;
+ for(EntityPlayer player : playerEntities) {
+ ItemStack currentStack = player.getCurrentEquippedItem();
+ if(currentStack != null && currentStack.itemID == ModItems.placementMirror.itemID && ItemPlacementMirror.getBlockID(currentStack) != 0)
+ renderPlayerLook(player, currentStack);
+ }
+ }
+
+ private void renderPlayerLook(EntityPlayer player, ItemStack stack) {
+ ChunkCoordinates[] coords = ItemPlacementMirror.getBlocksToPlace(stack, player);
+ if(ItemPlacementMirror.hasBlocks(stack, player, coords)) {
+ ItemStack block = new ItemStack(ItemPlacementMirror.getBlockID(stack), 1, ItemPlacementMirror.getBlockMeta(stack));
+ ChunkCoordinates lastCoords = new ChunkCoordinates(0, 0, 0);
+
+ GL11.glPushMatrix();
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+
+ for(ChunkCoordinates coord : coords) {
+ renderBlockAt(block, coord, lastCoords);
+ lastCoords = coord;
+ }
+ GL11.glPopMatrix();
+ }
+ }
+
+ private void renderBlockAt(ItemStack block, ChunkCoordinates pos, ChunkCoordinates last) {
+ GL11.glPushMatrix();
+ GL11.glTranslated(pos.posX + 0.5 - RenderManager.renderPosX, pos.posY + 0.5 - RenderManager.renderPosY, pos.posZ + 0.5 - RenderManager.renderPosZ);
+
+ GL11.glColor4f(1F, 1F, 1F, 0.6F);
+ Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
+ blockRender.useInventoryTint = false;
+ blockRender.renderBlockAsItem(Block.blocksList[block.itemID], block.getItemDamage(), 1F);
+
+ GL11.glPopMatrix();
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/core/handler/kami/SoulHeartClientHandler.java b/src/main/java/vazkii/tinkerer/client/core/handler/kami/SoulHeartClientHandler.java
new file mode 100644
index 00000000..8e853801
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/core/handler/kami/SoulHeartClientHandler.java
@@ -0,0 +1,87 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 9:35:38 PM (GMT)]
+ */
+package vazkii.tinkerer.client.core.handler.kami;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.client.event.RenderGameOverlayEvent;
+import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
+import net.minecraftforge.event.ForgeSubscribe;
+
+import org.lwjgl.opengl.GL11;
+
+import vazkii.tinkerer.client.lib.LibResources;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public final class SoulHeartClientHandler {
+
+ private static final ResourceLocation iconsResource = new ResourceLocation("textures/gui/icons.png");
+ private static final ResourceLocation heartsResource = new ResourceLocation(LibResources.GUI_SOUL_HEARTS);
+
+ @SideOnly(Side.CLIENT)
+ public static int clientPlayerHP = 0;
+
+ @SideOnly(Side.CLIENT)
+ @ForgeSubscribe
+ public void renderHealthBar(RenderGameOverlayEvent event) {
+ if(event.type == ElementType.FOOD && clientPlayerHP > 0) {
+ if(event instanceof RenderGameOverlayEvent.Post) {
+ Minecraft mc = Minecraft.getMinecraft();
+
+ int x = event.resolution.getScaledWidth() / 2 + 10;
+ int y = event.resolution.getScaledHeight() - 39;
+
+ GL11.glTranslatef(0F, 10F, 0F);
+ mc.renderEngine.bindTexture(heartsResource);
+ int it = 0;
+ for(int i = 0; i < clientPlayerHP; i++) {
+ boolean half = i == clientPlayerHP - 1 && clientPlayerHP % 2 != 0;
+ if(half || i % 2 == 0) {
+ renderHeart(x + it * 8, y, !half);
+ it++;
+ }
+ }
+
+ mc.renderEngine.bindTexture(iconsResource);
+ }
+
+ GL11.glTranslatef(0F, -10F, 0F);
+ }
+
+ if(event.type == ElementType.AIR && event instanceof RenderGameOverlayEvent.Post && clientPlayerHP > 0)
+ GL11.glTranslatef(0F, 10F, 0F);
+ }
+
+ @SideOnly(Side.CLIENT)
+ private static void renderHeart(int x, int y, boolean full) {
+ Tessellator tess = Tessellator.instance;
+ float size = 1 / 16F;
+
+ float startX = full ? 0 : 9 * size;
+ float endX = full ? 9 * size : 1;
+ float startY = 0;
+ float endY = 9 * size;
+
+ tess.startDrawingQuads();
+ tess.addVertexWithUV(x, y + 9, 0, startX, endY);
+ tess.addVertexWithUV(x + (full ? 9 : 7), y + 9, 0, endX, endY);
+ tess.addVertexWithUV(x + (full ? 9 : 7), y, 0, endX, startY);
+ tess.addVertexWithUV(x, y, 0, startX, startY);
+ tess.draw();
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/client/core/handler/kami/ToolModeHUDHandler.java b/src/main/java/vazkii/tinkerer/client/core/handler/kami/ToolModeHUDHandler.java
new file mode 100644
index 00000000..e35c97c0
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/core/handler/kami/ToolModeHUDHandler.java
@@ -0,0 +1,81 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 11:38:29 PM (GMT)]
+ */
+package vazkii.tinkerer.client.core.handler.kami;
+
+import java.awt.Color;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.util.MathHelper;
+import net.minecraftforge.client.event.RenderGameOverlayEvent;
+import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
+import net.minecraftforge.event.ForgeSubscribe;
+
+import org.lwjgl.opengl.GL11;
+
+import vazkii.tinkerer.client.core.handler.ClientTickHandler;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public final class ToolModeHUDHandler {
+
+ private static String currentTooltip;
+ private static int tooltipDisplayTicks;
+
+ @ForgeSubscribe
+ @SideOnly(Side.CLIENT)
+ public void drawDislocationFocusHUD(RenderGameOverlayEvent.Post event) {
+ if (event.type == ElementType.ALL && tooltipDisplayTicks > 0 && !MathHelper.stringNullOrLengthZero(currentTooltip)) {
+ Minecraft mc = Minecraft.getMinecraft();
+ ScaledResolution var5 = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
+ int var6 = var5.getScaledWidth();
+ int var7 = var5.getScaledHeight();
+ FontRenderer var8 = mc.fontRenderer;
+
+ int tooltipStartX = (var6 - var8.getStringWidth(currentTooltip)) / 2;
+ int tooltipStartY = var7 - 72;
+
+ int opacity = (int) (tooltipDisplayTicks * 256.0F / 10.0F);
+
+ if (opacity > 160)
+ opacity = 160;
+
+ if (opacity > 0) {
+ GL11.glPushMatrix();
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ int color = Color.getHSBColor((float) Math.cos(ClientTickHandler.elapsedTicks / 25D), 0.6F, 1F).getRGB();
+ var8.drawStringWithShadow(currentTooltip, tooltipStartX, tooltipStartY, color + (opacity << 24));
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glPopMatrix();
+ }
+ }
+ }
+
+ public static void setTooltip(String tooltip) {
+ if(!tooltip.equals(currentTooltip)) {
+ currentTooltip = tooltip;
+ tooltipDisplayTicks = 20;
+ }
+ }
+
+ @SideOnly(Side.CLIENT)
+ public static void clientTick() {
+ if(tooltipDisplayTicks > 0)
+ --tooltipDisplayTicks;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/core/helper/ClientHelper.java b/src/main/java/vazkii/tinkerer/client/core/helper/ClientHelper.java
new file mode 100644
index 00000000..69ddf796
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/core/helper/ClientHelper.java
@@ -0,0 +1,115 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 18:11:25 (GMT)]
+ */
+package vazkii.tinkerer.client.core.helper;
+
+import java.util.List;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityClientPlayerMP;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.renderer.Tessellator;
+
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL12;
+
+public final class ClientHelper {
+
+ public static Minecraft minecraft() {
+ return Minecraft.getMinecraft();
+ }
+
+ public static FontRenderer fontRenderer() {
+ return minecraft().fontRenderer;
+ }
+
+ public static EntityClientPlayerMP clientPlayer() {
+ return minecraft().thePlayer;
+ }
+
+ public static void renderTooltip(int x, int y, List tooltipData) {
+ int color = 0x505000ff;
+ int color2 = 0xf0100010;
+
+ GL11.glDisable(GL12.GL_RESCALE_NORMAL);
+ net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
+ GL11.glDisable(GL11.GL_LIGHTING);
+ GL11.glDisable(GL11.GL_DEPTH_TEST);
+
+ if (!tooltipData.isEmpty()) {
+ int var5 = 0;
+ int var6;
+ int var7;
+ FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
+ for (var6 = 0; var6 < tooltipData.size(); ++var6) {
+ var7 = fontRenderer.getStringWidth(tooltipData.get(var6));
+ if (var7 > var5)
+ var5 = var7;
+ }
+ var6 = x + 12;
+ var7 = y - 12;
+ int var9 = 8;
+ if (tooltipData.size() > 1)
+ var9 += 2 + (tooltipData.size() - 1) * 10;
+ float z = 300.0F;
+ drawGradientRect(var6 - 3, var7 - 4, z, var6 + var5 + 3, var7 - 3, color2, color2);
+ drawGradientRect(var6 - 3, var7 + var9 + 3, z, var6 + var5 + 3, var7 + var9 + 4, color2, color2);
+ drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 + var9 + 3, color2, color2);
+ drawGradientRect(var6 - 4, var7 - 3, z, var6 - 3, var7 + var9 + 3, color2, color2);
+ drawGradientRect(var6 + var5 + 3, var7 - 3, z, var6 + var5 + 4, var7 + var9 + 3, color2, color2);
+ int var12 = (color & 0xFFFFFF) >> 1 | color & -16777216;
+ drawGradientRect(var6 - 3, var7 - 3 + 1, z, var6 - 3 + 1, var7 + var9 + 3 - 1, color, var12);
+ drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, z, var6 + var5 + 3, var7 + var9 + 3 - 1, color, var12);
+ drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 - 3 + 1, color, color);
+ drawGradientRect(var6 - 3, var7 + var9 + 2, z, var6 + var5 + 3, var7 + var9 + 3, var12, var12);
+ for (int var13 = 0; var13 < tooltipData.size(); ++var13) {
+ String var14 = tooltipData.get(var13);
+ fontRenderer.drawStringWithShadow(var14, var6, var7, -1);
+ if (var13 == 0)
+ var7 += 2;
+ var7 += 10;
+ }
+ }
+ }
+
+ public static void drawGradientRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) {
+ float var7 = (par5 >> 24 & 255) / 255.0F;
+ float var8 = (par5 >> 16 & 255) / 255.0F;
+ float var9 = (par5 >> 8 & 255) / 255.0F;
+ float var10 = (par5 & 255) / 255.0F;
+ float var11 = (par6 >> 24 & 255) / 255.0F;
+ float var12 = (par6 >> 16 & 255) / 255.0F;
+ float var13 = (par6 >> 8 & 255) / 255.0F;
+ float var14 = (par6 & 255) / 255.0F;
+ GL11.glDisable(GL11.GL_TEXTURE_2D);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glDisable(GL11.GL_ALPHA_TEST);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GL11.glShadeModel(GL11.GL_SMOOTH);
+ Tessellator var15 = Tessellator.instance;
+ var15.startDrawingQuads();
+ var15.setColorRGBA_F(var8, var9, var10, var7);
+ var15.addVertex(par3, par2, z);
+ var15.addVertex(par1, par2, z);
+ var15.setColorRGBA_F(var12, var13, var14, var11);
+ var15.addVertex(par1, par4, z);
+ var15.addVertex(par3, par4, z);
+ var15.draw();
+ GL11.glShadeModel(GL11.GL_FLAT);
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glEnable(GL11.GL_ALPHA_TEST);
+ GL11.glEnable(GL11.GL_TEXTURE_2D);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/core/helper/IconHelper.java b/src/main/java/vazkii/tinkerer/client/core/helper/IconHelper.java
new file mode 100644
index 00000000..1a8b5ac8
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/core/helper/IconHelper.java
@@ -0,0 +1,63 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 15:47:08 (GMT)]
+ */
+package vazkii.tinkerer.client.core.helper;
+
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.item.Item;
+import net.minecraft.util.Icon;
+import vazkii.tinkerer.client.lib.LibResources;
+
+public class IconHelper {
+
+ private static Icon emptyTexture;
+
+ public static Icon forName(IconRegister ir, String name) {
+ return ir.registerIcon(LibResources.PREFIX_MOD + name);
+ }
+
+ public static Icon forNameRaw(IconRegister ir, String name) {
+ return ir.registerIcon(name);
+ }
+
+ public static Icon emptyTexture(IconRegister ir) {
+ return emptyTexture == null ? (emptyTexture = forName(ir, LibResources.EMTPY_TEXTURE)) : emptyTexture;
+ }
+
+ public static Icon forBlock(IconRegister ir, Block block) {
+ return forNameRaw(ir, block.getUnlocalizedName().replaceAll("tile.", ""));
+ }
+
+ public static Icon forBlock(IconRegister ir, Block block, int i) {
+ return forBlock(ir, block, Integer.toString(i));
+ }
+
+ public static Icon forBlock(IconRegister ir, Block block, String s) {
+ return forNameRaw(ir, block.getUnlocalizedName().replaceAll("tile.", "") + s);
+ }
+
+ public static Icon forItem(IconRegister ir, Item item) {
+ return forNameRaw(ir, item.getUnlocalizedName().replaceAll("item.", ""));
+ }
+
+ public static Icon forItem(IconRegister ir, Item item, int i) {
+ return forItem(ir, item, Integer.toString(i));
+ }
+
+ public static Icon forItem(IconRegister ir, Item item, String s) {
+ return forNameRaw(ir, item.getUnlocalizedName().replaceAll("item.", "") + s);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/core/proxy/TTClientProxy.java b/src/main/java/vazkii/tinkerer/client/core/proxy/TTClientProxy.java
new file mode 100644
index 00000000..9946dc58
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/core/proxy/TTClientProxy.java
@@ -0,0 +1,141 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [4 Sep 2013, 16:33:54 (GMT)]
+ */
+package vazkii.tinkerer.client.core.proxy;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.world.World;
+import net.minecraftforge.client.EnumHelperClient;
+import net.minecraftforge.client.MinecraftForgeClient;
+import net.minecraftforge.common.MinecraftForge;
+import vazkii.tinkerer.client.core.handler.ClientTickHandler;
+import vazkii.tinkerer.client.core.handler.HUDHandler;
+import vazkii.tinkerer.client.core.handler.LocalizationHandler;
+import vazkii.tinkerer.client.core.handler.kami.PlacementMirrorPredictionRenderer;
+import vazkii.tinkerer.client.core.handler.kami.SoulHeartClientHandler;
+import vazkii.tinkerer.client.core.handler.kami.ToolModeHUDHandler;
+import vazkii.tinkerer.client.core.helper.ClientHelper;
+import vazkii.tinkerer.client.lib.LibRenderIDs;
+import vazkii.tinkerer.client.render.block.RenderMagnet;
+import vazkii.tinkerer.client.render.block.RenderRepairer;
+import vazkii.tinkerer.client.render.block.kami.RenderWarpGate;
+import vazkii.tinkerer.client.render.item.kami.RenderPlacementMirror;
+import vazkii.tinkerer.client.render.tile.RenderTileAnimationTablet;
+import vazkii.tinkerer.client.render.tile.RenderTileEnchanter;
+import vazkii.tinkerer.client.render.tile.RenderTileFunnel;
+import vazkii.tinkerer.client.render.tile.RenderTileMagnet;
+import vazkii.tinkerer.client.render.tile.RenderTileRepairer;
+import vazkii.tinkerer.client.render.tile.kami.RenderTileWarpGate;
+import vazkii.tinkerer.common.block.tile.TileEnchanter;
+import vazkii.tinkerer.common.block.tile.TileFunnel;
+import vazkii.tinkerer.common.block.tile.TileMagnet;
+import vazkii.tinkerer.common.block.tile.TileRepairer;
+import vazkii.tinkerer.common.block.tile.kami.TileWarpGate;
+import vazkii.tinkerer.common.block.tile.tablet.TileAnimationTablet;
+import vazkii.tinkerer.common.core.handler.ConfigHandler;
+import vazkii.tinkerer.common.core.proxy.TTCommonProxy;
+import vazkii.tinkerer.common.item.ModItems;
+import vazkii.tinkerer.common.item.kami.foci.ItemFocusShadowbeam;
+import cpw.mods.fml.client.registry.ClientRegistry;
+import cpw.mods.fml.client.registry.RenderingRegistry;
+import cpw.mods.fml.common.event.FMLInitializationEvent;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import cpw.mods.fml.common.registry.TickRegistry;
+import cpw.mods.fml.relauncher.Side;
+
+public class TTClientProxy extends TTCommonProxy {
+
+ public static EnumRarity kamiRarity;
+
+ @Override
+ public void preInit(FMLPreInitializationEvent event) {
+ super.preInit(event);
+
+ if(ConfigHandler.enableKami)
+ kamiRarity = EnumHelperClient.addRarity("KAMI", 0x6, "Kami");
+ }
+
+ @Override
+ public void init(FMLInitializationEvent event) {
+ super.init(event);
+
+ LocalizationHandler.loadLocalizations();
+ MinecraftForge.EVENT_BUS.register(new HUDHandler());
+ TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);
+ registerTiles();
+ registerRenderIDs();
+
+ if(ConfigHandler.enableKami) {
+ MinecraftForge.EVENT_BUS.register(new SoulHeartClientHandler());
+ MinecraftForge.EVENT_BUS.register(new ToolModeHUDHandler());
+ if(ConfigHandler.showPlacementMirrorBlocks)
+ MinecraftForge.EVENT_BUS.register(new PlacementMirrorPredictionRenderer());
+ }
+ }
+
+ private void registerTiles() {
+ ClientRegistry.bindTileEntitySpecialRenderer(TileAnimationTablet.class, new RenderTileAnimationTablet());
+ ClientRegistry.bindTileEntitySpecialRenderer(TileMagnet.class, new RenderTileMagnet());
+ ClientRegistry.bindTileEntitySpecialRenderer(TileEnchanter.class, new RenderTileEnchanter());
+ ClientRegistry.bindTileEntitySpecialRenderer(TileFunnel.class, new RenderTileFunnel());
+ ClientRegistry.bindTileEntitySpecialRenderer(TileRepairer.class, new RenderTileRepairer());
+
+ if(ConfigHandler.enableKami) {
+ ClientRegistry.bindTileEntitySpecialRenderer(TileWarpGate.class, new RenderTileWarpGate());
+ }
+ }
+
+ private void registerRenderIDs() {
+ LibRenderIDs.idMagnet = RenderingRegistry.getNextAvailableRenderId();
+ LibRenderIDs.idRepairer = RenderingRegistry.getNextAvailableRenderId();
+
+ RenderingRegistry.registerBlockHandler(new RenderMagnet());
+ RenderingRegistry.registerBlockHandler(new RenderRepairer());
+
+ if(ConfigHandler.enableKami) {
+ MinecraftForgeClient.registerItemRenderer(ModItems.placementMirror.itemID, new RenderPlacementMirror());
+
+ LibRenderIDs.idWarpGate = RenderingRegistry.getNextAvailableRenderId();
+
+ RenderingRegistry.registerBlockHandler(new RenderWarpGate());
+ }
+ }
+
+ @Override
+ public void shadowSparkle(World world, float x, float y, float z, int size) {
+ ItemFocusShadowbeam.Particle particle = new ItemFocusShadowbeam.Particle(world, x, y, z, 1.5F, 0, size);
+ ClientHelper.minecraft().effectRenderer.addEffect(particle);
+ }
+
+ @Override
+ protected void initCCPeripherals() {
+ try {
+ super.initCCPeripherals();
+ } catch(Throwable e) {
+ System.out.println("Thaumic Tinkerer: ComputerCraft not found.");
+ }
+ }
+
+ @Override
+ public boolean isClient() {
+ return true;
+ }
+
+ @Override
+ public EntityPlayer getClientPlayer() {
+ return ClientHelper.clientPlayer();
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/gui/GuiAnimationTablet.java b/src/main/java/vazkii/tinkerer/client/gui/GuiAnimationTablet.java
new file mode 100644
index 00000000..39af1223
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/GuiAnimationTablet.java
@@ -0,0 +1,96 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 16:31:14 (GMT)]
+ */
+package vazkii.tinkerer.client.gui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+import org.lwjgl.opengl.GL11;
+
+import vazkii.tinkerer.client.gui.button.GuiButtonAT;
+import vazkii.tinkerer.client.gui.button.GuiButtonATRadio;
+import vazkii.tinkerer.client.gui.button.IRadioButton;
+import vazkii.tinkerer.client.lib.LibResources;
+import vazkii.tinkerer.common.block.tile.container.ContainerAnimationTablet;
+import vazkii.tinkerer.common.block.tile.tablet.TileAnimationTablet;
+import vazkii.tinkerer.common.network.PacketManager;
+import vazkii.tinkerer.common.network.packet.PacketTabletButton;
+import cpw.mods.fml.common.network.PacketDispatcher;
+
+public class GuiAnimationTablet extends GuiContainer {
+
+ private static final ResourceLocation gui = new ResourceLocation(LibResources.GUI_ANIMATION_TABLET);
+
+ int x, y;
+
+ TileAnimationTablet tablet;
+ List buttonListAT = new ArrayList();
+ List radioButtons = new ArrayList();
+
+ public GuiAnimationTablet(TileAnimationTablet tablet, InventoryPlayer playerInv) {
+ super(new ContainerAnimationTablet(tablet, playerInv));
+ this.tablet = tablet;
+ }
+
+ @Override
+ public void initGui() {
+ super.initGui();
+ x = (width - xSize) / 2;
+ y = (height - ySize) / 2;
+ buttonListAT.clear();
+ addButton(new GuiButtonAT(0, x + xSize / 2 - 7, y + 60, tablet.redstone));
+ addButton(new GuiButtonATRadio(1, x + 52, y + 15, tablet.leftClick, radioButtons));
+ addButton(new GuiButtonATRadio(2, x + 111, y + 15, !tablet.leftClick, radioButtons));
+ buttonList = buttonListAT;
+ }
+
+ private void addButton(GuiButtonAT button) {
+ buttonListAT.add(button);
+ if(button instanceof IRadioButton)
+ radioButtons.add((IRadioButton) button);
+ }
+
+ @Override
+ protected void actionPerformed(GuiButton par1GuiButton) {
+ if(par1GuiButton instanceof IRadioButton)
+ ((IRadioButton) par1GuiButton).enableFromClick();
+ else buttonListAT.get(0).enabled = !buttonListAT.get(0).enabled;
+
+ tablet.leftClick = buttonListAT.get(1).enabled;
+ tablet.redstone = buttonListAT.get(0).enabled;
+
+ PacketDispatcher.sendPacketToServer(PacketManager.buildPacket(new PacketTabletButton(tablet)));
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ mc.renderEngine.bindTexture(gui);
+ drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ String left = StatCollector.translateToLocal("ttmisc.leftClick");
+ String right = StatCollector.translateToLocal("ttmisc.rightClick");
+ String redstone = StatCollector.translateToLocal("ttmisc.redstoneControl");
+ fontRenderer.drawString(left, x + 48 - fontRenderer.getStringWidth(left), y + 18, 0x999999);
+ fontRenderer.drawString(right, x + 128, y + 18, 0x999999);
+ fontRenderer.drawString(redstone, x + xSize / 2 - fontRenderer.getStringWidth(redstone) / 2, y + 50, 0x999999);
+ GL11.glColor3f(1F, 1F, 1F);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/client/gui/GuiAspectAnalyzer.java b/src/main/java/vazkii/tinkerer/client/gui/GuiAspectAnalyzer.java
new file mode 100644
index 00000000..c27068c3
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/GuiAspectAnalyzer.java
@@ -0,0 +1,100 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 11, 2013, 10:46:14 PM (GMT)]
+ */
+package vazkii.tinkerer.client.gui;
+
+import java.util.Arrays;
+import java.util.List;
+
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+
+import org.lwjgl.opengl.GL11;
+
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.client.lib.UtilsFX;
+import thaumcraft.common.Thaumcraft;
+import thaumcraft.common.lib.ThaumcraftCraftingManager;
+import thaumcraft.common.lib.research.ScanManager;
+import vazkii.tinkerer.client.core.helper.ClientHelper;
+import vazkii.tinkerer.client.lib.LibResources;
+import vazkii.tinkerer.common.block.tile.TileAspectAnalyzer;
+import vazkii.tinkerer.common.block.tile.container.ContainerAspectAnalyzer;
+
+public class GuiAspectAnalyzer extends GuiContainer {
+
+ private static final ResourceLocation gui = new ResourceLocation(LibResources.GUI_ASPECT_ANALYZER);
+
+ int x, y;
+ TileAspectAnalyzer analyzer;
+ Aspect aspectHovered = null;
+
+ public GuiAspectAnalyzer(TileAspectAnalyzer analyzer, InventoryPlayer inv) {
+ super(new ContainerAspectAnalyzer(analyzer, inv));
+ this.analyzer = analyzer;
+ }
+
+ @Override
+ public void initGui() {
+ super.initGui();
+ x = (width - xSize) / 2;
+ y = (height - ySize) / 2;
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) {
+ aspectHovered = null;
+
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ mc.renderEngine.bindTexture(gui);
+ drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+
+ ItemStack stack = analyzer.getStackInSlot(0);
+ if(stack != null) {
+ String h = ScanManager.generateItemHash(stack.itemID, stack.getItemDamage());
+
+ List list = Thaumcraft.proxy.getScannedObjects().get(ClientHelper.clientPlayer().username);
+ if (h != null && list != null && (list.contains("@" + h) || list.contains("#" + h))) {
+ AspectList tags = ThaumcraftCraftingManager.getObjectTags(stack);
+ tags = ThaumcraftCraftingManager.getBonusTags(stack, tags);
+ if (tags != null) {
+ int i = 0;
+ for(Aspect aspect : tags.getAspectsSortedAmount()) {
+ int x = this.x + 20 + i * 18;
+ int y = this.y + 58;
+ UtilsFX.drawTag(x, y, aspect, tags.getAmount(aspect), 0, zLevel);
+
+ if(mx > x && mx < x + 16 && my > y && my < y + 16)
+ aspectHovered = aspect;
+
+ i++;
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int mx, int my) {
+ if(aspectHovered != null)
+ ClientHelper.renderTooltip(mx - x, my - y, Arrays.asList(EnumChatFormatting.AQUA + aspectHovered.getName(), EnumChatFormatting.GRAY + aspectHovered.getLocalizedDescription()));
+
+ super.drawGuiContainerForegroundLayer(mx, my);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/gui/GuiEnchanting.java b/src/main/java/vazkii/tinkerer/client/gui/GuiEnchanting.java
new file mode 100644
index 00000000..a656f554
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/GuiEnchanting.java
@@ -0,0 +1,248 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [15 Sep 2013, 00:58:22 (GMT)]
+ */
+package vazkii.tinkerer.client.gui;
+
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+
+import org.lwjgl.opengl.GL11;
+
+import thaumcraft.api.aspects.Aspect;
+import vazkii.tinkerer.client.core.helper.ClientHelper;
+import vazkii.tinkerer.client.gui.button.GuiButtonEnchant;
+import vazkii.tinkerer.client.gui.button.GuiButtonEnchanterLevel;
+import vazkii.tinkerer.client.gui.button.GuiButtonEnchantment;
+import vazkii.tinkerer.client.gui.button.GuiButtonFramedEnchantment;
+import vazkii.tinkerer.client.lib.LibResources;
+import vazkii.tinkerer.common.block.tile.TileEnchanter;
+import vazkii.tinkerer.common.block.tile.container.ContainerEnchanter;
+import vazkii.tinkerer.common.enchantment.core.EnchantmentManager;
+import vazkii.tinkerer.common.lib.LibFeatures;
+import vazkii.tinkerer.common.network.PacketManager;
+import vazkii.tinkerer.common.network.packet.PacketEnchanterAddEnchant;
+import vazkii.tinkerer.common.network.packet.PacketEnchanterStartWorking;
+import cpw.mods.fml.common.network.PacketDispatcher;
+
+public class GuiEnchanting extends GuiContainer {
+
+ private static final ResourceLocation gui = new ResourceLocation(LibResources.GUI_ENCHANTER);
+
+ int x, y;
+
+ public TileEnchanter enchanter;
+
+ GuiButtonEnchantment[] enchantButtons = new GuiButtonEnchantment[16];
+
+ public List tooltip = new ArrayList();
+
+ List lastTickEnchants;
+ List lastTickLevels;
+ ItemStack lastTickStack;
+ ItemStack currentStack;
+
+ public GuiEnchanting(TileEnchanter enchanter, InventoryPlayer inv) {
+ super(new ContainerEnchanter(enchanter, inv));
+ this.enchanter = enchanter;
+ lastTickStack = enchanter.getStackInSlot(0);
+ currentStack = enchanter.getStackInSlot(0);
+ lastTickEnchants = new ArrayList(enchanter.enchantments);
+ lastTickLevels = new ArrayList(enchanter.levels);
+ }
+
+ @Override
+ public void initGui() {
+ super.initGui();
+
+ x = (width - xSize) / 2;
+ y = (height - ySize) / 2;
+
+ buildButtonList();
+ }
+
+ public void buildButtonList() {
+ buttonList.clear();
+ GuiButton enchantButton = new GuiButtonEnchant(this, enchanter, 0, x + 151, y + 33);
+ buttonList.add(enchantButton);
+ enchantButton.enabled = !enchanter.enchantments.isEmpty();
+
+ for(int i = 0; i < 16; i++) {
+ int z = -24;
+ if (i > 7 || (enchantButtons[8]==null || !enchantButtons[8].enabled)) {
+ z = 0;
+ }
+ GuiButtonEnchantment button = new GuiButtonEnchantment(this, 1 + i, x + 34 + ((i)%8)* 16, y + 54 + z);
+ enchantButtons[i] = button;
+ buttonList.add(button);
+ }
+
+ asignEnchantButtons();
+
+ int i = 0;
+ for(Integer enchant : enchanter.enchantments) {
+ GuiButtonEnchantment button = new GuiButtonFramedEnchantment(this, 17 + i * 3, x + xSize + 4, y + i * 26);
+ button.enchant = Enchantment.enchantmentsList[enchant];
+ buttonList.add(button);
+ buttonList.add(new GuiButtonEnchanterLevel(17 + i * 3 + 1, x + xSize + 24, y + i * 26 - 4, false));
+ buttonList.add(new GuiButtonEnchanterLevel(17 + i * 3 + 2, x + xSize + 31, y + i * 26 - 4, true));
+ ++i;
+ }
+ }
+
+ public void asignEnchantButtons() {
+ for(int i = 0; i < 16; i++) {
+ enchantButtons[i].enchant = null;
+ enchantButtons[i].enabled = false;
+ }
+
+ if(currentStack == null || currentStack.isItemEnchanted())
+ return;
+
+ int it = 0;
+
+ for(int enchant : EnchantmentManager.enchantmentData.keySet()) {
+ if(EnchantmentManager.canApply(currentStack, Enchantment.enchantmentsList[enchant], enchanter.enchantments) && EnchantmentManager.canEnchantmentBeUsed(ClientHelper.clientPlayer().username, Enchantment.enchantmentsList[enchant])) {
+ enchantButtons[it].enchant = Enchantment.enchantmentsList[enchant];
+ enchantButtons[it].enabled = true;
+ it++;
+ if(it >= 16)
+ break;
+ }
+ }
+
+ }
+
+ @Override
+ protected void actionPerformed(GuiButton par1GuiButton) {
+ if(par1GuiButton.id == 0) {
+ PacketDispatcher.sendPacketToServer(PacketManager.buildPacket(new PacketEnchanterStartWorking(enchanter)));
+ } else if(par1GuiButton.id <= 16) {
+ GuiButtonEnchantment button = enchantButtons[par1GuiButton.id - 1];
+ if(button != null && button.enchant != null)
+ PacketDispatcher.sendPacketToServer(PacketManager.buildPacket(new PacketEnchanterAddEnchant(enchanter, button.enchant.effectId, 0)));
+ } else {
+ int type = (par1GuiButton.id - 17) % 3;
+ int index = (par1GuiButton.id - 17) / 3;
+
+ if(index >= enchanter.enchantments.size() || index >= enchanter.levels.size())
+ return;
+
+ int level = enchanter.levels.get(index);
+
+ Enchantment enchant = Enchantment.enchantmentsList[enchanter.enchantments.get(index)];
+
+ switch(type) {
+ case 0 : {
+ PacketDispatcher.sendPacketToServer(PacketManager.buildPacket(new PacketEnchanterAddEnchant(enchanter, enchant.effectId, -1)));
+ break;
+ }
+ case 1 : {
+ PacketDispatcher.sendPacketToServer(PacketManager.buildPacket(new PacketEnchanterAddEnchant(enchanter, enchant.effectId, level == 1 ? -1 : level - 1)));
+ break;
+ }
+ case 2 : {
+ PacketDispatcher.sendPacketToServer(PacketManager.buildPacket(new PacketEnchanterAddEnchant(enchanter, enchant.effectId, level + 1)));
+ break;
+ }
+ }
+ }
+
+ buildButtonList();
+ }
+
+ @Override
+ public void updateScreen() {
+ currentStack = enchanter.getStackInSlot(0);
+ buildButtonList();
+ if(currentStack != lastTickStack || !lastTickEnchants.equals(enchanter.enchantments) || !lastTickLevels.equals(enchanter.levels))
+ buildButtonList();
+
+ lastTickStack = currentStack;
+ lastTickEnchants = new ArrayList(enchanter.enchantments);
+ lastTickLevels = new ArrayList(enchanter.enchantments);
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
+ GL11.glColor4f(1F, 1F, 1F, 1F);
+ mc.renderEngine.bindTexture(gui);
+ drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+
+ ItemStack itemToEnchant = enchanter.getStackInSlot(0);
+ if (enchantButtons[8].enabled) {
+ if(itemToEnchant != null && !itemToEnchant.isItemEnchanted())
+ drawTexturedModalRect(x + 30, y + 26, 0, ySize, 147, 24);
+ }
+
+ if(itemToEnchant != null && !itemToEnchant.isItemEnchanted())
+ drawTexturedModalRect(x + 30, y + 50, 0, ySize, 147, 24);
+
+
+ if(!enchanter.enchantments.isEmpty()) {
+ int x = this.x + 40;
+ GL11.glEnable(GL11.GL_BLEND);
+ int xo = 15;
+ int z = 50;
+ if (enchantButtons[8].enabled)
+ z = 26;
+ for(Aspect aspect : LibFeatures.PRIMAL_ASPECTS) {
+ drawAspectBar(aspect, x + xo, y + z, i, j);
+ xo += 15;
+ }
+ GL11.glDisable(GL11.GL_BLEND);
+ }
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ if(!tooltip.isEmpty())
+ ClientHelper.renderTooltip(par1 - x, par2 - y, tooltip);
+ tooltip.clear();
+ }
+
+ private void drawAspectBar(Aspect aspect, int x, int y, int mx, int my) {
+ int totalCost = enchanter.totalAspects.getAmount(aspect);
+ int current = enchanter.currentAspects.getAmount(aspect);
+
+ int size = totalCost == 0 ? 11 : 59;
+
+ if(totalCost == 0) {
+ drawTexturedModalRect(x, y - size, 200, 0, 10, 4);
+ drawTexturedModalRect(x, y - size + 4, 200, 52, 10, 10);
+ } else {
+ int pixels = (int) (48D * ((double) current / (double) totalCost));
+ Color color = new Color(aspect.getColor());
+ GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
+ drawTexturedModalRect(x + 1, y - size + 4 + 48 - pixels, 210, 48 - pixels, 8, pixels);
+ GL11.glColor3f(1F, 1F, 1F);
+ drawTexturedModalRect(x, y - size, 200, 0, 10, size);
+ }
+
+ if(mx > x && mx <= x + 10 && my > y - size && my <= y) {
+ List tooltip = new ArrayList();
+ tooltip.add('\u00a7' + aspect.getChatcolor() + aspect.getName());
+ tooltip.add(current + "/" + totalCost);
+ this.tooltip = tooltip;
+ }
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/gui/GuiMobMagnet.java b/src/main/java/vazkii/tinkerer/client/gui/GuiMobMagnet.java
new file mode 100644
index 00000000..356418b1
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/GuiMobMagnet.java
@@ -0,0 +1,109 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 18:37:02 (GMT)]
+ */
+package vazkii.tinkerer.client.gui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+import org.lwjgl.opengl.GL11;
+
+import vazkii.tinkerer.client.gui.button.GuiButtonMM;
+import vazkii.tinkerer.client.gui.button.GuiButtonMMRadio;
+import vazkii.tinkerer.client.gui.button.IRadioButton;
+import vazkii.tinkerer.client.lib.LibResources;
+import vazkii.tinkerer.common.block.tile.TileMobMagnet;
+import vazkii.tinkerer.common.block.tile.container.ContainerMobMagnet;
+import vazkii.tinkerer.common.item.ItemSoulMould;
+import vazkii.tinkerer.common.network.PacketManager;
+import vazkii.tinkerer.common.network.packet.PacketMobMagnetButton;
+import cpw.mods.fml.common.network.PacketDispatcher;
+
+public class GuiMobMagnet extends GuiContainer {
+
+ private static final ResourceLocation gui = new ResourceLocation(LibResources.GUI_MOB_MAGNET);
+
+ int x, y;
+
+ ItemStack stack = null;
+ TileMobMagnet mobMagnet;
+
+ List buttonListMM = new ArrayList();
+ List radioButtons = new ArrayList();
+
+ public GuiMobMagnet(TileMobMagnet tile, InventoryPlayer playerInv) {
+ super(new ContainerMobMagnet(tile, playerInv));
+ mobMagnet = tile;
+ }
+
+ @Override
+ public void initGui() {
+ super.initGui();
+ x = (width - xSize) / 2;
+ y = (height - ySize) / 2;
+ buttonListMM.clear();
+ addButton(new GuiButtonMMRadio(0, x + 100, y + 28, mobMagnet.adult, radioButtons));
+ addButton(new GuiButtonMMRadio(1, x + 100, y + 48, !mobMagnet.adult, radioButtons));
+ buttonList = buttonListMM;
+ }
+
+ private void addButton(GuiButtonMM button) {
+ buttonListMM.add(button);
+ if(button instanceof IRadioButton)
+ radioButtons.add((IRadioButton) button);
+ }
+
+ @Override
+ protected void actionPerformed(GuiButton par1GuiButton) {
+ if(par1GuiButton instanceof IRadioButton)
+ ((IRadioButton) par1GuiButton).enableFromClick();
+ else buttonListMM.get(0).enabled = !buttonListMM.get(0).enabled;
+
+ mobMagnet.adult = buttonListMM.get(0).enabled;
+
+ PacketDispatcher.sendPacketToServer(PacketManager.buildPacket(new PacketMobMagnetButton(mobMagnet)));
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ mc.renderEngine.bindTexture(gui);
+ drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ String adult = StatCollector.translateToLocal("ttmisc.adult");
+ String child = StatCollector.translateToLocal("ttmisc.child");
+ stack = mobMagnet.getStackInSlot(0);
+
+ String filter;
+
+ if(stack != null) {
+ String name = ItemSoulMould.getPatternName(stack);
+ if(name.isEmpty())
+ filter = StatCollector.translateToLocal("ttmisc.none");
+ else filter = StatCollector.translateToLocal("entity." + name + ".name");
+ } else filter = StatCollector.translateToLocal("ttmisc.all");
+
+ fontRenderer.drawString(filter, x + xSize / 2 - fontRenderer.getStringWidth(filter) / 2 - 26, y + 16, 0x999999);
+ fontRenderer.drawString(adult, x + 120, y + 30, 0x999999);
+ fontRenderer.drawString(child, x + 120, y + 50, 0x999999);
+ GL11.glColor3f(1F, 1F, 1F);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/client/gui/GuiResearchPeripheral.java b/src/main/java/vazkii/tinkerer/client/gui/GuiResearchPeripheral.java
new file mode 100644
index 00000000..5354c08e
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/GuiResearchPeripheral.java
@@ -0,0 +1,42 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [13 Sep 2013, 14:50:41 (GMT)]
+ */
+package vazkii.tinkerer.client.gui;
+
+import java.awt.Desktop;
+import java.net.URI;
+
+import net.minecraft.util.StatCollector;
+import thaumcraft.api.research.ResearchItem;
+import thaumcraft.client.gui.GuiResearchRecipe;
+
+public class GuiResearchPeripheral extends GuiResearchRecipe {
+
+ public GuiResearchPeripheral(ResearchItem research) {
+ super(research, 0, -100, -75);
+ }
+
+ @Override
+ protected void keyTyped(char par1, int par2) {
+ if(par2 == 28) {
+ String url = StatCollector.translateToLocal("ttresearch.webpage.peripherals");
+ try {
+ Desktop.getDesktop().browse(new URI(url));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else super.keyTyped(par1, par2);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonAT.java b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonAT.java
new file mode 100644
index 00000000..39723a0f
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonAT.java
@@ -0,0 +1,41 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 16:33:24 (GMT)]
+ */
+package vazkii.tinkerer.client.gui.button;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.util.ResourceLocation;
+import vazkii.tinkerer.client.lib.LibResources;
+
+public class GuiButtonAT extends GuiButton {
+
+ private static final ResourceLocation gui = new ResourceLocation(LibResources.GUI_ANIMATION_TABLET);
+
+ public boolean enabled = false;
+
+ public GuiButtonAT(int par1, int par2, int par3, boolean enabled) {
+ super(par1, par2, par3, 13, 13, "");
+ this.enabled = enabled;
+ }
+
+ @Override
+ public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
+ if(drawButton) {
+ par1Minecraft.renderEngine.bindTexture(gui);
+ int y = enabled ? 13 : 0;
+ drawTexturedModalRect(xPosition, yPosition, 176, y, width, height);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonATRadio.java b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonATRadio.java
new file mode 100644
index 00000000..de46f2f9
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonATRadio.java
@@ -0,0 +1,51 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 16:33:43 (GMT)]
+ */
+package vazkii.tinkerer.client.gui.button;
+
+import java.util.List;
+
+public class GuiButtonATRadio extends GuiButtonAT implements IRadioButton {
+
+ List linkedButtons;
+
+ public GuiButtonATRadio(int par1, int par2, int par3, boolean enabled, List linkedButtons) {
+ super(par1, par2, par3, enabled);
+ this.linkedButtons = linkedButtons;
+ }
+
+ @Override
+ public void enableFromClick() {
+ setEnabled(true);
+ for(IRadioButton button : linkedButtons)
+ if(button != this)
+ button.updateStatus(this);
+ }
+
+ @Override
+ public void updateStatus(IRadioButton otherButton) {
+ if(otherButton.isEnabled())
+ setEnabled(false);
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonEnchant.java b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonEnchant.java
new file mode 100644
index 00000000..58050f1f
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonEnchant.java
@@ -0,0 +1,60 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [14 Sep 2013, 21:56:21 (GMT)]
+ */
+package vazkii.tinkerer.client.gui.button;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+import vazkii.tinkerer.client.core.helper.ClientHelper;
+import vazkii.tinkerer.client.gui.GuiEnchanting;
+import vazkii.tinkerer.client.lib.LibResources;
+import vazkii.tinkerer.common.block.tile.TileEnchanter;
+
+public class GuiButtonEnchant extends GuiButton {
+
+ private static final ResourceLocation gui = new ResourceLocation(LibResources.GUI_ENCHANTER);
+ TileEnchanter enchanter;
+ GuiEnchanting parent;
+
+ public GuiButtonEnchant(GuiEnchanting parent, TileEnchanter enchanter, int par1, int par2, int par3) {
+ super(par1, par2, par3, 15, 15, "");
+ this.enchanter = enchanter;
+ this.parent = parent;
+ }
+
+ @Override
+ public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
+ if(!enabled)
+ return;
+
+ final int x = 176;
+ final int y = enchanter.working ? 39 : 24;
+
+ ClientHelper.minecraft().renderEngine.bindTexture(gui);
+ drawTexturedModalRect(xPosition, yPosition, x, y, 15, 15);
+
+ if(par2 >= xPosition && par2 < xPosition + 15 && par3 >= yPosition && par3 < yPosition + 15 && !enchanter.working) {
+ List tooltip = new ArrayList();
+ tooltip.add(EnumChatFormatting.AQUA + StatCollector.translateToLocal("ttmisc.startEnchant"));
+ parent.tooltip = tooltip;
+ }
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonEnchanterLevel.java b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonEnchanterLevel.java
new file mode 100644
index 00000000..d730fc6f
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonEnchanterLevel.java
@@ -0,0 +1,44 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [16 Sep 2013, 16:13:50 (GMT)]
+ */
+package vazkii.tinkerer.client.gui.button;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.util.ResourceLocation;
+import vazkii.tinkerer.client.lib.LibResources;
+
+public class GuiButtonEnchanterLevel extends GuiButton {
+
+ private static final ResourceLocation gui = new ResourceLocation(LibResources.GUI_ENCHANTER);
+
+ boolean plus;
+
+ public GuiButtonEnchanterLevel(int par1, int par2, int par3, boolean plus) {
+ super(par1, par2, par3, 7, 7, "");
+ this.plus = plus;
+ }
+
+ @Override
+ public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
+ if(!enabled)
+ return;
+
+ int x = 218 + (plus ? 7 : 0);
+
+ par1Minecraft.renderEngine.bindTexture(gui);
+ drawTexturedModalRect(xPosition, yPosition, x, 0, 7, 7);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonEnchantment.java b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonEnchantment.java
new file mode 100644
index 00000000..173d9982
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonEnchantment.java
@@ -0,0 +1,87 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [15 Sep 2013, 00:13:10 (GMT)]
+ */
+package vazkii.tinkerer.client.gui.button;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
+
+import org.lwjgl.opengl.GL11;
+
+import thaumcraft.api.aspects.Aspect;
+import vazkii.tinkerer.client.core.helper.ClientHelper;
+import vazkii.tinkerer.client.gui.GuiEnchanting;
+import vazkii.tinkerer.common.enchantment.core.EnchantmentData;
+import vazkii.tinkerer.common.enchantment.core.EnchantmentManager;
+
+public class GuiButtonEnchantment extends GuiButton {
+
+ public Enchantment enchant;
+ GuiEnchanting parent;
+
+ public GuiButtonEnchantment(GuiEnchanting parent, int par1, int par2, int par3) {
+ super(par1, par2, par3, 16, 16, "");
+ this.parent = parent;
+ }
+
+ boolean canRender() {
+ if(enchant == null || !enabled || !EnchantmentManager.enchantmentData.containsKey(enchant.effectId))
+ return false;
+ return true;
+ }
+
+ @Override
+ public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
+ if(!canRender())
+ return;
+
+ EnchantmentData data = EnchantmentManager.enchantmentData.get(enchant.effectId).get(1);
+ ClientHelper.minecraft().renderEngine.bindTexture(data.texture);
+ GL11.glEnable(GL11.GL_BLEND);
+ drawTexturedModalRect16(xPosition, yPosition, 0, 0, 16, 16);
+ GL11.glDisable(GL11.GL_BLEND);
+
+ if(par2 >= xPosition && par2 < xPosition + 16 && par3 >= yPosition && par3 < yPosition + 16) {
+ List tooltip = new ArrayList();
+ tooltip.add(EnumChatFormatting.AQUA + StatCollector.translateToLocal(enchant.getName()));
+ for(Aspect aspect : data.aspects.getAspectsSorted())
+ tooltip.add(" \u00a7" + aspect.getChatcolor() + aspect.getName() + '\u00a7' + "r x " + data.aspects.getAmount(aspect) + " " + StatCollector.translateToLocal("ttmisc.baseCost"));
+ if(this instanceof GuiButtonFramedEnchantment && !parent.enchanter.working)
+ tooltip.add(EnumChatFormatting.GRAY + "" + EnumChatFormatting.ITALIC + " " + StatCollector.translateToLocal("ttmisc.clickToRemove"));
+
+ parent.tooltip = tooltip;
+ }
+ }
+
+ public void drawTexturedModalRect16(int par1, int par2, int par3, int par4, int par5, int par6)
+ {
+ float f = 1F / 16F;
+ float f1 = 1F / 16F;
+ Tessellator tessellator = Tessellator.instance;
+ tessellator.startDrawingQuads();
+ tessellator.addVertexWithUV(par1 + 0, par2 + par6, zLevel, (par3 + 0) * f, (par4 + par6) * f1);
+ tessellator.addVertexWithUV(par1 + par5, par2 + par6, zLevel, (par3 + par5) * f, (par4 + par6) * f1);
+ tessellator.addVertexWithUV(par1 + par5, par2 + 0, zLevel, (par3 + par5) * f, (par4 + 0) * f1);
+ tessellator.addVertexWithUV(par1 + 0, par2 + 0, zLevel, (par3 + 0) * f, (par4 + 0) * f1);
+ tessellator.draw();
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonFramedEnchantment.java b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonFramedEnchantment.java
new file mode 100644
index 00000000..0285dbba
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonFramedEnchantment.java
@@ -0,0 +1,49 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [16 Sep 2013, 15:31:55 (GMT)]
+ */
+package vazkii.tinkerer.client.gui.button;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+import vazkii.tinkerer.client.core.helper.ClientHelper;
+import vazkii.tinkerer.client.gui.GuiEnchanting;
+import vazkii.tinkerer.client.lib.LibResources;
+
+public class GuiButtonFramedEnchantment extends GuiButtonEnchantment {
+
+ private static final ResourceLocation gui = new ResourceLocation(LibResources.GUI_ENCHANTER);
+
+ public GuiButtonFramedEnchantment(GuiEnchanting parent, int par1, int par2, int par3) {
+ super(parent, par1, par2, par3);
+ }
+
+ @Override
+ public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
+ if(!canRender() || parent.enchanter.enchantments.isEmpty() || parent.enchanter.levels.isEmpty())
+ return;
+
+ ClientHelper.minecraft().renderEngine.bindTexture(gui);
+ drawTexturedModalRect(xPosition - 4, yPosition - 4, 176, 0, 24, 24);
+
+ int index = parent.enchanter.enchantments.indexOf(enchant.effectId);
+ if(index != -1) {
+ int level = parent.enchanter.levels.get(index);
+ par1Minecraft.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("enchantment.level." + level), xPosition + 26, yPosition + 8, 0xFFFFFF);
+ }
+
+ super.drawButton(par1Minecraft, par2, par3);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonMM.java b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonMM.java
new file mode 100644
index 00000000..85378447
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonMM.java
@@ -0,0 +1,41 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 18:39:55 (GMT)]
+ */
+package vazkii.tinkerer.client.gui.button;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.util.ResourceLocation;
+import vazkii.tinkerer.client.lib.LibResources;
+
+public class GuiButtonMM extends GuiButton {
+
+ private static final ResourceLocation gui = new ResourceLocation(LibResources.GUI_MOB_MAGNET);
+
+ public boolean enabled = false;
+
+ public GuiButtonMM(int par1, int par2, int par3, boolean enabled) {
+ super(par1, par2, par3, 13, 13, "");
+ this.enabled = enabled;
+ }
+
+ @Override
+ public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
+ if(drawButton) {
+ par1Minecraft.renderEngine.bindTexture(gui);
+ int y = enabled ? 13 : 0;
+ drawTexturedModalRect(xPosition, yPosition, 176, y, width, height);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonMMRadio.java b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonMMRadio.java
new file mode 100644
index 00000000..47d8ae11
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/button/GuiButtonMMRadio.java
@@ -0,0 +1,51 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 18:40:22 (GMT)]
+ */
+package vazkii.tinkerer.client.gui.button;
+
+import java.util.List;
+
+public class GuiButtonMMRadio extends GuiButtonMM implements IRadioButton {
+
+ List linkedButtons;
+
+ public GuiButtonMMRadio(int par1, int par2, int par3, boolean enabled, List linkedButtons) {
+ super(par1, par2, par3, enabled);
+ this.linkedButtons = linkedButtons;
+ }
+
+ @Override
+ public void enableFromClick() {
+ setEnabled(true);
+ for(IRadioButton button : linkedButtons)
+ if(button != this)
+ button.updateStatus(this);
+ }
+
+ @Override
+ public void updateStatus(IRadioButton otherButton) {
+ if(otherButton.isEnabled())
+ setEnabled(false);
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/client/gui/button/IRadioButton.java b/src/main/java/vazkii/tinkerer/client/gui/button/IRadioButton.java
new file mode 100644
index 00000000..1a590de0
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/button/IRadioButton.java
@@ -0,0 +1,27 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 16:32:08 (GMT)]
+ */
+package vazkii.tinkerer.client.gui.button;
+
+public interface IRadioButton {
+
+ public void enableFromClick();
+
+ public void updateStatus(IRadioButton otherButton);
+
+ public boolean isEnabled();
+
+ public void setEnabled(boolean enabled);
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/client/gui/button/kami/GuiButtonWG.java b/src/main/java/vazkii/tinkerer/client/gui/button/kami/GuiButtonWG.java
new file mode 100644
index 00000000..ea05b2d2
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/button/kami/GuiButtonWG.java
@@ -0,0 +1,41 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Jan 10, 2014, 5:58:46 PM (GMT)]
+ */
+package vazkii.tinkerer.client.gui.button.kami;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.util.ResourceLocation;
+import vazkii.tinkerer.client.lib.LibResources;
+
+public class GuiButtonWG extends GuiButton {
+
+ private static final ResourceLocation gui = new ResourceLocation(LibResources.GUI_WARP_GATE);
+
+ public boolean enabled = false;
+
+ public GuiButtonWG(int par1, int par2, int par3, boolean enabled) {
+ super(par1, par2, par3, 13, 13, "");
+ this.enabled = enabled;
+ }
+
+ @Override
+ public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
+ if(drawButton) {
+ par1Minecraft.renderEngine.bindTexture(gui);
+ int y = !enabled ? 13 : 0;
+ drawTexturedModalRect(xPosition, yPosition, 176, y, width, height);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/client/gui/kami/GuiIchorPouch.java b/src/main/java/vazkii/tinkerer/client/gui/kami/GuiIchorPouch.java
new file mode 100644
index 00000000..716bcc2e
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/kami/GuiIchorPouch.java
@@ -0,0 +1,53 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 10:54:58 PM (GMT)]
+ */
+package vazkii.tinkerer.client.gui.kami;
+
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.inventory.Container;
+import net.minecraft.util.ResourceLocation;
+
+import org.lwjgl.opengl.GL11;
+
+import vazkii.tinkerer.client.lib.LibResources;
+
+public class GuiIchorPouch extends GuiContainer {
+
+ private static final ResourceLocation gui = new ResourceLocation(LibResources.GUI_ICHOR_POUCH);
+
+ int x, y;
+
+ public GuiIchorPouch(Container par1Container) {
+ super(par1Container);
+ }
+
+ @Override
+ public void initGui() {
+ super.initGui();
+ xSize = ySize = 256;
+
+ guiLeft = x = (width - xSize) / 2;
+ guiTop = y = (height - ySize) / 2;
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GL11.glEnable(GL11.GL_BLEND);
+ mc.renderEngine.bindTexture(gui);
+ drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ GL11.glDisable(GL11.GL_BLEND);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/gui/kami/GuiWarpGate.java b/src/main/java/vazkii/tinkerer/client/gui/kami/GuiWarpGate.java
new file mode 100644
index 00000000..104cb838
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/kami/GuiWarpGate.java
@@ -0,0 +1,71 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Jan 10, 2014, 5:43:53 PM (GMT)]
+ */
+package vazkii.tinkerer.client.gui.kami;
+
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+import org.lwjgl.opengl.GL11;
+
+import vazkii.tinkerer.client.gui.button.kami.GuiButtonWG;
+import vazkii.tinkerer.client.lib.LibResources;
+import vazkii.tinkerer.common.block.tile.container.kami.ContainerWarpGate;
+import vazkii.tinkerer.common.block.tile.kami.TileWarpGate;
+import vazkii.tinkerer.common.network.PacketManager;
+import vazkii.tinkerer.common.network.packet.kami.PacketWarpGateButton;
+import cpw.mods.fml.common.network.PacketDispatcher;
+
+public class GuiWarpGate extends GuiContainer {
+
+ private static final ResourceLocation gui = new ResourceLocation(LibResources.GUI_WARP_GATE);
+
+ TileWarpGate warpGate;
+ int x, y;
+
+ public GuiWarpGate(TileWarpGate warpGate, InventoryPlayer inv) {
+ super(new ContainerWarpGate(warpGate, inv));
+ this.warpGate = warpGate;
+ }
+
+ @Override
+ protected void actionPerformed(GuiButton par1GuiButton) {
+ ((GuiButtonWG) par1GuiButton).enabled = !((GuiButtonWG) par1GuiButton).enabled;
+ warpGate.locked = ((GuiButtonWG) par1GuiButton).enabled;
+
+ PacketDispatcher.sendPacketToServer(PacketManager.buildPacket(new PacketWarpGateButton(warpGate)));
+ }
+
+ @Override
+ public void initGui() {
+ super.initGui();
+ x = (width - xSize) / 2;
+ y = (height - ySize) / 2;
+
+ buttonList.clear();
+ buttonList.add(new GuiButtonWG(0, x + 5, y + 5, warpGate.locked));
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ mc.renderEngine.bindTexture(gui);
+ drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("ttmisc.lockedGate"), x + 20, y + 7, 0x999999);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/gui/kami/GuiWarpGateDestinations.java b/src/main/java/vazkii/tinkerer/client/gui/kami/GuiWarpGateDestinations.java
new file mode 100644
index 00000000..87087f12
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/gui/kami/GuiWarpGateDestinations.java
@@ -0,0 +1,227 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Jan 10, 2014, 6:08:23 PM (GMT)]
+ */
+package vazkii.tinkerer.client.gui.kami;
+
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.entity.RenderItem;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.GL11;
+
+import thaumcraft.client.codechicken.core.vec.Vector3;
+import vazkii.tinkerer.client.core.helper.ClientHelper;
+import vazkii.tinkerer.common.block.tile.kami.TileWarpGate;
+import vazkii.tinkerer.common.item.ModItems;
+import vazkii.tinkerer.common.item.kami.ItemSkyPearl;
+import vazkii.tinkerer.common.network.PacketManager;
+import vazkii.tinkerer.common.network.packet.kami.PacketWarpGateTeleport;
+import cpw.mods.fml.common.network.PacketDispatcher;
+
+public class GuiWarpGateDestinations extends GuiScreen {
+
+ private static ResourceLocation enderField = new ResourceLocation("textures/entity/end_portal.png");
+ TileWarpGate warpGate;
+ RenderItem render = new RenderItem();
+
+ int lastMouseX, lastMouseY;
+ int x, y;
+ int ticks;
+
+ public GuiWarpGateDestinations(TileWarpGate warpGate) {
+ this.warpGate = warpGate;
+ }
+
+ @Override
+ public void initGui() {
+ super.initGui();
+
+ x = warpGate.xCoord - width / 2;
+ y = warpGate.zCoord - height / 2;
+ }
+
+ @Override
+ public void updateScreen() {
+ ++ticks;
+
+ ScaledResolution res = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
+ int i = res.getScaledWidth();
+ int j = res.getScaledHeight();
+ int mx = Mouse.getX() * i / mc.displayWidth;
+ int my = j - Mouse.getY() * j / mc.displayHeight - 1;
+
+ if(Mouse.isButtonDown(0)) {
+ int deltaX = mx - lastMouseX;
+ int deltaY = my - lastMouseY;
+ x -= deltaX;
+ y -= deltaY;
+ }
+
+ lastMouseX = mx;
+ lastMouseY = my;
+ }
+
+ @Override
+ protected void keyTyped(char par1, int par2) {
+ super.keyTyped(par1, par2);
+
+ if(par2 == 57) { // space
+ x = warpGate.xCoord - width / 2;
+ y = warpGate.zCoord - height / 2;
+ return;
+ }
+ if(par2 >= 2 && par2 < 12) {
+ int num = par2 - 2;
+ ItemStack stack = warpGate.getStackInSlot(num);
+ if(stack != null && ItemSkyPearl.isAttuned(stack) && ItemSkyPearl.getDim(stack) == warpGate.worldObj.provider.dimensionId) {
+ int x = ItemSkyPearl.getX(stack);
+ int z = ItemSkyPearl.getZ(stack);
+
+ this.x = x - width / 2;
+ y = z - height / 2;
+ }
+ }
+ }
+
+ List tooltip = new ArrayList();
+
+ @Override
+ public void drawScreen(int par1, int par2, float par3) {
+ drawDefaultBackground();
+ super.drawScreen(par1, par2, par3);
+
+ tooltip.clear();
+
+ int gateX = warpGate.xCoord - x;
+ int gateY = warpGate.zCoord - y;
+ mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
+
+ List coords = new ArrayList();
+
+ for(int i = 0; i < warpGate.getSizeInventory(); i++) {
+ ItemStack stack = warpGate.getStackInSlot(i);
+ if(stack != null && ItemSkyPearl.isAttuned(stack)) {
+ int dim = ItemSkyPearl.getDim(stack);
+ if(warpGate.worldObj.provider.dimensionId != dim)
+ continue;
+
+ int x = ItemSkyPearl.getX(stack);
+ int y = ItemSkyPearl.getY(stack);
+ int z = ItemSkyPearl.getZ(stack);
+
+ if(y != -1)
+ coords.add(new Object[] { x - this.x, z - this.y, stack, i});
+ }
+ }
+
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GL11.glColor4f(1F, 1F, 1F, (float) ((Math.sin(ticks / 10D) + 1F) / 4F + 0.25F));
+ GL11.glLineWidth(2F);
+ GL11.glDisable(GL11.GL_TEXTURE_2D);
+ for(Object[] coords_ : coords) {
+ int x = (Integer) coords_[0];
+ int y = (Integer) coords_[1];
+
+ GL11.glBegin(GL11.GL_LINES);
+ GL11.glVertex2i(gateX, gateY);
+ GL11.glVertex2i(x, y);
+ GL11.glEnd();
+ }
+ GL11.glEnable(GL11.GL_TEXTURE_2D);
+ GL11.glDisable(GL11.GL_BLEND);
+
+ fontRenderer.drawStringWithShadow(EnumChatFormatting.UNDERLINE + StatCollector.translateToLocal("ttmisc.destinations"), 3, 40, 0xFFFFFF);
+ GL11.glColor4f(1F, 1F, 1F, 1F);
+ drawPearlAt(0, null, gateX, gateY, par1, par2);
+ for(Object[] coords_ : coords)
+ drawPearlAt((Integer) coords_[3], (ItemStack) coords_[2], (Integer) coords_[0], (Integer) coords_[1], par1, par2);
+
+ if(!tooltip.isEmpty())
+ ClientHelper.renderTooltip(par1, par2, tooltip);
+
+ drawCenteredString(fontRenderer, StatCollector.translateToLocal("ttmisc.numberKeys"), width / 2, 5, 0xFFFFFF);
+ drawCenteredString(fontRenderer, StatCollector.translateToLocal("ttmisc.spaceToReset"), width / 2, 16, 0xFFFFFF);
+ }
+
+ public void drawPearlAt(int index, ItemStack stack, int xp, int yp, int mx, int my) {
+ int x = xp + this.x;
+ int y = yp + this.y;
+
+ String destName;
+
+ mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
+ GL11.glPushMatrix();
+ GL11.glTranslatef(xp, yp, 0);
+ GL11.glScalef(0.5F, 0.5F, 1F);
+ render.renderIcon(-8, -8, ModItems.skyPearl.getIconFromDamage(0), 16, 16);
+ GL11.glPopMatrix();
+
+ String destNum = " " + EnumChatFormatting.ITALIC + String.format(StatCollector.translateToLocal("ttmisc.destinationInd"), index + 1);
+ if(stack != null && stack.hasDisplayName())
+ destName = stack.getDisplayName();
+ else destName = StatCollector.translateToLocal(stack == null ? "ttmisc.entrancePoint" : "ttmisc.destination");
+
+ if(stack != null)
+ fontRenderer.drawString((index + 1) + ": " + destName, 5, 54 + index * 11, 0xFFFFFF);
+
+ if(mx >= xp - 4 && mx <= xp + 4 && my >= yp - 4 && my < yp + 4) {
+ tooltip.add(EnumChatFormatting.AQUA + destName + destNum);
+
+ if(stack != null) {
+ ItemSkyPearl.addInfo(stack, warpGate.worldObj.provider.dimensionId, Vector3.fromTileEntity(warpGate), tooltip, true);
+ tooltip.add(StatCollector.translateToLocal("ttmisc.clickToTeleport"));
+ } else {
+ tooltip.add("X: " + x);
+ tooltip.add("Z: " + y);
+ }
+
+ if(Mouse.isButtonDown(0) && isShiftKeyDown() && stack != null) {
+ PacketDispatcher.sendPacketToServer(PacketManager.buildPacket(new PacketWarpGateTeleport(warpGate, index)));
+ mc.displayGuiScreen(null);
+ }
+ }
+ }
+
+ @Override
+ public void drawDefaultBackground() {
+ int par1 = 0;
+ GL11.glDisable(GL11.GL_LIGHTING);
+ GL11.glDisable(GL11.GL_FOG);
+ Tessellator tessellator = Tessellator.instance;
+ mc.getTextureManager().bindTexture(enderField);
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ float f = 256.0F;
+ tessellator.startDrawingQuads();
+ float hue = (float) (Math.sin(ticks / 150D) + 1F / 2F);
+ tessellator.setColorOpaque_I(Color.HSBtoRGB(hue, 0.5F, 0.4F));
+ tessellator.addVertexWithUV(0.0D, height, 0.0D, 0.0D, height / f + par1);
+ tessellator.addVertexWithUV(width, height, 0.0D, width / f, height / f + par1);
+ tessellator.addVertexWithUV(width, 0.0D, 0.0D, width / f, par1);
+ tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, par1);
+ tessellator.draw();
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/lib/LibRenderIDs.java b/src/main/java/vazkii/tinkerer/client/lib/LibRenderIDs.java
new file mode 100644
index 00000000..1cecf5e8
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/lib/LibRenderIDs.java
@@ -0,0 +1,24 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 17:43:34 (GMT)]
+ */
+package vazkii.tinkerer.client.lib;
+
+public final class LibRenderIDs {
+
+ public static int idMagnet = -1;
+ public static int idRepairer = -1;
+
+ public static int idWarpGate = -1;
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/lib/LibResources.java b/src/main/java/vazkii/tinkerer/client/lib/LibResources.java
new file mode 100644
index 00000000..dd0b374d
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/lib/LibResources.java
@@ -0,0 +1,100 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [4 Sep 2013, 17:38:36 (GMT)]
+ */
+package vazkii.tinkerer.client.lib;
+
+public final class LibResources {
+
+ public static final String PREFIX_MOD = "ttinkerer:";
+
+ public static final String PREFIX_LANG = "/assets/ttinkerer/lang/";
+
+ public static final String PREFIX_GUI = PREFIX_MOD + "textures/gui/";
+ public static final String PREFIX_MISC = PREFIX_MOD + "textures/misc/";
+ public static final String PREFIX_MODEL = PREFIX_MOD + "textures/model/";
+ public static final String PREFIX_ENCHANTS = PREFIX_MOD + "textures/enchants/";
+
+ public static final String EMTPY_TEXTURE = "emptyTexture";
+
+ public static final String GUI_ANIMATION_TABLET = PREFIX_GUI + "animationTablet.png";
+ public static final String GUI_MOB_MAGNET = PREFIX_GUI + "mobMagnet.png";
+ public static final String GUI_ENCHANTER = PREFIX_GUI + "enchanter.png";
+ public static final String GUI_ASPECT_ANALYZER = PREFIX_GUI + "aspectAnalyzer.png";
+ public static final String GUI_SOUL_HEARTS = PREFIX_GUI + "soulHearts.png";
+ public static final String GUI_ICHOR_POUCH = PREFIX_GUI + "ichorPouch.png";
+ public static final String GUI_WARP_GATE = PREFIX_GUI + "warpGate.png";
+
+ public static final String MISC_R_ENCHANTING = PREFIX_MISC + "r_enchanting.png";
+ public static final String MISC_AT_CENTER = PREFIX_MISC + "atCenter.png";
+ public static final String MISC_AT_LEFT = PREFIX_MISC + "atLeft.png";
+ public static final String MISC_AT_RIGHT = PREFIX_MISC + "atRight.png";
+ public static final String MISC_AT_INDENT = PREFIX_MISC + "atFacingIndent.png";
+ public static final String MISC_REPAIR = PREFIX_MISC + "repair.png";
+ public static final String MISC_REPAIR_OFF = PREFIX_MISC + "repairOff.png";
+
+ public static final String MODEL_MAGNET_N = PREFIX_MODEL + "magnetN.png";
+ public static final String MODEL_MAGNET_S = PREFIX_MODEL + "magnetS.png";
+ public static final String MODEL_MOB_MAGNET_N = PREFIX_MODEL + "mobMagnetN.png";
+ public static final String MODEL_MOB_MAGNET_S = PREFIX_MODEL + "mobMagnetS.png";
+ public static final String MODEL_REVEALING_HELM = PREFIX_MODEL + "revealing.png";
+ public static final String MODEL_REPAIRER = PREFIX_MODEL + "repairer.png";
+ public static final String MODEL_CAP_ICHOR = PREFIX_MODEL + "capIchor.png";
+ public static final String MODEL_ROD_ICHORCLOTH = PREFIX_MODEL + "rodIchorcloth.png";
+ public static final String MODEL_ARMOR_ICHOR_1 = PREFIX_MODEL + "ichor1.png";
+ public static final String MODEL_ARMOR_ICHOR_2 = PREFIX_MODEL + "ichor2.png";
+ public static final String MODEL_ARMOR_ICHOR_GEM_1 = PREFIX_MODEL + "ichorGem1.png";
+ public static final String MODEL_ARMOR_ICHOR_GEM_2 = PREFIX_MODEL + "ichorGem2.png";
+
+ public static final String ENCHANT_PROTECTION = PREFIX_ENCHANTS + "protection.png";
+ public static final String ENCHANT_FIRE_PROTECTION = PREFIX_ENCHANTS + "fireProtection.png";
+ public static final String ENCHANT_FEATHER_FALLING = PREFIX_ENCHANTS + "featherFalling.png";
+ public static final String ENCHANT_BLAST_PROTECTION = PREFIX_ENCHANTS + "blastProtection.png";
+ public static final String ENCHANT_PROJECTILE_PROTECTION = PREFIX_ENCHANTS + "projectileProtection.png";
+ public static final String ENCHANT_RESPIRATION = PREFIX_ENCHANTS + "respiration.png";
+ public static final String ENCHANT_AQUA_AFFINITY = PREFIX_ENCHANTS + "aquaAffinity.png";
+ public static final String ENCHANT_THORNS = PREFIX_ENCHANTS + "thorns.png";
+ public static final String ENCHANT_SHARPNESS = PREFIX_ENCHANTS + "sharpness.png";
+ public static final String ENCHANT_SMITE = PREFIX_ENCHANTS + "smite.png";
+ public static final String ENCHANT_BANE_OF_ARTHROPODS = PREFIX_ENCHANTS + "baneOfAwfulTurds.png";
+ public static final String ENCHANT_KNOCKBACK = PREFIX_ENCHANTS + "knockback.png";
+ public static final String ENCHANT_FIRE_ASPECT = PREFIX_ENCHANTS + "fireAspect.png";
+ public static final String ENCHANT_LOOTING = PREFIX_ENCHANTS + "looting.png";
+ public static final String ENCHANT_EFFICIENCY = PREFIX_ENCHANTS + "efficiency.png";
+ public static final String ENCHANT_SILK_TOUCH = PREFIX_ENCHANTS + "silkTouch.png";
+ public static final String ENCHANT_UNBREAKING = PREFIX_ENCHANTS + "unbreaking.png";
+ public static final String ENCHANT_FORTUNE = PREFIX_ENCHANTS + "fortune.png";
+ public static final String ENCHANT_POWER = PREFIX_ENCHANTS + "power.png";
+ public static final String ENCHANT_PUNCH = PREFIX_ENCHANTS + "punch.png";
+ public static final String ENCHANT_FLAME = PREFIX_ENCHANTS + "flame.png";
+ public static final String ENCHANT_INFINITY = PREFIX_ENCHANTS + "infinity.png";
+ public static final String ENCHANT_LUCK_OF_THE_SEA = PREFIX_ENCHANTS + "luckOfTheSea.png";
+ public static final String ENCHANT_LURE = PREFIX_ENCHANTS + "lure.png";
+ public static final String ENCHANT_POTENCY = PREFIX_ENCHANTS + "potency.png";
+ public static final String ENCHANT_FRUGAL = PREFIX_ENCHANTS + "frugal.png";
+ public static final String ENCHANT_TREASURE = PREFIX_ENCHANTS + "treasure.png";
+ public static final String ENCHANT_HASTE = PREFIX_ENCHANTS + "haste.png";
+ public static final String ENCHANT_REPAIR = PREFIX_ENCHANTS + "repair.png";
+
+ public static final String ENCHANT_SLOW_FALL = PREFIX_ENCHANTS + "slowFall.png";
+ public static final String ENCHANT_ASCENT_BOOST = PREFIX_ENCHANTS + "ascentBoost.png";
+ public static final String ENCHANT_AUTO_SMELT = PREFIX_ENCHANTS + "autoSmelt.png";
+ public static final String ENCHANT_DESINTEGRATE = PREFIX_ENCHANTS + "desintegrate.png";
+ public static final String ENCHANT_VAMPIRISM = PREFIX_ENCHANTS + "vamprisim.png";
+ public static final String ENCHANT_QUICK_DRAW = PREFIX_ENCHANTS + "quickDraw.png";
+
+ public static final String[] LANGS = {
+ "en_US", "de_DE", "zh_CN", "ru_RU"
+ };
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/model/ModelMagnet.java b/src/main/java/vazkii/tinkerer/client/model/ModelMagnet.java
new file mode 100644
index 00000000..228b0686
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/model/ModelMagnet.java
@@ -0,0 +1,88 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 17:56:17 (GMT)]
+ */
+package vazkii.tinkerer.client.model;
+
+import net.minecraft.client.model.ModelBase;
+import net.minecraft.client.model.ModelRenderer;
+
+public class ModelMagnet extends ModelBase {
+
+ ModelRenderer panel;
+ ModelRenderer magnet;
+ ModelRenderer box1;
+ ModelRenderer box2;
+ ModelRenderer box3;
+ ModelRenderer box4;
+ ModelRenderer box5;
+
+ public ModelMagnet() {
+ textureWidth = 64;
+ textureHeight = 64;
+
+ panel = new ModelRenderer(this, 0, 0);
+ panel.addBox(0F, 0F, 0F, 14, 2, 14);
+ panel.setRotationPoint(-7F, 22F, -7F);
+ panel.setTextureSize(64, 64);
+ setRotation(panel, 0F, 0F, 0F);
+ magnet = new ModelRenderer(this, 0, 16);
+ magnet.addBox(0F, 0F, 0F, 4, 13, 4);
+ magnet.setRotationPoint(-2F, 9F, -2F);
+ magnet.setTextureSize(64, 64);
+ setRotation(magnet, 0F, 0F, 0F);
+ box1 = new ModelRenderer(this, 28, 19);
+ box1.addBox(0F, -2F, 0F, 6, 14, 0);
+ box1.setRotationPoint(3F, 10F, -3F);
+ box1.setTextureSize(64, 64);
+ setRotation(box1, 0F, -1.570796F, 0F);
+ box2 = new ModelRenderer(this, 28, 33);
+ box2.addBox(0F, 0F, 0F, 6, 14, 0);
+ box2.setRotationPoint(-3F, 8F, 3F);
+ box2.setTextureSize(64, 64);
+ setRotation(box2, 0F, 1.570796F, 0F);
+ box3 = new ModelRenderer(this, 40, 19);
+ box3.addBox(0F, 0F, 0F, 6, 14, 0);
+ box3.setRotationPoint(3F, 8F, 3F);
+ box3.setTextureSize(64, 64);
+ setRotation(box3, 0F, 3.141593F, 0F);
+ box4 = new ModelRenderer(this, 40, 33);
+ box4.addBox(0F, 0F, 0F, 6, 14, 0);
+ box4.setRotationPoint(-3F, 8F, -3F);
+ box4.setTextureSize(64, 64);
+ setRotation(box4, 0F, 0F, 0F);
+ box5 = new ModelRenderer(this, 28, 49);
+ box5.addBox(0F, 0F, 0F, 6, 0, 6);
+ box5.setRotationPoint(-3F, 8F, -3F);
+ box5.setTextureSize(64, 64);
+ setRotation(box5, 0F, 0F, 0F);
+ }
+
+ public void render() {
+ final float scale = 1F / 16F;
+
+ panel.render(scale);
+ magnet.render(scale);
+ box1.render(scale);
+ box2.render(scale);
+ box3.render(scale);
+ box4.render(scale);
+ box5.render(scale);
+ }
+
+ private void setRotation(ModelRenderer model, float x, float y, float z) {
+ model.rotateAngleX = x;
+ model.rotateAngleY = y;
+ model.rotateAngleZ = z;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/client/model/ModelRepairer.java b/src/main/java/vazkii/tinkerer/client/model/ModelRepairer.java
new file mode 100644
index 00000000..6027802c
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/model/ModelRepairer.java
@@ -0,0 +1,172 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 17:18:53 (GMT)]
+ */
+package vazkii.tinkerer.client.model;
+
+import net.minecraft.client.model.ModelBase;
+import net.minecraft.client.model.ModelRenderer;
+
+public class ModelRepairer extends ModelBase {
+
+ ModelRenderer Base;
+ ModelRenderer Support1;
+ ModelRenderer Support2;
+ ModelRenderer Support3;
+ ModelRenderer Support4;
+ ModelRenderer Top1;
+ ModelRenderer Top2;
+ ModelRenderer Top3;
+ ModelRenderer Top4;
+ ModelRenderer Opening1;
+ ModelRenderer Opening2;
+ ModelRenderer Opening3;
+ ModelRenderer Opening4;
+ ModelRenderer Glass1;
+ ModelRenderer Glass2;
+ ModelRenderer Glass3;
+ ModelRenderer Glass4;
+ ModelRenderer Glass5;
+
+ public ModelRepairer() {
+ textureWidth = 64;
+ textureHeight = 64;
+
+ Base = new ModelRenderer(this, 0, 0);
+ Base.addBox(0F, 0F, 0F, 16, 1, 16);
+ Base.setRotationPoint(-8F, 23F, -8F);
+ Base.setTextureSize(64, 64);
+ setRotation(Base, 0F, 0F, 0F);
+ Support1 = new ModelRenderer(this, 0, 17);
+ Support1.addBox(0F, 0F, 0F, 2, 14, 2);
+ Support1.setRotationPoint(-8F, 9F, 6F);
+ Support1.setTextureSize(64, 64);
+ setRotation(Support1, 0F, 0F, 0F);
+ Support2 = new ModelRenderer(this, 0, 17);
+ Support2.addBox(0F, 0F, 0F, 2, 14, 2);
+ Support2.setRotationPoint(6F, 9F, 6F);
+ Support2.setTextureSize(64, 64);
+ setRotation(Support2, 0F, 0F, 0F);
+ Support3 = new ModelRenderer(this, 0, 17);
+ Support3.addBox(0F, 0F, 0F, 2, 14, 2);
+ Support3.setRotationPoint(-8F, 9F, -8F);
+ Support3.setTextureSize(64, 64);
+ setRotation(Support3, 0F, 0F, 0F);
+ Support4 = new ModelRenderer(this, 0, 17);
+ Support4.addBox(0F, 0F, 0F, 2, 14, 2);
+ Support4.setRotationPoint(6F, 9F, -8F);
+ Support4.setTextureSize(64, 64);
+ setRotation(Support4, 0F, 0F, 0F);
+ Top1 = new ModelRenderer(this, 11, 19);
+ Top1.addBox(0F, 0F, 0F, 16, 1, 2);
+ Top1.setRotationPoint(-8F, 8F, -8F);
+ Top1.setTextureSize(64, 64);
+ setRotation(Top1, 0F, 0F, 0F);
+ Top2 = new ModelRenderer(this, 11, 19);
+ Top2.addBox(0F, 0F, 0F, 16, 1, 2);
+ Top2.setRotationPoint(-8F, 8F, 6F);
+ Top2.setTextureSize(64, 64);
+ setRotation(Top2, 0F, 0F, 0F);
+ Top3 = new ModelRenderer(this, 11, 23);
+ Top3.addBox(0F, 0F, 0F, 2, 1, 12);
+ Top3.setRotationPoint(6F, 8F, -6F);
+ Top3.setTextureSize(64, 64);
+ setRotation(Top3, 0F, 0F, 0F);
+ Top4 = new ModelRenderer(this, 11, 23);
+ Top4.addBox(0F, 0F, 0F, 2, 1, 12);
+ Top4.setRotationPoint(-8F, 8F, -6F);
+ Top4.setTextureSize(64, 64);
+ setRotation(Top4, 0F, 0F, 0F);
+ Opening1 = new ModelRenderer(this, 48, 30);
+ Opening1.addBox(0F, 0F, 0F, 5, 1, 1);
+ Opening1.setRotationPoint(-2.5F, 14F, 7F);
+ Opening1.setTextureSize(64, 64);
+ setRotation(Opening1, 0F, 0F, 0F);
+ Opening2 = new ModelRenderer(this, 48, 30);
+ Opening2.addBox(0F, 0F, 0F, 5, 1, 1);
+ Opening2.setRotationPoint(-2.5F, 17F, 7F);
+ Opening2.setTextureSize(64, 64);
+ setRotation(Opening2, 0F, 0F, 0F);
+ Opening3 = new ModelRenderer(this, 48, 24);
+ Opening3.addBox(0F, 0F, 0F, 1, 3, 1);
+ Opening3.setRotationPoint(-2F, 14.5F, 7F);
+ Opening3.setTextureSize(64, 64);
+ setRotation(Opening3, 0F, 0F, 0F);
+ Opening4 = new ModelRenderer(this, 48, 24);
+ Opening4.addBox(0F, 0F, 0F, 1, 3, 1);
+ Opening4.setRotationPoint(1F, 14.5F, 7F);
+ Opening4.setTextureSize(64, 64);
+ setRotation(Opening4, 0F, 0F, 0F);
+ Glass1 = new ModelRenderer(this, -11, 37);
+ Glass1.addBox(0F, 0F, 0F, 12, 0, 12);
+ Glass1.setRotationPoint(-6F, 8.5F, -6F);
+ Glass1.setTextureSize(64, 64);
+ setRotation(Glass1, 0F, 0F, 0F);
+ Glass2 = new ModelRenderer(this, 1, 38);
+ Glass2.addBox(0F, 0F, 0F, 0, 14, 12);
+ Glass2.setRotationPoint(7.5F, 9F, -6F);
+ Glass2.setTextureSize(64, 64);
+ setRotation(Glass2, 0F, 0F, 0F);
+ Glass3 = new ModelRenderer(this, 1, 38);
+ Glass3.addBox(0F, 0F, 0F, 0, 14, 12);
+ Glass3.setRotationPoint(-7.5F, 9F, 6F);
+ Glass3.setTextureSize(64, 64);
+ setRotation(Glass3, 0F, 3.141593F, 0F);
+ Glass4 = new ModelRenderer(this, 40, 34);
+ Glass4.addBox(0F, 0F, 0F, 12, 14, 0);
+ Glass4.setRotationPoint(-6F, 9F, -7.5F);
+ Glass4.setTextureSize(64, 64);
+ setRotation(Glass4, 0F, 0F, 0F);
+ Glass5 = new ModelRenderer(this, 33, 50);
+ Glass5.addBox(0F, 0F, 0F, 12, 14, 0);
+ Glass5.setRotationPoint(6F, 9F, 7.5F);
+ Glass5.setTextureSize(64, 64);
+ setRotation(Glass5, 0F, 3.141593F, 0F);
+ }
+
+ public void render() {
+ final float scale = 1F / 16F;
+
+ Base.render(scale);
+ Support1.render(scale);
+ Support2.render(scale);
+ Support3.render(scale);
+ Support4.render(scale);
+ Top1.render(scale);
+ Top2.render(scale);
+ Top3.render(scale);
+ Top4.render(scale);
+ Opening1.render(scale);
+ Opening2.render(scale);
+ Opening3.render(scale);
+ Opening4.render(scale);
+
+ }
+
+ public void renderGlass() {
+ final float scale = 1F / 16F;
+
+ Glass1.render(scale);
+ Glass2.render(scale);
+ Glass3.render(scale);
+ Glass4.render(scale);
+ Glass5.render(scale);
+ }
+
+ private void setRotation(ModelRenderer model, float x, float y, float z) {
+ model.rotateAngleX = x;
+ model.rotateAngleY = y;
+ model.rotateAngleZ = z;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/model/kami/ModelSpinningCubes.java b/src/main/java/vazkii/tinkerer/client/model/kami/ModelSpinningCubes.java
new file mode 100644
index 00000000..9b8862ad
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/model/kami/ModelSpinningCubes.java
@@ -0,0 +1,97 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Jan 10, 2014, 4:41:02 PM (GMT)]
+ */
+package vazkii.tinkerer.client.model.kami;
+
+import net.minecraft.client.model.ModelBase;
+import net.minecraft.client.model.ModelRenderer;
+import net.minecraft.client.renderer.OpenGlHelper;
+
+import org.lwjgl.opengl.GL11;
+
+import vazkii.tinkerer.client.core.helper.ClientHelper;
+
+public class ModelSpinningCubes extends ModelBase {
+
+ ModelRenderer spinningCube;
+
+ public ModelSpinningCubes() {
+ spinningCube = new ModelRenderer(this, 42, 0);
+ spinningCube.addBox(0F, 0F, 0F, 1, 1, 1);
+ spinningCube.setRotationPoint(0F, 0F, 0F);
+ spinningCube.setTextureSize(64, 64);
+ spinningCube.mirror = true;
+ }
+
+ public void render() {
+ // NO-OP
+ }
+
+ public void renderSpinningCubes(int cubes, int repeat, int origRepeat) {
+ GL11.glDisable(GL11.GL_TEXTURE_2D);
+
+ final float modifier = 6F;
+ final float rotationModifier = 0.25F;
+ final float radiusBase = 0.7F;
+ final float radiusMod = 0.1F;
+
+ double ticks = ClientHelper.clientPlayer().ticksExisted - 0.75 * (origRepeat - repeat);
+ float offsetPerCube = 360 / cubes;
+
+ GL11.glPushMatrix();
+ GL11.glTranslatef(-0.025F, 0.85F, -0.025F);
+ for(int i = 0; i < cubes; i++) {
+ float offset = offsetPerCube * i;
+ float deg = (int) (ticks / rotationModifier % 360F + offset);
+ float rad = deg * (float) Math.PI / 180F;
+ float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier));
+ float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier));
+ float x = (float) (radiusX * Math.cos(rad));
+ float z = (float) (radiusZ * Math.sin(rad));
+ float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F;
+
+ GL11.glPushMatrix();
+ GL11.glTranslatef(x, y, z);
+ float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F;
+ float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F);
+ float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F;
+
+ GL11.glRotatef(deg, xRotate, yRotate, zRotate);
+ if(repeat < origRepeat) {
+ GL11.glColor4f(1F, 1F, 1F, 0.2F);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ } else GL11.glColor4f(1F, 1F, 1F, 1F);
+
+ int light = 15728880;
+ int lightmapX = light % 65536;
+ int lightmapY = light / 65536;
+
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
+ spinningCube.render(1F / 16F);
+
+ if(repeat < origRepeat)
+ GL11.glDisable(GL11.GL_BLEND);
+
+ GL11.glPopMatrix();
+ }
+ GL11.glPopMatrix();
+
+ GL11.glEnable(GL11.GL_TEXTURE_2D);
+
+ if(repeat != 0)
+ renderSpinningCubes(cubes, repeat - 1, origRepeat);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/model/kami/ModelWings.java b/src/main/java/vazkii/tinkerer/client/model/kami/ModelWings.java
new file mode 100644
index 00000000..5593a0a0
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/model/kami/ModelWings.java
@@ -0,0 +1,94 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 25, 2013, 00:18:06 PM (GMT)]
+ */
+package vazkii.tinkerer.client.model.kami;
+
+import net.minecraft.client.model.ModelBiped;
+import net.minecraft.client.model.ModelRenderer;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumAction;
+import net.minecraft.item.ItemStack;
+
+public class ModelWings extends ModelBiped {
+
+ ModelRenderer Wing1;
+ ModelRenderer Wing2;
+
+ public ModelWings() {
+ super(1F);
+ textureWidth = 64;
+ textureHeight = 32;
+
+ Wing1 = new ModelRenderer(this, 16, -12);
+ Wing1.addBox(0F, 0F, 0F, 0, 7, 12);
+ Wing1.setRotationPoint(-2F, 1F, 2F);
+ setRotation(Wing1, 0F, -0.6108652F, 0F);
+ bipedBody.addChild(Wing1);
+
+ Wing2 = new ModelRenderer(this, 16, -12);
+ Wing2.addBox(0.1F, 0F, 0F, 0, 7, 12);
+ Wing2.setRotationPoint(2F, 1F, 2F);
+ setRotation(Wing2, 0F, 0.4468043F, 0F);
+ bipedBody.addChild(Wing2);
+ }
+
+ @Override
+ public void render(Entity entity, float v1, float v2, float v3, float v4, float v5, float v6) {
+ setRotationAngles(v1, v2, v3, v4, v5, v6, entity);
+
+ bipedHead.showModel = false;
+ bipedHeadwear.showModel = false;
+ bipedLeftLeg.showModel = false;
+ bipedRightLeg.showModel = false;
+
+ super.render(entity, v1, v2, v3, v4, v5, v6);
+ }
+
+ @Override
+ public void setRotationAngles(float v1, float v2, float v3, float v4, float v5, float v6, Entity entity) {
+ EntityLivingBase living = (EntityLivingBase) entity;
+ isSneak = living != null ? living.isSneaking() : false;
+ if(living != null && living instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) living;
+
+ ItemStack itemstack = player.inventory.getCurrentItem();
+ heldItemRight = itemstack != null ? 1 : 0;
+
+ if (itemstack != null && player.getItemInUseCount() > 0) {
+ EnumAction enumaction = itemstack.getItemUseAction();
+
+ if (enumaction == EnumAction.block)
+ heldItemRight = 3;
+ else if (enumaction == EnumAction.bow)
+ aimedBow = true;
+ }
+
+ if(player.capabilities.isFlying) {
+ Wing1.rotateAngleY = (float) ((Math.sin(entity.ticksExisted) + 1) * (Math.PI / 180F) * 15 - 0.6108652F);
+ Wing2.rotateAngleY = -Wing1.rotateAngleY;
+ }
+ }
+
+ super.setRotationAngles(v1, v2, v3, v4, v5, v6, entity);
+ }
+
+ private void setRotation(ModelRenderer model, float x, float y, float z) {
+ model.rotateAngleX = x;
+ model.rotateAngleY = y;
+ model.rotateAngleZ = z;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/render/block/RenderMagnet.java b/src/main/java/vazkii/tinkerer/client/render/block/RenderMagnet.java
new file mode 100644
index 00000000..07158163
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/render/block/RenderMagnet.java
@@ -0,0 +1,56 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 18:08:42 (GMT)]
+ */
+package vazkii.tinkerer.client.render.block;
+
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
+import net.minecraft.world.IBlockAccess;
+
+import org.lwjgl.opengl.GL11;
+
+import vazkii.tinkerer.client.lib.LibRenderIDs;
+import vazkii.tinkerer.client.render.tile.RenderTileMagnet;
+import vazkii.tinkerer.common.block.tile.TileMagnet;
+import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
+
+public class RenderMagnet implements ISimpleBlockRenderingHandler {
+
+ @Override
+ public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
+ RenderTileMagnet.mob = metadata == 1;
+
+ GL11.glPushMatrix();
+ GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
+ TileEntityRenderer.instance.renderTileEntityAt(new TileMagnet(), 0.0D, 0.0D, 0.0D, 0.0F);
+ GL11.glPopMatrix();
+ }
+
+ @Override
+ public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
+ return false;
+ }
+
+ @Override
+ public boolean shouldRender3DInInventory() {
+ return true;
+ }
+
+ @Override
+ public int getRenderId() {
+ return LibRenderIDs.idMagnet;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/client/render/block/RenderRepairer.java b/src/main/java/vazkii/tinkerer/client/render/block/RenderRepairer.java
new file mode 100644
index 00000000..da1c1e22
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/render/block/RenderRepairer.java
@@ -0,0 +1,53 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Nov 30, 2013, 5:50:21 PM (GMT)]
+ */
+package vazkii.tinkerer.client.render.block;
+
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
+import net.minecraft.world.IBlockAccess;
+
+import org.lwjgl.opengl.GL11;
+
+import vazkii.tinkerer.client.lib.LibRenderIDs;
+import vazkii.tinkerer.common.block.tile.TileRepairer;
+import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
+
+public class RenderRepairer implements ISimpleBlockRenderingHandler {
+
+ @Override
+ public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
+ GL11.glPushMatrix();
+ GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
+ TileEntityRenderer.instance.renderTileEntityAt(new TileRepairer(), 0.0D, 0.0D, 0.0D, 0.0F);
+ GL11.glPopMatrix();
+ }
+
+ @Override
+ public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
+ return false;
+ }
+
+ @Override
+ public boolean shouldRender3DInInventory() {
+ return true;
+ }
+
+ @Override
+ public int getRenderId() {
+ return LibRenderIDs.idRepairer;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/client/render/block/kami/RenderWarpGate.java b/src/main/java/vazkii/tinkerer/client/render/block/kami/RenderWarpGate.java
new file mode 100644
index 00000000..784ea162
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/render/block/kami/RenderWarpGate.java
@@ -0,0 +1,78 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Jan 10, 2014, 4:03:03 PM (GMT)]
+ */
+package vazkii.tinkerer.client.render.block.kami;
+
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.util.Icon;
+import net.minecraft.world.IBlockAccess;
+
+import org.lwjgl.opengl.GL11;
+
+import thaumcraft.client.renderers.block.BlockRenderer;
+import vazkii.tinkerer.client.lib.LibRenderIDs;
+import vazkii.tinkerer.common.block.kami.BlockWarpGate;
+import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
+
+public class RenderWarpGate extends BlockRenderer implements ISimpleBlockRenderingHandler {
+
+ @Override
+ public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
+ block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
+ Icon topIcon = BlockWarpGate.icons[0];
+ Icon sideIcon = BlockWarpGate.icons[1];
+ drawFaces(renderer, block, sideIcon, topIcon, sideIcon, sideIcon, sideIcon, sideIcon, false);
+ GL11.glColor3f(1F, 1F, 1F);
+
+ GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
+ Tessellator t = Tessellator.instance;
+ t.startDrawingQuads();
+ t.setBrightness(255);
+ t.setNormal(0, 1, 0);
+ renderer.renderFaceYPos(block, 0, 0, 0, BlockWarpGate.icons[2]);
+ t.draw();
+ GL11.glTranslatef(0.5F, 0.5F, 0.5F);
+ }
+
+ @Override
+ public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
+ block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
+ renderer.setRenderBoundsFromBlock(block);
+ renderer.renderStandardBlock(block, x, y, z);
+
+ Tessellator t = Tessellator.instance;
+ t.setColorOpaque_I(0xFFFFFF);
+ t.setBrightness(255);
+ renderer.renderFaceYPos(block, x, y, z, BlockWarpGate.icons[2]);
+
+ renderer.clearOverrideBlockTexture();
+ block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
+ renderer.renderStandardBlock(block, x, y, z);
+
+ return true;
+ }
+
+ @Override
+ public boolean shouldRender3DInInventory() {
+ return true;
+ }
+
+ @Override
+ public int getRenderId() {
+ return LibRenderIDs.idWarpGate;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/render/item/kami/RenderPlacementMirror.java b/src/main/java/vazkii/tinkerer/client/render/item/kami/RenderPlacementMirror.java
new file mode 100644
index 00000000..679af7d2
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/render/item/kami/RenderPlacementMirror.java
@@ -0,0 +1,65 @@
+package vazkii.tinkerer.client.render.item.kami;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.ItemRenderer;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.entity.RenderItem;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Icon;
+import net.minecraftforge.client.IItemRenderer;
+
+import org.lwjgl.opengl.GL11;
+
+import vazkii.tinkerer.common.item.ModItems;
+
+public class RenderPlacementMirror implements IItemRenderer {
+
+ RenderItem render = new RenderItem();
+ ItemRenderer renderer = new ItemRenderer(Minecraft.getMinecraft());
+
+ @Override
+ public boolean handleRenderType(ItemStack item, ItemRenderType type) {
+ return type != ItemRenderType.INVENTORY;
+ }
+
+ @Override
+ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
+ return false;
+ }
+
+ @Override
+ public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
+ switch(type) {
+ case ENTITY : {
+ GL11.glPushMatrix();
+ GL11.glTranslatef(-0.5F, 0F, 0F);
+ renderItem(ItemRenderType.EQUIPPED, item, data);
+ GL11.glPopMatrix();
+ break;
+ }
+ case EQUIPPED : {
+ for(int i = 1; i >= 0; i--) {
+ Icon icon = ModItems.placementMirror.getIconFromDamageForRenderPass(0, i);
+ if(i == 0) {
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ }
+
+ float f = icon.getMinU();
+ float f1 = icon.getMaxU();
+ float f2 = icon.getMinV();
+ float f3 = icon.getMaxV();
+ ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
+ }
+ GL11.glDisable(GL11.GL_BLEND);
+ break;
+ }
+ case EQUIPPED_FIRST_PERSON : {
+ renderItem(ItemRenderType.EQUIPPED, item, data);
+ break;
+ }
+ default : break;
+ }
+ }
+
+ }
diff --git a/src/main/java/vazkii/tinkerer/client/render/tile/RenderTileAnimationTablet.java b/src/main/java/vazkii/tinkerer/client/render/tile/RenderTileAnimationTablet.java
new file mode 100644
index 00000000..470803e1
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/render/tile/RenderTileAnimationTablet.java
@@ -0,0 +1,143 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 17:12:26 (GMT)]
+ */
+package vazkii.tinkerer.client.render.tile;
+
+import java.awt.Color;
+
+import net.minecraft.block.Block;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.ItemRenderer;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.Icon;
+import net.minecraft.util.ResourceLocation;
+
+import org.lwjgl.opengl.GL11;
+
+import vazkii.tinkerer.client.core.helper.ClientHelper;
+import vazkii.tinkerer.client.lib.LibResources;
+import vazkii.tinkerer.common.block.tile.tablet.TileAnimationTablet;
+
+public class RenderTileAnimationTablet extends TileEntitySpecialRenderer {
+
+ private static final ResourceLocation overlayCenter = new ResourceLocation(LibResources.MISC_AT_CENTER);
+ private static final ResourceLocation overlayLeft = new ResourceLocation(LibResources.MISC_AT_LEFT);
+ private static final ResourceLocation overlayRight = new ResourceLocation(LibResources.MISC_AT_RIGHT);
+ private static final ResourceLocation overlayIndent = new ResourceLocation(LibResources.MISC_AT_INDENT);
+
+ private static final float[][] TRANSLATIONS = new float[][] {
+ { 0F, 0F, -1F },
+ { -1F, 0F, 0F },
+ { 0F, 0F, 0F },
+ { -1F, 0F, -1F }
+ };
+
+ @Override
+ public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float partialTicks) {
+ TileAnimationTablet tile = (TileAnimationTablet) tileentity;
+
+ int meta = tile.getBlockMetadata() & 7;
+ if(meta < 2)
+ meta = 2; // Just in case
+
+ int rotation = meta == 2 ? 270 : meta == 3 ? 90 : meta == 4 ? 0 : 180;
+
+ GL11.glPushMatrix();
+ GL11.glTranslated(d0, d1, d2);
+ renderOverlay(tile, overlayCenter, -1, false, false, 0.65, 0.13F, 0F);
+ if(tile.leftClick)
+ renderOverlay(tile, overlayLeft, 1, false, true, 1, 0.13F, 0F);
+ else renderOverlay(tile, overlayRight, 1, false, true, 1, 0.131F, 0F);
+ renderOverlay(tile, overlayIndent, 0, false, false, 0.5F, 0.13F, rotation + 90F);
+
+ GL11.glRotatef(rotation, 0F, 1F, 0F);
+ GL11.glTranslated(0.1, 0.2 + Math.cos(System.currentTimeMillis() / 600D) / 18F, 0.5);
+ float[] translations = TRANSLATIONS[meta - 2];
+ GL11.glTranslatef(translations[0], translations[1], translations[2]);
+ GL11.glScalef(0.8F, 0.8F, 0.8F);
+ GL11.glTranslatef(0.5F, 0F, 0.5F);
+ GL11.glRotatef(tile.swingProgress, 0F, 0F, 1F);
+ GL11.glTranslatef(-0.5F, 0F, -0.5F);
+ GL11.glTranslatef(-tile.swingProgress / 250F, tile.swingProgress / 1000F, 0F);
+ GL11.glRotatef((float) Math.cos(System.currentTimeMillis() / 400F) * 5F, 1F, 0F, 1F);
+ renderItem(tile);
+ GL11.glPopMatrix();
+ }
+
+ private void renderItem(TileAnimationTablet tablet) {
+ ItemStack stack = tablet.getStackInSlot(0);
+ Minecraft mc = ClientHelper.minecraft();
+ if(stack != null) {
+ mc.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture);
+
+ if(stack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.blocksList[stack.itemID].getRenderType())) {
+ GL11.glTranslatef(0.5F, 0.55F, 0F);
+ new RenderBlocks().renderBlockAsItem(Block.blocksList[stack.itemID], stack.getItemDamage(), 1F);
+ GL11.glTranslatef(-0.5F, -0.55F, 0F);
+ } else {
+ int renderPass = 0;
+ do {
+ Icon icon = stack.getItem().getIcon(stack, renderPass);
+ if(icon != null) {
+ Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass));
+ GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
+ float f = icon.getMinU();
+ float f1 = icon.getMaxU();
+ float f2 = icon.getMinV();
+ float f3 = icon.getMaxV();
+ ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
+ GL11.glColor3f(1F, 1F, 1F);
+ }
+ renderPass++;
+ } while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage()));
+ }
+ }
+ }
+
+ private void renderOverlay(TileAnimationTablet tablet, ResourceLocation texture, int rotationMod, boolean useLighting, boolean useBlend, double size, float height, float forceDeg) {
+ Minecraft mc = ClientHelper.minecraft();
+ mc.renderEngine.bindTexture(texture);
+ GL11.glPushMatrix();
+ GL11.glDepthMask(false);
+ if(!useLighting)
+ GL11.glDisable(GL11.GL_LIGHTING);
+ if(useBlend) {
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ }
+ GL11.glTranslatef(0.5F, height, 0.5F);
+ float deg = rotationMod == 0 ? forceDeg : (float) (tablet.ticksExisted * rotationMod % 360F);
+ GL11.glRotatef(deg, 0F, 1F, 0F);
+ GL11.glColor4f(1F, 1F, 1F, 1F);
+ Tessellator tess = Tessellator.instance;
+ double size1 = size / 2;
+ double size2 = -size1;
+ tess.startDrawingQuads();
+ tess.addVertexWithUV(size2, 0, size1, 0, 1);
+ tess.addVertexWithUV(size1, 0, size1, 1, 1);
+ tess.addVertexWithUV(size1, 0, size2, 1, 0);
+ tess.addVertexWithUV(size2, 0, size2, 0, 0);
+ tess.draw();
+ GL11.glDepthMask(true);
+ if(!useLighting)
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glPopMatrix();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/client/render/tile/RenderTileEnchanter.java b/src/main/java/vazkii/tinkerer/client/render/tile/RenderTileEnchanter.java
new file mode 100644
index 00000000..da327395
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/render/tile/RenderTileEnchanter.java
@@ -0,0 +1,95 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [16 Sep 2013, 22:39:36 (GMT)]
+ */
+package vazkii.tinkerer.client.render.tile;
+
+import java.awt.Color;
+
+import net.minecraft.client.renderer.ItemRenderer;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.Icon;
+import net.minecraftforge.client.IItemRenderer.ItemRenderType;
+
+import org.lwjgl.opengl.GL11;
+
+import thaumcraft.client.renderers.item.ItemWandRenderer;
+import vazkii.tinkerer.client.core.helper.ClientHelper;
+import vazkii.tinkerer.common.block.tile.TileEnchanter;
+
+public class RenderTileEnchanter extends TileEntitySpecialRenderer {
+
+ ItemWandRenderer wandRenderer = new ItemWandRenderer();
+
+ @Override
+ public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float partTicks) {
+ TileEnchanter enchanter = (TileEnchanter) tileentity;
+
+ GL11.glPushMatrix();
+ GL11.glTranslated(d0, d1 + 0.75, d2);
+
+ ItemStack item = enchanter.getStackInSlot(0);
+ if(item != null) {
+ GL11.glPushMatrix();
+ GL11.glRotatef(90F, 1F, 0F, 0F);
+ final float scale = 0.7F;
+ GL11.glScalef(scale, scale, scale);
+ GL11.glTranslatef(0.6F, -0.2F, 0F);
+ GL11.glRotatef(30F, 0F, 0F, 1F);
+
+ ClientHelper.minecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
+
+ int renderPass = 0;
+ do {
+ Icon icon = item.getItem().getIcon(item, renderPass);
+ if(icon != null) {
+ Color color = new Color(item.getItem().getColorFromItemStack(item, renderPass));
+ GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
+ float f = icon.getMinU();
+ float f1 = icon.getMaxU();
+ float f2 = icon.getMinV();
+ float f3 = icon.getMaxV();
+ ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
+ GL11.glColor3f(1F, 1F, 1F);
+ }
+ renderPass++;
+ } while(renderPass < item.getItem().getRenderPasses(item.getItemDamage()));
+ GL11.glPopMatrix();
+ }
+
+ item = enchanter.getStackInSlot(1);
+ if(item != null) {
+ GL11.glPushMatrix();
+ GL11.glRotatef(90F, 1F, 0F, 0F);
+ final float scale = 0.5F;
+ GL11.glScalef(scale, scale, scale);
+ GL11.glTranslatef(0.6F, 1.5F, -0.1F);
+ GL11.glRotatef(-70F, 0F, 0F, 1F);
+ long millis = System.currentTimeMillis();
+
+ GL11.glTranslatef(0F, 0F, (float) (Math.cos((double) millis / 1000F) - 1.2F) / 10F);
+ GL11.glTranslatef(0F, 0.325F, 0F);
+ GL11.glRotatef((float) Math.cos((double) millis / 500F) * 5F, 1F, 0F, 0F);
+ GL11.glTranslatef(0F, -0.325F, 0F);
+
+ wandRenderer.renderItem(ItemRenderType.ENTITY, item, (Object[]) null);
+ GL11.glPopMatrix();
+ }
+
+ GL11.glPopMatrix();
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/client/render/tile/RenderTileFunnel.java b/src/main/java/vazkii/tinkerer/client/render/tile/RenderTileFunnel.java
new file mode 100644
index 00000000..98e1273e
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/render/tile/RenderTileFunnel.java
@@ -0,0 +1,50 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [28 Sep 2013, 20:24:39 (GMT)]
+ */
+package vazkii.tinkerer.client.render.tile;
+
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.client.IItemRenderer.ItemRenderType;
+
+import org.lwjgl.opengl.GL11;
+
+import thaumcraft.client.renderers.block.BlockJarRenderer;
+import thaumcraft.client.renderers.tile.ItemJarFilledRenderer;
+import thaumcraft.common.config.ConfigBlocks;
+import vazkii.tinkerer.common.block.tile.TileFunnel;
+
+public class RenderTileFunnel extends TileEntitySpecialRenderer {
+
+ BlockJarRenderer jarRenderer = new BlockJarRenderer();
+ ItemJarFilledRenderer jarRenderer1 = new ItemJarFilledRenderer();
+
+ @Override
+ public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) {
+ TileFunnel funnel = (TileFunnel) tileentity;
+ ItemStack stack = funnel.getStackInSlot(0);
+ if(stack != null) {
+ GL11.glPushMatrix();
+ GL11.glTranslated(d0 + 0.5, d1 + 0.365, d2 + 0.5);
+ if(stack.itemID == ConfigBlocks.blockJar.blockID) {
+ GL11.glTranslatef(0F, 0.25F, 0F);
+ jarRenderer.renderInventoryBlock(ConfigBlocks.blockJar, 0, 0, new RenderBlocks());
+ } else jarRenderer1.renderItem(ItemRenderType.ENTITY, stack, (Object[]) null);
+ GL11.glPopMatrix();
+ }
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/render/tile/RenderTileMagnet.java b/src/main/java/vazkii/tinkerer/client/render/tile/RenderTileMagnet.java
new file mode 100644
index 00000000..db6275ef
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/render/tile/RenderTileMagnet.java
@@ -0,0 +1,80 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 17:55:04 (GMT)]
+ */
+package vazkii.tinkerer.client.render.tile;
+
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.Icon;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.common.ForgeDirection;
+
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL12;
+
+import thaumcraft.client.lib.UtilsFX;
+import thaumcraft.common.config.ConfigItems;
+import thaumcraft.common.items.armor.ItemHoverHarness;
+import vazkii.tinkerer.client.core.helper.ClientHelper;
+import vazkii.tinkerer.client.lib.LibResources;
+import vazkii.tinkerer.client.model.ModelMagnet;
+
+public class RenderTileMagnet extends TileEntitySpecialRenderer {
+
+ public static boolean mob = false;
+ ModelMagnet model = new ModelMagnet();
+
+ private static final ResourceLocation blue = new ResourceLocation(LibResources.MODEL_MAGNET_S);
+ private static final ResourceLocation red = new ResourceLocation(LibResources.MODEL_MAGNET_N);
+ private static final ResourceLocation blueMob = new ResourceLocation(LibResources.MODEL_MOB_MAGNET_S);
+ private static final ResourceLocation redMob = new ResourceLocation(LibResources.MODEL_MOB_MAGNET_N);
+
+ @Override
+ public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
+ GL11.glPushMatrix();
+ GL11.glEnable(GL12.GL_RESCALE_NORMAL);
+ GL11.glColor4f(1F, 1F, 1F, 1F);
+ GL11.glTranslatef((float)x, (float)y , (float)z);
+ boolean blue = tileentity.worldObj == null || (tileentity.getBlockMetadata() & 1) == 0;
+ boolean mob = tileentity.worldObj == null ? RenderTileMagnet.mob : (tileentity.getBlockMetadata() & 2) == 2;
+
+ ClientHelper.minecraft().renderEngine.bindTexture(mob ? blue ? blueMob : redMob : blue ? RenderTileMagnet.blue : red);
+
+ int redstone = 0;
+ if(tileentity.worldObj != null) {
+ for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
+ redstone = Math.max(redstone, tileentity.worldObj.getIndirectPowerLevelTo(tileentity.xCoord + dir.offsetX, tileentity.yCoord + dir.offsetY, tileentity.zCoord + dir.offsetZ, dir.ordinal()));
+ } else redstone = 15;
+
+ GL11.glTranslatef(0.5F, 1.5F, 0.5F);
+ GL11.glScalef(1F, -1F, -1F);
+ model.render();
+
+ GL11.glRotatef(90F, 1F, 0F, 0F);
+ GL11.glTranslatef(0F, 0F, -0.6F);
+ Icon icon = ((ItemHoverHarness) ConfigItems.itemHoverHarness).iconLightningRing;
+
+ for(int i = 0; i < 3; i++) {
+ for(int j = 0; j < 2; j++) {
+ GL11.glScalef(1F, -1F, 1F);
+ UtilsFX.renderQuadCenteredFromIcon(false, icon, redstone / 15F * 0.7F + (redstone == 0 ? 0 : 0.4F), blue ? 0F : 1F, 0F, blue ? 1F : 0F, 225, GL11.GL_ONE_MINUS_SRC_ALPHA, 0.9F);
+ }
+
+ GL11.glTranslated(0, 0, -(Math.cos(System.currentTimeMillis() / 500F) + 1) * 0.09 - 0.1);
+ }
+ GL11.glEnable(GL12.GL_RESCALE_NORMAL);
+
+ GL11.glPopMatrix();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/client/render/tile/RenderTileRepairer.java b/src/main/java/vazkii/tinkerer/client/render/tile/RenderTileRepairer.java
new file mode 100644
index 00000000..404a56f2
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/render/tile/RenderTileRepairer.java
@@ -0,0 +1,139 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Nov 30, 2013, 5:27:39 PM (GMT)]
+ */
+package vazkii.tinkerer.client.render.tile;
+
+import java.awt.Color;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.ItemRenderer;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.Icon;
+import net.minecraft.util.ResourceLocation;
+
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL12;
+
+import vazkii.tinkerer.client.core.helper.ClientHelper;
+import vazkii.tinkerer.client.lib.LibResources;
+import vazkii.tinkerer.client.model.ModelRepairer;
+import vazkii.tinkerer.common.block.tile.TileRepairer;
+
+public class RenderTileRepairer extends TileEntitySpecialRenderer {
+
+ ModelRepairer model = new ModelRepairer();
+
+ private static final ResourceLocation modelTex = new ResourceLocation(LibResources.MODEL_REPAIRER);
+ private static final ResourceLocation repair = new ResourceLocation(LibResources.MISC_REPAIR);
+ private static final ResourceLocation repairOff = new ResourceLocation(LibResources.MISC_REPAIR_OFF);
+
+ @Override
+ public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float t) {
+ int meta = tileentity.worldObj == null ? 3 : tileentity.getBlockMetadata();
+ int rotation = meta == 2 ? 0 : meta == 3 ? 180 : meta == 4 ? 270 : 90;
+
+ TileRepairer repairer = (TileRepairer) tileentity;
+
+ GL11.glPushMatrix();
+ GL11.glEnable(GL12.GL_RESCALE_NORMAL);
+ GL11.glColor4f(1F, 1F, 1F, 1F);
+ GL11.glTranslatef((float)x, (float)y , (float)z);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ bindTexture(modelTex);
+ GL11.glTranslatef(0F, 2F, 1F);
+ GL11.glScalef(1F, -1F, -1F);
+ GL11.glTranslatef(0.5F, 0.5F, 0.5F);
+ GL11.glRotatef(rotation, 0F, 1F, 0F);
+ model.render();
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glScalef(1F, -1F, -1F);
+
+ ItemStack item = ((TileRepairer) tileentity).getStackInSlot(0);
+ if(item != null) {
+ GL11.glPushMatrix();
+ final float scale = 0.5F;
+ GL11.glScalef(scale, scale, scale);
+ GL11.glTranslatef(-0.5F, (float) (-2.5F + Math.sin(repairer.ticksExisted / 10F) * 0.1F), 0F);
+
+ float deg = repairer.ticksExisted * 0.75F % 360F;
+ GL11.glTranslatef(1F / 2F, 1F / 2F, 1F / 32F);
+ GL11.glRotatef(deg, 0F, 1F, 0F);
+ GL11.glTranslatef(-1F / 2F, -1F / 2F, -1F / 32F);
+
+ bindTexture(TextureMap.locationItemsTexture);
+
+ int renderPass = 0;
+ do {
+ Icon icon = item.getItem().getIcon(item, renderPass);
+ if(icon != null) {
+ Color color = new Color(item.getItem().getColorFromItemStack(item, renderPass));
+ GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
+ float f = icon.getMinU();
+ float f1 = icon.getMaxU();
+ float f2 = icon.getMinV();
+ float f3 = icon.getMaxV();
+ ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
+ GL11.glColor3f(1F, 1F, 1F);
+ }
+ renderPass++;
+ } while(renderPass < item.getItem().getRenderPasses(item.getItemDamage()));
+ GL11.glPopMatrix();
+ }
+
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ bindTexture(modelTex);
+ GL11.glScalef(1F, -1F, -1F);
+ GL11.glRotatef(rotation, 0F, 1F, 0F);
+ model.renderGlass();
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glScalef(1F, -1F, -1F);
+
+ renderOverlay((TileRepairer) tileentity, ((TileRepairer) tileentity).tookLastTick ? repair : repairOff , 1.25F);
+ GL11.glPopMatrix();
+ GL11.glColor4f(1F, 1F, 1F, 1F);
+ }
+
+
+ private void renderOverlay(TileRepairer tablet, ResourceLocation texture, double size) {
+ Minecraft mc = ClientHelper.minecraft();
+ mc.renderEngine.bindTexture(texture);
+ GL11.glPushMatrix();
+ GL11.glDepthMask(false);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GL11.glTranslatef(0F, -0.525F, 0F);
+ float deg = tablet.ticksExisted * 0.75F % 360F;
+ GL11.glRotatef(deg, 0F, 1F, 0F);
+ GL11.glColor4f(1F, 1F, 1F, 1F);
+ Tessellator tess = Tessellator.instance;
+ double size1 = size / 2;
+ double size2 = -size1;
+ tess.startDrawingQuads();
+ tess.addVertexWithUV(size2, 0, size1, 0, 1);
+ tess.addVertexWithUV(size1, 0, size1, 1, 1);
+ tess.addVertexWithUV(size1, 0, size2, 1, 0);
+ tess.addVertexWithUV(size2, 0, size2, 0, 0);
+ tess.draw();
+ GL11.glDepthMask(true);
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glPopMatrix();
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/client/render/tile/kami/RenderTileWarpGate.java b/src/main/java/vazkii/tinkerer/client/render/tile/kami/RenderTileWarpGate.java
new file mode 100644
index 00000000..5bc24473
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/client/render/tile/kami/RenderTileWarpGate.java
@@ -0,0 +1,39 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Jan 10, 2014, 4:44:15 PM (GMT)]
+ */
+package vazkii.tinkerer.client.render.tile.kami;
+
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.tileentity.TileEntity;
+
+import org.lwjgl.opengl.GL11;
+
+import vazkii.tinkerer.client.model.kami.ModelSpinningCubes;
+
+public class RenderTileWarpGate extends TileEntitySpecialRenderer {
+
+ ModelSpinningCubes cubes = new ModelSpinningCubes();
+
+ @Override
+ public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
+ GL11.glPushMatrix();
+ GL11.glColor4f(1F, 1F, 1F, 1F);
+ GL11.glTranslated(x + 0.5, y + 2.5, z + 0.5);
+ GL11.glRotatef(180F, 1F, 0F, 1F);
+ int repeat = 5;
+ cubes.renderSpinningCubes(12, repeat, repeat);
+ GL11.glPopMatrix();
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/ThaumicTinkerer.java b/src/main/java/vazkii/tinkerer/common/ThaumicTinkerer.java
new file mode 100644
index 00000000..1a6cddc5
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/ThaumicTinkerer.java
@@ -0,0 +1,59 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [4 Sep 2013, 16:01:28 (GMT)]
+ */
+package vazkii.tinkerer.common;
+
+import thaumcraft.common.CommonProxy;
+import thaumcraft.common.Thaumcraft;
+import vazkii.tinkerer.common.core.proxy.TTCommonProxy;
+import vazkii.tinkerer.common.lib.LibMisc;
+import vazkii.tinkerer.common.network.PacketManager;
+import cpw.mods.fml.common.Mod;
+import cpw.mods.fml.common.Mod.EventHandler;
+import cpw.mods.fml.common.Mod.Instance;
+import cpw.mods.fml.common.SidedProxy;
+import cpw.mods.fml.common.event.FMLInitializationEvent;
+import cpw.mods.fml.common.event.FMLPostInitializationEvent;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import cpw.mods.fml.common.network.NetworkMod;
+
+@Mod(modid = LibMisc.MOD_ID, name = LibMisc.MOD_NAME, version = LibMisc.VERSION, dependencies = LibMisc.DEPENDENCIES)
+@NetworkMod(clientSideRequired = true, channels = { LibMisc.NETWORK_CHANNEL }, packetHandler = PacketManager.class)
+public class ThaumicTinkerer {
+
+ @Instance(LibMisc.MOD_ID)
+ public static ThaumicTinkerer instance;
+
+ @SidedProxy(clientSide = LibMisc.CLIENT_PROXY, serverSide = LibMisc.COMMON_PROXY)
+ public static TTCommonProxy proxy;
+
+ public static CommonProxy tcProxy;
+
+ @EventHandler
+ public void preInit(FMLPreInitializationEvent event) {
+ tcProxy = Thaumcraft.proxy;
+
+ proxy.preInit(event);
+ }
+
+ @EventHandler
+ public void init(FMLInitializationEvent event) {
+ proxy.init(event);
+ }
+
+ @EventHandler
+ public void postInit(FMLPostInitializationEvent event) {
+ proxy.postInit(event);
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/BlockAnimationTablet.java b/src/main/java/vazkii/tinkerer/common/block/BlockAnimationTablet.java
new file mode 100644
index 00000000..071e9cc2
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/BlockAnimationTablet.java
@@ -0,0 +1,207 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 15:52:53 (GMT)]
+ */
+package vazkii.tinkerer.common.block;
+
+import java.util.Random;
+
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ChunkCoordinates;
+import net.minecraft.util.Icon;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import net.minecraftforge.common.ForgeDirection;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.block.tile.tablet.TileAnimationTablet;
+import vazkii.tinkerer.common.lib.LibGuiIDs;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class BlockAnimationTablet extends BlockModContainer {
+
+ Icon iconBottom;
+ Icon iconTop;
+ Icon iconSides;
+
+ Random random;
+
+ public BlockAnimationTablet(int par1) {
+ super(par1, Material.iron);
+ setBlockBounds(0F, 0F, 0F, 1F, 1F / 16F * 2F, 1F);
+ setHardness(3F);
+ setResistance(50F);
+ setStepSound(soundMetalFootstep);
+
+ random = new Random();
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ iconBottom = IconHelper.forBlock(par1IconRegister, this, 0);
+ iconTop = IconHelper.forBlock(par1IconRegister, this, 1);
+ iconSides = IconHelper.forBlock(par1IconRegister, this, 2);
+ }
+
+ @Override
+ public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack) {
+ byte b0 = 0;
+ int l1 = MathHelper.floor_double(par5EntityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
+
+ if (l1 == 0)
+ b0 = 2;
+
+ if (l1 == 1)
+ b0 = 5;
+
+ if (l1 == 2)
+ b0 = 3;
+
+ if (l1 == 3)
+ b0 = 4;
+
+ par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 2);
+ }
+
+ @Override
+ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {
+ TileAnimationTablet tablet = (TileAnimationTablet) par1World.getBlockTileEntity(par2, par3, par4);
+
+ if (tablet != null) {
+ if(tablet.getIsBreaking()) {
+ ChunkCoordinates coords = tablet.getTargetLoc();
+ par1World.destroyBlockInWorldPartially(tablet.getFakePlayer().entityId, coords.posX, coords.posY, coords.posZ, -1);
+ }
+
+ for (int j1 = 0; j1 < tablet.getSizeInventory(); ++j1) {
+ ItemStack itemstack = tablet.getStackInSlot(j1);
+
+ if (itemstack != null) {
+ float f = random.nextFloat() * 0.8F + 0.1F;
+ float f1 = random.nextFloat() * 0.8F + 0.1F;
+ EntityItem entityitem;
+
+ for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
+ int k1 = random.nextInt(21) + 10;
+
+ if (k1 > itemstack.stackSize)
+ k1 = itemstack.stackSize;
+
+ itemstack.stackSize -= k1;
+ entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));
+ float f3 = 0.05F;
+ entityitem.motionX = (float)random.nextGaussian() * f3;
+ entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
+ entityitem.motionZ = (float)random.nextGaussian() * f3;
+
+ if (itemstack.hasTagCompound())
+ entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
+ }
+ }
+ }
+
+ par1World.func_96440_m(par2, par3, par4, par5);
+ }
+
+ super.breakBlock(par1World, par2, par3, par4, par5, par6);
+ }
+
+ @Override
+ public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
+ if(par1World.isRemote)
+ return;
+
+ boolean power = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4) || par1World.isBlockIndirectlyGettingPowered(par2, par3 + 1, par4);
+ int meta = par1World.getBlockMetadata(par2, par3, par4);
+ boolean on = (meta & 8) != 0;
+
+ if (power && !on) {
+ par1World.scheduleBlockUpdate(par2, par3, par4, blockID, tickRate(par1World));
+ par1World.setBlockMetadataWithNotify(par2, par3, par4, meta | 8, 4);
+ } else if (!power && on)
+ par1World.setBlockMetadataWithNotify(par2, par3, par4, meta & 7, 4);
+ }
+
+ @Override
+ public int tickRate(World par1World) {
+ return 1;
+ }
+
+ @Override
+ public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
+ TileEntity tile = par1World.getBlockTileEntity(par2, par3, par4);
+ if(tile != null && tile instanceof TileAnimationTablet) {
+ TileAnimationTablet tablet = (TileAnimationTablet) tile;
+ if(tablet.redstone && tablet.swingProgress == 0) {
+ tablet.findEntities(tablet.getTargetLoc());
+ tablet.initiateSwing();
+ par1World.addBlockEvent(par2, par3, par4, ModBlocks.animationTablet.blockID, 0, 0);
+ }
+ }
+ }
+
+ @Override
+ public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
+ if(!par1World.isRemote) {
+ TileEntity tile = par1World.getBlockTileEntity(par2, par3, par4);
+ if(tile != null) {
+ TileAnimationTablet tablet = (TileAnimationTablet) tile;
+ if(par5EntityPlayer.getCurrentEquippedItem() != null && par5EntityPlayer.getCurrentEquippedItem().getItem() instanceof ItemWandCasting) {
+ int meta = par1World.getBlockMetadata(par2, par3, par4);
+ boolean activated = (meta & 8) != 0;
+ if(!activated && !tablet.getIsBreaking() && tablet.swingProgress == 0) {
+ par1World.setBlockMetadataWithNotify(par2, par3, par4, meta == 5 ? 2 : meta + 1, 1 | 2);
+ par1World.playSoundEffect(par2, par3, par4, "thaumcraft:tool", 0.6F, 1F);
+ } else par5EntityPlayer.addChatMessage(StatCollector.translateToLocal("ttmisc.animationTablet.notRotatable"));
+ // Rare chance this might happen, but better to cope for it.
+
+ return true;
+ } else par5EntityPlayer.openGui(ThaumicTinkerer.instance, LibGuiIDs.GUI_ID_TABLET, par1World, par2, par3, par4);
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public Icon getIcon(int par1, int par2) {
+ return par1 == ForgeDirection.UP.ordinal() ? iconTop : par1 == ForgeDirection.DOWN.ordinal() ? iconBottom : iconSides;
+ }
+
+ @Override
+ public boolean renderAsNormalBlock() {
+ return false;
+ }
+
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world) {
+ return new TileAnimationTablet();
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/BlockAspectAnalyzer.java b/src/main/java/vazkii/tinkerer/common/block/BlockAspectAnalyzer.java
new file mode 100644
index 00000000..5d200d87
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/BlockAspectAnalyzer.java
@@ -0,0 +1,112 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 11, 2013, 10:31:09 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block;
+
+import java.util.Random;
+
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.Icon;
+import net.minecraft.world.World;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.block.tile.TileAspectAnalyzer;
+import vazkii.tinkerer.common.lib.LibGuiIDs;
+
+public class BlockAspectAnalyzer extends BlockModContainer {
+
+ Icon[] icons = new Icon[5];
+ Random random;
+
+ protected BlockAspectAnalyzer(int par1) {
+ super(par1, Material.wood);
+ setHardness(1.7F);
+ setResistance(1F);
+ setStepSound(soundWoodFootstep);
+
+ random = new Random();
+ }
+
+ @Override
+ public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
+ if(!par1World.isRemote) {
+ TileEntity tile = par1World.getBlockTileEntity(par2, par3, par4);
+ if(tile != null)
+ par5EntityPlayer.openGui(ThaumicTinkerer.instance, LibGuiIDs.GUI_ID_ASPECT_ANALYZER, par1World, par2, par3, par4);
+ }
+
+ return true;
+ }
+
+ @Override
+ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {
+ TileAspectAnalyzer analyzer = (TileAspectAnalyzer) par1World.getBlockTileEntity(par2, par3, par4);
+
+ if (analyzer != null) {
+ for (int j1 = 0; j1 < analyzer.getSizeInventory(); ++j1) {
+ ItemStack itemstack = analyzer.getStackInSlot(j1);
+
+ if (itemstack != null) {
+ float f = random.nextFloat() * 0.8F + 0.1F;
+ float f1 = random.nextFloat() * 0.8F + 0.1F;
+ EntityItem entityitem;
+
+ for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
+ int k1 = random.nextInt(21) + 10;
+
+ if (k1 > itemstack.stackSize)
+ k1 = itemstack.stackSize;
+
+ itemstack.stackSize -= k1;
+ entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));
+ float f3 = 0.05F;
+ entityitem.motionX = (float)random.nextGaussian() * f3;
+ entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
+ entityitem.motionZ = (float)random.nextGaussian() * f3;
+
+ if (itemstack.hasTagCompound())
+ entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
+ }
+ }
+ }
+
+ par1World.func_96440_m(par2, par3, par4, par5);
+ }
+
+ super.breakBlock(par1World, par2, par3, par4, par5, par6);
+ }
+
+ @Override
+ public void registerIcons(IconRegister par1IconRegister) {
+ for(int i = 0; i < 5; i++)
+ icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
+ }
+
+ @Override
+ public Icon getIcon(int par1, int par2) {
+ return icons[par1 == 0 || par1 == 1 ? 0 : par1 - 1];
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world) {
+ return new TileAspectAnalyzer();
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/BlockCamo.java b/src/main/java/vazkii/tinkerer/common/block/BlockCamo.java
new file mode 100644
index 00000000..e647353b
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/BlockCamo.java
@@ -0,0 +1,150 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 27, 2013, 6:25:36 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block;
+
+import java.util.Arrays;
+import java.util.List;
+
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockDirectional;
+import net.minecraft.block.material.Material;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.Icon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import vazkii.tinkerer.common.block.tile.TileCamo;
+import cpw.mods.fml.common.network.PacketDispatcher;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public abstract class BlockCamo extends BlockModContainer {
+
+ static List validRenderTypes = Arrays.asList(0, 31, 39);
+
+ protected BlockCamo(int par1, Material par2Material) {
+ super(par1, par2Material);
+ }
+
+ @Override
+ public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side) {
+ TileEntity tile = world.getBlockTileEntity(x, y, z);
+ int meta = world.getBlockMetadata(x, y, z);
+
+ if (tile instanceof TileCamo) {
+ TileCamo camo = (TileCamo) tile;
+ if (camo.camo > 0 && camo.camo < 4096) {
+ Block block = Block.blocksList[camo.camo];
+ if (block != null && isValidRenderType(block.getRenderType()))
+ return block.getIcon(side, camo.camoMeta);
+ }
+ }
+
+ return getIconFromSideAfterCheck(tile, meta, side);
+ }
+
+ public boolean isValidRenderType(int type) {
+ return validRenderTypes.contains(type);
+ }
+
+ @Override
+ public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
+ TileEntity tile = par1World.getBlockTileEntity(par2, par3, par4);
+
+ if (tile instanceof TileCamo) {
+ TileCamo camo = (TileCamo) tile;
+ ItemStack currentStack = par5EntityPlayer.getCurrentEquippedItem();
+
+ if(currentStack == null)
+ currentStack = new ItemStack(0, 1, 0);
+
+ boolean doChange = true;
+ Block block = null;
+ checkChange : {
+ if(currentStack.itemID != 0) {
+ if(currentStack.itemID >= 4096) {
+ doChange = false;
+ break checkChange;
+ }
+
+ block = Block.blocksList[currentStack.itemID];
+ if(block == null || !isValidRenderType(block.getRenderType()) || block instanceof BlockCamo || block.blockMaterial == Material.air)
+ doChange = false;
+ }
+ }
+
+ if(doChange) {
+ int metadata = currentStack.getItemDamage();
+ if (block instanceof BlockDirectional) {
+ switch (par6) {
+ case 0:
+ case 1:
+ break;
+ case 2:
+ metadata = metadata & 12 | 2;
+ break;
+ case 3:
+ metadata = metadata & 12 | 0;
+ break;
+ case 4:
+ metadata = metadata & 12 | 1;
+ break;
+ case 5:
+ metadata = metadata & 12 | 3;
+ break;
+ }
+ }
+ camo.camo = currentStack.itemID;
+ camo.camoMeta = metadata;
+ PacketDispatcher.sendPacketToAllInDimension(camo.getDescriptionPacket(), par1World.provider.dimensionId);
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ public boolean renderAsNormalBlock() {
+ return false;
+ }
+
+ @SideOnly(Side.CLIENT)
+ @Override
+ public int colorMultiplier(IBlockAccess par1World, int par2, int par3, int par4) {
+ TileEntity tile = par1World.getBlockTileEntity(par2, par3, par4);
+ if (tile instanceof TileCamo) {
+ TileCamo camo = (TileCamo) tile;
+ if (camo.camo >= 0 && camo.camo < 4096) {
+ Block block = Block.blocksList[camo.camo];
+ if (block != null)
+ return block instanceof BlockCamo ? 0xFFFFFF : block.colorMultiplier(par1World, par2, par3, par4);
+ }
+ }
+ return 0xFFFFFF;
+ }
+
+ public Icon getIconFromSideAfterCheck(TileEntity tile, int meta, int side) {
+ return blockIcon;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/BlockEnchanter.java b/src/main/java/vazkii/tinkerer/common/block/BlockEnchanter.java
new file mode 100644
index 00000000..243c3c40
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/BlockEnchanter.java
@@ -0,0 +1,134 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [14 Sep 2013, 01:13:25 (GMT)]
+ */
+package vazkii.tinkerer.common.block;
+
+import java.util.Random;
+
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.Icon;
+import net.minecraft.world.World;
+import net.minecraftforge.common.ForgeDirection;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.block.tile.TileEnchanter;
+import vazkii.tinkerer.common.lib.LibGuiIDs;
+import cpw.mods.fml.common.network.PacketDispatcher;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class BlockEnchanter extends BlockModContainer {
+
+ Random random;
+
+ Icon iconBottom;
+ Icon iconTop;
+ Icon iconSides;
+
+ protected BlockEnchanter(int par1) {
+ super(par1, Material.rock);
+ setBlockBounds(0F, 0F, 0F, 1F, 0.75F, 1F);
+ setHardness(5.0F);
+ setResistance(2000.0F);
+
+ random = new Random();
+ }
+
+ @Override
+ public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
+ if(!par1World.isRemote) {
+ TileEntity tile = par1World.getBlockTileEntity(par2, par3, par4);
+ if(tile != null) {
+ PacketDispatcher.sendPacketToAllInDimension(tile.getDescriptionPacket(), par1World.provider.dimensionId);
+ par5EntityPlayer.openGui(ThaumicTinkerer.instance, LibGuiIDs.GUI_ID_ENCHANTER, par1World, par2, par3, par4);
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {
+ TileEnchanter enchanter = (TileEnchanter) par1World.getBlockTileEntity(par2, par3, par4);
+
+ if (enchanter != null) {
+ for (int j1 = 0; j1 < enchanter.getSizeInventory(); ++j1) {
+ ItemStack itemstack = enchanter.getStackInSlot(j1);
+
+ if (itemstack != null) {
+ float f = random.nextFloat() * 0.8F + 0.1F;
+ float f1 = random.nextFloat() * 0.8F + 0.1F;
+ EntityItem entityitem;
+
+ for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
+ int k1 = random.nextInt(21) + 10;
+
+ if (k1 > itemstack.stackSize)
+ k1 = itemstack.stackSize;
+
+ itemstack.stackSize -= k1;
+ entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));
+ float f3 = 0.05F;
+ entityitem.motionX = (float)random.nextGaussian() * f3;
+ entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
+ entityitem.motionZ = (float)random.nextGaussian() * f3;
+
+ if (itemstack.hasTagCompound())
+ entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
+ }
+ }
+ }
+
+ par1World.func_96440_m(par2, par3, par4, par5);
+ }
+
+ super.breakBlock(par1World, par2, par3, par4, par5, par6);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ iconBottom = IconHelper.forBlock(par1IconRegister, this, 0);
+ iconTop = IconHelper.forBlock(par1IconRegister, this, 1);
+ iconSides = IconHelper.forBlock(par1IconRegister, this, 2);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public Icon getIcon(int par1, int par2) {
+ return par1 == ForgeDirection.UP.ordinal() ? iconTop : par1 == ForgeDirection.DOWN.ordinal() ? iconBottom : iconSides;
+ }
+
+ @Override
+ public boolean renderAsNormalBlock() {
+ return false;
+ }
+
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world) {
+ return new TileEnchanter();
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/BlockFunnel.java b/src/main/java/vazkii/tinkerer/common/block/BlockFunnel.java
new file mode 100644
index 00000000..3fd7dcac
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/BlockFunnel.java
@@ -0,0 +1,164 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [28 Sep 2013, 19:33:05 (GMT)]
+ */
+package vazkii.tinkerer.common.block;
+
+import java.util.Random;
+
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.Icon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.common.block.tile.TileFunnel;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class BlockFunnel extends BlockModContainer {
+
+ Icon sideIcon, topIcon;
+
+ Random random;
+
+ protected BlockFunnel(int par1) {
+ super(par1, Material.rock);
+ setHardness(3.0F);
+ setResistance(8.0F);
+ setStepSound(Block.soundStoneFootstep);
+ setBlockBounds(0F, 0F, 0F, 1F, 1F / 8F, 1F);
+
+ random = new Random();
+ }
+
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public boolean shouldSideBeRendered(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) {
+ return true;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ topIcon = IconHelper.forBlock(par1IconRegister, this, 0);
+ sideIcon = IconHelper.forBlock(par1IconRegister, this, 1);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public Icon getIcon(int par1, int par2) {
+ return par1 > 1 ? sideIcon : topIcon;
+ }
+
+ @Override
+ public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
+ return AxisAlignedBB.getBoundingBox(par2, par3, par4, par2 + 1, par3 + 1, par4 + 1);
+ }
+
+ @Override
+ public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) {
+ return par1World.getBlockId(par2, par3 - 1, par4) == Block.hopperBlock.blockID;
+ }
+
+ @Override
+ public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
+ if(par1World.getBlockId(par2, par3 - 1, par4) != Block.hopperBlock.blockID) {
+ dropBlockAsItem(par1World, par2, par3, par4, 0, 0);
+ par1World.setBlock(par2, par3, par4, 0);
+ }
+ }
+
+ @Override
+ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {
+ TileFunnel funnel = (TileFunnel) par1World.getBlockTileEntity(par2, par3, par4);
+
+ if (funnel != null) {
+ for (int j1 = 0; j1 < funnel.getSizeInventory(); ++j1) {
+ ItemStack itemstack = funnel.getStackInSlot(j1);
+
+ if (itemstack != null) {
+ float f = random.nextFloat() * 0.8F + 0.1F;
+ float f1 = random.nextFloat() * 0.8F + 0.1F;
+ EntityItem entityitem;
+
+ for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
+ int k1 = random.nextInt(21) + 10;
+
+ if (k1 > itemstack.stackSize)
+ k1 = itemstack.stackSize;
+
+ itemstack.stackSize -= k1;
+ entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));
+ float f3 = 0.05F;
+ entityitem.motionX = (float)random.nextGaussian() * f3;
+ entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
+ entityitem.motionZ = (float)random.nextGaussian() * f3;
+
+ if (itemstack.hasTagCompound())
+ entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
+ }
+ }
+ }
+
+ par1World.func_96440_m(par2, par3, par4, par5);
+ }
+
+ super.breakBlock(par1World, par2, par3, par4, par5, par6);
+ }
+
+ @Override
+ public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
+ TileFunnel funnel = (TileFunnel) par1World.getBlockTileEntity(par2, par3, par4);
+ ItemStack stack = funnel.getStackInSlot(0);
+
+ if(stack == null) {
+ ItemStack playerStack = par5EntityPlayer.getCurrentEquippedItem();
+ if(funnel.canInsertItem(0, playerStack, 1)) {
+ funnel.setInventorySlotContents(0, playerStack.splitStack(1));
+
+ if(playerStack.stackSize <= 0)
+ par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null);
+
+ funnel.onInventoryChanged();
+ return true;
+ }
+ } else {
+ if(!par5EntityPlayer.inventory.addItemStackToInventory(stack))
+ par5EntityPlayer.dropPlayerItem(stack);
+
+ funnel.setInventorySlotContents(0, null);
+ funnel.onInventoryChanged();
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world) {
+ return new TileFunnel();
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/BlockGas.java b/src/main/java/vazkii/tinkerer/common/block/BlockGas.java
new file mode 100644
index 00000000..d29c5ccb
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/BlockGas.java
@@ -0,0 +1,130 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 22:13:36 (GMT)]
+ */
+package vazkii.tinkerer.common.block;
+
+import java.util.ArrayList;
+import java.util.Random;
+
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.world.Explosion;
+import net.minecraft.world.World;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public abstract class BlockGas extends BlockMod {
+
+ public BlockGas(int par1) {
+ super(par1, Material.air);
+ setBlockBounds(0, 0, 0, 0, 0, 0);
+ setTickRandomly(true);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ blockIcon = IconHelper.emptyTexture(par1IconRegister);
+ }
+
+ @Override
+ public int getRenderType() {
+ return -1;
+ }
+
+ @Override
+ public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
+ int meta = par1World.getBlockMetadata(par2, par3, par4);
+ if(meta != 0) {
+ setAt(par1World, par2 - 1, par3, par4, meta - 1);
+ setAt(par1World, par2 + 1, par3, par4, meta - 1);
+
+ setAt(par1World, par2, par3 - 1, par4, meta - 1);
+ setAt(par1World, par2, par3 + 1, par4, meta - 1);
+
+ setAt(par1World, par2, par3, par4 - 1, meta - 1);
+ setAt(par1World, par2, par3, par4 + 1, meta - 1);
+
+ // Just in case...
+ par1World.setBlockMetadataWithNotify(par2, par3, par4, 0, 2);
+
+ placeParticle(par1World, par2, par3, par4);
+ }
+ }
+
+ public void placeParticle(World world, int par2, int par3, int par4) {
+ // NO-OP, override
+ }
+
+ private void setAt(World world, int x, int y, int z, int meta) {
+ if(world.isAirBlock(x, y, z) && world.getBlockId(x, y, z) != blockID) {
+ if(!world.isRemote)
+ world.setBlock(x, y, z, blockID, meta, 2);
+ world.scheduleBlockUpdate(x, y, z, blockID, 10);
+ }
+ }
+
+ @Override
+ public boolean isBlockNormalCube(World world, int x, int y, int z) {
+ return false;
+ }
+
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ public boolean canDragonDestroy(World world, int x, int y, int z) {
+ return false;
+ }
+
+ @Override
+ public boolean canCollideCheck(int par1, boolean par2) {
+ return false;
+ }
+
+ @Override
+ public boolean canBeReplacedByLeaves(World world, int x, int y, int z) {
+ return true;
+ }
+
+ @Override
+ public boolean canDropFromExplosion(Explosion par1Explosion) {
+ return false;
+ }
+
+ @Override
+ public ArrayList getBlockDropped(World world, int x, int y, int z, int metadata, int fortune) {
+ return new ArrayList(); // Empty List
+ }
+
+ @Override
+ public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
+ return null;
+ }
+
+ @Override
+ public boolean isAirBlock(World world, int x, int y, int z) {
+ return true;
+ }
+
+ @Override
+ boolean registerInCreative() {
+ return false;
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/BlockGaseousLight.java b/src/main/java/vazkii/tinkerer/common/block/BlockGaseousLight.java
new file mode 100644
index 00000000..8281be99
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/BlockGaseousLight.java
@@ -0,0 +1,42 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 22:20:30 (GMT)]
+ */
+package vazkii.tinkerer.common.block;
+
+import java.util.Random;
+
+import net.minecraft.world.World;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class BlockGaseousLight extends BlockGas {
+
+ public BlockGaseousLight(int par1) {
+ super(par1);
+ setLightValue(0.85F);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
+ if(par5Random.nextFloat() < 0.0075F)
+ ThaumicTinkerer.tcProxy.sparkle(par2 + 0.5F, par3 + 0.5F, par4 + 0.5F, 1F, 1, par5Random.nextFloat() / 2);
+ }
+
+ @Override
+ public void placeParticle(World world, int par2, int par3, int par4) {
+ ThaumicTinkerer.tcProxy.sparkle(par2 + 0.5F, par3 + 0.5F, par4 + 0.5F, 1);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/block/BlockGaseousShadow.java b/src/main/java/vazkii/tinkerer/common/block/BlockGaseousShadow.java
new file mode 100644
index 00000000..75d9caf2
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/BlockGaseousShadow.java
@@ -0,0 +1,42 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 22:21:13 (GMT)]
+ */
+package vazkii.tinkerer.common.block;
+
+import java.util.Random;
+
+import net.minecraft.world.World;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class BlockGaseousShadow extends BlockGas {
+
+ public BlockGaseousShadow(int par1) {
+ super(par1);
+ setLightOpacity(215);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
+ if(par5Random.nextFloat() < 0.0075F)
+ ThaumicTinkerer.tcProxy.wispFX2(par1World, par2 + 0.5, par3 + 0.5, par4 + 0.5, 0.125F, 5, true, -0.02F);
+ }
+
+ @Override
+ public void placeParticle(World world, int par2, int par3, int par4) {
+ ThaumicTinkerer.tcProxy.wispFX2(world, par2 + 0.5, par3 + 0.5, par4 + 0.5, 0.125F, 5, true, -0.02F);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/block/BlockMagnet.java b/src/main/java/vazkii/tinkerer/common/block/BlockMagnet.java
new file mode 100644
index 00000000..defc63aa
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/BlockMagnet.java
@@ -0,0 +1,166 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 17:01:27 (GMT)]
+ */
+package vazkii.tinkerer.common.block;
+
+import java.util.List;
+import java.util.Random;
+
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.Icon;
+import net.minecraft.world.World;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import vazkii.tinkerer.client.lib.LibRenderIDs;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.block.tile.TileMagnet;
+import vazkii.tinkerer.common.block.tile.TileMobMagnet;
+import vazkii.tinkerer.common.lib.LibGuiIDs;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class BlockMagnet extends BlockModContainer {
+
+ Random random;
+
+ public BlockMagnet(int par1) {
+ super(par1, Material.iron);
+ setBlockBounds(0.0625F, 0F, 0.0625F, 0.9375F, 1F / 16F * 2F, 0.9375F);
+ setHardness(1.7F);
+ setResistance(1F);
+ setStepSound(soundWoodFootstep);
+
+ random = new Random();
+ }
+
+ @Override
+ public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
+ if(par5EntityPlayer.getCurrentEquippedItem() != null) {
+ if(par5EntityPlayer.getCurrentEquippedItem().getItem() instanceof ItemWandCasting) {
+ TileEntity tile = par1World.getBlockTileEntity(par2, par3, par4);
+ if(tile != null && tile instanceof TileMobMagnet) {
+ par5EntityPlayer.openGui(ThaumicTinkerer.instance, LibGuiIDs.GUI_ID_MOB_MAGNET, par1World, par2, par3, par4);
+ if(!par1World.isRemote) {
+ par1World.playSoundEffect(par2, par3, par4, "thaumcraft:key", 1F, 0.5F);
+ }
+ }
+ return true;
+ }
+ }
+
+ int meta = par1World.getBlockMetadata(par2, par3, par4);
+ par1World.setBlockMetadataWithNotify(par2, par3, par4, (meta & 1) == 0 ? meta + 1 : meta - 1, 2);
+ if(!par1World.isRemote) {
+ par1World.playSoundEffect(par2, par3, par4, "random.click", 1F, 0.5F);
+ }
+ return true;
+ }
+
+ @Override
+ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {
+ TileMagnet magnet = (TileMagnet) par1World.getBlockTileEntity(par2, par3, par4);
+ TileMobMagnet mobMagnet = magnet instanceof TileMobMagnet ? (TileMobMagnet) magnet : null;
+
+ if (mobMagnet != null) {
+ for (int j1 = 0; j1 < mobMagnet.getSizeInventory(); ++j1) {
+ ItemStack itemstack = mobMagnet.getStackInSlot(j1);
+
+ if (itemstack != null) {
+ float f = random.nextFloat() * 0.8F + 0.1F;
+ float f1 = random.nextFloat() * 0.8F + 0.1F;
+ EntityItem entityitem;
+
+ for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
+ int k1 = random.nextInt(21) + 10;
+
+ if (k1 > itemstack.stackSize)
+ k1 = itemstack.stackSize;
+
+ itemstack.stackSize -= k1;
+ entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));
+ float f3 = 0.05F;
+ entityitem.motionX = (float)random.nextGaussian() * f3;
+ entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
+ entityitem.motionZ = (float)random.nextGaussian() * f3;
+
+ if (itemstack.hasTagCompound())
+ entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
+ }
+ }
+ }
+
+ par1World.func_96440_m(par2, par3, par4, par5);
+ }
+
+ super.breakBlock(par1World, par2, par3, par4, par5, par6);
+ }
+
+ @Override
+ public int damageDropped(int par1) {
+ switch(par1) {
+ case 1:
+ return 0;
+ case 2:
+ return 1;
+ case 3:
+ return 1;
+ default:
+ return 0;
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) {
+ super.getSubBlocks(par1, par2CreativeTabs, par3List);
+ par3List.add(new ItemStack(par1, 1, 1));
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public Icon getIcon(int par1, int par2) {
+ return Block.wood.getIcon(par1, 1);
+ }
+
+ @Override
+ public int getRenderType() {
+ return LibRenderIDs.idMagnet;
+ }
+
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ public boolean renderAsNormalBlock() {
+ return false;
+ }
+
+ @Override
+ public TileEntity createTileEntity(World world, int metadata) {
+ return (metadata & 2) == 2 ? new TileMobMagnet() : new TileMagnet();
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world) {
+ return null;
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/BlockMod.java b/src/main/java/vazkii/tinkerer/common/block/BlockMod.java
new file mode 100644
index 00000000..4bc8f107
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/BlockMod.java
@@ -0,0 +1,44 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 15:57:04 (GMT)]
+ */
+package vazkii.tinkerer.common.block;
+
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IconRegister;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.common.core.handler.ModCreativeTab;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class BlockMod extends Block {
+
+ public BlockMod(int par1, Material par2Material) {
+ super(par1, par2Material);
+ if(registerInCreative())
+ setCreativeTab(ModCreativeTab.INSTANCE);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ blockIcon = IconHelper.forBlock(par1IconRegister, this);
+ }
+
+ boolean registerInCreative() {
+ return true;
+ }
+
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/BlockModContainer.java b/src/main/java/vazkii/tinkerer/common/block/BlockModContainer.java
new file mode 100644
index 00000000..e379cafc
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/BlockModContainer.java
@@ -0,0 +1,49 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 18:57:45 (GMT)]
+ */
+package vazkii.tinkerer.common.block;
+
+import net.minecraft.block.BlockContainer;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.common.core.handler.ModCreativeTab;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public abstract class BlockModContainer extends BlockContainer {
+
+ protected BlockModContainer(int par1, Material par2Material) {
+ super(par1, par2Material);
+ if(registerInCreative())
+ setCreativeTab(ModCreativeTab.INSTANCE);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ blockIcon = IconHelper.forBlock(par1IconRegister, this);
+ }
+
+ /** Does the block register in the creative inv? **/
+ boolean registerInCreative() {
+ return true;
+ }
+
+ @Override
+ public abstract T createNewTileEntity(World world);
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/BlockNitorGas.java b/src/main/java/vazkii/tinkerer/common/block/BlockNitorGas.java
new file mode 100644
index 00000000..d92087b4
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/BlockNitorGas.java
@@ -0,0 +1,80 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [11 Sep 2013, 17:47:28 (GMT)]
+ */
+package vazkii.tinkerer.common.block;
+
+import java.util.List;
+import java.util.Random;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.item.ModItems;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class BlockNitorGas extends BlockGas {
+
+ public BlockNitorGas(int par1) {
+ super(par1);
+ }
+
+ @Override
+ public int tickRate(World par1World) {
+ return par1World.provider.dimensionId == -1 ? 60 : 20;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
+ if(par5Random.nextFloat() < 0.03F)
+ ThaumicTinkerer.tcProxy.sparkle(par2 + 0.5F, par3 + 0.5F, par4 + 0.5F, 1F, 4, par5Random.nextFloat() / 2);
+ }
+
+ @Override
+ public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
+ if(!par1World.isRemote) {
+ int dist = par1World.getBlockMetadata(par2, par3, par4) == 1 ? 6 : 1;
+ List players = par1World.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(par2 - dist, par3 - dist, par4 - dist, par2 + dist, par3 + dist, par4 + dist));
+ if(players.isEmpty())
+ par1World.setBlockToAir(par2, par3, par4);
+ else {
+ boolean has = false;
+ for(EntityPlayer player : players)
+ if(player.inventory.hasItem(ModItems.brightNitor.itemID) || ModItems.ichorLegsGem != null && player.getCurrentArmor(1) != null && player.getCurrentArmor(1).itemID == ModItems.ichorLegsGem.itemID) {
+ has = true;
+ break;
+ }
+
+ if(!has)
+ par1World.setBlockToAir(par2, par3, par4);
+ }
+ par1World.scheduleBlockUpdate(par2, par3, par4, blockID, tickRate(par1World));
+ }
+ }
+
+ @Override
+ public int getLightValue(IBlockAccess world, int x, int y, int z) {
+ return world.getBlockMetadata(x, y, z) == 1 ? 15 : 12;
+ }
+
+ @Override
+ public void onBlockAdded(World par1World, int par2, int par3, int par4) {
+ if(!par1World.isRemote)
+ par1World.scheduleBlockUpdate(par2, par3, par4, blockID, tickRate(par1World));
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/block/BlockPlatform.java b/src/main/java/vazkii/tinkerer/common/block/BlockPlatform.java
new file mode 100644
index 00000000..fb721897
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/BlockPlatform.java
@@ -0,0 +1,52 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 27, 2013, 6:36:19 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block;
+
+import java.util.List;
+
+import net.minecraft.block.material.Material;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import vazkii.tinkerer.common.block.tile.TileCamo;
+
+public class BlockPlatform extends BlockCamo {
+
+ public BlockPlatform(int par1) {
+ super(par1, Material.wood);
+ setHardness(2.0F);
+ setResistance(5.0F);
+ setStepSound(soundWoodFootstep);
+ }
+
+ @Override
+ public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) {
+ if(par7Entity != null && par7Entity.posY > par3 + (par7Entity instanceof EntityPlayer ? 2 : 0) && (!(par7Entity instanceof EntityPlayer) || !par7Entity.isSneaking()))
+ super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
+ }
+
+ @Override
+ public boolean getBlocksMovement(IBlockAccess par1iBlockAccess, int par2, int par3, int par4) {
+ return false;
+ }
+
+ @Override
+ public TileCamo createNewTileEntity(World world) {
+ return new TileCamo();
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/BlockRepairer.java b/src/main/java/vazkii/tinkerer/common/block/BlockRepairer.java
new file mode 100644
index 00000000..8d9900eb
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/BlockRepairer.java
@@ -0,0 +1,160 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Nov 30, 2013, 5:36:26 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block;
+
+import java.util.Random;
+
+import net.minecraft.block.material.Material;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.Icon;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.World;
+import thaumcraft.common.config.ConfigBlocks;
+import vazkii.tinkerer.client.lib.LibRenderIDs;
+import vazkii.tinkerer.common.block.tile.TileRepairer;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class BlockRepairer extends BlockModContainer {
+
+ Random random;
+
+ protected BlockRepairer(int par1) {
+ super(par1, Material.iron);
+ setHardness(5F);
+ setResistance(10F);
+
+ random = new Random();
+ }
+
+ @Override
+ public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
+ TileRepairer repairer = (TileRepairer) par1World.getBlockTileEntity(par2, par3, par4);
+ ItemStack stack = repairer.getStackInSlot(0);
+
+ if(stack == null) {
+ ItemStack playerStack = par5EntityPlayer.getCurrentEquippedItem();
+ if(repairer.canInsertItem(0, playerStack, 1)) {
+ repairer.setInventorySlotContents(0, playerStack.splitStack(1));
+
+ if(playerStack.stackSize <= 0)
+ par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null);
+
+ repairer.onInventoryChanged();
+ return true;
+ }
+ } else {
+ if(!par5EntityPlayer.inventory.addItemStackToInventory(stack))
+ par5EntityPlayer.dropPlayerItem(stack);
+
+ repairer.setInventorySlotContents(0, null);
+ repairer.onInventoryChanged();
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack) {
+ byte b0 = 0;
+ int l1 = MathHelper.floor_double(par5EntityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
+
+ if (l1 == 0)
+ b0 = 2;
+
+ if (l1 == 1)
+ b0 = 5;
+
+ if (l1 == 2)
+ b0 = 3;
+
+ if (l1 == 3)
+ b0 = 4;
+
+ par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 2);
+ }
+
+ @Override
+ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {
+ TileRepairer repairer = (TileRepairer) par1World.getBlockTileEntity(par2, par3, par4);
+
+ if (repairer != null) {
+ for (int j1 = 0; j1 < repairer.getSizeInventory(); ++j1) {
+ ItemStack itemstack = repairer.getStackInSlot(j1);
+
+ if (itemstack != null) {
+ float f = random.nextFloat() * 0.8F + 0.1F;
+ float f1 = random.nextFloat() * 0.8F + 0.1F;
+ EntityItem entityitem;
+
+ for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
+ int k1 = random.nextInt(21) + 10;
+
+ if (k1 > itemstack.stackSize)
+ k1 = itemstack.stackSize;
+
+ itemstack.stackSize -= k1;
+ entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));
+ float f3 = 0.05F;
+ entityitem.motionX = (float)random.nextGaussian() * f3;
+ entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
+ entityitem.motionZ = (float)random.nextGaussian() * f3;
+
+ if (itemstack.hasTagCompound())
+ entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
+ }
+ }
+ }
+
+ par1World.func_96440_m(par2, par3, par4, par5);
+ }
+
+ super.breakBlock(par1World, par2, par3, par4, par5, par6);
+ }
+
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public Icon getIcon(int par1, int par2) {
+ return ConfigBlocks.blockCosmeticSolid.getIcon(par1, 4);
+ }
+
+ @Override
+ public int getRenderType() {
+ return LibRenderIDs.idRepairer;
+ }
+
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ public boolean renderAsNormalBlock() {
+ return false;
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world) {
+ return new TileRepairer();
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/ModBlocks.java b/src/main/java/vazkii/tinkerer/common/block/ModBlocks.java
new file mode 100644
index 00000000..a59701b2
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/ModBlocks.java
@@ -0,0 +1,141 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [4 Sep 2013, 16:56:52 (GMT)]
+ */
+package vazkii.tinkerer.common.block;
+
+import net.minecraft.block.Block;
+import vazkii.tinkerer.common.block.kami.BlockWarpGate;
+import vazkii.tinkerer.common.block.quartz.BlockDarkQuartz;
+import vazkii.tinkerer.common.block.quartz.BlockDarkQuartzSlab;
+import vazkii.tinkerer.common.block.quartz.BlockDarkQuartzStairs;
+import vazkii.tinkerer.common.block.tile.TileAspectAnalyzer;
+import vazkii.tinkerer.common.block.tile.TileCamo;
+import vazkii.tinkerer.common.block.tile.TileEnchanter;
+import vazkii.tinkerer.common.block.tile.TileFunnel;
+import vazkii.tinkerer.common.block.tile.TileMagnet;
+import vazkii.tinkerer.common.block.tile.TileMobMagnet;
+import vazkii.tinkerer.common.block.tile.TileRepairer;
+import vazkii.tinkerer.common.block.tile.kami.TileWarpGate;
+import vazkii.tinkerer.common.block.tile.tablet.TileAnimationTablet;
+import vazkii.tinkerer.common.block.tile.transvector.TileTransvectorDislocator;
+import vazkii.tinkerer.common.block.tile.transvector.TileTransvectorInterface;
+import vazkii.tinkerer.common.block.transvector.BlockTransvectorDislocator;
+import vazkii.tinkerer.common.block.transvector.BlockTransvectorInterface;
+import vazkii.tinkerer.common.core.handler.ConfigHandler;
+import vazkii.tinkerer.common.item.ItemBlockMagnet;
+import vazkii.tinkerer.common.item.kami.ItemBlockWarpGate;
+import vazkii.tinkerer.common.item.quartz.ItemDarkQuartzBlock;
+import vazkii.tinkerer.common.item.quartz.ItemDarkQuartzSlab;
+import vazkii.tinkerer.common.lib.LibBlockIDs;
+import vazkii.tinkerer.common.lib.LibBlockNames;
+import cpw.mods.fml.common.Loader;
+import cpw.mods.fml.common.registry.GameRegistry;
+
+public final class ModBlocks {
+
+ public static Block darkQuartz;
+ public static Block darkQuartzSlab;
+ public static Block darkQuartzSlabFull;
+ public static Block darkQuartzStairs;
+ public static Block interfase;
+ public static Block gaseousLight;
+ public static Block gaseousShadow;
+ public static Block animationTablet;
+ public static Block nitorGas;
+ public static Block magnet;
+ public static Block enchanter;
+ public static Block funnel;
+ public static Block dislocator;
+ public static Block repairer;
+ public static Block aspectAnalyzer;
+ public static Block platform;
+
+ public static Block warpGate;
+
+ public static void initBlocks() {
+ darkQuartz = new BlockDarkQuartz(LibBlockIDs.idDarkQuartz).setUnlocalizedName(LibBlockNames.DARK_QUARTZ);
+ darkQuartzSlab = new BlockDarkQuartzSlab(LibBlockIDs.idDarkQuartzSlab, false).setUnlocalizedName(LibBlockNames.DARK_QUARTZ_SLAB);
+ darkQuartzSlabFull = new BlockDarkQuartzSlab(LibBlockIDs.idDarkQuartzSlabFull, true).setUnlocalizedName(LibBlockNames.DARK_QUARTZ_SLAB);
+ darkQuartzStairs = new BlockDarkQuartzStairs(LibBlockIDs.idDarkQuartzStairs).setUnlocalizedName(LibBlockNames.DARK_QUARTZ_STAIRS);
+ interfase = new BlockTransvectorInterface(LibBlockIDs.idInterface).setUnlocalizedName(LibBlockNames.INTERFACE);
+ gaseousLight = new BlockGaseousLight(LibBlockIDs.idGaseousLight).setUnlocalizedName(LibBlockNames.GASEOUS_LIGHT);
+ gaseousShadow = new BlockGaseousShadow(LibBlockIDs.idGaseousShadow).setUnlocalizedName(LibBlockNames.GASEOUS_SHADOW);
+ animationTablet = new BlockAnimationTablet(LibBlockIDs.idAnimationTablet).setUnlocalizedName(LibBlockNames.ANIMATION_TABLET);
+ nitorGas = new BlockNitorGas(LibBlockIDs.idNitorGas).setUnlocalizedName(LibBlockNames.NITOR_GAS);
+ magnet = new BlockMagnet(LibBlockIDs.idMagnet).setUnlocalizedName(LibBlockNames.MAGNET);
+ enchanter = new BlockEnchanter(LibBlockIDs.idEnchanter).setUnlocalizedName(LibBlockNames.ENCHANTER);
+ funnel = new BlockFunnel(LibBlockIDs.idFunnel).setUnlocalizedName(LibBlockNames.FUNNEL);
+ dislocator = new BlockTransvectorDislocator(LibBlockIDs.idDislocator).setUnlocalizedName(LibBlockNames.DISLOCATOR);
+ repairer = new BlockRepairer(LibBlockIDs.idRepairer).setUnlocalizedName(LibBlockNames.REPAIRER);
+ aspectAnalyzer = new BlockAspectAnalyzer(LibBlockIDs.idAspectAnalyzer).setUnlocalizedName(LibBlockNames.ASPECT_ANALYZER);
+ platform = new BlockPlatform(LibBlockIDs.idPlatform).setUnlocalizedName(LibBlockNames.PLATFORM);
+
+ if(ConfigHandler.enableKami) {
+ warpGate = new BlockWarpGate(LibBlockIDs.idWarpGate).setUnlocalizedName(LibBlockNames.WARP_GATE);
+ }
+
+ registerBlocks();
+ registerMultiparts();
+ }
+
+ private static void registerBlocks() {
+ GameRegistry.registerBlock(darkQuartz, ItemDarkQuartzBlock.class, LibBlockNames.DARK_QUARTZ);
+ GameRegistry.registerBlock(darkQuartzStairs, LibBlockNames.DARK_QUARTZ_STAIRS);
+ GameRegistry.registerBlock(darkQuartzSlab, ItemDarkQuartzSlab.class, LibBlockNames.DARK_QUARTZ_SLAB);
+ GameRegistry.registerBlock(darkQuartzSlabFull, ItemDarkQuartzSlab.class, LibBlockNames.DARK_QUARTZ_SLAB_FULL);
+ GameRegistry.registerBlock(interfase, LibBlockNames.INTERFACE);
+ GameRegistry.registerBlock(gaseousLight, LibBlockNames.GASEOUS_LIGHT);
+ GameRegistry.registerBlock(gaseousShadow, LibBlockNames.GASEOUS_SHADOW);
+ GameRegistry.registerBlock(animationTablet, LibBlockNames.ANIMATION_TABLET);
+ GameRegistry.registerBlock(magnet, ItemBlockMagnet.class, LibBlockNames.MAGNET);
+ GameRegistry.registerBlock(enchanter, LibBlockNames.ENCHANTER);
+ GameRegistry.registerBlock(funnel, LibBlockNames.FUNNEL);
+ GameRegistry.registerBlock(dislocator, LibBlockNames.DISLOCATOR);
+ GameRegistry.registerBlock(repairer, LibBlockNames.REPAIRER);
+ GameRegistry.registerBlock(aspectAnalyzer, LibBlockNames.ASPECT_ANALYZER);
+ GameRegistry.registerBlock(platform, LibBlockNames.PLATFORM);
+
+ if(ConfigHandler.enableKami) {
+ GameRegistry.registerBlock(warpGate, ItemBlockWarpGate.class, LibBlockNames.WARP_GATE);
+ }
+ }
+
+ private static void registerMultiparts() {
+ if(Loader.isModLoaded("ForgeMultipart")) {
+ try {
+ Class clazz = Class.forName("vazkii.tinkerer.common.block.multipart.MultipartHandler");
+ clazz.newInstance();
+ } catch(Throwable e) {}
+ }
+ }
+
+
+ public static void initTileEntities() {
+ GameRegistry.registerTileEntity(TileTransvectorInterface.class, LibBlockNames.INTERFACE);
+ GameRegistry.registerTileEntity(TileAnimationTablet.class, LibBlockNames.ANIMATION_TABLET);
+ GameRegistry.registerTileEntity(TileMagnet.class, LibBlockNames.MAGNET);
+ GameRegistry.registerTileEntity(TileMobMagnet.class, LibBlockNames.MOB_MAGNET);
+ GameRegistry.registerTileEntity(TileEnchanter.class, LibBlockNames.ENCHANTER);
+ GameRegistry.registerTileEntity(TileFunnel.class, LibBlockNames.FUNNEL);
+ GameRegistry.registerTileEntity(TileTransvectorDislocator.class, LibBlockNames.DISLOCATOR);
+ GameRegistry.registerTileEntity(TileRepairer.class, LibBlockNames.REPAIRER);
+ GameRegistry.registerTileEntity(TileAspectAnalyzer.class, LibBlockNames.ASPECT_ANALYZER);
+ GameRegistry.registerTileEntity(TileCamo.class, LibBlockNames.CAMO);
+
+ if(ConfigHandler.enableKami) {
+ GameRegistry.registerTileEntity(TileWarpGate.class, LibBlockNames.WARP_GATE);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/block/kami/BlockWarpGate.java b/src/main/java/vazkii/tinkerer/common/block/kami/BlockWarpGate.java
new file mode 100644
index 00000000..84da4667
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/kami/BlockWarpGate.java
@@ -0,0 +1,133 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Jan 10, 2014, 3:54:41 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.kami;
+
+
+import java.util.Random;
+
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.Icon;
+import net.minecraft.world.World;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.client.lib.LibRenderIDs;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.block.BlockModContainer;
+import vazkii.tinkerer.common.block.tile.kami.TileWarpGate;
+import vazkii.tinkerer.common.lib.LibGuiIDs;
+import cpw.mods.fml.common.network.PacketDispatcher;
+import cpw.mods.fml.common.network.Player;
+
+public class BlockWarpGate extends BlockModContainer {
+
+ public static Icon[] icons = new Icon[3];
+ Random random;
+
+ public BlockWarpGate(int par1) {
+ super(par1, Material.rock);
+ setHardness(5.0F);
+ setResistance(2000.0F);
+
+ random = new Random();
+ }
+
+ @Override
+ public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
+ if(!par1World.isRemote) {
+ TileEntity tile = par1World.getBlockTileEntity(par2, par3, par4);
+ if(tile != null) {
+ PacketDispatcher.sendPacketToPlayer(tile.getDescriptionPacket(), (Player) par5EntityPlayer);
+ par5EntityPlayer.openGui(ThaumicTinkerer.instance, LibGuiIDs.GUI_ID_WARP_GATE, par1World, par2, par3, par4);
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {
+ TileWarpGate warpGate = (TileWarpGate) par1World.getBlockTileEntity(par2, par3, par4);
+
+ if (warpGate != null) {
+ for (int j1 = 0; j1 < warpGate.getSizeInventory(); ++j1) {
+ ItemStack itemstack = warpGate.getStackInSlot(j1);
+
+ if (itemstack != null) {
+ float f = random.nextFloat() * 0.8F + 0.1F;
+ float f1 = random.nextFloat() * 0.8F + 0.1F;
+ EntityItem entityitem;
+
+ for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
+ int k1 = random.nextInt(21) + 10;
+
+ if (k1 > itemstack.stackSize)
+ k1 = itemstack.stackSize;
+
+ itemstack.stackSize -= k1;
+ entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));
+ float f3 = 0.05F;
+ entityitem.motionX = (float)random.nextGaussian() * f3;
+ entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
+ entityitem.motionZ = (float)random.nextGaussian() * f3;
+
+ if (itemstack.hasTagCompound())
+ entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
+ }
+ }
+ }
+
+ par1World.func_96440_m(par2, par3, par4, par5);
+ }
+
+ super.breakBlock(par1World, par2, par3, par4, par5, par6);
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world) {
+ return new TileWarpGate();
+ }
+
+ @Override
+ public Icon getIcon(int par1, int par2) {
+ return icons[par1 == 1 ? 0 : 1];
+ }
+
+ @Override
+ public void registerIcons(IconRegister par1IconRegister) {
+ for(int i = 0; i < icons.length; i++)
+ icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
+ }
+
+ @Override
+ public int getRenderType() {
+ return LibRenderIDs.idWarpGate;
+ }
+
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ public boolean renderAsNormalBlock() {
+ return false;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/multipart/MultipartHandler.java b/src/main/java/vazkii/tinkerer/common/block/multipart/MultipartHandler.java
new file mode 100644
index 00000000..d579b5ef
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/multipart/MultipartHandler.java
@@ -0,0 +1,49 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [29 Oct 2013, 14:23:16 (GMT)]
+ */
+package vazkii.tinkerer.common.block.multipart;
+
+import net.minecraft.block.Block;
+import thaumcraft.common.config.ConfigBlocks;
+import vazkii.tinkerer.common.block.ModBlocks;
+import codechicken.microblock.BlockMicroMaterial;
+import codechicken.microblock.MicroMaterialRegistry;
+
+public class MultipartHandler {
+
+ public MultipartHandler() {
+ registerMultipart(ConfigBlocks.blockCustomOre, 0);
+ registerMultipart(ConfigBlocks.blockCustomOre, 7);
+ registerMultipart(ConfigBlocks.blockWoodenDevice, 6);
+ registerMultipart(ConfigBlocks.blockWoodenDevice, 7);
+ registerMultipartMetadataLine(ConfigBlocks.blockMagicalLog, 1);
+ registerMultipartMetadataLine(ConfigBlocks.blockMagicalLeaves, 1);
+ registerMultipartMetadataLine(ConfigBlocks.blockCosmeticOpaque, 1);
+ registerMultipartMetadataLine(ConfigBlocks.blockCosmeticSolid, 7);
+ registerMultipartMetadataLine(ModBlocks.darkQuartz, 2);
+
+ new RegisterBlockPart(ConfigBlocks.blockCandle, PartCandle.class, ConfigBlocks.blockCandle.getUnlocalizedName()).init();
+ //(new RegisterBlockPart(ConfigBlocks.blockAiry, PartNitor.class, ConfigBlocks.blockAiry.getUnlocalizedName())).init();
+ }
+
+ private static void registerMultipartMetadataLine(Block block, int maxMeta) {
+ for(int i = 0; i < maxMeta; i++)
+ registerMultipart(block, i);
+ }
+
+ private static void registerMultipart(Block block, int meta) {
+ MicroMaterialRegistry.registerMaterial(new BlockMicroMaterial(block, meta), block.getUnlocalizedName() + (meta == 0 ? "" : "_" + meta));
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/block/multipart/PartCandle.java b/src/main/java/vazkii/tinkerer/common/block/multipart/PartCandle.java
new file mode 100644
index 00000000..fab1aa1a
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/multipart/PartCandle.java
@@ -0,0 +1,62 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [25 Oct 2013, 17:26:07 (GMT)]
+ */
+package vazkii.tinkerer.common.block.multipart;
+
+import java.util.Arrays;
+import java.util.Random;
+
+import net.minecraft.block.Block;
+import net.minecraft.item.ItemStack;
+import thaumcraft.common.config.ConfigBlocks;
+import codechicken.lib.vec.Cuboid6;
+import codechicken.multipart.IRandomDisplayTick;
+import codechicken.multipart.minecraft.McMetaPart;
+
+public class PartCandle extends McMetaPart implements IRandomDisplayTick {
+
+ public PartCandle(int meta) {
+ super(meta);
+ }
+
+ public PartCandle() {
+ super();
+ }
+
+ @Override
+ public Cuboid6 getBounds() {
+ return new Cuboid6(0.375, 0, 0.375, 0.625, 0.5, 0.625);
+ }
+
+ @Override
+ public void randomDisplayTick(Random arg0) {
+ getBlock().randomDisplayTick(world(), x(), y(), z(), arg0);
+ }
+
+ @Override
+ public Block getBlock() {
+ return ConfigBlocks.blockCandle;
+ }
+
+ @Override
+ public Iterable getDrops() {
+ return Arrays.asList(new ItemStack(getBlock(), 1, meta));
+ }
+
+ @Override
+ public String getType() {
+ return getBlock().getUnlocalizedName();
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/multipart/PartNitor.java b/src/main/java/vazkii/tinkerer/common/block/multipart/PartNitor.java
new file mode 100644
index 00000000..68eeed52
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/multipart/PartNitor.java
@@ -0,0 +1,65 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [25 Oct 2013, 19:11:44 (GMT)]
+ */
+package vazkii.tinkerer.common.block.multipart;
+
+import net.minecraft.block.Block;
+import thaumcraft.common.config.ConfigBlocks;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import codechicken.lib.vec.Cuboid6;
+import codechicken.multipart.minecraft.McMetaPart;
+
+public class PartNitor extends McMetaPart {
+
+ public PartNitor() {
+ super(1);
+ }
+
+ @Override
+ public Cuboid6 getBounds() {
+ return new Cuboid6(0.3, 0.3, 0.3, 0.7, 0.7, 0.7);
+ }
+
+ @Override
+ public boolean doesTick() {
+ return true;
+ }
+
+ @Override
+ public void update() {
+ if (world().isRemote) {
+ if (world().rand.nextInt(9 - ThaumicTinkerer.tcProxy.particleCount(3)) == 0)
+ ThaumicTinkerer.tcProxy.wispFX3(world(), x() + 0.5F, y() + 0.5F, z() + 0.5F, x() + 0.3F + world().rand.nextFloat() * 0.4F, y() + 0.5F, z() + 0.3F + world().rand.nextFloat() * 0.4F, 0.5F, 4, true, -0.025F);
+
+ if (world().rand.nextInt(15 - ThaumicTinkerer.tcProxy.particleCount(5)) == 0)
+ ThaumicTinkerer.tcProxy.wispFX3(world(), x() + 0.5F, y()+ 0.5F, z() + 0.5F, x() + 0.4F + world().rand.nextFloat() * 0.2F, y() + 0.5F, z() + 0.4F + world().rand.nextFloat() * 0.2F, 0.25F, 1, true, -0.02F);
+ }
+ }
+
+ @Override
+ public Block getBlock() {
+ return ConfigBlocks.blockAiry;
+ }
+
+ @Override
+ public int getMetadata() {
+ return 1;
+ }
+
+ @Override
+ public String getType() {
+ return getBlock().getUnlocalizedName();
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/block/multipart/RegisterBlockPart.java b/src/main/java/vazkii/tinkerer/common/block/multipart/RegisterBlockPart.java
new file mode 100644
index 00000000..7b4c3191
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/multipart/RegisterBlockPart.java
@@ -0,0 +1,89 @@
+/**
+ * @author RWTema
+ * Thanks man!
+ *
+ * Check out his mod, ExtraUtilities:
+ * http://www.minecraftforum.net/topic/1776056-
+ */
+package vazkii.tinkerer.common.block.multipart;
+
+import net.minecraft.block.Block;
+import net.minecraft.world.World;
+import codechicken.lib.vec.BlockCoord;
+import codechicken.multipart.MultiPartRegistry;
+import codechicken.multipart.MultiPartRegistry.IPartConverter;
+import codechicken.multipart.MultiPartRegistry.IPartFactory;
+import codechicken.multipart.TMultiPart;
+
+// This class is used by FMP to recreate a part during loading and to convert already existing non-mutlipart blocks into multiparts.
+
+// this is copied from the version FMP uses for vanilla torches
+
+public class RegisterBlockPart implements IPartFactory, IPartConverter {
+ Block block = null;
+ Class extends TMultiPart> part = null;
+ String name = "";
+
+ public RegisterBlockPart(Block block, Class extends TMultiPart> part) {
+ //Autoloads the multi-parts name
+ try {
+ name = part.getConstructor().newInstance(new Object[] {}).getType();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public RegisterBlockPart(Block block, Class extends TMultiPart> part, String name) {
+ this.block = block;
+ this.part = part;
+ this.name = name;
+ }
+
+ @Override
+ public TMultiPart createPart(String name, boolean client) {
+ if (name.equals(name))
+ try {
+ return part.getConstructor().newInstance();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ return null;
+ }
+
+ //register the converter and the parts
+ public void init() {
+ if (name.isEmpty() || block == null || part == null)
+ return;
+
+ MultiPartRegistry.registerConverter(this);
+ MultiPartRegistry.registerParts(this, new String[] { name });
+ }
+
+ @Override
+ public boolean canConvert(int blockID) {
+ return blockID == block.blockID;
+ }
+
+ @Override
+ public TMultiPart convert(World world, BlockCoord pos) {
+ int id = world.getBlockId(pos.x, pos.y, pos.z);
+ int meta = world.getBlockMetadata(pos.x, pos.y, pos.z);
+ if (id == block.blockID) {
+ try {
+ if(part.getName().equals("vazkii.tinkerer.common.block.multipart.PartNitor") && meta != 1)
+ return null;
+
+ if(part.getDeclaredConstructor(int.class) != null)
+ return part.getDeclaredConstructor(int.class).newInstance(meta);
+
+ return part.getConstructor().newInstance();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/quartz/BlockDarkQuartz.java b/src/main/java/vazkii/tinkerer/common/block/quartz/BlockDarkQuartz.java
new file mode 100644
index 00000000..6cd1943c
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/quartz/BlockDarkQuartz.java
@@ -0,0 +1,122 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 15:59:00 (GMT)]
+ */
+package vazkii.tinkerer.common.block.quartz;
+
+import java.util.List;
+
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Icon;
+import net.minecraft.world.World;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.common.block.BlockMod;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class BlockDarkQuartz extends BlockMod {
+
+ private static final String[] iconNames = new String[] {"darkQuartz0", "chiseledDarkQuartz0", "pillarDarkQuartz0", null, null};
+ private Icon[] darkQuartzIcons;
+ private Icon chiseledDarkQuartzIcon;
+ private Icon pillarDarkQuartzIcon;
+ private Icon darkQuartzTopIcon;
+
+ public BlockDarkQuartz(int par1) {
+ super(par1, Material.rock);
+ setHardness(0.8F);
+ setResistance(10F);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public Icon getIcon(int par1, int par2) {
+ if (par2 != 2 && par2 != 3 && par2 != 4) {
+ if (par1 != 1 && (par1 != 0 || par2 != 1)) {
+ if (par1 == 0)
+ return darkQuartzTopIcon;
+ else {
+ if (par2 < 0 || par2 >= darkQuartzIcons.length)
+ par2 = 0;
+
+ return darkQuartzIcons[par2];
+ }
+ }
+ else return par2 == 1 ? chiseledDarkQuartzIcon : darkQuartzTopIcon;
+ }
+ else return par2 == 2 && (par1 == 1 || par1 == 0) ? pillarDarkQuartzIcon : par2 == 3 && (par1 == 5 || par1 == 4) ? pillarDarkQuartzIcon : par2 == 4 && (par1 == 2 || par1 == 3) ? pillarDarkQuartzIcon : darkQuartzIcons[par2];
+ }
+
+ @Override
+ public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9) {
+ if (par9 == 2) {
+ switch (par5) {
+ case 0:
+ case 1:
+ par9 = 2;
+ break;
+ case 2:
+ case 3:
+ par9 = 4;
+ break;
+ case 4:
+ case 5:
+ par9 = 3;
+ }
+ }
+
+ return par9;
+ }
+
+ @Override
+ public int damageDropped(int par1) {
+ return par1 != 3 && par1 != 4 ? par1 : 2;
+ }
+
+ @Override
+ public ItemStack createStackedBlock(int par1) {
+ return par1 != 3 && par1 != 4 ? super.createStackedBlock(par1) : new ItemStack(blockID, 1, 2);
+ }
+
+ @Override
+ public int getRenderType() {
+ return 39;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) {
+ par3List.add(new ItemStack(par1, 1, 0));
+ par3List.add(new ItemStack(par1, 1, 1));
+ par3List.add(new ItemStack(par1, 1, 2));
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ darkQuartzIcons = new Icon[iconNames.length];
+
+ for (int i = 0; i < darkQuartzIcons.length; ++i) {
+ if (iconNames[i] == null)
+ darkQuartzIcons[i] = darkQuartzIcons[i - 1];
+ else darkQuartzIcons[i] = IconHelper.forName(par1IconRegister, iconNames[i]);
+ }
+
+ darkQuartzTopIcon = IconHelper.forName(par1IconRegister, "darkQuartz1");
+ chiseledDarkQuartzIcon = IconHelper.forName(par1IconRegister, "chiseledDarkQuartz1");
+ pillarDarkQuartzIcon = IconHelper.forName(par1IconRegister, "pillarDarkQuartz1");
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/quartz/BlockDarkQuartzSlab.java b/src/main/java/vazkii/tinkerer/common/block/quartz/BlockDarkQuartzSlab.java
new file mode 100644
index 00000000..89b73b7d
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/quartz/BlockDarkQuartzSlab.java
@@ -0,0 +1,75 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 15:59:37 (GMT)]
+ */
+package vazkii.tinkerer.common.block.quartz;
+
+import java.util.Random;
+
+import net.minecraft.block.BlockHalfSlab;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Icon;
+import net.minecraft.world.World;
+import vazkii.tinkerer.common.block.ModBlocks;
+import vazkii.tinkerer.common.core.handler.ModCreativeTab;
+import vazkii.tinkerer.common.lib.LibBlockNames;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class BlockDarkQuartzSlab extends BlockHalfSlab {
+
+ public BlockDarkQuartzSlab(int par1, boolean par2) {
+ super(par1, par2, Material.rock);
+ setHardness(0.8F);
+ setResistance(10F);
+ if(!par2) {
+ setLightOpacity(0);
+ setCreativeTab(ModCreativeTab.INSTANCE);
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public Icon getIcon(int par1, int par2) {
+ return ModBlocks.darkQuartz.getBlockTextureFromSide(par1);
+ }
+
+ @Override
+ public int idDropped(int par1, Random par2Random, int par3) {
+ return ModBlocks.darkQuartzSlab.blockID;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public int idPicked(World par1World, int par2, int par3, int par4) {
+ return blockID;
+ }
+
+ @Override
+ public ItemStack createStackedBlock(int par1) {
+ return new ItemStack(ModBlocks.darkQuartzSlab);
+ }
+
+ @Override
+ public String getFullSlabName(int i) {
+ return "tile." + LibBlockNames.DARK_QUARTZ_SLAB;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ // NO-OP
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/block/quartz/BlockDarkQuartzStairs.java b/src/main/java/vazkii/tinkerer/common/block/quartz/BlockDarkQuartzStairs.java
new file mode 100644
index 00000000..ac2b8a7f
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/quartz/BlockDarkQuartzStairs.java
@@ -0,0 +1,27 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 16:02:19 (GMT)]
+ */
+package vazkii.tinkerer.common.block.quartz;
+
+import net.minecraft.block.BlockStairs;
+import vazkii.tinkerer.common.block.ModBlocks;
+import vazkii.tinkerer.common.core.handler.ModCreativeTab;
+
+public class BlockDarkQuartzStairs extends BlockStairs {
+
+ public BlockDarkQuartzStairs(int par1) {
+ super(par1, ModBlocks.darkQuartz, 0);
+ setCreativeTab(ModCreativeTab.INSTANCE);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/TileAspectAnalyzer.java b/src/main/java/vazkii/tinkerer/common/block/tile/TileAspectAnalyzer.java
new file mode 100644
index 00000000..9ff8e3d5
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/TileAspectAnalyzer.java
@@ -0,0 +1,206 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 11, 2013, 10:33:26 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.tileentity.TileEntity;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.common.lib.ThaumcraftCraftingManager;
+import vazkii.tinkerer.common.lib.LibBlockNames;
+import dan200.computer.api.IComputerAccess;
+import dan200.computer.api.ILuaContext;
+import dan200.computer.api.IPeripheral;
+
+public class TileAspectAnalyzer extends TileEntity implements IInventory, IPeripheral {
+
+ ItemStack[] inventorySlots = new ItemStack[1];
+
+ @Override
+ public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
+ super.readFromNBT(par1NBTTagCompound);
+
+ NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
+ inventorySlots = new ItemStack[getSizeInventory()];
+ for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
+ NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
+ byte var5 = var4.getByte("Slot");
+ if (var5 >= 0 && var5 < inventorySlots.length)
+ inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
+ }
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
+ super.writeToNBT(par1NBTTagCompound);
+
+ NBTTagList var2 = new NBTTagList();
+ for (int var3 = 0; var3 < inventorySlots.length; ++var3) {
+ if (inventorySlots[var3] != null) {
+ NBTTagCompound var4 = new NBTTagCompound();
+ var4.setByte("Slot", (byte)var3);
+ inventorySlots[var3].writeToNBT(var4);
+ var2.appendTag(var4);
+ }
+ }
+ par1NBTTagCompound.setTag("Items", var2);
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return inventorySlots.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int i) {
+ return inventorySlots[i];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int i, int j) {
+ if (inventorySlots[i] != null) {
+ ItemStack stackAt;
+
+ if (inventorySlots[i].stackSize <= j) {
+ stackAt = inventorySlots[i];
+ inventorySlots[i] = null;
+ return stackAt;
+ } else {
+ stackAt = inventorySlots[i].splitStack(j);
+
+ if (inventorySlots[i].stackSize == 0)
+ inventorySlots[i] = null;
+
+ return stackAt;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ return getStackInSlot(i);
+ }
+
+ @Override
+ public void setInventorySlotContents(int i, ItemStack itemstack) {
+ inventorySlots[i] = itemstack;
+ }
+
+ @Override
+ public String getInvName() {
+ return LibBlockNames.MAGNET;
+ }
+
+ @Override
+ public boolean isInvNameLocalized() {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer) {
+ return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this ? false : entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64;
+ }
+
+ @Override
+ public void openChest() {
+ // NO-OP
+ }
+
+ @Override
+ public void closeChest() {
+ // NO-OP
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int i, ItemStack itemstack) {
+ return true;
+ }
+
+ @Override
+ public String getType() {
+ return "tt_aspectanalyzer";
+ }
+
+ @Override
+ public String[] getMethodNames() {
+ return new String[] { "hasItem", "itemHasAspects", "getAspects", "getAspectCount" };
+ }
+
+ @Override
+ public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
+ ItemStack stack = getStackInSlot(0);
+ AspectList aspects = null;
+ if(stack != null) {
+ aspects = ThaumcraftCraftingManager.getObjectTags(stack);
+ aspects = ThaumcraftCraftingManager.getBonusTags(stack, aspects);
+ }
+
+ switch(method) {
+ case 0 : return new Object[] { stack != null };
+ case 1 : return new Object[] { aspects != null && aspects.size() > 0 };
+ case 2 : {
+ List returnStuff = new ArrayList();
+ if(aspects == null)
+ return new String[0];
+
+ for(Aspect aspect : aspects.getAspectsSorted())
+ returnStuff.add(aspect.getTag());
+
+ return returnStuff.toArray();
+ }
+ case 3 : {
+ String aspectName = (String) arguments[0];
+ Aspect aspect = Aspect.getAspect(aspectName);
+
+ if(aspects == null)
+ return new Object[] { 0 };
+
+ return new Object[] { aspects.getAmount(aspect) };
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean canAttachToSide(int side) {
+ return true;
+ }
+
+ @Override
+ public void attach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+ @Override
+ public void detach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/TileCamo.java b/src/main/java/vazkii/tinkerer/common/block/tile/TileCamo.java
new file mode 100644
index 00000000..6c8d1e4a
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/TileCamo.java
@@ -0,0 +1,74 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 27, 2013, 6:26:18 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile;
+
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.INetworkManager;
+import net.minecraft.network.packet.Packet;
+import net.minecraft.network.packet.Packet132TileEntityData;
+import net.minecraft.tileentity.TileEntity;
+
+public class TileCamo extends TileEntity {
+
+ private static final String TAG_CAMO = "camo";
+ private static final String TAG_CAMO_META = "camoMeta";
+
+ public int camo;
+ public int camoMeta;
+
+ @Override
+ public boolean canUpdate() {
+ return false;
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound par1nbtTagCompound) {
+ super.writeToNBT(par1nbtTagCompound);
+
+ writeCustomNBT(par1nbtTagCompound);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound par1nbtTagCompound) {
+ super.readFromNBT(par1nbtTagCompound);
+
+ readCustomNBT(par1nbtTagCompound);
+ }
+
+ public void writeCustomNBT(NBTTagCompound cmp) {
+ cmp.setInteger(TAG_CAMO, camo);
+ cmp.setInteger(TAG_CAMO_META, camoMeta);
+ }
+
+ public void readCustomNBT(NBTTagCompound cmp) {
+ camo = cmp.getInteger(TAG_CAMO);
+ camoMeta = cmp.getInteger(TAG_CAMO_META);
+ }
+
+ @Override
+ public Packet getDescriptionPacket() {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ writeCustomNBT(nbttagcompound);
+ return new Packet132TileEntityData(xCoord, yCoord, zCoord, -999, nbttagcompound);
+ }
+
+ @Override
+ public void onDataPacket(INetworkManager manager, Packet132TileEntityData packet) {
+ super.onDataPacket(manager, packet);
+ readCustomNBT(packet.data);
+ worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/TileEnchanter.java b/src/main/java/vazkii/tinkerer/common/block/tile/TileEnchanter.java
new file mode 100644
index 00000000..a41e97c0
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/TileEnchanter.java
@@ -0,0 +1,432 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [14 Sep 2013, 01:07:25 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagInt;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.network.INetworkManager;
+import net.minecraft.network.packet.Packet;
+import net.minecraft.network.packet.Packet132TileEntityData;
+import net.minecraft.tileentity.TileEntity;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.common.Thaumcraft;
+import thaumcraft.common.config.ConfigBlocks;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import vazkii.tinkerer.common.core.helper.Tuple4Int;
+import vazkii.tinkerer.common.enchantment.core.EnchantmentManager;
+import vazkii.tinkerer.common.lib.LibBlockNames;
+import vazkii.tinkerer.common.lib.LibFeatures;
+import cpw.mods.fml.common.network.PacketDispatcher;
+public class TileEnchanter extends TileEntity implements ISidedInventory {
+
+ private static final String TAG_ENCHANTS = "enchants";
+ private static final String TAG_LEVELS = "levels";
+ private static final String TAG_TOTAL_ASPECTS = "totalAspects";
+ private static final String TAG_CURRENT_ASPECTS = "currentAspects";
+ private static final String TAG_WORKING = "working";
+
+ public List enchantments = new ArrayList();
+ public List levels = new ArrayList();
+
+ public AspectList totalAspects = new AspectList();
+ public AspectList currentAspects = new AspectList();
+
+ public boolean working = false;
+
+ private List pillars = new ArrayList();
+
+ ItemStack[] inventorySlots = new ItemStack[2];
+
+ public void clearEnchants() {
+ enchantments.clear();
+ levels.clear();
+ }
+
+ public void appendEnchant(int enchant) {
+ enchantments.add(enchant);
+ }
+
+ public void appendLevel(int level) {
+ levels.add(level);
+ }
+
+ public void removeEnchant(int index) {
+ enchantments.remove(index);
+ }
+
+ public void removeLevel(int index) {
+ levels.remove(index);
+ }
+
+ public void setEnchant(int index, int enchant) {
+ enchantments.set(index, enchant);
+ }
+
+ public void setLevel(int index, int level) {
+ levels.set(index, level);
+ }
+
+ @Override
+ public void updateEntity() {
+ if(getStackInSlot(0) == null) {
+ enchantments.clear();
+ levels.clear();
+ }
+
+ if(working) {
+ ItemStack tool = getStackInSlot(0);
+ if(tool == null) {
+ working = false;
+ return;
+ }
+
+ checkPillars();
+
+ if(!working) // Pillar check
+ return;
+
+ enchantItem : {
+ for(Aspect aspect : LibFeatures.PRIMAL_ASPECTS) {
+ int currentAmount = currentAspects.getAmount(aspect);
+ int totalAmount = totalAspects.getAmount(aspect);
+
+ if(currentAmount < totalAmount)
+ break enchantItem;
+ }
+
+ working = false;
+ currentAspects = new AspectList();
+ totalAspects = new AspectList();
+
+ for(int i = 0; i < enchantments.size(); i++) {
+ int enchant = enchantments.get(i);
+ int level = levels.get(i);
+
+ if(!worldObj.isRemote)
+ tool.addEnchantment(Enchantment.enchantmentsList[enchant], level);
+ }
+
+ enchantments.clear();
+ levels.clear();
+ worldObj.playSoundEffect(xCoord, yCoord, zCoord, "thaumcraft:wand", 1F, 1F);
+ PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
+ return;
+ }
+
+ ItemStack wand = getStackInSlot(1);
+
+ if(wand != null && wand.getItem() instanceof ItemWandCasting) {
+ ItemWandCasting wandItem = (ItemWandCasting) wand.getItem();
+ AspectList wandAspects = wandItem.getAllVis(wand);
+
+ int missing, onWand;
+ List aspectsThatCanGet = new ArrayList();
+
+ for(Aspect aspect : LibFeatures.PRIMAL_ASPECTS) {
+ missing = totalAspects.getAmount(aspect) - currentAspects.getAmount(aspect);
+ onWand = wandAspects.getAmount(aspect);
+
+ if(missing > 0 && onWand >= 100)
+ aspectsThatCanGet.add(aspect);
+ }
+
+ int i = aspectsThatCanGet.isEmpty() ? 0 : worldObj.rand.nextInt(aspectsThatCanGet.size());
+ Aspect aspect = aspectsThatCanGet.isEmpty() ? null : aspectsThatCanGet.get(i);
+
+ if(aspect != null) {
+ wandItem.consumeAllVisCrafting(wand, null, new AspectList().add(aspect, 1), true);
+ currentAspects.add(aspect, 1);
+ Tuple4Int p = pillars.get(i);
+ if(worldObj.rand.nextBoolean()) {
+ Thaumcraft.proxy.blockRunes(worldObj, p.i1, p.i4 - 0.75, p.i3, 0.3F + worldObj.rand.nextFloat() * 0.7F, 0.0F, 0.3F + worldObj.rand.nextFloat() * 0.7F, 15, worldObj.rand.nextFloat() / 8F);
+ Thaumcraft.proxy.blockRunes(worldObj, xCoord, yCoord + 0.25, zCoord, 0.3F + worldObj.rand.nextFloat() * 0.7F, 0.0F, 0.3F + worldObj.rand.nextFloat() * 0.7F, 15, worldObj.rand.nextFloat() / 8F);
+ if(worldObj.rand.nextInt(5) == 0)
+ worldObj.playSoundEffect(p.i1, p.i2, p.i3, "thaumcraft:brain", 0.5F, 1F);
+ }
+
+ return;
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onInventoryChanged() {
+ super.onInventoryChanged();
+ if(!worldObj.isRemote && !working) {
+ enchantments.clear();
+ levels.clear();
+ PacketDispatcher.sendPacketToAllInDimension(getDescriptionPacket(), worldObj.provider.dimensionId);
+ }
+ }
+
+ public boolean checkPillars() {
+ if(pillars.isEmpty()) {
+ if(!assignPillars()) {
+ working = false;
+ currentAspects = new AspectList();
+ return false;
+ }
+ return true;
+ }
+
+ for(int i = 0; i < pillars.size(); i++) {
+ Tuple4Int pillar = pillars.get(i);
+ int pillarHeight = findPillar(pillar.i1, pillar.i2, pillar.i3);
+ if(pillarHeight == -1) {
+ pillars.clear();
+ return checkPillars();
+ } else if(pillarHeight != pillar.i4)
+ pillar.i4 = pillarHeight;
+ }
+
+ return true;
+ }
+
+ public boolean assignPillars() {
+ int y = yCoord;
+ for(int x = xCoord - 4; x <= xCoord + 4; x++)
+ for(int z = zCoord - 4; z <= zCoord + 4; z++) {
+ int height = findPillar(x, y, z);
+ if(height != -1)
+ pillars.add(new Tuple4Int(x, y, z, height));
+
+ if(pillars.size() == 6)
+ return true;
+ }
+
+ pillars.clear();
+ return false;
+ }
+
+ public int findPillar(int x, int y, int z) {
+ int obsidianFound = 0;
+ for(int i = 0; true; i++) {
+ if(y + i >= 256)
+ return -1;
+
+ int id = worldObj.getBlockId(x, y + i, z);
+ int meta = worldObj.getBlockMetadata(x, y + i, z);
+ if(id == ConfigBlocks.blockCosmeticSolid.blockID && meta == 0) {
+ ++obsidianFound;
+ continue;
+ }
+ if(id == ConfigBlocks.blockAiry.blockID && meta == 1) {
+ if(obsidianFound >= 2 && obsidianFound < 13)
+ return y + i;
+ return -1;
+ }
+
+ return -1;
+ }
+ }
+
+ public void updateAspectList() {
+ totalAspects = new AspectList();
+ for(int i = 0; i < enchantments.size(); i++) {
+ int enchant = enchantments.get(i);
+ int level = levels.get(i);
+
+ AspectList aspects = EnchantmentManager.enchantmentData.get(enchant).get(level).aspects;
+ for(Aspect aspect : aspects.getAspectsSorted())
+ totalAspects.add(aspect, aspects.getAmount(aspect));
+ }
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
+ super.readFromNBT(par1NBTTagCompound);
+
+ readCustomNBT(par1NBTTagCompound);
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
+ super.writeToNBT(par1NBTTagCompound);
+
+ writeCustomNBT(par1NBTTagCompound);
+ }
+
+ public void readCustomNBT(NBTTagCompound par1NBTTagCompound) {
+ working = par1NBTTagCompound.getBoolean(TAG_WORKING);
+ currentAspects.readFromNBT(par1NBTTagCompound.getCompoundTag(TAG_CURRENT_ASPECTS));
+ totalAspects.readFromNBT(par1NBTTagCompound.getCompoundTag(TAG_TOTAL_ASPECTS));
+
+ NBTTagList enchants = par1NBTTagCompound.getTagList(TAG_ENCHANTS);
+ enchantments.clear();
+ for(int i = 0; i < enchants.tagCount(); i++)
+ enchantments.add(((NBTTagInt) enchants.tagAt(i)).data);
+
+ NBTTagList levels = par1NBTTagCompound.getTagList(TAG_LEVELS);
+ this.levels.clear();
+ for(int i = 0; i < levels.tagCount(); i++)
+ this.levels.add(((NBTTagInt) levels.tagAt(i)).data);
+
+ NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
+ inventorySlots = new ItemStack[getSizeInventory()];
+ for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
+ NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
+ byte var5 = var4.getByte("Slot");
+ if (var5 >= 0 && var5 < inventorySlots.length)
+ inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
+ }
+ }
+
+ public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) {
+ NBTTagList enchants = new NBTTagList();
+ for(int enchant : enchantments)
+ enchants.appendTag(new NBTTagInt("", enchant));
+ NBTTagList levels = new NBTTagList();
+ for(int level : this.levels)
+ levels.appendTag(new NBTTagInt("", level));
+
+ NBTTagCompound totalAspectsCmp = new NBTTagCompound();
+ totalAspects.writeToNBT(totalAspectsCmp);
+
+ NBTTagCompound currentAspectsCmp = new NBTTagCompound();
+ currentAspects.writeToNBT(currentAspectsCmp);
+
+ par1NBTTagCompound.setBoolean(TAG_WORKING, working);
+ par1NBTTagCompound.setCompoundTag(TAG_TOTAL_ASPECTS, totalAspectsCmp);
+ par1NBTTagCompound.setCompoundTag(TAG_CURRENT_ASPECTS, currentAspectsCmp);
+ par1NBTTagCompound.setTag(TAG_ENCHANTS, enchants);
+ par1NBTTagCompound.setTag(TAG_LEVELS, levels);
+
+ NBTTagList var2 = new NBTTagList();
+ for (int var3 = 0; var3 < inventorySlots.length; ++var3) {
+ if (inventorySlots[var3] != null) {
+ NBTTagCompound var4 = new NBTTagCompound();
+ var4.setByte("Slot", (byte)var3);
+ inventorySlots[var3].writeToNBT(var4);
+ var2.appendTag(var4);
+ }
+ }
+ par1NBTTagCompound.setTag("Items", var2);
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return inventorySlots.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int i) {
+ return inventorySlots[i];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int i, int j) {
+ if (inventorySlots[i] != null) {
+ ItemStack stackAt;
+
+ if (inventorySlots[i].stackSize <= j) {
+ stackAt = inventorySlots[i];
+ inventorySlots[i] = null;
+ return stackAt;
+ } else {
+ stackAt = inventorySlots[i].splitStack(j);
+
+ if (inventorySlots[i].stackSize == 0)
+ inventorySlots[i] = null;
+
+ return stackAt;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ return getStackInSlot(i);
+ }
+
+ @Override
+ public void setInventorySlotContents(int i, ItemStack itemstack) {
+ inventorySlots[i] = itemstack;
+ }
+
+ @Override
+ public String getInvName() {
+ return LibBlockNames.ENCHANTER;
+ }
+
+ @Override
+ public boolean isInvNameLocalized() {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 1;
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer) {
+ return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this ? false : entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64;
+ }
+
+ @Override
+ public void openChest() {
+ // NO-OP
+ }
+
+ @Override
+ public void closeChest() {
+ // NO-OP
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int i, ItemStack itemstack) {
+ return false;
+ }
+
+ @Override
+ public Packet getDescriptionPacket() {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ writeCustomNBT(nbttagcompound);
+ return new Packet132TileEntityData(xCoord, yCoord, zCoord, -999, nbttagcompound);
+ }
+
+ @Override
+ public void onDataPacket(INetworkManager manager, Packet132TileEntityData packet) {
+ super.onDataPacket(manager, packet);
+ readCustomNBT(packet.data);
+ }
+
+ @Override
+ public int[] getAccessibleSlotsFromSide(int var1) {
+ return new int[0];
+ }
+
+ @Override
+ public boolean canInsertItem(int i, ItemStack itemstack, int j) {
+ return false;
+ }
+
+ @Override
+ public boolean canExtractItem(int i, ItemStack itemstack, int j) {
+ return false;
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/TileFunnel.java b/src/main/java/vazkii/tinkerer/common/block/tile/TileFunnel.java
new file mode 100644
index 00000000..3c63526c
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/TileFunnel.java
@@ -0,0 +1,276 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [28 Sep 2013, 19:34:46 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile;
+
+import net.minecraft.block.BlockHopper;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.network.INetworkManager;
+import net.minecraft.network.packet.Packet;
+import net.minecraft.network.packet.Packet132TileEntityData;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.tileentity.TileEntityHopper;
+import net.minecraft.util.Facing;
+import net.minecraftforge.common.ForgeDirection;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.api.aspects.IAspectContainer;
+import thaumcraft.api.aspects.IEssentiaContainerItem;
+import thaumcraft.common.blocks.ItemJarFilled;
+import thaumcraft.common.config.ConfigBlocks;
+import thaumcraft.common.config.ConfigItems;
+import thaumcraft.common.tiles.TileJarFillable;
+import vazkii.tinkerer.common.lib.LibBlockNames;
+import cpw.mods.fml.common.network.PacketDispatcher;
+
+public class TileFunnel extends TileEntity implements ISidedInventory, IAspectContainer {
+
+ ItemStack[] inventorySlots = new ItemStack[1];
+
+ @Override
+ public void updateEntity() {
+ ItemStack jar = getStackInSlot(0);
+ if(jar != null && jar.getItem() instanceof ItemJarFilled) {
+ if(!worldObj.isRemote) {
+ ItemJarFilled item = (ItemJarFilled) jar.getItem();
+ AspectList aspectList = item.getAspects(jar);
+ if(aspectList != null && aspectList.size() == 1) {
+ Aspect aspect = aspectList.getAspects()[0];
+
+ TileEntity tile = worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord);
+ if(tile != null && tile instanceof TileEntityHopper) {
+ TileEntity tile1 = getHopperFacing(tile.xCoord, tile.yCoord, tile.zCoord, tile.getBlockMetadata());
+ if(tile1 instanceof TileJarFillable) {
+ TileJarFillable jar1 = (TileJarFillable) tile1;
+
+ AspectList aspectList1 = jar1.getAspects();
+ if(aspectList1 != null && aspectList1.size() == 0 || aspectList1.getAspects()[0] == aspect && aspectList1.getAmount(aspectList1.getAspects()[0]) < 64) {
+ jar1.addToContainer(aspect, 1);
+ item.setAspects(jar, aspectList.remove(aspect, 1));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onInventoryChanged() {
+ PacketDispatcher.sendPacketToAllInDimension(getDescriptionPacket(), worldObj.provider.dimensionId);
+ }
+
+ private TileEntity getHopperFacing(int x, int y, int z, int meta) {
+ int i = BlockHopper.getDirectionFromMetadata(meta);
+ return worldObj.getBlockTileEntity(x + Facing.offsetsXForSide[i], y + Facing.offsetsYForSide[i], z + Facing.offsetsZForSide[i]);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
+ super.readFromNBT(par1NBTTagCompound);
+
+ readCustomNBT(par1NBTTagCompound);
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
+ super.writeToNBT(par1NBTTagCompound);
+
+ writeCustomNBT(par1NBTTagCompound);
+ }
+
+ public void readCustomNBT(NBTTagCompound par1NBTTagCompound) {
+ NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
+ inventorySlots = new ItemStack[getSizeInventory()];
+ for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
+ NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
+ byte var5 = var4.getByte("Slot");
+ if (var5 >= 0 && var5 < inventorySlots.length)
+ inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
+ }
+ }
+
+ public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) {
+ NBTTagList var2 = new NBTTagList();
+ for (int var3 = 0; var3 < inventorySlots.length; ++var3) {
+ if (inventorySlots[var3] != null) {
+ NBTTagCompound var4 = new NBTTagCompound();
+ var4.setByte("Slot", (byte)var3);
+ inventorySlots[var3].writeToNBT(var4);
+ var2.appendTag(var4);
+ }
+ }
+ par1NBTTagCompound.setTag("Items", var2);
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return inventorySlots.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int i) {
+ AspectList aspects = getAspects();
+ if(inventorySlots[i] != null && inventorySlots[i].itemID == ConfigItems.itemJarFilled.itemID && aspects == null) {
+ inventorySlots[i] = new ItemStack(ConfigBlocks.blockJar);
+ onInventoryChanged();
+ }
+
+ return inventorySlots[i];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int i, int j) {
+ if (inventorySlots[i] != null) {
+ ItemStack stackAt;
+
+ if (inventorySlots[i].stackSize <= j) {
+ stackAt = inventorySlots[i];
+ inventorySlots[i] = null;
+ return stackAt;
+ } else {
+ stackAt = inventorySlots[i].splitStack(j);
+
+ if (inventorySlots[i].stackSize == 0)
+ inventorySlots[i] = null;
+
+ return stackAt;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ return getStackInSlot(i);
+ }
+
+ @Override
+ public void setInventorySlotContents(int i, ItemStack itemstack) {
+ inventorySlots[i] = itemstack;
+ }
+
+ @Override
+ public String getInvName() {
+ return LibBlockNames.FUNNEL;
+ }
+
+ @Override
+ public boolean isInvNameLocalized() {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 1;
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer) {
+ return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this ? false : entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64;
+ }
+
+ @Override
+ public void openChest() {
+ // NO-OP
+ }
+
+ @Override
+ public void closeChest() {
+ // NO-OP
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int i, ItemStack itemstack) {
+ return true;
+ }
+
+ @Override
+ public Packet getDescriptionPacket() {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ writeCustomNBT(nbttagcompound);
+ return new Packet132TileEntityData(xCoord, yCoord, zCoord, -999, nbttagcompound);
+ }
+
+ @Override
+ public void onDataPacket(INetworkManager manager, Packet132TileEntityData packet) {
+ super.onDataPacket(manager, packet);
+ readCustomNBT(packet.data);
+ }
+
+ @Override
+ public int[] getAccessibleSlotsFromSide(int var1) {
+ return var1 == ForgeDirection.DOWN.ordinal() ? new int[0] : new int[] { 0 };
+ }
+
+ @Override
+ public boolean canInsertItem(int i, ItemStack itemstack, int j) {
+ return itemstack != null && itemstack.getItem() instanceof ItemJarFilled;
+ }
+
+ @Override
+ public boolean canExtractItem(int i, ItemStack itemstack, int j) {
+ return j != ForgeDirection.DOWN.ordinal();
+ }
+
+ @Override
+ public AspectList getAspects() {
+ ItemStack stack = inventorySlots[0];
+ return stack != null && stack.getItem() instanceof IEssentiaContainerItem ? ((IEssentiaContainerItem) stack.getItem()).getAspects(stack) : null;
+ }
+
+ @Override
+ public void setAspects(AspectList paramAspectList) { }
+
+ @Override
+ public boolean doesContainerAccept(Aspect paramAspect) {
+ return false;
+ }
+
+ @Override
+ public int addToContainer(Aspect paramAspect, int paramInt) {
+ return 0;
+ }
+
+ @Override
+ public boolean takeFromContainer(Aspect paramAspect, int paramInt) {
+ return false;
+ }
+
+ @Override
+ public boolean takeFromContainer(AspectList paramAspectList) {
+ return false;
+ }
+
+ @Override
+ public boolean doesContainerContainAmount(Aspect paramAspect, int paramInt) {
+ return false;
+ }
+
+ @Override
+ public boolean doesContainerContain(AspectList paramAspectList) {
+ return false;
+ }
+
+ @Override
+ public int containerContains(Aspect paramAspect) {
+ return 0;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/TileMagnet.java b/src/main/java/vazkii/tinkerer/common/block/tile/TileMagnet.java
new file mode 100644
index 00000000..565891fc
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/TileMagnet.java
@@ -0,0 +1,126 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 17:10:55 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile;
+
+import java.util.List;
+
+import net.minecraft.command.IEntitySelector;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraftforge.common.ForgeDirection;
+import thaumcraft.client.codechicken.core.vec.Vector3;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.core.helper.MiscHelper;
+import dan200.computer.api.IComputerAccess;
+import dan200.computer.api.ILuaContext;
+import dan200.computer.api.IPeripheral;
+
+public class TileMagnet extends TileEntity implements IPeripheral {
+
+ @Override
+ public void updateEntity() {
+ int redstone = 0;
+ for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
+ redstone = Math.max(redstone, worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()));
+
+ if(redstone > 0) {
+ double x1 = xCoord + 0.5;
+ double y1 = yCoord + 0.5;
+ double z1 = zCoord + 0.5;
+
+ boolean blue = (getBlockMetadata() & 1) == 0;
+ int speedMod = blue ? 1 : -1;
+ double range = redstone / 2;
+
+ AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox(x1 - range, yCoord, z1 - range, x1 + range, y1 + range, z1 + range);
+ List entities = worldObj.selectEntitiesWithinAABB(Entity.class, boundingBox, getEntitySelector());
+
+ for(Entity entity : entities) {
+ double x2 = entity.posX;
+ double y2 = entity.posY;
+ double z2 = entity.posZ;
+
+ float distanceSqrd = blue ? (float) ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2)) : 1.1F;
+
+ if(distanceSqrd > 1) {
+ MiscHelper.setEntityMotionFromVector(entity, new Vector3(x1, y1, z1), speedMod * 0.25F);
+ ThaumicTinkerer.tcProxy.sparkle((float) x2, (float) y2, (float) z2, blue ? 2 : 4);
+ }
+ }
+ }
+ }
+
+ IEntitySelector getEntitySelector() {
+ return new IEntitySelector() {
+
+ @Override
+ public boolean isEntityApplicable(Entity entity) {
+ return entity instanceof EntityItem;
+ }
+
+ };
+ }
+
+ @Override
+ public String getType() {
+ return "tt_magnet";
+ }
+
+ @Override
+ public String[] getMethodNames() {
+ return new String[] { "isPulling", "setPulling", "getSignal" };
+ }
+
+ @Override
+ public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
+ switch(method) {
+ case 0 : return new Object[] { (getBlockMetadata() & 1) == 0 };
+ case 1 : {
+ boolean pull = (Boolean) arguments[0];
+ int meta = (getBlockMetadata() & 2) + (pull ? 0 : 1);
+
+ worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, meta, 1 | 2);
+ return null;
+ }
+ case 2 : {
+ int redstone = 0;
+ for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
+ redstone = Math.max(redstone, worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()));
+
+ return new Object[] { redstone };
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean canAttachToSide(int side) {
+ return true;
+ }
+
+ @Override
+ public void attach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+ @Override
+ public void detach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/TileMobMagnet.java b/src/main/java/vazkii/tinkerer/common/block/tile/TileMobMagnet.java
new file mode 100644
index 00000000..c506fb1f
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/TileMobMagnet.java
@@ -0,0 +1,225 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 17:14:05 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile;
+
+import net.minecraft.command.IEntitySelector;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityAgeable;
+import net.minecraft.entity.EntityList;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.network.INetworkManager;
+import net.minecraft.network.packet.Packet;
+import net.minecraft.network.packet.Packet132TileEntityData;
+import vazkii.tinkerer.common.item.ItemSoulMould;
+import vazkii.tinkerer.common.lib.LibBlockNames;
+import cpw.mods.fml.common.network.PacketDispatcher;
+import dan200.computer.api.IComputerAccess;
+import dan200.computer.api.ILuaContext;
+
+public class TileMobMagnet extends TileMagnet implements IInventory {
+
+ private static final String TAG_ADULT = "adultCheck";
+
+ ItemStack[] inventorySlots = new ItemStack[1];
+
+ public boolean adult = true;
+
+ @Override
+ IEntitySelector getEntitySelector() {
+ return new IEntitySelector() {
+
+ @Override
+ public boolean isEntityApplicable(Entity entity) {
+ if(!(entity instanceof EntityLivingBase) || entity == null || entity instanceof EntityPlayer)
+ return false;
+
+ boolean can = false;
+ if(entity instanceof EntityAgeable)
+ can = adult != ((EntityAgeable) entity).isChild();
+ else can = true;
+
+ if(can && inventorySlots[0] != null) {
+ String pattern = ItemSoulMould.getPatternName(inventorySlots[0]);
+ String name = EntityList.getEntityString(entity);
+ if(name != null && name.equals(pattern))
+ return true;
+ else return false;
+ }
+
+ return can;
+ }
+ };
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
+ super.readFromNBT(par1NBTTagCompound);
+
+ readCustomNBT(par1NBTTagCompound);
+
+ NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
+ inventorySlots = new ItemStack[getSizeInventory()];
+ for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
+ NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
+ byte var5 = var4.getByte("Slot");
+ if (var5 >= 0 && var5 < inventorySlots.length)
+ inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
+ }
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
+ super.writeToNBT(par1NBTTagCompound);
+
+ writeCustomNBT(par1NBTTagCompound);
+
+ NBTTagList var2 = new NBTTagList();
+ for (int var3 = 0; var3 < inventorySlots.length; ++var3) {
+ if (inventorySlots[var3] != null) {
+ NBTTagCompound var4 = new NBTTagCompound();
+ var4.setByte("Slot", (byte)var3);
+ inventorySlots[var3].writeToNBT(var4);
+ var2.appendTag(var4);
+ }
+ }
+ par1NBTTagCompound.setTag("Items", var2);
+ }
+
+ public void readCustomNBT(NBTTagCompound par1NBTTagCompound) {
+ adult = par1NBTTagCompound.getBoolean(TAG_ADULT);
+ }
+
+ public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) {
+ par1NBTTagCompound.setBoolean(TAG_ADULT, adult);
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return inventorySlots.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int i) {
+ return inventorySlots[i];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int i, int j) {
+ if (inventorySlots[i] != null) {
+ ItemStack stackAt;
+
+ if (inventorySlots[i].stackSize <= j) {
+ stackAt = inventorySlots[i];
+ inventorySlots[i] = null;
+ return stackAt;
+ } else {
+ stackAt = inventorySlots[i].splitStack(j);
+
+ if (inventorySlots[i].stackSize == 0)
+ inventorySlots[i] = null;
+
+ return stackAt;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ return getStackInSlot(i);
+ }
+
+ @Override
+ public void setInventorySlotContents(int i, ItemStack itemstack) {
+ inventorySlots[i] = itemstack;
+ }
+
+ @Override
+ public String getInvName() {
+ return LibBlockNames.MAGNET;
+ }
+
+ @Override
+ public boolean isInvNameLocalized() {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 1;
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer) {
+ return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this ? false : entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64;
+ }
+
+ @Override
+ public void openChest() {
+ // NO-OP
+ }
+
+ @Override
+ public void closeChest() {
+ // NO-OP
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int i, ItemStack itemstack) {
+ return true;
+ }
+
+ @Override
+ public String[] getMethodNames() {
+ return new String[] { "isPulling", "setPulling", "getSignal", "getAdultSearch", "setAdultSearch" };
+ }
+
+ @Override
+ public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
+ switch(method) {
+ case 3 : return new Object[] { adult };
+ case 4 : {
+ boolean adult = (Boolean) arguments[0];
+
+ this.adult = adult;
+ PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
+ return null;
+
+ }
+ }
+ return super.callMethod(computer, context, method, arguments);
+ }
+
+
+ @Override
+ public Packet getDescriptionPacket() {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ writeCustomNBT(nbttagcompound);
+ return new Packet132TileEntityData(xCoord, yCoord, zCoord, -999, nbttagcompound);
+ }
+
+ @Override
+ public void onDataPacket(INetworkManager manager, Packet132TileEntityData packet) {
+ super.onDataPacket(manager, packet);
+ readCustomNBT(packet.data);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/TileRepairer.java b/src/main/java/vazkii/tinkerer/common/block/tile/TileRepairer.java
new file mode 100644
index 00000000..08434959
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/TileRepairer.java
@@ -0,0 +1,343 @@
+/**
+x * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Nov 30, 2013, 5:39:09 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.network.INetworkManager;
+import net.minecraft.network.packet.Packet;
+import net.minecraft.network.packet.Packet132TileEntityData;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.ForgeDirection;
+import thaumcraft.api.ThaumcraftApiHelper;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.api.aspects.IAspectContainer;
+import thaumcraft.api.aspects.IEssentiaTransport;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.lib.LibBlockNames;
+import cpw.mods.fml.common.network.PacketDispatcher;
+
+public class TileRepairer extends TileEntity implements ISidedInventory, IAspectContainer, IEssentiaTransport {
+
+ int dmgLastTick = 0;
+ public int ticksExisted = 0;
+ public boolean tookLastTick = true;
+ private static final Map repairValues = new HashMap();
+
+ static {
+ repairValues.put(Aspect.TOOL, 8);
+ repairValues.put(Aspect.CRAFT, 5);
+ repairValues.put(Aspect.ORDER, 3);
+ }
+
+ ItemStack[] inventorySlots = new ItemStack[1];
+
+ @Override
+ public void updateEntity() {
+ if(++ticksExisted % 10 == 0) {
+ if(inventorySlots[0] != null && inventorySlots[0].getItemDamage() > 0) {
+ int essentia = drawEssentia();
+ int dmg = inventorySlots[0].getItemDamage();
+ inventorySlots[0].setItemDamage(Math.max(0, dmg - essentia));
+ onInventoryChanged();
+
+ if(dmgLastTick != 0 && dmgLastTick != dmg) {
+ ThaumicTinkerer.tcProxy.sparkle((float) (xCoord + 0.25 + Math.random() / 2F), (float) (yCoord + 1 + Math.random() / 2F), (float) (zCoord + 0.25 + Math.random() / 2F), 0);
+ tookLastTick = true;
+ } else tookLastTick = false;
+ } else tookLastTick = false;
+
+ dmgLastTick = inventorySlots[0] == null ? 0 : inventorySlots[0].getItemDamage();
+ }
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
+ super.readFromNBT(par1NBTTagCompound);
+
+ readCustomNBT(par1NBTTagCompound);
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
+ super.writeToNBT(par1NBTTagCompound);
+
+ writeCustomNBT(par1NBTTagCompound);
+ }
+
+ public void readCustomNBT(NBTTagCompound par1NBTTagCompound) {
+ NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
+ inventorySlots = new ItemStack[getSizeInventory()];
+ for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
+ NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
+ byte var5 = var4.getByte("Slot");
+ if (var5 >= 0 && var5 < inventorySlots.length)
+ inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
+ }
+ }
+
+ public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) {
+ NBTTagList var2 = new NBTTagList();
+ for (int var3 = 0; var3 < inventorySlots.length; ++var3) {
+ if (inventorySlots[var3] != null) {
+ NBTTagCompound var4 = new NBTTagCompound();
+ var4.setByte("Slot", (byte)var3);
+ inventorySlots[var3].writeToNBT(var4);
+ var2.appendTag(var4);
+ }
+ }
+ par1NBTTagCompound.setTag("Items", var2);
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return inventorySlots.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int i) {
+ return inventorySlots[i];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int i, int j) {
+ if (inventorySlots[i] != null) {
+ ItemStack stackAt;
+
+ if (inventorySlots[i].stackSize <= j) {
+ stackAt = inventorySlots[i];
+ inventorySlots[i] = null;
+ return stackAt;
+ } else {
+ stackAt = inventorySlots[i].splitStack(j);
+
+ if (inventorySlots[i].stackSize == 0)
+ inventorySlots[i] = null;
+
+ return stackAt;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ return getStackInSlot(i);
+ }
+
+ @Override
+ public void setInventorySlotContents(int i, ItemStack itemstack) {
+ inventorySlots[i] = itemstack;
+ }
+
+ @Override
+ public String getInvName() {
+ return LibBlockNames.FUNNEL;
+ }
+
+ @Override
+ public boolean isInvNameLocalized() {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 1;
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer) {
+ return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this ? false : entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64;
+ }
+
+ @Override
+ public void openChest() {
+ // NO-OP
+ }
+
+ @Override
+ public void closeChest() {
+ // NO-OP
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int i, ItemStack itemstack) {
+ return true;
+ }
+
+ @Override
+ public Packet getDescriptionPacket() {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ writeCustomNBT(nbttagcompound);
+ return new Packet132TileEntityData(xCoord, yCoord, zCoord, -999, nbttagcompound);
+ }
+
+ @Override
+ public void onDataPacket(INetworkManager manager, Packet132TileEntityData packet) {
+ super.onDataPacket(manager, packet);
+ readCustomNBT(packet.data);
+ }
+
+ @Override
+ public void onInventoryChanged() {
+ PacketDispatcher.sendPacketToAllInDimension(getDescriptionPacket(), worldObj.provider.dimensionId);
+ }
+
+ @Override
+ public int[] getAccessibleSlotsFromSide(int var1) {
+ return new int[] { 0 };
+ }
+
+ @Override
+ public boolean canInsertItem(int i, ItemStack itemstack, int j) {
+ return itemstack != null && itemstack.getItem().isRepairable();
+ }
+
+ @Override
+ public boolean canExtractItem(int i, ItemStack itemstack, int j) {
+ return true;
+ }
+
+ int drawEssentia() {
+ ForgeDirection orientation = getOrientation();
+ TileEntity tile = ThaumcraftApiHelper.getConnectableTile(worldObj, xCoord, yCoord, zCoord, orientation);
+
+ if (tile != null) {
+ IEssentiaTransport ic = (IEssentiaTransport) tile;
+
+ if (!ic.canOutputTo(orientation.getOpposite()))
+ return 0;
+
+ for(Aspect aspect : repairValues.keySet())
+ if (ic.getSuction(orientation.getOpposite()).getAmount(aspect) < getSuction(orientation).getAmount(aspect) && ic.takeVis(aspect, 1) == 1)
+ return repairValues.get(aspect);
+
+ return 0;
+ }
+
+ return 0;
+ }
+
+ ForgeDirection getOrientation() {
+ return ForgeDirection.getOrientation(getBlockMetadata());
+ }
+
+ @Override
+ public AspectList getAspects() {
+ ItemStack stack = inventorySlots[0];
+ if(stack == null)
+ return null;
+ else return new AspectList().add(Aspect.ENTROPY, stack.getItemDamage());
+ }
+
+ @Override
+ public void setAspects(AspectList paramAspectList) { }
+
+ @Override
+ public boolean doesContainerAccept(Aspect paramAspect) {
+
+ return false;
+ }
+
+ @Override
+ public int addToContainer(Aspect paramAspect, int paramInt) {
+ return 0;
+ }
+
+ @Override
+ public boolean takeFromContainer(Aspect paramAspect, int paramInt) {
+ return false;
+ }
+
+ @Override
+ public boolean takeFromContainer(AspectList paramAspectList) {
+ return false;
+ }
+
+ @Override
+ public boolean doesContainerContainAmount(Aspect paramAspect, int paramInt) {
+ return false;
+ }
+
+ @Override
+ public boolean doesContainerContain(AspectList paramAspectList) {
+ return false;
+ }
+
+ @Override
+ public int containerContains(Aspect paramAspect) {
+ return 0;
+ }
+
+ @Override
+ public boolean isConnectable(ForgeDirection paramForgeDirection) {
+ return paramForgeDirection == getOrientation();
+ }
+
+ @Override
+ public boolean canInputFrom(ForgeDirection paramForgeDirection) {
+ return false;
+ }
+
+ @Override
+ public boolean canOutputTo(ForgeDirection paramForgeDirection) {
+ return isConnectable(paramForgeDirection);
+ }
+
+ @Override
+ public void setSuction(AspectList paramAspectList) {
+ }
+
+ @Override
+ public void setSuction(Aspect paramAspect, int paramInt) { }
+
+ @Override
+ public AspectList getSuction(ForgeDirection paramForgeDirection) {
+ AspectList list = new AspectList();
+ for(Aspect aspect : repairValues.keySet())
+ list.add(aspect, 256 + repairValues.get(aspect));
+
+ return list;
+ }
+
+ @Override
+ public int takeVis(Aspect paramAspect, int paramInt) {
+ return 0;
+ }
+
+ @Override
+ public AspectList getEssentia(ForgeDirection paramForgeDirection) {
+ return null;
+ }
+
+ @Override
+ public int getMinimumSuction() {
+ return 0;
+ }
+
+ @Override
+ public boolean renderExtendedTube() {
+ return false;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/container/ContainerAnimationTablet.java b/src/main/java/vazkii/tinkerer/common/block/tile/container/ContainerAnimationTablet.java
new file mode 100644
index 00000000..269a1cbd
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/container/ContainerAnimationTablet.java
@@ -0,0 +1,71 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 16:26:46 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.container;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import vazkii.tinkerer.common.block.tile.tablet.TileAnimationTablet;
+
+public class ContainerAnimationTablet extends ContainerPlayerInv {
+
+ public TileAnimationTablet tablet;
+
+ public ContainerAnimationTablet(TileAnimationTablet tablet, InventoryPlayer playerInv) {
+ super(playerInv);
+
+ this.tablet = tablet;
+
+ addSlotToContainer(new Slot(tablet, 0, 80, 15));
+
+ initPlayerInv();
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer entityplayer) {
+ return tablet.isUseableByPlayer(entityplayer);
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
+ ItemStack var3 = null;
+ Slot var4 = (Slot)inventorySlots.get(par2);
+
+ if (var4 != null && var4.getHasStack()) {
+ ItemStack var5 = var4.getStack();
+
+ var3 = var5.copy();
+
+ if (par2 < 1) {
+ if(!mergeItemStack(var5, 1, 37, false))
+ return null;
+ } else if(!mergeItemStack(var5, 0, 1, false))
+ return null;
+
+ if (var5.stackSize == 0)
+ var4.putStack((ItemStack)null);
+ else
+ var4.onSlotChanged();
+
+ if (var5.stackSize == var3.stackSize)
+ return null;
+
+ var4.onPickupFromSlot(par1EntityPlayer, var5);
+ }
+
+ return var3;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/container/ContainerAspectAnalyzer.java b/src/main/java/vazkii/tinkerer/common/block/tile/container/ContainerAspectAnalyzer.java
new file mode 100644
index 00000000..7f7d1a30
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/container/ContainerAspectAnalyzer.java
@@ -0,0 +1,76 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 11, 2013, 10:42:23 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.container;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import thaumcraft.common.container.SlotLimitedHasAspects;
+import vazkii.tinkerer.common.block.tile.TileAspectAnalyzer;
+
+public class ContainerAspectAnalyzer extends ContainerPlayerInv {
+
+ public TileAspectAnalyzer analyzer;
+ Slot slot;
+
+ public ContainerAspectAnalyzer(TileAspectAnalyzer analyzer, InventoryPlayer playerInv) {
+ super(playerInv);
+
+ this.analyzer = analyzer;
+
+ addSlotToContainer(slot = new SlotLimitedHasAspects(analyzer, 0, 20, 30));
+
+ initPlayerInv();
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer entityplayer) {
+ return analyzer.isUseableByPlayer(entityplayer);
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
+ ItemStack var3 = null;
+ Slot var4 = (Slot) inventorySlots.get(par2);
+
+ if (var4 != null && var4.getHasStack()) {
+ ItemStack var5 = var4.getStack();
+
+ if(par2 == 0 || var5 != null && slot.isItemValid(var5)) {
+ var3 = var5.copy();
+
+ if (par2 < 1) {
+ if(!mergeItemStack(var5, 1, 37, false))
+ return null;
+ } else if(!mergeItemStack(var5, 0, 1, false))
+ return null;
+
+ if (var5.stackSize == 0)
+ var4.putStack((ItemStack)null);
+ else
+ var4.onSlotChanged();
+
+ if (var5.stackSize == var3.stackSize)
+ return null;
+
+ var4.onPickupFromSlot(par1EntityPlayer, var5);
+ }
+ }
+
+ return var3;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/container/ContainerEnchanter.java b/src/main/java/vazkii/tinkerer/common/block/tile/container/ContainerEnchanter.java
new file mode 100644
index 00000000..5094f4db
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/container/ContainerEnchanter.java
@@ -0,0 +1,80 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [14 Sep 2013, 18:10:21 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.container;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import vazkii.tinkerer.common.block.tile.TileEnchanter;
+import vazkii.tinkerer.common.block.tile.container.slot.SlotTool;
+import vazkii.tinkerer.common.block.tile.container.slot.SlotWand;
+
+public class ContainerEnchanter extends ContainerPlayerInv {
+
+ TileEnchanter enchanter;
+
+ public ContainerEnchanter(TileEnchanter enchanter, InventoryPlayer playerInv) {
+ super(playerInv);
+ this.enchanter = enchanter;
+
+ addSlotToContainer(new SlotTool(enchanter, 0, 6, 6));
+ addSlotToContainer(new SlotWand(enchanter, 1, 6, 31));
+
+ initPlayerInv();
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
+ ItemStack var3 = null;
+ Slot var4 = (Slot)inventorySlots.get(par2);
+
+ if (var4 != null && var4.getHasStack()) {
+ ItemStack var5 = var4.getStack();
+
+ if(var5 != null && var5.itemID == Item.book.itemID)
+ return null;
+
+ boolean wand = ((Slot) inventorySlots.get(1)).isItemValid(var5);
+
+ var3 = var5.copy();
+
+ if (par2 < 2) {
+ if(!mergeItemStack(var5, 2, 38, false))
+ return null;
+ } else if(wand ? !mergeItemStack(var5, 1, 2, false) : var5.getItem().isItemTool(var5) && !mergeItemStack(var5, 0, 1, false))
+ return null;
+
+ if (var5.stackSize == 0)
+ var4.putStack((ItemStack)null);
+ else
+ var4.onSlotChanged();
+
+ if (var5.stackSize == var3.stackSize)
+ return null;
+
+ var4.onPickupFromSlot(par1EntityPlayer, var5);
+ }
+
+ return var3;
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer entityplayer) {
+ return enchanter.isUseableByPlayer(entityplayer);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/container/ContainerMobMagnet.java b/src/main/java/vazkii/tinkerer/common/block/tile/container/ContainerMobMagnet.java
new file mode 100644
index 00000000..90d852fd
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/container/ContainerMobMagnet.java
@@ -0,0 +1,75 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 18:42:28 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.container;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import vazkii.tinkerer.common.block.tile.TileMobMagnet;
+import vazkii.tinkerer.common.block.tile.container.slot.SlotMobMagnet;
+import vazkii.tinkerer.common.item.ItemSoulMould;
+
+public class ContainerMobMagnet extends ContainerPlayerInv {
+
+ public TileMobMagnet mobMagnet;
+
+ public ContainerMobMagnet(TileMobMagnet mobMagnet, InventoryPlayer playerInv) {
+ super(playerInv);
+
+ this.mobMagnet = mobMagnet;
+
+ addSlotToContainer(new SlotMobMagnet(mobMagnet, 0, 53, 37));
+
+ initPlayerInv();
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer entityplayer) {
+ return mobMagnet.isUseableByPlayer(entityplayer);
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
+ ItemStack var3 = null;
+ Slot var4 = (Slot)inventorySlots.get(par2);
+
+ if (var4 != null && var4.getHasStack()) {
+ ItemStack var5 = var4.getStack();
+
+ if(var5.getItem() instanceof ItemSoulMould) {
+ var3 = var5.copy();
+
+ if (par2 < 1) {
+ if(!mergeItemStack(var5, 1, 37, false))
+ return null;
+ } else if(!mergeItemStack(var5, 0, 1, false))
+ return null;
+
+ if (var5.stackSize == 0)
+ var4.putStack((ItemStack)null);
+ else
+ var4.onSlotChanged();
+
+ if (var5.stackSize == var3.stackSize)
+ return null;
+
+ var4.onPickupFromSlot(par1EntityPlayer, var5);
+ }
+ }
+
+ return var3;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/container/ContainerPlayerInv.java b/src/main/java/vazkii/tinkerer/common/block/tile/container/ContainerPlayerInv.java
new file mode 100644
index 00000000..cf3e51c3
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/container/ContainerPlayerInv.java
@@ -0,0 +1,48 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 16:27:10 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.container;
+
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.Slot;
+
+public abstract class ContainerPlayerInv extends Container {
+
+ InventoryPlayer playerInv;
+
+ public ContainerPlayerInv(InventoryPlayer playerInv) {
+ this.playerInv = playerInv;
+ }
+
+ public void initPlayerInv() {
+ int ys = getInvYStart();
+ int xs = getInvXStart();
+
+ for (int x = 0; x < 3; ++x)
+ for (int y = 0; y < 9; ++y)
+ addSlotToContainer(new Slot(playerInv, y + x * 9 + 9, xs + y * 18, ys + x * 18));
+
+ for (int x = 0; x < 9; ++x)
+ addSlotToContainer(new Slot(playerInv, x, xs + x * 18, ys + 58));
+ }
+
+ public int getInvYStart() {
+ return 84;
+ }
+
+ public int getInvXStart() {
+ return 8;
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/container/kami/ContainerIchorPouch.java b/src/main/java/vazkii/tinkerer/common/block/tile/container/kami/ContainerIchorPouch.java
new file mode 100644
index 00000000..afb90c8f
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/container/kami/ContainerIchorPouch.java
@@ -0,0 +1,135 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 10:37:08 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.container.kami;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import thaumcraft.common.container.InventoryFocusPouch;
+import thaumcraft.common.items.wands.ItemFocusPouch;
+import vazkii.tinkerer.common.block.tile.container.ContainerPlayerInv;
+import vazkii.tinkerer.common.block.tile.container.slot.kami.SlotNoPouches;
+
+public class ContainerIchorPouch extends ContainerPlayerInv {
+
+ private static class InventoryIchorPouch extends InventoryFocusPouch {
+
+ public InventoryIchorPouch(Container par1Container) {
+ super(par1Container);
+ stackList = new ItemStack[13 * 9];
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int i, ItemStack itemstack) {
+ return itemstack != null && !(itemstack.getItem() instanceof ItemFocusPouch);
+ }
+
+ }
+
+ public IInventory inv = new InventoryIchorPouch(this);
+ EntityPlayer player;
+ ItemStack pouch;
+ int blockSlot;
+
+ public ContainerIchorPouch(EntityPlayer player) {
+ super(player.inventory);
+
+ this.player = player;
+ pouch = player.getCurrentEquippedItem();
+ blockSlot = player.inventory.currentItem + 27 + 13 * 9;
+
+ for(int y = 0; y < 9; y++)
+ for(int x = 0; x < 13; x++)
+ addSlotToContainer(new SlotNoPouches(inv, y * 13 + x, 12 + x * 18, 8 + y * 18));
+ initPlayerInv();
+
+ if (!player.worldObj.isRemote)
+ try{
+ ((InventoryIchorPouch) inv).stackList = ((ItemFocusPouch) pouch.getItem()).getInventory(pouch);
+ } catch (Exception e) { }
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slot) {
+ if (slot == blockSlot)
+ return null;
+
+ ItemStack stack = null;
+ Slot slotObject = (Slot) inventorySlots.get(slot);
+ if (slotObject != null && slotObject.getHasStack()) {
+ ItemStack stackInSlot = slotObject.getStack();
+ stack = stackInSlot.copy();
+ if (slot < 13 * 9) {
+ if (!inv.isItemValidForSlot(slot, stackInSlot) || !mergeItemStack(stackInSlot, 13 * 9, inventorySlots.size(), true))
+ return null;
+ }
+ else if (!inv.isItemValidForSlot(slot, stackInSlot) || !mergeItemStack(stackInSlot, 0, 13 * 9, false)) {
+ return null;
+ }
+ if (stackInSlot.stackSize == 0)
+ slotObject.putStack(null);
+ else slotObject.onSlotChanged();
+ }
+
+ return stack;
+ }
+
+
+ @Override
+ public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer)
+ {
+ if (par1 == blockSlot) {
+ return null;
+ }
+ return super.slotClick(par1, par2, par3, par4EntityPlayer);
+ }
+
+ @Override
+ public void onContainerClosed(EntityPlayer par1EntityPlayer)
+ {
+ super.onContainerClosed(par1EntityPlayer);
+ if (!player.worldObj.isRemote) {
+ ((ItemFocusPouch) pouch.getItem()).setInventory(pouch, ((InventoryIchorPouch) inv).stackList);
+ if (player == null)
+ return;
+ if (player.getHeldItem() != null && player.getHeldItem().isItemEqual(pouch))
+ player.setCurrentItemOrArmor(0, pouch);
+
+ player.inventory.onInventoryChanged();
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer entityplayer) {
+ return true;
+ }
+
+ @Override
+ public int getInvXStart() {
+ return 48;
+ }
+
+ @Override
+ public int getInvYStart() {
+ return 177;
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/container/kami/ContainerWarpGate.java b/src/main/java/vazkii/tinkerer/common/block/tile/container/kami/ContainerWarpGate.java
new file mode 100644
index 00000000..1fbc9c0f
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/container/kami/ContainerWarpGate.java
@@ -0,0 +1,78 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Jan 10, 2014, 5:45:28 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.container.kami;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import vazkii.tinkerer.common.block.tile.container.ContainerPlayerInv;
+import vazkii.tinkerer.common.block.tile.container.slot.kami.SlotSkyPearl;
+import vazkii.tinkerer.common.block.tile.kami.TileWarpGate;
+import vazkii.tinkerer.common.item.ModItems;
+
+public class ContainerWarpGate extends ContainerPlayerInv {
+
+ TileWarpGate gate;
+
+ public ContainerWarpGate(TileWarpGate gate, InventoryPlayer playerInv) {
+ super(playerInv);
+ this.gate = gate;
+
+ for(int y = 0; y < 2; y++)
+ for(int x = 0; x < 5; x++)
+ addSlotToContainer(new SlotSkyPearl(gate, y * 5 + x, 30 + x * 25, 27 + y * 25));
+
+ initPlayerInv();
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer entityplayer) {
+ return gate.isUseableByPlayer(entityplayer);
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
+ ItemStack var3 = null;
+ Slot var4 = (Slot) inventorySlots.get(par2);
+
+ if (var4 != null && var4.getHasStack()) {
+ ItemStack var5 = var4.getStack();
+
+ if(par2 < 10 || var5 != null) {
+ var3 = var5.copy();
+
+ if (par2 < 10) {
+ if(!mergeItemStack(var5, 10, 36, false))
+ return null;
+ } else if(var3.itemID == ModItems.skyPearl.itemID && !mergeItemStack(var5, 0, 10, false))
+ return null;
+
+ if (var5.stackSize == 0)
+ var4.putStack((ItemStack)null);
+ else
+ var4.onSlotChanged();
+
+ if (var5.stackSize == var3.stackSize)
+ return null;
+
+ var4.onPickupFromSlot(par1EntityPlayer, var5);
+ }
+ }
+
+ return var3;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/SlotMobMagnet.java b/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/SlotMobMagnet.java
new file mode 100644
index 00000000..111dce55
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/SlotMobMagnet.java
@@ -0,0 +1,37 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 18:43:26 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.container.slot;
+
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import vazkii.tinkerer.common.block.tile.TileMobMagnet;
+import vazkii.tinkerer.common.item.ItemSoulMould;
+
+public class SlotMobMagnet extends Slot {
+
+ public SlotMobMagnet(TileMobMagnet mobMagnet, int par2, int par3, int par4) {
+ super(mobMagnet, par2, par3, par4);
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack par1ItemStack) {
+ return par1ItemStack.getItem() instanceof ItemSoulMould;
+ }
+
+ @Override
+ public int getSlotStackLimit() {
+ return 1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/SlotResearchTableOverride.java b/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/SlotResearchTableOverride.java
new file mode 100644
index 00000000..2dc59c0f
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/SlotResearchTableOverride.java
@@ -0,0 +1,34 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Nov 30, 2013, 11:03:09 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.container.slot;
+
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import thaumcraft.common.items.ItemInkwell;
+import vazkii.tinkerer.common.item.ItemInfusedInkwell;
+
+public class SlotResearchTableOverride extends Slot {
+
+ public SlotResearchTableOverride(IInventory par1iInventory, int par2, int par3, int par4) {
+ super(par1iInventory, par2, par3, par4);
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack par1ItemStack) {
+ return par1ItemStack.getItem() instanceof ItemInkwell || par1ItemStack.getItem() instanceof ItemInfusedInkwell;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/SlotTool.java b/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/SlotTool.java
new file mode 100644
index 00000000..541f36b6
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/SlotTool.java
@@ -0,0 +1,47 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [14 Sep 2013, 18:35:37 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.container.slot;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import vazkii.tinkerer.common.block.tile.TileEnchanter;
+
+public class SlotTool extends Slot {
+
+ TileEnchanter enchanter;
+
+ public SlotTool(TileEnchanter enchanter, int par2, int par3, int par4) {
+ super(enchanter, par2, par3, par4);
+ this.enchanter = enchanter;
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack par1ItemStack) {
+ return !enchanter.working && par1ItemStack.itemID != Item.book.itemID && par1ItemStack.getItem().isItemTool(par1ItemStack);
+ }
+
+ @Override
+ public int getSlotStackLimit() {
+ return 1;
+ }
+
+ @Override
+ public boolean canTakeStack(EntityPlayer par1EntityPlayer) {
+ return !enchanter.working;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/SlotWand.java b/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/SlotWand.java
new file mode 100644
index 00000000..efc1292c
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/SlotWand.java
@@ -0,0 +1,42 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [14 Sep 2013, 18:35:49 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.container.slot;
+
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import thaumcraft.common.items.wands.ItemWandCasting;
+
+public class SlotWand extends Slot {
+
+ public SlotWand(IInventory par1iInventory, int par2, int par3, int par4) {
+ super(par1iInventory, par2, par3, par4);
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack par1ItemStack) {
+ if(!(par1ItemStack.getItem() instanceof ItemWandCasting))
+ return false;
+
+ ItemWandCasting wand = (ItemWandCasting) par1ItemStack.getItem();
+ return wand.getCap(par1ItemStack).getBaseCostModifier() <= 1F;
+ }
+
+ @Override
+ public int getSlotStackLimit() {
+ return 1;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/kami/SlotNoPouches.java b/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/kami/SlotNoPouches.java
new file mode 100644
index 00000000..0368ad92
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/kami/SlotNoPouches.java
@@ -0,0 +1,34 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 11:12:29 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.container.slot.kami;
+
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import thaumcraft.common.items.wands.ItemFocusPouch;
+
+public class SlotNoPouches extends Slot {
+
+ public SlotNoPouches(IInventory par1iInventory, int par2, int par3, int par4) {
+ super(par1iInventory, par2, par3, par4);
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack par1ItemStack) {
+ Item item = par1ItemStack.getItem();
+ return !(item instanceof ItemFocusPouch);
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/kami/SlotSkyPearl.java b/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/kami/SlotSkyPearl.java
new file mode 100644
index 00000000..9ab50ac5
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/container/slot/kami/SlotSkyPearl.java
@@ -0,0 +1,38 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Jan 10, 2014, 5:51:20 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.container.slot.kami;
+
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import vazkii.tinkerer.common.item.ModItems;
+
+public class SlotSkyPearl extends Slot {
+
+ public SlotSkyPearl(IInventory par1iInventory, int par2, int par3, int par4) {
+ super(par1iInventory, par2, par3, par4);
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack par1ItemStack) {
+ return par1ItemStack.itemID == ModItems.skyPearl.itemID;
+ }
+
+ @Override
+ public int getSlotStackLimit() {
+ return 1;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/kami/TileWarpGate.java b/src/main/java/vazkii/tinkerer/common/block/tile/kami/TileWarpGate.java
new file mode 100644
index 00000000..1f22f98f
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/kami/TileWarpGate.java
@@ -0,0 +1,237 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Jan 10, 2014, 3:56:13 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.kami;
+
+import java.util.List;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.network.INetworkManager;
+import net.minecraft.network.packet.Packet;
+import net.minecraft.network.packet.Packet132TileEntityData;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.ChunkCoordinates;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.item.ModItems;
+import vazkii.tinkerer.common.item.kami.ItemSkyPearl;
+import vazkii.tinkerer.common.lib.LibBlockNames;
+import vazkii.tinkerer.common.lib.LibGuiIDs;
+
+public class TileWarpGate extends TileEntity implements IInventory {
+
+ private static final String TAG_LOCKED = "locked";
+
+ public boolean locked = false;
+ boolean teleportedThisTick = false;
+ ItemStack[] inventorySlots = new ItemStack[10];
+
+ @Override
+ public void updateEntity() {
+ List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 1.5, zCoord + 1));
+
+ EntityPlayer clientPlayer = ThaumicTinkerer.proxy.getClientPlayer();
+ for(EntityPlayer player : players)
+ if(player != null && player == clientPlayer && player.isSneaking()) {
+ player.openGui(ThaumicTinkerer.instance, LibGuiIDs.GUI_ID_WARP_GATE_DESTINATIONS, worldObj, xCoord, yCoord, zCoord);
+ break;
+ }
+
+ teleportedThisTick = false;
+ }
+
+ public void teleportPlayer(EntityPlayer player, int index) {
+ if(teleportedThisTick)
+ return;
+
+ ItemStack stack = index < getSizeInventory() ? getStackInSlot(index) : null;
+ if(stack != null && ItemSkyPearl.isAttuned(stack)) {
+ int x = ItemSkyPearl.getX(stack);
+ int y = ItemSkyPearl.getY(stack);
+ int z = ItemSkyPearl.getZ(stack);
+
+ if(teleportPlayer(player, new ChunkCoordinates(x, y, z)))
+ teleportedThisTick = true;
+ }
+ }
+
+ public static boolean teleportPlayer(EntityPlayer player, ChunkCoordinates coords) {
+ int x = coords.posX;
+ int y = coords.posY;
+ int z = coords.posZ;
+
+ TileEntity tile = player.worldObj.getBlockTileEntity(x, y, z);
+ if(tile != null && tile instanceof TileWarpGate) {
+ TileWarpGate destGate = (TileWarpGate) tile;
+ if(!destGate.locked) {
+ player.worldObj.playSoundAtEntity(player, "thaumcraft:wand", 1F, 1F);
+
+ for(int i = 0; i < 20; i++)
+ ThaumicTinkerer.tcProxy.sparkle((float)player.posX + player.worldObj.rand.nextFloat() - 0.5F, (float)player.posY + player.worldObj.rand.nextFloat(), (float)player.posZ + player.worldObj.rand.nextFloat() - 0.5F, 6);
+
+ player.mountEntity(null);
+ if(player instanceof EntityPlayerMP)
+ ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(x + 0.5, y + 1.6, z + 0.5, player.rotationYaw, player.rotationPitch);
+
+ for(int i = 0; i < 20; i++)
+ ThaumicTinkerer.tcProxy.sparkle((float)player.posX + player.worldObj.rand.nextFloat() - 0.5F, (float)player.posY + player.worldObj.rand.nextFloat(), (float)player.posZ + player.worldObj.rand.nextFloat() - 0.5F, 6);
+
+ player.worldObj.playSoundAtEntity(player, "thaumcraft:wand", 1F, 0.1F);
+ return true;
+ } else if(!player.worldObj.isRemote)
+ player.addChatMessage("ttmisc.noTeleport");
+ } else if(!player.worldObj.isRemote)
+ player.addChatMessage("ttmisc.noDest");
+
+ return false;
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
+ super.readFromNBT(par1NBTTagCompound);
+
+ readCustomNBT(par1NBTTagCompound);
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
+ super.writeToNBT(par1NBTTagCompound);
+
+ writeCustomNBT(par1NBTTagCompound);
+ }
+
+ public void readCustomNBT(NBTTagCompound par1NBTTagCompound) {
+ locked = par1NBTTagCompound.getBoolean(TAG_LOCKED);
+
+ NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
+ inventorySlots = new ItemStack[getSizeInventory()];
+ for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
+ NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
+ byte var5 = var4.getByte("Slot");
+ if (var5 >= 0 && var5 < inventorySlots.length)
+ inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
+ }
+ }
+
+ public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) {
+ par1NBTTagCompound.setBoolean(TAG_LOCKED, locked);
+
+ NBTTagList var2 = new NBTTagList();
+ for (int var3 = 0; var3 < inventorySlots.length; ++var3) {
+ if (inventorySlots[var3] != null) {
+ NBTTagCompound var4 = new NBTTagCompound();
+ var4.setByte("Slot", (byte)var3);
+ inventorySlots[var3].writeToNBT(var4);
+ var2.appendTag(var4);
+ }
+ }
+ par1NBTTagCompound.setTag("Items", var2);
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return inventorySlots.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int i) {
+ return inventorySlots[i];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int i, int j) {
+ if (inventorySlots[i] != null) {
+ ItemStack stackAt;
+
+ if (inventorySlots[i].stackSize <= j) {
+ stackAt = inventorySlots[i];
+ inventorySlots[i] = null;
+ return stackAt;
+ } else {
+ stackAt = inventorySlots[i].splitStack(j);
+
+ if (inventorySlots[i].stackSize == 0)
+ inventorySlots[i] = null;
+
+ return stackAt;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ return getStackInSlot(i);
+ }
+
+ @Override
+ public void setInventorySlotContents(int i, ItemStack itemstack) {
+ inventorySlots[i] = itemstack;
+ }
+
+ @Override
+ public String getInvName() {
+ return LibBlockNames.WARP_GATE;
+ }
+
+ @Override
+ public boolean isInvNameLocalized() {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 1;
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer) {
+ return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this ? false : entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64;
+ }
+
+ @Override
+ public void openChest() {
+ // NO-OP
+ }
+
+ @Override
+ public void closeChest() {
+ // NO-OP
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int i, ItemStack itemstack) {
+ return itemstack.itemID == ModItems.skyPearl.itemID;
+ }
+
+ @Override
+ public Packet getDescriptionPacket() {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ writeCustomNBT(nbttagcompound);
+ return new Packet132TileEntityData(xCoord, yCoord, zCoord, -999, nbttagcompound);
+ }
+
+ @Override
+ public void onDataPacket(INetworkManager manager, Packet132TileEntityData packet) {
+ super.onDataPacket(manager, packet);
+ readCustomNBT(packet.data);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralArcaneBore.java b/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralArcaneBore.java
new file mode 100644
index 00000000..1b816aac
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralArcaneBore.java
@@ -0,0 +1,95 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 11, 2013, 10:03:09 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.peripheral;
+
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import thaumcraft.common.items.equipment.ItemElementalPickaxe;
+import thaumcraft.common.tiles.TileArcaneBore;
+import dan200.computer.api.IComputerAccess;
+import dan200.computer.api.IHostedPeripheral;
+import dan200.computer.api.ILuaContext;
+
+public class PeripheralArcaneBore implements IHostedPeripheral {
+
+ TileArcaneBore bore;
+
+ public PeripheralArcaneBore(TileArcaneBore bore) {
+ this.bore = bore;
+ }
+
+ @Override
+ public String getType() {
+ return "tt_arcanebore";
+ }
+
+ @Override
+ public String[] getMethodNames() {
+ return new String[] { "hasPickaxe", "hasFocus", "isPickaxeBroken", "isWorking", "getRadius", "getSpeed", "hasNativeClusters", "getFortune", "hasSilkTouch" };
+ }
+
+ @Override
+ public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
+ ItemStack pickaxe = bore.getStackInSlot(1);
+ boolean nearBroken = pickaxe != null && pickaxe.getItemDamage() + 1 == pickaxe.getMaxDamage();
+
+ switch(method) {
+ case 0 : return new Object[] { bore.hasPickaxe };
+ case 1 : return new Object[] { bore.hasFocus };
+ case 2 : return new Object[] { nearBroken };
+ case 3 : return new Object[] { bore.gettingPower() && bore.hasFocus && bore.hasPickaxe && pickaxe.isItemStackDamageable() && !nearBroken };
+ case 4 : return new Object[] { 1 + (bore.area + bore.maxRadius) * 2 };
+ case 5 : return new Object[] { bore.speed };
+ case 6 : return new Object[] { pickaxe != null && pickaxe.getItem() instanceof ItemElementalPickaxe };
+ case 7 : return new Object[] { EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, pickaxe) };
+ case 8 : return new Object[] { EnchantmentHelper.getEnchantmentLevel(Enchantment.silkTouch.effectId, pickaxe) > 0 };
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean canAttachToSide(int side) {
+ return true;
+ }
+
+ @Override
+ public void attach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+ @Override
+ public void detach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+ @Override
+ public void update() {
+ // NO-OP
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound) {
+ // NO-OP
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound) {
+ // NO-OP
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralArcaneEar.java b/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralArcaneEar.java
new file mode 100644
index 00000000..868a8b26
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralArcaneEar.java
@@ -0,0 +1,82 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 11, 2013, 9:41:49 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.peripheral;
+
+import net.minecraft.nbt.NBTTagCompound;
+import thaumcraft.common.tiles.TileSensor;
+import dan200.computer.api.IComputerAccess;
+import dan200.computer.api.IHostedPeripheral;
+import dan200.computer.api.ILuaContext;
+
+public class PeripheralArcaneEar implements IHostedPeripheral {
+
+ TileSensor ear;
+
+ public PeripheralArcaneEar(TileSensor ear) {
+ this.ear = ear;
+ }
+
+ @Override
+ public String getType() {
+ return "tt_arcaneear";
+ }
+
+ @Override
+ public String[] getMethodNames() {
+ return new String[] { "getNote", "setNote" };
+ }
+
+ @Override
+ public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
+ if(method == 0) {
+ return new Object[]{ ear.note };
+ } else {
+ ear.note = (byte) ((Double) arguments[0]).doubleValue();
+
+ return null;
+ }
+ }
+
+ @Override
+ public boolean canAttachToSide(int side) {
+ return true;
+ }
+
+ @Override
+ public void attach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+ @Override
+ public void detach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+ @Override
+ public void update() {
+ // NO-OP
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound) {
+ // NO-OP
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound) {
+ // NO-OP
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralAspectContainer.java b/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralAspectContainer.java
new file mode 100644
index 00000000..b0ec2b71
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralAspectContainer.java
@@ -0,0 +1,102 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [13 Sep 2013, 00:58:21 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.peripheral;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.nbt.NBTTagCompound;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.IAspectContainer;
+import dan200.computer.api.IComputerAccess;
+import dan200.computer.api.IHostedPeripheral;
+import dan200.computer.api.ILuaContext;
+
+public class PeripheralAspectContainer implements IHostedPeripheral {
+
+ IAspectContainer container;
+
+ public PeripheralAspectContainer(IAspectContainer container) {
+ this.container = container;
+ }
+
+ @Override
+ public String getType() {
+ return "tt_aspectContainer";
+ }
+
+ @Override
+ public String[] getMethodNames() {
+ return new String[] { "getAspects", "getAspectCount" };
+ }
+
+ @Override
+ public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
+ switch(method) {
+ case 0 : {
+ List returnStuff = new ArrayList();
+ if(container.getAspects() == null)
+ return new String[0];
+
+ for(Aspect aspect : container.getAspects().getAspectsSorted())
+ returnStuff.add(aspect.getTag());
+
+ return returnStuff.toArray();
+ }
+ case 1 : {
+ String aspectName = (String) arguments[0];
+ Aspect aspect = Aspect.getAspect(aspectName);
+
+ if(container.getAspects() == null)
+ return new Object[] { 0 };
+
+ return new Object[] { container.getAspects().getAmount(aspect) };
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean canAttachToSide(int side) {
+ return true;
+ }
+
+ @Override
+ public void attach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+ @Override
+ public void detach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+ @Override
+ public void update() {
+ // NO-OP
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound) {
+ // NO-OP
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound) {
+ // NO-OP
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralBrainInAJar.java b/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralBrainInAJar.java
new file mode 100644
index 00000000..4eeada84
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralBrainInAJar.java
@@ -0,0 +1,76 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 11, 2013, 9:36:45 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.peripheral;
+
+import net.minecraft.nbt.NBTTagCompound;
+import thaumcraft.common.tiles.TileJarBrain;
+import dan200.computer.api.IComputerAccess;
+import dan200.computer.api.IHostedPeripheral;
+import dan200.computer.api.ILuaContext;
+
+public class PeripheralBrainInAJar implements IHostedPeripheral {
+
+ TileJarBrain jar;
+
+ public PeripheralBrainInAJar(TileJarBrain jar) {
+ this.jar = jar;
+ }
+
+ @Override
+ public String getType() {
+ return "tt_braininajar";
+ }
+
+ @Override
+ public String[] getMethodNames() {
+ return new String[] { "getXP" };
+ }
+
+ @Override
+ public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
+ return new Object[] { jar.xp };
+ }
+
+ @Override
+ public boolean canAttachToSide(int side) {
+ return true;
+ }
+
+ @Override
+ public void attach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+ @Override
+ public void detach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+ @Override
+ public void update() {
+ // NO-OP
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound) {
+ // NO-OP
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound) {
+ // NO-OP
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralDeconstructor.java b/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralDeconstructor.java
new file mode 100644
index 00000000..b24c189b
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralDeconstructor.java
@@ -0,0 +1,82 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [13 Sep 2013, 01:10:52 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.peripheral;
+
+import net.minecraft.nbt.NBTTagCompound;
+import thaumcraft.common.tiles.TileDeconstructionTable;
+import dan200.computer.api.IComputerAccess;
+import dan200.computer.api.IHostedPeripheral;
+import dan200.computer.api.ILuaContext;
+
+public class PeripheralDeconstructor implements IHostedPeripheral {
+
+ TileDeconstructionTable deconstructor;
+
+ public PeripheralDeconstructor(TileDeconstructionTable deconstructor) {
+ this.deconstructor = deconstructor;
+ }
+
+ @Override
+ public String getType() {
+ return "tt_deconstructor";
+ }
+
+ @Override
+ public String[] getMethodNames() {
+ return new String[] { "hasAspect", "hasItem", "getAspect" };
+ }
+
+ @Override
+ public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
+ switch(method) {
+ case 0 : return new Object[] { deconstructor.aspect != null };
+ case 1 : return new Object[] { deconstructor.getStackInSlot(0) != null };
+ case 2 : return deconstructor.aspect == null ? null : new Object[] { deconstructor.aspect.getTag() };
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean canAttachToSide(int side) {
+ return true;
+ }
+
+ @Override
+ public void attach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+ @Override
+ public void detach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+ @Override
+ public void update() {
+ // NO-OP
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound) {
+ // NO-OP
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound) {
+ // NO-OP
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralHandler.java b/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralHandler.java
new file mode 100644
index 00000000..19870b2d
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralHandler.java
@@ -0,0 +1,52 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [13 Sep 2013, 00:56:19 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.peripheral;
+
+import net.minecraft.tileentity.TileEntity;
+import thaumcraft.api.aspects.IAspectContainer;
+import thaumcraft.common.tiles.TileArcaneBore;
+import thaumcraft.common.tiles.TileDeconstructionTable;
+import thaumcraft.common.tiles.TileJarBrain;
+import thaumcraft.common.tiles.TileSensor;
+import vazkii.tinkerer.common.block.tile.transvector.TileTransvectorInterface;
+import dan200.computer.api.IHostedPeripheral;
+import dan200.computer.api.IPeripheralHandler;
+
+public final class PeripheralHandler implements IPeripheralHandler {
+
+ @Override
+ public IHostedPeripheral getPeripheral(TileEntity tile) {
+ if(tile instanceof TileTransvectorInterface)
+ return new PeripheralTransvectorInterface((TileTransvectorInterface) tile);
+
+ if(tile instanceof IAspectContainer)
+ return new PeripheralAspectContainer((IAspectContainer) tile);
+
+ if(tile instanceof TileDeconstructionTable)
+ return new PeripheralDeconstructor((TileDeconstructionTable) tile);
+
+ if(tile instanceof TileJarBrain)
+ return new PeripheralBrainInAJar((TileJarBrain) tile);
+
+ if(tile instanceof TileSensor)
+ return new PeripheralArcaneEar((TileSensor) tile);
+
+ if(tile instanceof TileArcaneBore)
+ return new PeripheralArcaneBore((TileArcaneBore) tile);
+
+ return null;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralTransvectorInterface.java b/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralTransvectorInterface.java
new file mode 100644
index 00000000..eb609fd3
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/peripheral/PeripheralTransvectorInterface.java
@@ -0,0 +1,68 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 11, 2013, 9:49:46 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.peripheral;
+
+import ic2.api.energy.tile.IEnergySink;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.fluids.IFluidHandler;
+import thaumcraft.api.aspects.IAspectContainer;
+import thaumcraft.api.aspects.IEssentiaTransport;
+import vazkii.tinkerer.common.block.tile.transvector.TileTransvectorInterface;
+import buildcraft.api.power.IPowerReceptor;
+import cofh.api.energy.IEnergyHandler;
+import dan200.computer.api.IComputerAccess;
+import dan200.computer.api.ILuaContext;
+
+public class PeripheralTransvectorInterface extends PeripheralAspectContainer {
+
+ TileTransvectorInterface interfase;
+
+ public PeripheralTransvectorInterface(TileTransvectorInterface interfase) {
+ super(interfase);
+ this.interfase = interfase;
+ }
+
+ @Override
+ public String getType() {
+ return "tt_transvectorinterface";
+ }
+
+ @Override
+ public String[] getMethodNames() {
+ return new String[] { "getAspects", "getAspectCount", "isBound", "isInventory", "isSidedInventory", "isFluidContainer", "isMJHandler", "isEUHandler", "isRFHandler", "isAspectContainer", "isAspectTransport" };
+ }
+
+ @Override
+ public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
+ TileEntity tile = interfase.getTile();
+
+ switch(method) {
+ case 2 : return new Object[] { tile != null };
+ case 3 : return new Object[] { tile instanceof IInventory };
+ case 4 : return new Object[] { tile instanceof ISidedInventory };
+ case 5 : return new Object[] { tile instanceof IFluidHandler };
+ case 6 : return new Object[] { tile instanceof IPowerReceptor };
+ case 7 : return new Object[] { tile instanceof IEnergySink };
+ case 8 : return new Object[] { tile instanceof IEnergyHandler };
+ case 9 : return new Object[] { tile instanceof IAspectContainer };
+ case 10 : return new Object[] { tile instanceof IEssentiaTransport };
+ }
+
+ return super.callMethod(computer, context, method, arguments);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/tablet/FakeInvPlayer.java b/src/main/java/vazkii/tinkerer/common/block/tile/tablet/FakeInvPlayer.java
new file mode 100644
index 00000000..81492d3c
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/tablet/FakeInvPlayer.java
@@ -0,0 +1,36 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 15:55:23 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.tablet;
+
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+
+public class FakeInvPlayer extends InventoryPlayer {
+
+ TabletFakePlayer fakePlayer;
+
+ public FakeInvPlayer(TabletFakePlayer fakePlayer) {
+ super(fakePlayer);
+ this.fakePlayer = fakePlayer;
+ }
+
+ @Override
+ public void setInventorySlotContents(int par1, ItemStack par2ItemStack) {
+ super.setInventorySlotContents(par1, par2ItemStack);
+
+ if(par1 == currentItem)
+ fakePlayer.tablet.setInventorySlotContents(0, getStackInSlot(currentItem));
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/tablet/TabletFakePlayer.java b/src/main/java/vazkii/tinkerer/common/block/tile/tablet/TabletFakePlayer.java
new file mode 100644
index 00000000..a918f041
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/tablet/TabletFakePlayer.java
@@ -0,0 +1,84 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 15:54:36 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.tablet;
+
+import net.minecraft.inventory.Container;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ChunkCoordinates;
+import net.minecraft.world.World;
+import net.minecraftforge.common.FakePlayer;
+import vazkii.tinkerer.common.lib.LibBlockNames;
+
+public class TabletFakePlayer extends FakePlayer {
+
+ TileAnimationTablet tablet;
+
+ public TabletFakePlayer(TileAnimationTablet tablet) {
+ super(tablet.worldObj, "tile." + LibBlockNames.ANIMATION_TABLET + ".name");
+ this.tablet = tablet;
+ inventory = new FakeInvPlayer(this);
+ }
+
+ @Override
+ public void openGui(Object mod, int modGuiId, World world, int x, int y, int z) {
+ // NO-OP
+ }
+
+ @Override
+ public void sendContainerToPlayer(Container par1Container) {
+ // NO-OP
+ }
+
+ @Override
+ public void onUpdate() {
+ capabilities.isCreativeMode = false;
+
+ posX = tablet.xCoord + 0.5;
+ posY = tablet.yCoord + 1.6;
+ posZ = tablet.zCoord + 0.5;
+
+ if(riddenByEntity != null)
+ riddenByEntity.ridingEntity = null;
+ if(ridingEntity != null)
+ ridingEntity.riddenByEntity = null;
+ riddenByEntity = null;
+ ridingEntity = null;
+
+ motionX = motionY = motionZ = 0;
+ setHealth(20);
+ isDead = false;
+
+ int meta = tablet.getBlockMetadata() & 7;
+ int rotation = meta == 2 ? 180 : meta == 3 ? 0 : meta == 4 ? 90 : -90;
+ rotationYaw = rotationYawHead = rotation;
+ rotationPitch = -15;
+
+ for(int i = 0; i < inventory.getSizeInventory(); i++) {
+ if(i != inventory.currentItem) {
+ ItemStack stack = inventory.getStackInSlot(i);
+ if(stack != null) {
+ dropPlayerItem(stack);
+ inventory.setInventorySlotContents(i, null);
+ }
+ }
+ }
+ }
+
+ @Override
+ public ChunkCoordinates getPlayerCoordinates() {
+ return new ChunkCoordinates(tablet.xCoord, tablet.yCoord, tablet.zCoord);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/tablet/TileAnimationTablet.java b/src/main/java/vazkii/tinkerer/common/block/tile/tablet/TileAnimationTablet.java
new file mode 100644
index 00000000..0363c72f
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/tablet/TileAnimationTablet.java
@@ -0,0 +1,576 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 15:51:34 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.tablet;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLiving;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.passive.EntityAnimal;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.network.INetworkManager;
+import net.minecraft.network.packet.Packet;
+import net.minecraft.network.packet.Packet132TileEntityData;
+import net.minecraft.network.packet.Packet3Chat;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.ChatMessageComponent;
+import net.minecraft.util.ChunkCoordinates;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraftforge.common.FakePlayer;
+import net.minecraftforge.common.ForgeDirection;
+import net.minecraftforge.event.Event;
+import net.minecraftforge.event.ForgeEventFactory;
+import net.minecraftforge.event.entity.player.PlayerInteractEvent;
+import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
+import vazkii.tinkerer.common.block.ModBlocks;
+import vazkii.tinkerer.common.lib.LibBlockNames;
+import cpw.mods.fml.common.network.PacketDispatcher;
+import dan200.computer.api.IComputerAccess;
+import dan200.computer.api.ILuaContext;
+import dan200.computer.api.IPeripheral;
+
+public class TileAnimationTablet extends TileEntity implements IInventory, IPeripheral {
+
+ private static final String TAG_LEFT_CLICK = "leftClick";
+ private static final String TAG_REDSTONE = "redstone";
+ private static final String TAG_PROGRESS = "progress";
+ private static final String TAG_MOD = "mod";
+
+ private static final int[][] LOC_INCREASES = new int[][] {
+ { 0, -1 },
+ { 0, +1 },
+ { -1, 0 },
+ { +1, 0 }
+ };
+
+ private static final ForgeDirection[] SIDES = new ForgeDirection[] {
+ ForgeDirection.NORTH,
+ ForgeDirection.SOUTH,
+ ForgeDirection.WEST,
+ ForgeDirection.EAST
+ };
+
+ private static final int SWING_SPEED = 3;
+ private static final int MAX_DEGREE = 45;
+
+ List detectedEntities = new ArrayList();
+
+ ItemStack[] inventorySlots = new ItemStack[1];
+ public double ticksExisted = 0;
+
+ public boolean leftClick = true;
+ public boolean redstone = false;
+
+ public int swingProgress = 0;
+ private int swingMod = 0;
+
+ private boolean isBreaking = false;
+ private int initialDamage = 0;
+ private int curblockDamage = 0;
+ private int durabilityRemainingOnBlock;
+
+ FakePlayer player;
+
+ @Override
+ public void updateEntity() {
+ if(player == null)
+ player = new TabletFakePlayer(this);
+
+ player.onUpdate();
+
+ ticksExisted++;
+
+ ItemStack stack = getStackInSlot(0);
+
+ if(stack != null) {
+ if(swingProgress >= MAX_DEGREE)
+ swingHit();
+
+ swingMod = swingProgress <= 0 ? 0 : swingProgress >= MAX_DEGREE ? -SWING_SPEED : swingMod;
+ swingProgress += swingMod;
+ if(swingProgress < 0)
+ swingProgress = 0;
+ } else {
+ swingMod = 0;
+ swingProgress = 0;
+
+ if(isBreaking)
+ stopBreaking();
+ }
+
+ boolean detect = detect();
+ if(!detect)
+ stopBreaking();
+
+ if(detect && isBreaking)
+ continueBreaking();
+
+ if((!redstone || isBreaking) && detect && swingProgress == 0) {
+ initiateSwing();
+ worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.animationTablet.blockID, 0, 0);
+ }
+ }
+
+ public void initiateSwing() {
+ swingMod = SWING_SPEED;
+ swingProgress = 1;
+ }
+
+ public void swingHit() {
+ ChunkCoordinates coords = getTargetLoc();
+ ItemStack stack = getStackInSlot(0);
+ Item item = stack.getItem();
+ int id = worldObj.getBlockId(coords.posX, coords.posY, coords.posZ);
+
+ player.setCurrentItemOrArmor(0, stack);
+
+ boolean done = false;
+
+ if(leftClick) {
+ Entity entity = detectedEntities.isEmpty() ? null : detectedEntities.get(worldObj.rand.nextInt(detectedEntities.size()));
+ if(entity != null) {
+ player.getAttributeMap().applyAttributeModifiers(stack.getAttributeModifiers()); // Set attack strenght
+ player.attackTargetEntityWithCurrentItem(entity);
+ done = true;
+ } else if(!isBreaking){
+ if(id != 0 && !Block.blocksList[id].isAirBlock(worldObj, coords.posX, coords.posY, coords.posZ) && Block.blocksList[id].getBlockHardness(worldObj, coords.posX, coords.posY, coords.posZ) >= 0) {
+ isBreaking = true;
+ startBreaking(Block.blocksList[id], worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ));
+ done = true;
+ }
+ }
+ } else {
+ int side = SIDES[(getBlockMetadata() & 7) - 2].getOpposite().ordinal();
+
+ if(!(id != 0 && !Block.blocksList[id].isAirBlock(worldObj, coords.posX, coords.posY, coords.posZ))) {
+ coords.posY -= 1;
+ side = ForgeDirection.UP.ordinal();
+ id = worldObj.getBlockId(coords.posX, coords.posY, coords.posZ);
+ }
+
+ try {
+ ForgeEventFactory.onPlayerInteract(player, Action.RIGHT_CLICK_AIR, coords.posX, coords.posY, coords.posZ, side);
+ Entity entity = detectedEntities.isEmpty() ? null : detectedEntities.get(worldObj.rand.nextInt(detectedEntities.size()));
+ done = entity != null && entity instanceof EntityLiving && (item.itemInteractionForEntity(stack, player, (EntityLivingBase) entity) || (entity instanceof EntityAnimal ? ((EntityAnimal) entity).interact(player) : true));
+
+ if(!done)
+ item.onItemUseFirst(stack, player, worldObj, coords.posX, coords.posY, coords.posZ, side, 0F, 0F, 0F);
+ if(!done)
+ done = Block.blocksList[id] != null && Block.blocksList[id].onBlockActivated(worldObj, coords.posX, coords.posY, coords.posZ, player, side, 0F, 0F, 0F);
+ if(!done)
+ done = item.onItemUse(stack, player, worldObj, coords.posX, coords.posY, coords.posZ, side, 0F, 0F, 0F);
+ if(!done) {
+ stack = item.onItemRightClick(stack, worldObj, player);
+ done = true;
+ }
+ } catch(Throwable e) {
+ e.printStackTrace();
+ Packet3Chat packet = new Packet3Chat(new ChatMessageComponent().addText(EnumChatFormatting.RED + "Something went wrong with a Tool Dynamism Tablet! Check your FML log."));
+ Packet3Chat packet1 = new Packet3Chat(new ChatMessageComponent().addText(EnumChatFormatting.RED + "" + EnumChatFormatting.ITALIC + e.getMessage()));
+
+ PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 16, worldObj.provider.dimensionId, packet);
+ PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 16, worldObj.provider.dimensionId, packet1);
+ }
+ }
+
+ if(done) {
+ stack = getStackInSlot(0);
+ if(stack == null || stack.stackSize == 0)
+ setInventorySlotContents(0, null);
+
+ PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
+ }
+ }
+
+ // Copied from ItemInWorldManager, seems to do the trick.
+ private void stopBreaking() {
+ isBreaking = false;
+ ChunkCoordinates coords = getTargetLoc();
+ worldObj.destroyBlockInWorldPartially(player.entityId, coords.posX, coords.posY, coords.posZ, -1);
+ }
+
+ // Copied from ItemInWorldManager, seems to do the trick.
+ private void startBreaking(Block block, int meta) {
+ int side = SIDES[(getBlockMetadata() & 7) - 2].getOpposite().ordinal();
+ ChunkCoordinates coords = getTargetLoc();
+
+ PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(player, Action.LEFT_CLICK_BLOCK, coords.posX, coords.posY, coords.posZ, side);
+ if (event.isCanceled()) {
+ stopBreaking();
+ return;
+ }
+
+ initialDamage = curblockDamage;
+ float var5 = 1F;
+
+ if (block != null) {
+ if (event.useBlock != Event.Result.DENY)
+ block.onBlockClicked(worldObj, coords.posX, coords.posY, coords.posZ, player);
+ var5 = block.getPlayerRelativeBlockHardness(player, worldObj, coords.posX, coords.posY, coords.posZ);
+ }
+
+ if (event.useItem == Event.Result.DENY) {
+ stopBreaking();
+ return;
+ }
+
+ if(var5 >= 1F) {
+ tryHarvestBlock(coords.posX, coords.posY, coords.posZ);
+ stopBreaking();
+ } else {
+ int var7 = (int) (var5 * 10);
+ worldObj.destroyBlockInWorldPartially(player.entityId, coords.posX, coords.posY, coords.posZ, var7);
+ durabilityRemainingOnBlock = var7;
+ }
+ }
+
+ // Copied from ItemInWorldManager, seems to do the trick.
+ private void continueBreaking() {
+ ++curblockDamage;
+ int var1;
+ float var4;
+ int var5;
+ ChunkCoordinates coords = getTargetLoc();
+
+ var1 = curblockDamage - initialDamage;
+ int var2 = worldObj.getBlockId(coords.posX, coords.posY, coords.posZ);
+
+ if (var2 == 0)
+ stopBreaking();
+ else {
+ Block var3 = Block.blocksList[var2];
+ var4 = var3.getPlayerRelativeBlockHardness(player, worldObj,coords.posX, coords.posY, coords.posZ) * var1;
+ var5 = (int) (var4 * 10);
+
+ if (var5 != durabilityRemainingOnBlock) {
+ worldObj.destroyBlockInWorldPartially(player.entityId, coords.posX, coords.posY, coords.posZ, var5);
+ durabilityRemainingOnBlock = var5;
+ }
+
+ if (var4 >= 1F) {
+ tryHarvestBlock(coords.posX, coords.posY, coords.posZ);
+ stopBreaking();
+ }
+ }
+ }
+
+ // Copied from ItemInWorldManager, seems to do the trick.
+ public boolean tryHarvestBlock(int par1, int par2, int par3) {
+ ItemStack stack = getStackInSlot(0);
+ if (stack != null && stack.getItem().onBlockStartBreak(stack, par1, par2, par3, player))
+ return false;
+
+ int var4 = worldObj.getBlockId(par1, par2, par3);
+ int var5 = worldObj.getBlockMetadata(par1, par2, par3);
+ worldObj.playAuxSFXAtEntity(player, 2001, par1, par2, par3, var4 + (var5 << 12));
+ boolean var6 = false;
+
+ boolean var8 = false;
+ Block block = Block.blocksList[var4];
+ if (block != null)
+ var8 = block.canHarvestBlock(player, var5);
+
+ worldObj.loadedEntityList.size();
+ if (stack != null)
+ stack.onBlockDestroyed(worldObj, var4, par1, par2, par3, player);
+
+ var6 = removeBlock(par1, par2, par3);
+ if (var6 && var8)
+ Block.blocksList[var4].harvestBlock(worldObj, player, par1, par2, par3, var5);
+
+ return var6;
+ }
+
+ // Copied from ItemInWorldManager, seems to do the trick.
+ private boolean removeBlock(int par1, int par2, int par3) {
+ Block var4 = Block.blocksList[worldObj.getBlockId(par1, par2, par3)];
+ int var5 = worldObj.getBlockMetadata(par1, par2, par3);
+
+ if (var4 != null)
+ var4.onBlockHarvested(worldObj, par1, par2, par3, var5, player);
+
+ boolean var6 = var4 != null && var4.removeBlockByPlayer(worldObj, player, par1, par2, par3);
+
+ if (var4 != null && var6)
+ var4.onBlockDestroyedByPlayer(worldObj, par1, par2, par3, var5);
+
+ return var6;
+ }
+
+ public boolean detect() {
+ ChunkCoordinates coords = getTargetLoc();
+ findEntities(coords);
+ return !worldObj.isAirBlock(coords.posX, coords.posY, coords.posZ) || !detectedEntities.isEmpty();
+ }
+
+ public void findEntities(ChunkCoordinates coords) {
+ AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox(coords.posX, coords.posY, coords.posZ, coords.posX + 1, coords.posY + 1, coords.posZ + 1);
+ detectedEntities = worldObj.getEntitiesWithinAABB(Entity.class, boundingBox);
+ }
+
+ public ChunkCoordinates getTargetLoc() {
+ ChunkCoordinates coords = new ChunkCoordinates(xCoord, yCoord, zCoord);
+
+ int meta = getBlockMetadata();
+ int[] increase = LOC_INCREASES[(meta & 7) - 2];
+ coords.posX += increase[0];
+ coords.posZ += increase[1];
+
+ return coords;
+ }
+
+ public boolean getIsBreaking() {
+ return isBreaking;
+ }
+
+ public FakePlayer getFakePlayer() {
+ return player;
+ }
+
+ @Override
+ public boolean receiveClientEvent(int par1, int par2) {
+ if(par1 == 0) {
+ initiateSwing();
+ return true;
+ }
+
+ return tileEntityInvalid;
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
+ super.readFromNBT(par1NBTTagCompound);
+
+ swingProgress = par1NBTTagCompound.getInteger(TAG_PROGRESS);
+ swingMod = par1NBTTagCompound.getInteger(TAG_MOD);
+ readCustomNBT(par1NBTTagCompound);
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
+ super.writeToNBT(par1NBTTagCompound);
+
+ par1NBTTagCompound.setInteger(TAG_PROGRESS, swingProgress);
+ par1NBTTagCompound.setInteger(TAG_MOD, swingMod);
+ writeCustomNBT(par1NBTTagCompound);
+ }
+
+ public void readCustomNBT(NBTTagCompound par1NBTTagCompound) {
+ leftClick = par1NBTTagCompound.getBoolean(TAG_LEFT_CLICK);
+ redstone = par1NBTTagCompound.getBoolean(TAG_REDSTONE);
+
+ NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
+ inventorySlots = new ItemStack[getSizeInventory()];
+ for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
+ NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
+ byte var5 = var4.getByte("Slot");
+ if (var5 >= 0 && var5 < inventorySlots.length)
+ inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
+ }
+ }
+
+ public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) {
+ par1NBTTagCompound.setBoolean(TAG_LEFT_CLICK, leftClick);
+ par1NBTTagCompound.setBoolean(TAG_REDSTONE, redstone);
+
+ NBTTagList var2 = new NBTTagList();
+ for (int var3 = 0; var3 < inventorySlots.length; ++var3) {
+ if (inventorySlots[var3] != null) {
+ NBTTagCompound var4 = new NBTTagCompound();
+ var4.setByte("Slot", (byte)var3);
+ inventorySlots[var3].writeToNBT(var4);
+ var2.appendTag(var4);
+ }
+ }
+ par1NBTTagCompound.setTag("Items", var2);
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return inventorySlots.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int i) {
+ return inventorySlots[i];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int par1, int par2) {
+ if (inventorySlots[par1] != null) {
+ ItemStack stackAt;
+
+ if (inventorySlots[par1].stackSize <= par2) {
+ stackAt = inventorySlots[par1];
+ inventorySlots[par1] = null;
+
+ if(!worldObj.isRemote)
+ PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
+
+ return stackAt;
+ } else {
+ stackAt = inventorySlots[par1].splitStack(par2);
+
+ if (inventorySlots[par1].stackSize == 0)
+ inventorySlots[par1] = null;
+
+ if(!worldObj.isRemote)
+ PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
+
+ return stackAt;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ return getStackInSlot(i);
+ }
+
+ @Override
+ public void setInventorySlotContents(int i, ItemStack itemstack) {
+ inventorySlots[i] = itemstack;
+
+ if(!worldObj.isRemote)
+ PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
+ }
+
+ @Override
+ public String getInvName() {
+ return LibBlockNames.ANIMATION_TABLET;
+ }
+
+ @Override
+ public boolean isInvNameLocalized() {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int i, ItemStack itemstack) {
+ return true;
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer) {
+ return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this ? false : entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64;
+ }
+
+ @Override
+ public void openChest() {
+ // NO-OP
+ }
+
+ @Override
+ public void closeChest() {
+ // NO-OP
+ }
+
+ @Override
+ public Packet getDescriptionPacket() {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ writeCustomNBT(nbttagcompound);
+ return new Packet132TileEntityData(xCoord, yCoord, zCoord, -999, nbttagcompound);
+ }
+
+ @Override
+ public void onDataPacket(INetworkManager manager, Packet132TileEntityData packet) {
+ super.onDataPacket(manager, packet);
+ readCustomNBT(packet.data);
+ }
+
+ @Override
+ public String getType() {
+ return "tt_animationTablet";
+ }
+
+ @Override
+ public String[] getMethodNames() {
+ return new String[]{ "getRedstone", "setRedstone", "getLeftClick", "setLeftClick", "getRotation", "setRotation", "hasItem", "trigger" };
+ }
+
+ @Override
+ public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
+ switch(method) {
+ case 0 : return new Object[]{ redstone };
+ case 1 : {
+ boolean redstone = (Boolean) arguments[0];
+ this.redstone = redstone;
+ PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
+ return null;
+ }
+ case 2 : return new Object[]{ leftClick };
+ case 3 : {
+ boolean leftClick = (Boolean) arguments[0];
+ this.leftClick = leftClick;
+ PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
+ return null;
+ }
+ case 4 : return new Object[] { getBlockMetadata() - 2 };
+ case 5 : {
+ int rotation = (int) ((Double) arguments[0]).doubleValue();
+
+ if(rotation > 3)
+ throw new Exception("Invalid value: " + rotation + ".");
+
+ worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, rotation + 2, 1 | 2);
+ return null;
+ }
+ case 6 : return new Object[] { getStackInSlot(0) != null };
+ case 7 : {
+ if(swingProgress != 0)
+ return new Object[] { false };
+
+ findEntities(getTargetLoc());
+ initiateSwing();
+ worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.animationTablet.blockID, 0, 0);
+
+ return new Object[] { true };
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean canAttachToSide(int side) {
+ return true;
+ }
+
+ @Override
+ public void attach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+ @Override
+ public void detach(IComputerAccess computer) {
+ // NO-OP
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/transvector/TileTransvector.java b/src/main/java/vazkii/tinkerer/common/block/tile/transvector/TileTransvector.java
new file mode 100644
index 00000000..fb1bc779
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/transvector/TileTransvector.java
@@ -0,0 +1,77 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Nov 24, 2013, 6:40:49 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.transvector;
+
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import vazkii.tinkerer.common.block.tile.TileCamo;
+
+public abstract class TileTransvector extends TileCamo {
+
+ private static final String TAG_X_TARGET = "xt";
+ private static final String TAG_Y_TARGET = "yt";
+ private static final String TAG_Z_TARGET = "zt";
+ private static final String TAG_CHEATY_MODE = "cheatyMode";
+
+ public int x = 0, y = -1, z = 0;
+ private boolean cheaty;
+
+ @Override
+ public boolean canUpdate() {
+ return true;
+ }
+
+ @Override
+ public void writeCustomNBT(NBTTagCompound cmp) {
+ super.writeCustomNBT(cmp);
+
+ cmp.setInteger(TAG_X_TARGET, x);
+ cmp.setInteger(TAG_Y_TARGET, y);
+ cmp.setInteger(TAG_Z_TARGET, z);
+ cmp.setBoolean(TAG_CHEATY_MODE, cheaty);
+ }
+
+ @Override
+ public void readCustomNBT(NBTTagCompound cmp) {
+ super.readCustomNBT(cmp);
+
+ x = cmp.getInteger(TAG_X_TARGET);
+ y = cmp.getInteger(TAG_Y_TARGET);
+ z = cmp.getInteger(TAG_Z_TARGET);
+ cheaty = cmp.getBoolean(TAG_CHEATY_MODE);
+
+ }
+
+ public final TileEntity getTile() {
+ if(!worldObj.blockExists(x, y, z))
+ return null;
+
+ TileEntity tile = worldObj.getBlockTileEntity(x, y, z);
+
+ if(tile == null && tileRequiredAtLink() || (Math.abs(x - xCoord) > getMaxDistance() || Math.abs(y - yCoord) > getMaxDistance() || Math.abs(z - zCoord) > getMaxDistance()) && !cheaty) {
+ y = -1;
+ return null;
+ }
+
+ return tile;
+ }
+
+ public abstract int getMaxDistance();
+
+ boolean tileRequiredAtLink() {
+ return !cheaty;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/transvector/TileTransvectorDislocator.java b/src/main/java/vazkii/tinkerer/common/block/tile/transvector/TileTransvectorDislocator.java
new file mode 100644
index 00000000..9e5f2933
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/transvector/TileTransvectorDislocator.java
@@ -0,0 +1,194 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Nov 24, 2013, 6:48:04 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.transvector;
+
+import java.util.List;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.Item;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.ChunkCoordinates;
+import net.minecraftforge.common.ForgeDirection;
+import thaumcraft.api.ThaumcraftApi;
+import thaumcraft.client.codechicken.core.vec.Vector3;
+import thaumcraft.common.config.ConfigBlocks;
+import vazkii.tinkerer.common.block.ModBlocks;
+import vazkii.tinkerer.common.lib.LibFeatures;
+
+public class TileTransvectorDislocator extends TileTransvector {
+
+ private static final String TAG_ORIENTATION = "orientation";
+ public int orientation;
+ private int cooldown = 0;
+ private boolean pulseStored = false;
+
+ class BlockData {
+
+ int id;
+ int meta;
+ NBTTagCompound tile;
+
+ ChunkCoordinates coords;
+
+ public BlockData(int id, int meta, TileEntity tile, ChunkCoordinates coords) {
+ this.id = id;
+ this.meta = meta;
+
+ if(tile != null) {
+ NBTTagCompound cmp = new NBTTagCompound();
+ tile.writeToNBT(cmp);
+ this.tile = cmp;
+ } else tile = null;
+
+ this.coords = coords;
+ }
+
+ public BlockData(ChunkCoordinates coords) {
+ this(worldObj.getBlockId(coords.posX, coords.posY, coords.posZ), worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ), worldObj.getBlockTileEntity(coords.posX, coords.posY, coords.posZ), coords);
+ }
+
+ public void clearTileEntityAt() {
+ Block block = Block.blocksList[id];
+ if(block != null) {
+ TileEntity tileToSet = block.createTileEntity(worldObj, meta);
+ worldObj.setBlockTileEntity(coords.posX, coords.posY, coords.posZ, tileToSet);
+ }
+ }
+
+ public void setTo(ChunkCoordinates coords) {
+ worldObj.setBlock(coords.posX, coords.posY, coords.posZ, id, meta, 1 | 2);
+
+ TileEntity tile = this.tile == null ? null : TileEntity.createAndLoadEntity(this.tile);
+ worldObj.setBlockTileEntity(coords.posX, coords.posY, coords.posZ, tile);
+
+ if(tile != null) {
+ tile.xCoord = coords.posX;
+ tile.yCoord = coords.posY;
+ tile.zCoord = coords.posZ;
+ }
+
+ if(Block.blocksList[id] != null)
+ Block.blocksList[id].onNeighborBlockChange(worldObj, coords.posX, coords.posY, coords.posZ, ModBlocks.dislocator.blockID);
+ }
+ }
+
+ @Override
+ public void updateEntity() {
+ super.updateEntity();
+
+ cooldown = Math.max(0, cooldown - 1);
+ if(cooldown == 0 && pulseStored) {
+ pulseStored = false;
+ receiveRedstonePulse();
+ }
+ }
+
+ public void receiveRedstonePulse() {
+ getTile(); // sanity check
+
+ if(y < 0)
+ return;
+
+ if(cooldown > 0) {
+ pulseStored = true;
+ return;
+ }
+
+ ChunkCoordinates endCoords = new ChunkCoordinates(x, y, z);
+ ChunkCoordinates targetCoords = getBlockTarget();
+
+ if(worldObj.blockExists(x, y, z)) {
+ BlockData endData = new BlockData(endCoords);
+ BlockData targetData = new BlockData(targetCoords);
+
+ if(checkBlock(targetCoords) && checkBlock(endCoords)) {
+ endData.clearTileEntityAt();
+ targetData.clearTileEntityAt();
+
+ endData.setTo(targetCoords);
+ targetData.setTo(endCoords);
+ }
+ }
+
+ List entitiesAtEnd = getEntitiesAtPoint(endCoords);
+ List entitiesAtTarget = getEntitiesAtPoint(targetCoords);
+
+ Vector3 targetToEnd = asVector(targetCoords, endCoords);
+ Vector3 endToTarget = asVector(endCoords, targetCoords);
+
+ for(Entity entity : entitiesAtEnd)
+ moveEntity(entity, endToTarget);
+ for(Entity entity : entitiesAtTarget)
+ moveEntity(entity, targetToEnd);
+
+ cooldown = 10;
+ }
+
+ private boolean checkBlock(ChunkCoordinates coords) {
+ int id = worldObj.getBlockId(coords.posX, coords.posY, coords.posZ);
+ int meta = worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ);
+
+ return !(id == ConfigBlocks.blockAiry.blockID && meta == 0) && !ThaumcraftApi.portableHoleBlackList.contains(id) && Item.itemsList[id] != null && Block.blocksList[id] != null && Block.blocksList[id].getBlockHardness(worldObj, coords.posX, coords.posY, coords.posZ) != -1F || id == 0;
+ }
+
+ private List getEntitiesAtPoint(ChunkCoordinates coords) {
+ return worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(coords.posX, coords.posY, coords.posZ, coords.posX + 1, coords.posY + 1, coords.posZ + 1));
+ }
+
+ private Vector3 asVector(ChunkCoordinates source, ChunkCoordinates target) {
+ return new Vector3(target.posX, target.posY, target.posZ).subtract(new Vector3(source.posX, source.posY, source.posZ));
+ }
+
+ private void moveEntity(Entity entity, Vector3 vec) {
+ if(entity instanceof EntityPlayerMP) {
+ EntityPlayerMP player = (EntityPlayerMP) entity;
+ player.playerNetServerHandler.setPlayerLocation(entity.posX + vec.x, entity.posY + vec.y, entity.posZ + vec.z, player.rotationYaw, player.rotationPitch);
+ } else entity.setPosition(entity.posX + vec.x, entity.posY + vec.y, entity.posZ + vec.z);
+ }
+
+ public ChunkCoordinates getBlockTarget() {
+ ForgeDirection dir = ForgeDirection.getOrientation(orientation);
+ return new ChunkCoordinates(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
+ }
+
+ @Override
+ public void readCustomNBT(NBTTagCompound cmp) {
+ super.readCustomNBT(cmp);
+
+ orientation = cmp.getInteger(TAG_ORIENTATION);
+ }
+
+ @Override
+ public void writeCustomNBT(NBTTagCompound cmp) {
+ super.writeCustomNBT(cmp);
+
+ cmp.setInteger(TAG_ORIENTATION, orientation);
+ }
+
+ @Override
+ public int getMaxDistance() {
+ return LibFeatures.DISLOCATOR_DISTANCE;
+ }
+
+ @Override
+ boolean tileRequiredAtLink() {
+ return false;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java b/src/main/java/vazkii/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java
new file mode 100644
index 00000000..39e287b4
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java
@@ -0,0 +1,404 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 19:01:20 (GMT)]
+ */
+package vazkii.tinkerer.common.block.tile.transvector;
+
+import ic2.api.energy.event.EnergyTileLoadEvent;
+import ic2.api.energy.event.EnergyTileUnloadEvent;
+import ic2.api.energy.tile.IEnergySink;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import net.minecraftforge.common.ForgeDirection;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTankInfo;
+import net.minecraftforge.fluids.IFluidHandler;
+import net.minecraftforge.fluids.IFluidTank;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.api.aspects.IAspectContainer;
+import thaumcraft.api.aspects.IEssentiaTransport;
+import vazkii.tinkerer.common.lib.LibFeatures;
+import buildcraft.api.power.IPowerReceptor;
+import buildcraft.api.power.PowerHandler;
+import buildcraft.api.power.PowerHandler.PowerReceiver;
+import cofh.api.energy.IEnergyHandler;
+
+public class TileTransvectorInterface extends TileTransvector implements ISidedInventory, IFluidHandler, IPowerReceptor, IEnergySink, IEnergyHandler, IAspectContainer, IEssentiaTransport {
+
+ private boolean addedToICEnergyNet = false;
+
+ @Override
+ public void updateEntity() {
+ if(!addedToICEnergyNet && !worldObj.isRemote) {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
+ addedToICEnergyNet = true;
+ }
+ }
+
+ @Override
+ public int getMaxDistance() {
+ return LibFeatures.INTERFACE_DISTANCE;
+ }
+
+ @Override
+ public void invalidate() {
+ removeFromIC2EnergyNet();
+ super.invalidate();
+ }
+
+ @Override
+ public void onChunkUnload() {
+ removeFromIC2EnergyNet();
+ }
+
+ private void removeFromIC2EnergyNet() {
+ if(addedToICEnergyNet && !worldObj.isRemote) {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ addedToICEnergyNet = false;
+ }
+ }
+
+ @Override
+ public void onInventoryChanged() {
+ TileEntity tile = getTile();
+ if(tile != null)
+ tile.onInventoryChanged();
+ }
+
+ @Override
+ public int getSizeInventory() {
+ TileEntity tile = getTile();
+ return tile instanceof IInventory ? ((IInventory) tile).getSizeInventory() : 0;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int i) {
+ TileEntity tile = getTile();
+ return tile instanceof IInventory ? ((IInventory) tile).getStackInSlot(i) : null;
+ }
+
+ @Override
+ public ItemStack decrStackSize(int i, int j) {
+ TileEntity tile = getTile();
+ return tile instanceof IInventory ? ((IInventory) tile).decrStackSize(i, j) : null;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ TileEntity tile = getTile();
+ return tile instanceof IInventory ? ((IInventory) tile).getStackInSlotOnClosing(i) : null;
+ }
+
+ @Override
+ public void setInventorySlotContents(int i, ItemStack itemstack) {
+ TileEntity tile = getTile();
+ if (tile instanceof IInventory)
+ ((IInventory) tile).setInventorySlotContents(i, itemstack);
+ }
+
+ @Override
+ public String getInvName() {
+ TileEntity tile = getTile();
+ return tile instanceof IInventory ? ((IInventory) tile).getInvName() : "";
+ }
+
+ @Override
+ public boolean isInvNameLocalized() {
+ TileEntity tile = getTile();
+ return tile instanceof IInventory ? ((IInventory) tile).isInvNameLocalized() : false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ TileEntity tile = getTile();
+ return tile instanceof IInventory ? ((IInventory) tile).getInventoryStackLimit() : 0;
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer) {
+ return false;
+ }
+
+ @Override
+ public void openChest() {
+ }
+
+ @Override
+ public void closeChest() {
+ }
+
+
+ @Override
+ public boolean isItemValidForSlot(int i, ItemStack itemstack) {
+ TileEntity tile = getTile();
+ return tile instanceof IInventory ? ((IInventory) tile).isItemValidForSlot(i, itemstack) : false;
+ }
+
+ @Override
+ public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
+ TileEntity tile = getTile();
+ return tile instanceof IFluidTank ? ((IFluidHandler) tile).fill(from, resource, doFill) : 0;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
+ TileEntity tile = getTile();
+ return tile instanceof IFluidHandler ? ((IFluidHandler) tile).drain(from, resource, doDrain) : null;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
+ TileEntity tile = getTile();
+ return tile instanceof IFluidHandler ? ((IFluidHandler) tile).drain(from, maxDrain, doDrain) : null;
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection from, Fluid fluid) {
+ TileEntity tile = getTile();
+ return tile instanceof IFluidHandler ? ((IFluidHandler) tile).canFill(from, fluid) : false;
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection from, Fluid fluid) {
+ TileEntity tile = getTile();
+ return tile instanceof IFluidHandler ? ((IFluidHandler) tile).canDrain(from, fluid) : false;
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection from) {
+ TileEntity tile = getTile();
+ return tile instanceof IFluidHandler ? ((IFluidHandler) tile).getTankInfo(from) : null;
+ }
+
+ @Override
+ public int[] getAccessibleSlotsFromSide(int var1) {
+ TileEntity tile = getTile();
+ return tile instanceof ISidedInventory ? ((ISidedInventory) tile).getAccessibleSlotsFromSide(var1) : tile instanceof IInventory ? buildSlotsForLinearInventory((IInventory) tile) : new int[0];
+ }
+
+ @Override
+ public boolean canInsertItem(int i, ItemStack itemstack, int j) {
+ TileEntity tile = getTile();
+ return tile instanceof ISidedInventory ? ((ISidedInventory) tile).canInsertItem(i, itemstack, j) : tile instanceof IInventory;
+ }
+
+ @Override
+ public boolean canExtractItem(int i, ItemStack itemstack, int j) {
+ TileEntity tile = getTile();
+ return tile instanceof ISidedInventory ? ((ISidedInventory) tile).canExtractItem(i, itemstack, j) : tile instanceof IInventory;
+ }
+
+ public static int[] buildSlotsForLinearInventory(IInventory inv) {
+ int[] slots = new int[inv.getSizeInventory()];
+ for (int i = 0; i < slots.length; i++)
+ slots[i] = i;
+
+ return slots;
+ }
+
+ @Override
+ public PowerReceiver getPowerReceiver(ForgeDirection side) {
+ TileEntity tile = getTile();
+ return tile instanceof IPowerReceptor ? ((IPowerReceptor) tile).getPowerReceiver(side) : null;
+ }
+
+ @Override
+ public void doWork(PowerHandler workProvider) {
+ TileEntity tile = getTile();
+ if (tile instanceof IPowerReceptor)
+ ((IPowerReceptor) tile).doWork(workProvider);
+ }
+
+ @Override
+ public World getWorld() {
+ return worldObj;
+ }
+
+ @Override
+ public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) {
+ TileEntity tile = getTile();
+ return tile instanceof IEnergySink ? ((IEnergySink) tile).acceptsEnergyFrom(emitter, direction) : false;
+ }
+
+ @Override
+ public double demandedEnergyUnits() {
+ TileEntity tile = getTile();
+ return tile instanceof IEnergySink ? ((IEnergySink) tile).demandedEnergyUnits() : 0;
+ }
+
+ @Override
+ public double injectEnergyUnits(ForgeDirection directionFrom, double amount) {
+ TileEntity tile = getTile();
+ return tile instanceof IEnergySink ? ((IEnergySink) tile).injectEnergyUnits(directionFrom, amount) : 0;
+ }
+
+ @Override
+ public int getMaxSafeInput() {
+ TileEntity tile = getTile();
+ return tile instanceof IEnergySink ? ((IEnergySink) tile).getMaxSafeInput() : 0;
+ }
+
+ @Override
+ public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
+ TileEntity tile = getTile();
+ return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).receiveEnergy(from, maxReceive, simulate) : 0;
+ }
+
+ @Override
+ public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
+ TileEntity tile = getTile();
+ return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).extractEnergy(from, maxExtract, simulate) : 0;
+ }
+
+ @Override
+ public boolean canInterface(ForgeDirection from) {
+ TileEntity tile = getTile();
+ return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).canInterface(from) : false;
+ }
+
+ @Override
+ public int getEnergyStored(ForgeDirection from) {
+ TileEntity tile = getTile();
+ return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).getEnergyStored(from) : 0;
+ }
+
+ @Override
+ public int getMaxEnergyStored(ForgeDirection from) {
+ TileEntity tile = getTile();
+ return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).getMaxEnergyStored(from) : 0;
+ }
+
+ @Override
+ public AspectList getAspects() {
+ TileEntity tile = getTile();
+ return tile instanceof IAspectContainer ? ((IAspectContainer) tile).getAspects() : null;
+ }
+
+ @Override
+ public void setAspects(AspectList paramAspectList) {
+ TileEntity tile = getTile();
+ if(tile != null)
+ ((IAspectContainer) tile).setAspects(paramAspectList);
+ }
+
+ @Override
+ public boolean doesContainerAccept(Aspect paramAspect) {
+ TileEntity tile = getTile();
+ return tile instanceof IAspectContainer ? ((IAspectContainer) tile).doesContainerAccept(paramAspect) : false;
+ }
+
+ @Override
+ public int addToContainer(Aspect paramAspect, int paramInt) {
+ TileEntity tile = getTile();
+ return tile instanceof IAspectContainer ? ((IAspectContainer) tile).addToContainer(paramAspect, paramInt) : 0;
+ }
+
+ @Override
+ public boolean takeFromContainer(Aspect paramAspect, int paramInt) {
+ TileEntity tile = getTile();
+ return tile instanceof IAspectContainer ? ((IAspectContainer) tile).takeFromContainer(paramAspect, paramInt) : false;
+ }
+
+ @Override
+ public boolean takeFromContainer(AspectList paramAspectList) {
+ TileEntity tile = getTile();
+ return tile instanceof IAspectContainer ? ((IAspectContainer) tile).takeFromContainer(paramAspectList) : false;
+ }
+
+ @Override
+ public boolean doesContainerContainAmount(Aspect paramAspect, int paramInt) {
+ TileEntity tile = getTile();
+ return tile instanceof IAspectContainer ? ((IAspectContainer) tile).doesContainerContainAmount(paramAspect, paramInt) : false;
+ }
+
+ @Override
+ public boolean doesContainerContain(AspectList paramAspectList) {
+ TileEntity tile = getTile();
+ return tile instanceof IAspectContainer ? ((IAspectContainer) tile).doesContainerContain(paramAspectList) : false;
+ }
+
+ @Override
+ public int containerContains(Aspect paramAspect) {
+ TileEntity tile = getTile();
+ return tile instanceof IAspectContainer ? ((IAspectContainer) tile).containerContains(paramAspect) : 0;
+ }
+
+ @Override
+ public boolean isConnectable(ForgeDirection paramForgeDirection) {
+ TileEntity tile = getTile();
+ return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).isConnectable(paramForgeDirection) : false;
+ }
+
+ @Override
+ public boolean canInputFrom(ForgeDirection paramForgeDirection) {
+ TileEntity tile = getTile();
+ return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).canInputFrom(paramForgeDirection) : false;
+ }
+
+ @Override
+ public boolean canOutputTo(ForgeDirection paramForgeDirection) {
+ TileEntity tile = getTile();
+ return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).canOutputTo(paramForgeDirection) : false;
+ }
+
+ @Override
+ public void setSuction(AspectList paramAspectList) {
+ TileEntity tile = getTile();
+ if(tile instanceof IEssentiaTransport)
+ ((IEssentiaTransport) tile).setSuction(paramAspectList);
+ }
+
+ @Override
+ public void setSuction(Aspect paramAspect, int paramInt) {
+ TileEntity tile = getTile();
+ if(tile instanceof IEssentiaTransport)
+ ((IEssentiaTransport) tile).setSuction(paramAspect, paramInt);
+ }
+
+ @Override
+ public AspectList getSuction(ForgeDirection paramForgeDirection) {
+ TileEntity tile = getTile();
+ return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).getSuction(paramForgeDirection) : null;
+ }
+
+ @Override
+ public int takeVis(Aspect paramAspect, int paramInt) {
+ TileEntity tile = getTile();
+ return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).takeVis(paramAspect, paramInt) : 0;
+ }
+
+ @Override
+ public AspectList getEssentia(ForgeDirection paramForgeDirection) {
+ TileEntity tile = getTile();
+ return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).getEssentia(paramForgeDirection) : null;
+ }
+
+ @Override
+ public int getMinimumSuction() {
+ TileEntity tile = getTile();
+ return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).getMinimumSuction() : 0;
+ }
+
+ @Override
+ public boolean renderExtendedTube() {
+ return false;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/block/transvector/BlockTransvectorDislocator.java b/src/main/java/vazkii/tinkerer/common/block/transvector/BlockTransvectorDislocator.java
new file mode 100644
index 00000000..20ad1214
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/transvector/BlockTransvectorDislocator.java
@@ -0,0 +1,123 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Nov 24, 2013, 10:08:39 PM (GMT)]
+ */
+package vazkii.tinkerer.common.block.transvector;
+
+import java.util.Random;
+
+import net.minecraft.block.BlockPistonBase;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.Icon;
+import net.minecraft.world.World;
+import thaumcraft.common.config.ConfigItems;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.common.block.BlockCamo;
+import vazkii.tinkerer.common.block.tile.transvector.TileTransvector;
+import vazkii.tinkerer.common.block.tile.transvector.TileTransvectorDislocator;
+import cpw.mods.fml.common.network.PacketDispatcher;
+
+public class BlockTransvectorDislocator extends BlockCamo {
+
+ Icon[] icons = new Icon[2];
+
+ public BlockTransvectorDislocator(int par1) {
+ super(par1, Material.iron);
+ setHardness(3F);
+ setResistance(10F);
+ }
+
+ @Override
+ public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
+ TileEntity tile = par1World.getBlockTileEntity(par2, par3, par4);
+
+ TileTransvectorDislocator dislocator = (TileTransvectorDislocator) tile;
+ ItemStack currentStack = par5EntityPlayer.getCurrentEquippedItem();
+
+ if(currentStack != null && currentStack.itemID == ConfigItems.itemWandCasting.itemID) {
+ dislocator.orientation = par6;
+ par1World.playSoundEffect(par2, par3, par4, "thaumcraft:tool", 0.6F, 1F);
+
+ PacketDispatcher.sendPacketToAllInDimension(tile.getDescriptionPacket(), par1World.provider.dimensionId);
+
+ return true;
+ }
+
+ return super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);
+ }
+
+ @Override
+ public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
+ if(par1World.isRemote)
+ return;
+
+ boolean power = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4) || par1World.isBlockIndirectlyGettingPowered(par2, par3 + 1, par4);
+ int meta = par1World.getBlockMetadata(par2, par3, par4);
+ boolean on = meta != 0;
+
+ if (power && !on) {
+ par1World.scheduleBlockUpdate(par2, par3, par4, blockID, tickRate(par1World));
+ par1World.setBlockMetadataWithNotify(par2, par3, par4, 1, 4);
+ } else if (!power && on)
+ par1World.setBlockMetadataWithNotify(par2, par3, par4, 0, 4);
+ }
+
+ @Override
+ public int tickRate(World par1World) {
+ return 1;
+ }
+
+ @Override
+ public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
+ TileEntity tile = par1World.getBlockTileEntity(par2, par3, par4);
+ if(tile != null && tile instanceof TileTransvectorDislocator) {
+ TileTransvectorDislocator dislocator = (TileTransvectorDislocator) tile;
+ dislocator.receiveRedstonePulse();
+ }
+ }
+
+ @Override
+ public void registerIcons(IconRegister par1IconRegister) {
+ icons[0] = IconHelper.forBlock(par1IconRegister, this, 0);
+ icons[1] = IconHelper.forBlock(par1IconRegister, this, 1);
+ }
+
+ @Override
+ public Icon getIconFromSideAfterCheck(TileEntity tile, int meta, int side) {
+ return icons[((TileTransvectorDislocator) tile).orientation == side ? 1 : 0];
+ }
+
+ @Override
+ public Icon getIcon(int par1, int par2) {
+ return icons[0];
+ }
+
+ @Override
+ public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
+ TileEntity tile = par1World.getBlockTileEntity(par2, par3, par4);
+ int orientation = BlockPistonBase.determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase);
+ ((TileTransvectorDislocator) tile).orientation = orientation;
+ PacketDispatcher.sendPacketToAllInDimension(tile.getDescriptionPacket(), par1World.provider.dimensionId);
+ }
+
+ @Override
+ public TileTransvector createNewTileEntity(World world) {
+ return new TileTransvectorDislocator();
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/block/transvector/BlockTransvectorInterface.java b/src/main/java/vazkii/tinkerer/common/block/transvector/BlockTransvectorInterface.java
new file mode 100644
index 00000000..c37ceadb
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/block/transvector/BlockTransvectorInterface.java
@@ -0,0 +1,37 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 18:57:25 (GMT)]
+ */
+package vazkii.tinkerer.common.block.transvector;
+
+import net.minecraft.block.material.Material;
+import net.minecraft.world.World;
+import vazkii.tinkerer.common.block.BlockCamo;
+import vazkii.tinkerer.common.block.tile.transvector.TileTransvector;
+import vazkii.tinkerer.common.block.tile.transvector.TileTransvectorInterface;
+
+public class BlockTransvectorInterface extends BlockCamo {
+
+ public BlockTransvectorInterface(int par1) {
+ super(par1, Material.iron);
+ setHardness(3F);
+ setResistance(10F);
+ }
+
+ @Override
+ public TileTransvector createNewTileEntity(World world) {
+ return new TileTransvectorInterface();
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/core/handler/ConfigHandler.java b/src/main/java/vazkii/tinkerer/common/core/handler/ConfigHandler.java
new file mode 100644
index 00000000..762b3d47
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/core/handler/ConfigHandler.java
@@ -0,0 +1,192 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [4 Sep 2013, 16:53:24 (GMT)]
+ */
+package vazkii.tinkerer.common.core.handler;
+
+import java.io.File;
+
+import net.minecraftforge.common.ConfigCategory;
+import net.minecraftforge.common.Configuration;
+import net.minecraftforge.common.Property;
+import vazkii.tinkerer.common.lib.LibBlockIDs;
+import vazkii.tinkerer.common.lib.LibBlockNames;
+import vazkii.tinkerer.common.lib.LibEnchantIDs;
+import vazkii.tinkerer.common.lib.LibEnchantNames;
+import vazkii.tinkerer.common.lib.LibItemIDs;
+import vazkii.tinkerer.common.lib.LibItemNames;
+import cpw.mods.fml.common.Loader;
+
+public final class ConfigHandler {
+
+ private static Configuration config;
+
+ private static final String CATEGORY_POTIONS = "potions";
+ private static final String CATEGORY_ENCHANTMENTS = "enchantments";
+
+ private static final String CATEGORY_KAMI_ITEMS = "item.kami";
+ private static final String CATEGORY_KAMI_BLOCKS = "block.kami";
+ private static final String CATEGORY_KAMI_GENERAL = "general.kami";
+
+ public static boolean enableKami = false;
+ public static boolean useTootlipIndicators = true;
+ public static boolean enableSurvivalShareTome = true;
+ public static boolean enableEasymodeResearch = false;
+ public static boolean useOreDictMetal = true;
+
+ public static boolean showPlacementMirrorBlocks = true;
+ public static int netherDimensionID = -1;
+ public static int endDimensionID = 1;
+
+ public static void loadConfig(File configFile) {
+ config = new Configuration(configFile);
+
+ new ConfigCategory(CATEGORY_POTIONS);
+ new ConfigCategory(CATEGORY_ENCHANTMENTS);
+ new ConfigCategory(CATEGORY_KAMI_ITEMS);
+ new ConfigCategory(CATEGORY_KAMI_BLOCKS);
+ new ConfigCategory(CATEGORY_KAMI_GENERAL);
+
+ String comment = "These will only be used if KAMI is loaded. (KAMI is a separate download you can find in the Thaumic Tinkerer thread)";
+ config.addCustomCategoryComment(CATEGORY_KAMI_ITEMS, comment);
+ config.addCustomCategoryComment(CATEGORY_KAMI_BLOCKS, comment);
+ config.addCustomCategoryComment(CATEGORY_KAMI_GENERAL, comment);
+
+ config.load();
+
+ enableKami = Loader.isModLoaded("ThaumicTinkererKami");
+
+ Property propEnableTooltips = config.get(Configuration.CATEGORY_GENERAL, "tooltipIndicators.enabled", true);
+ propEnableTooltips.comment = "Set to false to disable the [TT] tooltips in the thauminomicon.";
+ useTootlipIndicators = propEnableTooltips.getBoolean(true);
+
+ Property propEnableSurvivalShareTome = config.get(Configuration.CATEGORY_GENERAL, "shareTome.survival.enabled", true);
+ propEnableSurvivalShareTome.comment = "Set to false to disable the crafting recipe for the Tome of Research Sharing.";
+ enableSurvivalShareTome = propEnableSurvivalShareTome.getBoolean(true);
+
+ Property propEasymodeResearch = config.get(Configuration.CATEGORY_GENERAL, "research.easymode.enabled", false);
+ propEasymodeResearch.comment = "Set to true to enable Easy Research (getting research notes = instant discovery). For those who don't like research.";
+ enableEasymodeResearch = propEasymodeResearch.getBoolean(false);
+
+ Property propOreDict = config.get(Configuration.CATEGORY_GENERAL, "oreDictMetal.enabled", true);
+ propOreDict.comment = "Set to false to disable usage of ore dictionary metals (tin and copper).";
+ useOreDictMetal = propOreDict.getBoolean(true);
+
+ if(enableKami) {
+ Property propShowPlacementMirrorBlocks = config.get(CATEGORY_KAMI_GENERAL, "placementMirror.blocks.show", true);
+ propShowPlacementMirrorBlocks.comment = "Set to false to remove the phantom blocks displayed by the Worldshaper's Seeing Glass.";
+ showPlacementMirrorBlocks = propShowPlacementMirrorBlocks.getBoolean(true);
+
+ Property propNetherID = config.get(CATEGORY_KAMI_GENERAL, "dimension.nether.id", -1);
+ propNetherID.comment = "The Dimension ID for the Nether, leave at -1 if you don't modify it with another mod/plugin.";
+ netherDimensionID = propNetherID.getInt(-1);
+
+ Property propEndID = config.get(CATEGORY_KAMI_GENERAL, "dimension.end.id", 1);
+ propEndID.comment = "The Dimension ID for the End, leave at 1 if you don't modify it with another mod/plugin.";
+ endDimensionID = propEndID.getInt(1);
+ }
+
+ LibBlockIDs.idDarkQuartz = loadBlock(LibBlockNames.DARK_QUARTZ, LibBlockIDs.idDarkQuartz);
+ LibBlockIDs.idDarkQuartzSlab = loadBlock(LibBlockNames.DARK_QUARTZ_SLAB, LibBlockIDs.idDarkQuartzSlab);
+ LibBlockIDs.idDarkQuartzSlabFull = loadBlock(LibBlockNames.DARK_QUARTZ_SLAB_FULL, LibBlockIDs.idDarkQuartzSlabFull);
+ LibBlockIDs.idDarkQuartzStairs = loadBlock(LibBlockNames.DARK_QUARTZ_STAIRS, LibBlockIDs.idDarkQuartzStairs);
+ LibBlockIDs.idInterface = loadBlock(LibBlockNames.INTERFACE, LibBlockIDs.idInterface);
+ LibBlockIDs.idGaseousLight = loadBlock(LibBlockNames.GASEOUS_LIGHT, LibBlockIDs.idGaseousLight);
+ LibBlockIDs.idGaseousShadow = loadBlock(LibBlockNames.GASEOUS_SHADOW, LibBlockIDs.idGaseousShadow);
+ LibBlockIDs.idAnimationTablet = loadBlock(LibBlockNames.ANIMATION_TABLET, LibBlockIDs.idAnimationTablet);
+ LibBlockIDs.idNitorGas = loadBlock(LibBlockNames.NITOR_GAS, LibBlockIDs.idNitorGas);
+ LibBlockIDs.idMagnet = loadBlock(LibBlockNames.MAGNET, LibBlockIDs.idMagnet);
+ LibBlockIDs.idEnchanter = loadBlock(LibBlockNames.ENCHANTER, LibBlockIDs.idEnchanter);
+ LibBlockIDs.idFunnel = loadBlock(LibBlockNames.FUNNEL, LibBlockIDs.idFunnel);
+ LibBlockIDs.idDislocator = loadBlock(LibBlockNames.DISLOCATOR, LibBlockIDs.idDislocator);
+ LibBlockIDs.idRepairer = loadBlock(LibBlockNames.REPAIRER, LibBlockIDs.idRepairer);
+ LibBlockIDs.idAspectAnalyzer = loadBlock(LibBlockNames.ASPECT_ANALYZER, LibBlockIDs.idAspectAnalyzer);
+ LibBlockIDs.idPlatform = loadBlock(LibBlockNames.PLATFORM, LibBlockIDs.idPlatform);
+
+ LibBlockIDs.idWarpGate = loadBlock(LibBlockNames.WARP_GATE, LibBlockIDs.idWarpGate);
+
+ LibItemIDs.idDarkQuartz = loadItem(LibItemNames.DARK_QUARTZ, LibItemIDs.idDarkQuartz);
+ LibItemIDs.idConnector = loadItem(LibItemNames.CONNECTOR, LibItemIDs.idConnector);
+ LibItemIDs.idGaseousLight = loadItem(LibItemNames.GASEOUS_LIGHT, LibItemIDs.idGaseousLight);
+ LibItemIDs.idGaseousShadow = loadItem(LibItemNames.GASEOUS_SHADOW, LibItemIDs.idGaseousShadow);
+ LibItemIDs.idGasRemover = loadItem(LibItemNames.GAS_REMOVER, LibItemIDs.idGasRemover);
+ LibItemIDs.idSpellCloth = loadItem(LibItemNames.SPELL_CLOTH, LibItemIDs.idSpellCloth);
+ LibItemIDs.idFocusFlight = loadItem(LibItemNames.FOCUS_FLIGHT, LibItemIDs.idFocusFlight);
+ LibItemIDs.idFocusDislocation = loadItem(LibItemNames.FOCUS_DISLOCATION, LibItemIDs.idFocusDislocation);
+ LibItemIDs.idCleansingTalisman = loadItem(LibItemNames.CLEANSING_TALISMAN, LibItemIDs.idCleansingTalisman);
+ LibItemIDs.idFocusTelekinesis = loadItem(LibItemNames.FOCUS_TELEKINESIS, LibItemIDs.idFocusTelekinesis);
+ LibItemIDs.idBrightNitor = loadItem(LibItemNames.BRIGHT_NTIOR, LibItemIDs.idBrightNitor);
+ LibItemIDs.idSoulMould = loadItem(LibItemNames.SOUL_MOULD, LibItemIDs.idSoulMould);
+ LibItemIDs.idXPTalisman = loadItem(LibItemNames.XP_TALISMAN, LibItemIDs.idXPTalisman);
+ LibItemIDs.idFocusSmelt = loadItem(LibItemNames.FOCUS_SMELT, LibItemIDs.idFocusSmelt);
+ LibItemIDs.idFocusHeal = loadItem(LibItemNames.FOCUS_HEAL, LibItemIDs.idFocusHeal);
+ LibItemIDs.idFocusEnderChest = loadItem(LibItemNames.FOCUS_ENDER_CHEST, LibItemIDs.idFocusEnderChest);
+ LibItemIDs.idBloodSword = loadItem(LibItemNames.BLOOD_SWORD, LibItemIDs.idBloodSword);
+ LibItemIDs.idRevealingHelm = loadItem(LibItemNames.REVEALING_HELM, LibItemIDs.idRevealingHelm);
+ LibItemIDs.idInfusedInkwell = loadItem(LibItemNames.INFUSED_INKWELL, LibItemIDs.idInfusedInkwell);
+ LibItemIDs.idFocusDeflect = loadItem(LibItemNames.FOCUS_DEFLECT, LibItemIDs.idFocusDeflect);
+ LibItemIDs.idShareBook = loadItem(LibItemNames.SHARE_BOOK, LibItemIDs.idShareBook);
+
+ LibItemIDs.idKamiResource = loadKamiItem(LibItemNames.KAMI_RESOURCE, LibItemIDs.idKamiResource);
+ LibItemIDs.idIchorHelm = loadKamiItem(LibItemNames.ICHOR_HELM, LibItemIDs.idIchorHelm);
+ LibItemIDs.idIchorChest = loadKamiItem(LibItemNames.ICHOR_CHEST, LibItemIDs.idIchorChest);
+ LibItemIDs.idIchorLegs = loadKamiItem(LibItemNames.ICHOR_LEGS, LibItemIDs.idIchorLegs);
+ LibItemIDs.idIchorBoots = loadKamiItem(LibItemNames.ICHOR_BOOTS, LibItemIDs.idIchorBoots);
+ LibItemIDs.idIchorHelmGem = loadKamiItem(LibItemNames.ICHOR_HELM_GEM, LibItemIDs.idIchorHelmGem);
+ LibItemIDs.idIchorChestGem = loadKamiItem(LibItemNames.ICHOR_CHEST_GEM, LibItemIDs.idIchorChestGem);
+ LibItemIDs.idIchorLegsGem = loadKamiItem(LibItemNames.ICHOR_LEGS_GEM, LibItemIDs.idIchorLegsGem);
+ LibItemIDs.idIchorBootsGem = loadKamiItem(LibItemNames.ICHOR_BOOTS_GEM, LibItemIDs.idIchorBootsGem);
+ LibItemIDs.idCatAmulet = loadKamiItem(LibItemNames.CAT_AMULET, LibItemIDs.idCatAmulet);
+ LibItemIDs.idIchorPick = loadKamiItem(LibItemNames.ICHOR_PICK, LibItemIDs.idIchorPick);
+ LibItemIDs.idIchorShovel = loadKamiItem(LibItemNames.ICHOR_SHOVEL, LibItemIDs.idIchorShovel);
+ LibItemIDs.idIchorAxe = loadKamiItem(LibItemNames.ICHOR_AXE, LibItemIDs.idIchorAxe);
+ LibItemIDs.idIchorSword = loadKamiItem(LibItemNames.ICHOR_SWORD, LibItemIDs.idIchorSword);
+ LibItemIDs.idIchorPickGem = loadKamiItem(LibItemNames.ICHOR_PICK_GEM, LibItemIDs.idIchorPickGem);
+ LibItemIDs.idIchorShovelGem = loadKamiItem(LibItemNames.ICHOR_SHOVEL_GEM, LibItemIDs.idIchorShovelGem);
+ LibItemIDs.idIchorAxeGem = loadKamiItem(LibItemNames.ICHOR_AXE_GEM, LibItemIDs.idIchorAxeGem);
+ LibItemIDs.idIchorSwordGem = loadKamiItem(LibItemNames.ICHOR_SWORD_GEM, LibItemIDs.idIchorSwordGem);
+ LibItemIDs.idIchorPouch = loadKamiItem(LibItemNames.ICHOR_POUCH, LibItemIDs.idIchorPouch);
+ LibItemIDs.idBlockTalisman = loadKamiItem(LibItemNames.BLOCK_TALISMAN, LibItemIDs.idBlockTalisman);
+ LibItemIDs.idPlacementMirror = loadKamiItem(LibItemNames.PLACEMENT_MIRROR, LibItemIDs.idPlacementMirror);
+ LibItemIDs.idFocusShadowbeam = loadKamiItem(LibItemNames.FOCUS_SHADOWBEAM, LibItemIDs.idFocusShadowbeam);
+ LibItemIDs.idFocusXPDrain = loadKamiItem(LibItemNames.FOCUS_XP_DRAIN, LibItemIDs.idFocusXPDrain);
+ LibItemIDs.idProtoclay = loadKamiItem(LibItemNames.PROTOCLAY, LibItemIDs.idProtoclay);
+ LibItemIDs.idSkyPearl = loadKamiItem(LibItemNames.SKY_PEARL, LibItemIDs.idSkyPearl);
+ LibItemIDs.idFocusRecall = loadKamiItem(LibItemNames.FOCUS_RECALL, LibItemIDs.idFocusRecall);
+
+ LibEnchantIDs.idAscentBoost = loadEnchant(LibEnchantNames.ASCENT_BOOST, LibEnchantIDs.idAscentBoost);
+ LibEnchantIDs.idSlowFall = loadEnchant(LibEnchantNames.SLOW_FALL, LibEnchantIDs.idSlowFall);
+ LibEnchantIDs.idAutoSmelt = loadEnchant(LibEnchantNames.AUTO_SMELT, LibEnchantIDs.idAutoSmelt);
+ LibEnchantIDs.idDesintegrate = loadEnchant(LibEnchantNames.DESINTEGRATE, LibEnchantIDs.idDesintegrate);
+ LibEnchantIDs.idQuickDraw = loadEnchant(LibEnchantNames.QUICK_DRAW, LibEnchantIDs.idQuickDraw);
+ LibEnchantIDs.idVampirism = loadEnchant(LibEnchantNames.VAMPIRISM, LibEnchantIDs.idVampirism);
+
+ config.save();
+ }
+
+ private static int loadItem(String label, int defaultID) {
+ return config.getItem("id_item." + label, defaultID).getInt(defaultID);
+ }
+
+ private static int loadKamiItem(String label, int defaultID) {
+ return config.getItem(CATEGORY_KAMI_ITEMS, "id_item." + label, defaultID).getInt(defaultID);
+ }
+
+ private static int loadBlock(String label, int defaultID) {
+ return config.getBlock("id_tile." + label, defaultID).getInt(defaultID);
+ }
+
+ private static int loadEnchant(String label, int deafultID) {
+ return config.get(CATEGORY_ENCHANTMENTS, "id_enchant." + label, deafultID).getInt(deafultID);
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/core/handler/EasymodeResearchHandler.java b/src/main/java/vazkii/tinkerer/common/core/handler/EasymodeResearchHandler.java
new file mode 100644
index 00000000..ba973407
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/core/handler/EasymodeResearchHandler.java
@@ -0,0 +1,73 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Jan 10, 2014, 1:59:51 PM (GMT)]
+ */
+package vazkii.tinkerer.common.core.handler;
+
+import java.util.EnumSet;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import thaumcraft.common.container.ContainerResearchTable;
+import thaumcraft.common.items.ItemResearchNotes;
+import thaumcraft.common.lib.research.ResearchManager;
+import thaumcraft.common.lib.research.ResearchNoteData;
+import cpw.mods.fml.common.ITickHandler;
+import cpw.mods.fml.common.TickType;
+
+public class EasymodeResearchHandler implements ITickHandler {
+
+ public static void onPlayerTick(EntityPlayer player) {
+ if(player != null && player.openContainer != null && player.openContainer instanceof ContainerResearchTable) {
+ ContainerResearchTable researchContainer = (ContainerResearchTable) player.openContainer;
+ ItemStack notes = researchContainer.tileEntity.getStackInSlot(2);
+ if(notes != null && notes.getItem() instanceof ItemResearchNotes) {
+ ResearchNoteData data = ResearchManager.getData(notes);
+ boolean didAny = false;
+
+ if(data != null && data.grid != null)
+ for(int i = 0; i < 15; i++)
+ for(int j = 0; j < 15; j++)
+ if(data.grid[i][j].equals("O")) {
+ data.grid[i][j] = "S";
+ didAny = true;
+ }
+
+ if(didAny)
+ ResearchManager.updateData(notes, data);
+ researchContainer.tileEntity.setInventorySlotContents(2, notes.copy());
+ }
+ }
+ }
+
+ @Override
+ public void tickStart(EnumSet type, Object... tickData) {
+ // NO-OP
+ }
+
+ @Override
+ public void tickEnd(EnumSet type, Object... tickData) {
+ onPlayerTick((EntityPlayer) tickData[0]);
+ }
+
+ @Override
+ public EnumSet ticks() {
+ return EnumSet.of(TickType.PLAYER);
+ }
+
+ @Override
+ public String getLabel() {
+ return "TT_Easymode";
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/core/handler/ModCreativeTab.java b/src/main/java/vazkii/tinkerer/common/core/handler/ModCreativeTab.java
new file mode 100644
index 00000000..e919bf09
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/core/handler/ModCreativeTab.java
@@ -0,0 +1,163 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 15:48:07 (GMT)]
+ */
+package vazkii.tinkerer.common.core.handler;
+
+import java.util.List;
+
+import net.minecraft.block.Block;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.common.config.ConfigItems;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import vazkii.tinkerer.common.block.ModBlocks;
+import vazkii.tinkerer.common.item.ModItems;
+import vazkii.tinkerer.common.lib.LibMisc;
+import cpw.mods.fml.common.Loader;
+
+public class ModCreativeTab extends CreativeTabs {
+
+ public static ModCreativeTab INSTANCE = new ModCreativeTab();
+ ItemStack displayItem;
+ List list;
+
+ public ModCreativeTab() {
+ super(LibMisc.MOD_ID);
+ }
+
+ @Override
+ public ItemStack getIconItemStack() {
+ if(displayItem == null)
+ addWand();
+
+ return displayItem;
+ }
+
+ @Override
+ public void displayAllReleventItems(List list) {
+ this.list = list;
+
+ addWand();
+
+ addItem(ModItems.darkQuartz);
+ addBlock(ModBlocks.darkQuartz);
+ addBlock(ModBlocks.darkQuartzStairs);
+ addBlock(ModBlocks.darkQuartzSlab);
+
+ addItem(ModItems.connector);
+ addBlock(ModBlocks.interfase);
+ addBlock(ModBlocks.dislocator);
+
+ addBlock(ModBlocks.funnel);
+ addBlock(ModBlocks.platform);
+ addBlock(ModBlocks.repairer);
+ addBlock(ModBlocks.magnet);
+ addItem(ModItems.soulMould);
+ addBlock(ModBlocks.animationTablet);
+
+ if(Loader.isModLoaded("ComputerCraft"))
+ addBlock(ModBlocks.aspectAnalyzer);
+
+ if(ConfigHandler.enableKami) {
+ addBlock(ModBlocks.warpGate);
+ }
+
+ addItem(ModItems.gaseousLight);
+ addItem(ModItems.gaseousShadow);
+ addItem(ModItems.gasRemover);
+
+ addItem(ModItems.revealingHelm);
+ addItem(ModItems.cleansingTalisman);
+ addItem(ModItems.bloodSword);
+ addItem(ModItems.brightNitor);
+ addItem(ModItems.shareBook);
+
+ addItem(ModItems.focusFlight);
+ addItem(ModItems.focusDislocation);
+ addItem(ModItems.focusTelekinesis);
+ addItem(ModItems.focusDeflect);
+ addItem(ModItems.focusSmelt);
+ addItem(ModItems.focusHeal);
+ addItem(ModItems.focusEnderChest);
+
+ addBlock(ModBlocks.enchanter);
+ addItem(ModItems.xpTalisman);
+ addItem(ModItems.spellCloth);
+
+ if(ConfigHandler.enableKami) {
+ addItem(ModItems.kamiResource);
+
+ addItem(ModItems.ichorHelm);
+ addItem(ModItems.ichorHelmGem);
+ addItem(ModItems.ichorChest);
+ addItem(ModItems.ichorChestGem);
+ addItem(ModItems.ichorLegs);
+ addItem(ModItems.ichorLegsGem);
+ addItem(ModItems.ichorBoots);
+ addItem(ModItems.ichorBootsGem);
+
+ addItem(ModItems.ichorPick);
+ addItem(ModItems.ichorPickGem);
+ addItem(ModItems.ichorShovel);
+ addItem(ModItems.ichorShovelGem);
+ addItem(ModItems.ichorAxe);
+ addItem(ModItems.ichorAxeGem);
+ addItem(ModItems.ichorSword);
+ addItem(ModItems.ichorSwordGem);
+
+ addItem(ModItems.focusShadowbeam);
+ addItem(ModItems.focusXPDrain);
+ addItem(ModItems.focusRecall);
+
+ addItem(ModItems.ichorPouch);
+ addItem(ModItems.catAmulet);
+ addItem(ModItems.blockTalisman);
+ addItem(ModItems.placementMirror);
+ addItem(ModItems.protoclay);
+ addItem(ModItems.skyPearl);
+ }
+ }
+
+ private void addWand() {
+ ItemStack wand = new ItemStack(ConfigItems.itemWandCasting);
+ ((ItemWandCasting) wand.getItem()).setRod(wand, ConfigItems.WAND_ROD_SILVERWOOD);
+ ((ItemWandCasting) wand.getItem()).setCap(wand, ConfigItems.WAND_CAP_THAUMIUM);
+ ((ItemWandCasting) wand.getItem()).storeAllVis(wand, new AspectList().add(Aspect.AIR, 10000).add(Aspect.EARTH, 10000).add(Aspect.FIRE, 10000).add(Aspect.WATER, 10000).add(Aspect.ORDER, 10000).add(Aspect.ENTROPY, 10000));
+ if(list != null)
+ list.add(wand);
+ displayItem = wand;
+
+ if(ConfigHandler.enableKami) {
+ ItemStack wand1 = new ItemStack(ConfigItems.itemWandCasting);
+ ((ItemWandCasting) wand1.getItem()).setRod(wand1, ModItems.rodIchorcloth);
+ ((ItemWandCasting) wand1.getItem()).setCap(wand1, ModItems.capIchor);
+ ((ItemWandCasting) wand1.getItem()).storeAllVis(wand1, new AspectList().add(Aspect.AIR, 100000).add(Aspect.EARTH, 100000).add(Aspect.FIRE, 100000).add(Aspect.WATER, 100000).add(Aspect.ORDER, 100000).add(Aspect.ENTROPY, 100000));
+ if(list != null)
+ list.add(wand1);
+ displayItem = wand1;
+ }
+ }
+
+ private void addItem(Item item) {
+ item.getSubItems(item.itemID, this, list);
+ }
+
+ private void addBlock(Block block) {
+ block.getSubBlocks(block.blockID, this, list);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/core/handler/kami/DimensionalShardDropHandler.java b/src/main/java/vazkii/tinkerer/common/core/handler/kami/DimensionalShardDropHandler.java
new file mode 100644
index 00000000..3298431f
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/core/handler/kami/DimensionalShardDropHandler.java
@@ -0,0 +1,39 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 27, 2013, 11:05:53 PM (GMT)]
+ */
+package vazkii.tinkerer.common.core.handler.kami;
+
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.monster.EntityEnderman;
+import net.minecraft.entity.monster.EntityPigZombie;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.event.ForgeSubscribe;
+import net.minecraftforge.event.entity.living.LivingDropsEvent;
+import vazkii.tinkerer.common.core.handler.ConfigHandler;
+import vazkii.tinkerer.common.item.ModItems;
+
+public class DimensionalShardDropHandler {
+
+ @ForgeSubscribe
+ public void onEntityLivingDrops(LivingDropsEvent event) {
+ if(event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) {
+ if(event.entityLiving instanceof EntityEnderman && event.entityLiving.dimension == ConfigHandler.endDimensionID && Math.random() <= 1D / 32D)
+ event.drops.add(new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, new ItemStack(ModItems.kamiResource, 1, 7)));
+
+ if(event.entityLiving instanceof EntityPigZombie && event.entityLiving.dimension == ConfigHandler.netherDimensionID && Math.random() <= 1D / 16D)
+ event.drops.add(new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, new ItemStack(ModItems.kamiResource, 1, 6)));
+ }
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/core/handler/kami/SoulHeartHandler.java b/src/main/java/vazkii/tinkerer/common/core/handler/kami/SoulHeartHandler.java
new file mode 100644
index 00000000..559fd309
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/core/handler/kami/SoulHeartHandler.java
@@ -0,0 +1,133 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 9:33:23 PM (GMT)]
+ */
+package vazkii.tinkerer.common.core.handler.kami;
+
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.potion.Potion;
+import net.minecraft.util.DamageSource;
+import net.minecraftforge.event.ForgeSubscribe;
+import net.minecraftforge.event.entity.living.LivingHurtEvent;
+import vazkii.tinkerer.common.lib.LibMisc;
+import vazkii.tinkerer.common.network.PacketManager;
+import vazkii.tinkerer.common.network.packet.kami.PacketSoulHearts;
+import cpw.mods.fml.common.network.PacketDispatcher;
+import cpw.mods.fml.common.network.Player;
+
+public class SoulHeartHandler {
+
+ private static final String COMPOUND = LibMisc.MOD_ID;
+ private static final String TAG_HP = "soulHearts";
+ private static final int MAX_HP = 20;
+
+ @ForgeSubscribe
+ public void onPlayerDamage(LivingHurtEvent event) {
+ if(event.entityLiving instanceof EntityPlayer && event.ammount > 0) {
+ EntityPlayer player = (EntityPlayer) event.entityLiving;
+ event.ammount = removeHP(player, (int) event.ammount);
+ updateClient(player);
+ }
+ }
+
+ public static void addHearts(EntityPlayer player) {
+ addHP(player, 1);
+ updateClient(player);
+ }
+
+ public static boolean addHP(EntityPlayer player, int hp) {
+ int current = getHP(player);
+ if(current >= MAX_HP)
+ return false;
+
+ setHP(player, Math.min(MAX_HP, current + hp));
+ return true;
+ }
+
+ // Returns overflow damage
+ public static int removeHP(EntityPlayer player, int hp) {
+ int current = getHP(player);
+ int newHp = current - hp;
+ setHP(player, Math.max(0, newHp));
+
+ return Math.max(0, -newHp);
+ }
+
+ public static void setHP(EntityPlayer player, int hp) {
+ NBTTagCompound cmp = getCompoundToSet(player);
+ cmp.setInteger(TAG_HP, hp);
+ }
+
+ public static int getHP(EntityPlayer player) {
+ NBTTagCompound cmp = getCompoundToSet(player);
+ return cmp.hasKey(TAG_HP) ? cmp.getInteger(TAG_HP) : 0;
+ }
+
+ private static NBTTagCompound getCompoundToSet(EntityPlayer player) {
+ NBTTagCompound cmp = player.getEntityData();
+ if(!cmp.hasKey(COMPOUND))
+ cmp.setCompoundTag(COMPOUND, new NBTTagCompound());
+
+ return cmp.getCompoundTag(COMPOUND);
+ }
+
+ public static void updateClient(EntityPlayer player) {
+ PacketDispatcher.sendPacketToPlayer(PacketManager.buildPacket(new PacketSoulHearts(getHP(player))), (Player) player);
+ }
+
+ // =============== METHODS COPIED FROM ENTITYLIVING ==================== //
+
+ protected float applyArmorCalculations(EntityLivingBase entity, DamageSource par1DamageSource, float par2) {
+ if (!par1DamageSource.isUnblockable()) {
+ int i = 25 - entity.getTotalArmorValue();
+ float f1 = par2 * i;
+ // this.damageArmor(par2);
+ par2 = f1 / 25.0F;
+ }
+
+ return par2;
+ }
+
+ protected float applyPotionDamageCalculations(EntityLivingBase entity, DamageSource par1DamageSource, float par2) {
+ int i;
+ int j;
+ float f1;
+
+ if (entity.isPotionActive(Potion.resistance) && par1DamageSource != DamageSource.outOfWorld) {
+ i = (entity.getActivePotionEffect(Potion.resistance).getAmplifier() + 1) * 5;
+ j = 25 - i;
+ f1 = par2 * j;
+ par2 = f1 / 25.0F;
+ }
+
+ if (par2 <= 0.0F)
+ return 0.0F;
+ else {
+ i = EnchantmentHelper.getEnchantmentModifierDamage(entity.getLastActiveItems(), par1DamageSource);
+
+ if (i > 20)
+ i = 20;
+
+ if (i > 0 && i <= 20) {
+ j = 25 - i;
+ f1 = par2 * j;
+ par2 = f1 / 25.0F;
+ }
+
+ return par2;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/core/handler/updater/ThreadUpdateChecker.java b/src/main/java/vazkii/tinkerer/common/core/handler/updater/ThreadUpdateChecker.java
new file mode 100644
index 00000000..6eae6d6d
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/core/handler/updater/ThreadUpdateChecker.java
@@ -0,0 +1,25 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [3 Oct 2013, 21:36:13 (GMT)]
+ */
+package vazkii.tinkerer.common.core.handler.updater;
+
+public class ThreadUpdateChecker extends Thread {
+
+ boolean checkBuilds;
+
+ public ThreadUpdateChecker(boolean checkBuilds) {
+
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/core/handler/updater/UpdateHandler.java b/src/main/java/vazkii/tinkerer/common/core/handler/updater/UpdateHandler.java
new file mode 100644
index 00000000..a84f935b
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/core/handler/updater/UpdateHandler.java
@@ -0,0 +1,24 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [3 Oct 2013, 21:35:22 (GMT)]
+ */
+package vazkii.tinkerer.common.core.handler.updater;
+
+public final class UpdateHandler {
+
+ public static void initChecking(int type) {
+ if(type == 0)
+ return;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/core/helper/ExperienceHelper.java b/src/main/java/vazkii/tinkerer/common/core/helper/ExperienceHelper.java
new file mode 100644
index 00000000..a5e2edc0
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/core/helper/ExperienceHelper.java
@@ -0,0 +1,43 @@
+package vazkii.tinkerer.common.core.helper;
+
+import net.minecraft.entity.player.EntityPlayer;
+
+// From OpenBlocksLib: https://github.com/OpenMods/OpenModsLib
+public class ExperienceHelper {
+
+ public static int getPlayerXP(EntityPlayer player) {
+ return (int)(getExperienceForLevel(player.experienceLevel) + player.experience * player.xpBarCap());
+}
+
+ public static void drainPlayerXP(EntityPlayer player, int amount) {
+ addPlayerXP(player, -amount);
+ }
+
+ public static void addPlayerXP(EntityPlayer player, int amount) {
+ int experience = getPlayerXP(player) + amount;
+ player.experienceTotal = experience;
+ player.experienceLevel = getLevelForExperience(experience);
+ int expForLevel = getExperienceForLevel(player.experienceLevel);
+ player.experience = (float)(experience - expForLevel) / (float)player.xpBarCap();
+ }
+
+ public static int getExperienceForLevel(int level) {
+ if (level == 0) { return 0; }
+ if (level > 0 && level < 16) {
+ return level * 17;
+ } else if (level > 15 && level < 31) {
+ return (int)(1.5 * Math.pow(level, 2) - 29.5 * level + 360);
+ } else {
+ return (int)(3.5 * Math.pow(level, 2) - 151.5 * level + 2220);
+ }
+ }
+
+ public static int getLevelForExperience(int experience) {
+ int i = 0;
+ while (getExperienceForLevel(i) <= experience) {
+ i++;
+ }
+ return i - 1;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/core/helper/ItemNBTHelper.java b/src/main/java/vazkii/tinkerer/common/core/helper/ItemNBTHelper.java
new file mode 100644
index 00000000..8d0121ba
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/core/helper/ItemNBTHelper.java
@@ -0,0 +1,135 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 19:36:25 (GMT)]
+ */
+package vazkii.tinkerer.common.core.helper;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public final class ItemNBTHelper {
+
+ /** Checks if an ItemStack has a Tag Compound **/
+ public static boolean detectNBT(ItemStack stack) {
+ return stack.hasTagCompound();
+ }
+
+ /** Tries to initialize an NBT Tag Compound in an ItemStack,
+ * this will not do anything if the stack already has a tag
+ * compound **/
+ public static void initNBT(ItemStack stack) {
+ if(!detectNBT(stack))
+ injectNBT(stack, new NBTTagCompound());
+ }
+
+ /** Injects an NBT Tag Compound to an ItemStack, no checks
+ * are made previously **/
+ public static void injectNBT(ItemStack stack, NBTTagCompound nbt) {
+ stack.setTagCompound(nbt);
+ }
+
+ /** Gets the NBTTagCompound in an ItemStack. Tries to init it
+ * previously in case there isn't one present **/
+ public static NBTTagCompound getNBT(ItemStack stack) {
+ initNBT(stack);
+ return stack.getTagCompound();
+ }
+
+ // SETTERS ///////////////////////////////////////////////////////////////////
+
+ public static void setBoolean(ItemStack stack, String tag, boolean b) {
+ getNBT(stack).setBoolean(tag, b);
+ }
+
+ public static void setByte(ItemStack stack, String tag, byte b) {
+ getNBT(stack).setByte(tag, b);
+ }
+
+ public static void setShort(ItemStack stack, String tag, short s) {
+ getNBT(stack).setShort(tag, s);
+ }
+
+ public static void setInt(ItemStack stack, String tag, int i) {
+ getNBT(stack).setInteger(tag, i);
+ }
+
+ public static void setLong(ItemStack stack, String tag, long l) {
+ getNBT(stack).setLong(tag, l);
+ }
+
+ public static void setFloat(ItemStack stack, String tag, float f) {
+ getNBT(stack).setFloat(tag, f);
+ }
+
+ public static void setDouble(ItemStack stack, String tag, double d) {
+ getNBT(stack).setDouble(tag, d);
+ }
+
+ public static void setCompound(ItemStack stack, String tag, NBTTagCompound cmp) {
+ if(!tag.equalsIgnoreCase("ench")) // not override the enchantments
+ getNBT(stack).setCompoundTag(tag, cmp);
+ }
+
+ public static void setCompound(ItemStack stack, NBTTagCompound cmp) {
+ setCompound(stack, cmp.getName(), cmp);
+ }
+
+ public static void setString(ItemStack stack, String tag, String s) {
+ getNBT(stack).setString(tag, s);
+ }
+
+ // GETTERS ///////////////////////////////////////////////////////////////////
+
+ public static boolean verifyExistance(ItemStack stack, String tag) {
+ return getNBT(stack).hasKey(tag);
+ }
+
+ public static boolean getBoolean(ItemStack stack, String tag, boolean defaultExpected) {
+ return verifyExistance(stack, tag) ? getNBT(stack).getBoolean(tag) : defaultExpected;
+ }
+
+ public static byte getByte(ItemStack stack, String tag, byte defaultExpected) {
+ return verifyExistance(stack, tag) ? getNBT(stack).getByte(tag) : defaultExpected;
+ }
+
+ public static short getShort(ItemStack stack, String tag, short defaultExpected) {
+ return verifyExistance(stack, tag) ? getNBT(stack).getShort(tag) : defaultExpected;
+ }
+
+ public static int getInt(ItemStack stack, String tag, int defaultExpected) {
+ return verifyExistance(stack, tag) ? getNBT(stack).getInteger(tag) : defaultExpected;
+ }
+
+ public static long getLong(ItemStack stack, String tag, long defaultExpected) {
+ return verifyExistance(stack, tag) ? getNBT(stack).getLong(tag) : defaultExpected;
+ }
+
+ public static float getFloat(ItemStack stack, String tag, float defaultExpected) {
+ return verifyExistance(stack, tag) ? getNBT(stack).getFloat(tag) : defaultExpected;
+ }
+
+ public static double getDouble(ItemStack stack, String tag, double defaultExpected) {
+ return verifyExistance(stack, tag) ? getNBT(stack).getDouble(tag) : defaultExpected;
+ }
+
+ /** If nullifyOnFail is true it'll return null if it doesn't find any
+ * compounds, otherwise it'll return a new one. **/
+ public static NBTTagCompound getCompound(ItemStack stack, String tag, boolean nullifyOnFail) {
+ return verifyExistance(stack, tag) ? getNBT(stack).getCompoundTag(tag) : nullifyOnFail ? null : new NBTTagCompound();
+ }
+
+ public static String getString(ItemStack stack, String tag, String defaultExpected) {
+ return verifyExistance(stack, tag) ? getNBT(stack).getString(tag) : defaultExpected;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/core/helper/MiscHelper.java b/src/main/java/vazkii/tinkerer/common/core/helper/MiscHelper.java
new file mode 100644
index 00000000..f4b9cfa8
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/core/helper/MiscHelper.java
@@ -0,0 +1,64 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 01:29:47 (GMT)]
+ */
+package vazkii.tinkerer.common.core.helper;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.server.MinecraftServer;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.client.codechicken.core.vec.Vector3;
+
+public final class MiscHelper {
+
+ public static double pointDistanceSpace(double x1, double y1, double z1, double x2, double y2, double z2) {
+ return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2) + Math.pow(z1 - z2, 2));
+ }
+
+ public static MinecraftServer server() {
+ return MinecraftServer.getServer();
+ }
+
+ public static void setEntityMotionFromVector(Entity entity, Vector3 originalPosVector, float modifier) {
+ Vector3 entityVector = Vector3.fromEntityCenter(entity);
+ Vector3 finalVector = originalPosVector.copy().subtract(entityVector);
+
+ if(finalVector.mag() > 1)
+ finalVector.normalize();
+
+ entity.motionX = finalVector.x * modifier;
+ entity.motionY = finalVector.y * modifier;
+ entity.motionZ = finalVector.z * modifier;
+ }
+
+ public static AspectList multiplyAspectList(AspectList list, double multiplier) {
+ AspectList newList = list.copy();
+ if(multiplier == 1)
+ return newList;
+
+ for(Aspect aspect : newList.aspects.keySet())
+ newList.aspects.put(aspect, (int) ((double) newList.aspects.get(aspect) * multiplier));
+
+ return newList;
+ }
+
+ public static void printCurrentStackTrace(String message) {
+ if(message != null)
+ System.out.println(message);
+
+ for(StackTraceElement element : Thread.currentThread().getStackTrace())
+ System.out.println(element);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/core/helper/Tuple4Int.java b/src/main/java/vazkii/tinkerer/common/core/helper/Tuple4Int.java
new file mode 100644
index 00000000..82b49b2a
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/core/helper/Tuple4Int.java
@@ -0,0 +1,28 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [16 Sep 2013, 23:02:49 (GMT)]
+ */
+package vazkii.tinkerer.common.core.helper;
+
+public class Tuple4Int {
+
+ public int i1, i2, i3, i4;
+
+ public Tuple4Int(int i1, int i2, int i3, int i4) {
+ this.i1 = i1;
+ this.i2 = i2;
+ this.i3 = i3;
+ this.i4 = i4;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/core/proxy/TTCommonProxy.java b/src/main/java/vazkii/tinkerer/common/core/proxy/TTCommonProxy.java
new file mode 100644
index 00000000..af2c7f4f
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/core/proxy/TTCommonProxy.java
@@ -0,0 +1,119 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [4 Sep 2013, 16:29:41 (GMT)]
+ */
+package vazkii.tinkerer.common.core.proxy;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.world.World;
+import net.minecraftforge.common.MinecraftForge;
+import thaumcraft.common.tiles.TileAlembic;
+import thaumcraft.common.tiles.TileArcaneBore;
+import thaumcraft.common.tiles.TileCentrifuge;
+import thaumcraft.common.tiles.TileCrucible;
+import thaumcraft.common.tiles.TileDeconstructionTable;
+import thaumcraft.common.tiles.TileInfusionMatrix;
+import thaumcraft.common.tiles.TileJarBrain;
+import thaumcraft.common.tiles.TileJarFillable;
+import thaumcraft.common.tiles.TileJarNode;
+import thaumcraft.common.tiles.TileNode;
+import thaumcraft.common.tiles.TileSensor;
+import thaumcraft.common.tiles.TileTubeFilter;
+import thaumcraft.common.tiles.TileWandPedestal;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.block.ModBlocks;
+import vazkii.tinkerer.common.block.tile.TileFunnel;
+import vazkii.tinkerer.common.block.tile.TileRepairer;
+import vazkii.tinkerer.common.block.tile.peripheral.PeripheralHandler;
+import vazkii.tinkerer.common.block.tile.transvector.TileTransvectorInterface;
+import vazkii.tinkerer.common.core.handler.ConfigHandler;
+import vazkii.tinkerer.common.core.handler.EasymodeResearchHandler;
+import vazkii.tinkerer.common.core.handler.kami.DimensionalShardDropHandler;
+import vazkii.tinkerer.common.core.handler.kami.SoulHeartHandler;
+import vazkii.tinkerer.common.enchantment.ModEnchantments;
+import vazkii.tinkerer.common.enchantment.core.EnchantmentManager;
+import vazkii.tinkerer.common.item.ModItems;
+import vazkii.tinkerer.common.network.GuiHandler;
+import vazkii.tinkerer.common.network.PlayerTracker;
+import vazkii.tinkerer.common.potion.ModPotions;
+import vazkii.tinkerer.common.research.ModRecipes;
+import vazkii.tinkerer.common.research.ModResearch;
+import cpw.mods.fml.common.event.FMLInitializationEvent;
+import cpw.mods.fml.common.event.FMLPostInitializationEvent;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import cpw.mods.fml.common.network.NetworkRegistry;
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.common.registry.TickRegistry;
+import cpw.mods.fml.relauncher.Side;
+import dan200.computer.api.ComputerCraftAPI;
+import dan200.computer.api.IPeripheralHandler;
+
+public class TTCommonProxy {
+
+ public void preInit(FMLPreInitializationEvent event) {
+ ConfigHandler.loadConfig(event.getSuggestedConfigurationFile());
+
+ ModBlocks.initBlocks();
+ ModItems.initItems();
+
+ initCCPeripherals();
+ }
+
+ public void init(FMLInitializationEvent event) {
+ ModEnchantments.initEnchantments();
+ EnchantmentManager.initEnchantmentData();
+ ModPotions.initPotions();
+ ModBlocks.initTileEntities();
+ NetworkRegistry.instance().registerGuiHandler(ThaumicTinkerer.instance, new GuiHandler());
+ GameRegistry.registerPlayerTracker(new PlayerTracker());
+
+ if(ConfigHandler.enableEasymodeResearch)
+ TickRegistry.registerTickHandler(new EasymodeResearchHandler(), Side.SERVER);
+
+ if(ConfigHandler.enableKami) {
+ MinecraftForge.EVENT_BUS.register(new DimensionalShardDropHandler());
+ MinecraftForge.EVENT_BUS.register(new SoulHeartHandler());
+ }
+ }
+
+ public void postInit(FMLPostInitializationEvent event) {
+ ModRecipes.initRecipes();
+ ModResearch.initResearch();
+ }
+
+ protected void initCCPeripherals() {
+ IPeripheralHandler handler = new PeripheralHandler();
+
+ Class[] peripheralClasses = new Class[] {
+ TileAlembic.class, TileCentrifuge.class, TileCrucible.class, TileFunnel.class,
+ TileInfusionMatrix.class, TileJarFillable.class, TileJarNode.class, TileNode.class,
+ TileRepairer.class, TileTubeFilter.class, TileTransvectorInterface.class, TileWandPedestal.class,
+ TileDeconstructionTable.class, TileJarBrain.class, TileSensor.class, TileArcaneBore.class
+ };
+
+ for(Class clazz : peripheralClasses)
+ ComputerCraftAPI.registerExternalPeripheral(clazz, handler);
+ }
+
+ public boolean isClient() {
+ return false;
+ }
+
+ public EntityPlayer getClientPlayer() {
+ return null;
+ }
+
+ public void shadowSparkle(World world, float x, float y, float z, int size) {
+ // NO-OP
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentAscentBoost.java b/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentAscentBoost.java
new file mode 100644
index 00000000..c95deb5c
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentAscentBoost.java
@@ -0,0 +1,25 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [29 Sep 2013, 11:50:08 (GMT)]
+ */
+package vazkii.tinkerer.common.enchantment;
+
+import net.minecraft.enchantment.EnumEnchantmentType;
+
+public class EnchantmentAscentBoost extends EnchantmentMod {
+
+ protected EnchantmentAscentBoost(int par1) {
+ super(par1, 4, EnumEnchantmentType.armor_legs);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentAutoSmelt.java b/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentAutoSmelt.java
new file mode 100644
index 00000000..34e0387b
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentAutoSmelt.java
@@ -0,0 +1,39 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [29 Sep 2013, 15:16:03 (GMT)]
+ */
+package vazkii.tinkerer.common.enchantment;
+
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.enchantment.EnumEnchantmentType;
+import net.minecraft.item.ItemStack;
+import thaumcraft.common.config.Config;
+import thaumcraft.common.config.ConfigItems;
+
+public class EnchantmentAutoSmelt extends EnchantmentMod {
+
+ protected EnchantmentAutoSmelt(int par1) {
+ super(par1, 1, EnumEnchantmentType.digger);
+ }
+
+ @Override
+ public boolean canApplyTogether(Enchantment par1Enchantment) {
+ return par1Enchantment.effectId == Enchantment.unbreaking.effectId || par1Enchantment.effectId == Config.enchRepair.effectId;
+ }
+
+ @Override
+ public boolean canApply(ItemStack par1ItemStack) {
+ return super.canApply(par1ItemStack) && par1ItemStack.itemID != ConfigItems.itemAxeElemental.itemID;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentDesintegrate.java b/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentDesintegrate.java
new file mode 100644
index 00000000..b2426eee
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentDesintegrate.java
@@ -0,0 +1,31 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [29 Sep 2013, 15:13:35 (GMT)]
+ */
+package vazkii.tinkerer.common.enchantment;
+
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.enchantment.EnumEnchantmentType;
+import thaumcraft.common.config.Config;
+
+public class EnchantmentDesintegrate extends EnchantmentMod {
+
+ protected EnchantmentDesintegrate(int par1) {
+ super(par1, 1, EnumEnchantmentType.digger);
+ }
+
+ @Override
+ public boolean canApplyTogether(Enchantment par1Enchantment) {
+ return par1Enchantment.effectId == Enchantment.unbreaking.effectId || par1Enchantment.effectId == Config.enchRepair.effectId;
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentMod.java b/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentMod.java
new file mode 100644
index 00000000..c04ecf10
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentMod.java
@@ -0,0 +1,40 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [29 Sep 2013, 11:48:50 (GMT)]
+ */
+package vazkii.tinkerer.common.enchantment;
+
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.enchantment.EnumEnchantmentType;
+import net.minecraft.item.ItemStack;
+
+public class EnchantmentMod extends Enchantment {
+
+ int maxLevel;
+
+ protected EnchantmentMod(int par1, int max, EnumEnchantmentType par3EnumEnchantmentType) {
+ super(par1, 0, par3EnumEnchantmentType);
+ maxLevel = max;
+ }
+
+ @Override
+ public boolean canApplyAtEnchantingTable(ItemStack stack) {
+ return false;
+ }
+
+ @Override
+ public int getMaxLevel() {
+ return maxLevel;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentQuickDraw.java b/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentQuickDraw.java
new file mode 100644
index 00000000..0fe236d4
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentQuickDraw.java
@@ -0,0 +1,31 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [29 Sep 2013, 15:18:09 (GMT)]
+ */
+package vazkii.tinkerer.common.enchantment;
+
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.enchantment.EnumEnchantmentType;
+
+public class EnchantmentQuickDraw extends EnchantmentMod {
+
+ protected EnchantmentQuickDraw(int par1) {
+ super(par1, 2, EnumEnchantmentType.bow);
+ }
+
+ @Override
+ public boolean canApplyTogether(Enchantment par1Enchantment) {
+ return par1Enchantment.effectId != Enchantment.punch.effectId;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentSlowFall.java b/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentSlowFall.java
new file mode 100644
index 00000000..c8b9be20
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentSlowFall.java
@@ -0,0 +1,37 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [29 Sep 2013, 11:58:52 (GMT)]
+ */
+package vazkii.tinkerer.common.enchantment;
+
+import vazkii.tinkerer.common.item.kami.armor.ItemGemBoots;
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.enchantment.EnumEnchantmentType;
+import net.minecraft.item.ItemStack;
+
+public class EnchantmentSlowFall extends EnchantmentMod {
+
+ protected EnchantmentSlowFall(int par1) {
+ super(par1, 3, EnumEnchantmentType.armor_feet);
+ }
+
+ @Override
+ public boolean canApplyTogether(Enchantment par1Enchantment) {
+ return par1Enchantment.effectId != Enchantment.featherFalling.effectId;
+ }
+
+ @Override
+ public boolean canApply(ItemStack par1ItemStack) {
+ return !(par1ItemStack.getItem() instanceof ItemGemBoots);
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentVampirism.java b/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentVampirism.java
new file mode 100644
index 00000000..25bb45e2
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/enchantment/EnchantmentVampirism.java
@@ -0,0 +1,38 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [29 Sep 2013, 15:06:38 (GMT)]
+ */
+package vazkii.tinkerer.common.enchantment;
+
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.enchantment.EnumEnchantmentType;
+import net.minecraft.item.ItemStack;
+import vazkii.tinkerer.common.item.ModItems;
+
+public class EnchantmentVampirism extends EnchantmentMod {
+
+ protected EnchantmentVampirism(int par1) {
+ super(par1, 2, EnumEnchantmentType.weapon);
+ }
+
+ @Override
+ public boolean canApplyTogether(Enchantment par1Enchantment) {
+ return par1Enchantment.effectId != Enchantment.fireAspect.effectId;
+ }
+
+ @Override
+ public boolean canApply(ItemStack par1ItemStack) {
+ return super.canApply(par1ItemStack) && par1ItemStack.itemID != ModItems.bloodSword.itemID;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/enchantment/ModEnchantmentHandler.java b/src/main/java/vazkii/tinkerer/common/enchantment/ModEnchantmentHandler.java
new file mode 100644
index 00000000..5cf1e60d
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/enchantment/ModEnchantmentHandler.java
@@ -0,0 +1,110 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [29 Sep 2013, 11:52:00 (GMT)]
+ */
+package vazkii.tinkerer.common.enchantment;
+
+import net.minecraft.block.material.Material;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemBow;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.event.EventPriority;
+import net.minecraftforge.event.ForgeSubscribe;
+import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
+import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
+import net.minecraftforge.event.entity.living.LivingHurtEvent;
+import net.minecraftforge.event.entity.player.PlayerEvent;
+import vazkii.tinkerer.common.lib.LibEnchantIDs;
+import vazkii.tinkerer.common.lib.LibObfuscation;
+import cpw.mods.fml.relauncher.ReflectionHelper;
+
+public class ModEnchantmentHandler {
+
+ @ForgeSubscribe
+ public void onEntityDamaged(LivingHurtEvent event) {
+ if(event.source.getEntity() instanceof EntityLivingBase) {
+ EntityLivingBase attacker = (EntityLivingBase) event.source.getEntity();
+ ItemStack heldItem = attacker.getHeldItem();
+
+ if(heldItem == null)
+ return;
+
+ int vampirism = EnchantmentHelper.getEnchantmentLevel(LibEnchantIDs.idVampirism, heldItem);
+ if(vampirism > 0) {
+ attacker.heal(vampirism);
+ event.entityLiving.worldObj.playSoundAtEntity(event.entityLiving, "thaumcraft:zap", 0.6F, 1F);
+ }
+ }
+ }
+
+ @ForgeSubscribe
+ public void onEntityUpdate(LivingUpdateEvent event) {
+ final double min = -0.0784000015258789;
+
+ if(event.entityLiving instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) event.entityLiving;
+ int slowfall = EnchantmentHelper.getMaxEnchantmentLevel(LibEnchantIDs.idSlowFall, player.inventory.armorInventory);
+ if(slowfall > 0 && !event.entityLiving.isSneaking() && event.entityLiving.motionY < min && event.entityLiving.fallDistance >= 2.9) {
+ event.entityLiving.motionY /= 1 + slowfall * 0.33F;
+ event.entityLiving.fallDistance = Math.max(2.9F, player.fallDistance - slowfall / 3F);
+
+ player.worldObj.spawnParticle("cloud", player.posX + 0.25, player.posY - 1, player.posZ + 0.25, -player.motionX, player.motionY, -player.motionZ);
+ }
+
+ ItemStack heldItem = player.getHeldItem();
+
+ if(heldItem == null)
+ return;
+
+ int quickDraw = EnchantmentHelper.getEnchantmentLevel(LibEnchantIDs.idQuickDraw, heldItem);
+ ItemStack usingItem = ReflectionHelper.getPrivateValue(EntityPlayer.class, player, LibObfuscation.ITEM_IN_USE);
+ int time = ReflectionHelper.getPrivateValue(EntityPlayer.class, player, LibObfuscation.ITEM_IN_USE_COUNT);
+ if(quickDraw > 0 && usingItem != null && usingItem.getItem() instanceof ItemBow)
+ if((usingItem.getItem().getMaxItemUseDuration(usingItem) - time) % (6 - quickDraw) == 0)
+ ReflectionHelper.setPrivateValue(EntityPlayer.class, player, time - 1, LibObfuscation.ITEM_IN_USE_COUNT);
+ }
+ }
+
+ @ForgeSubscribe
+ public void onPlayerJump(LivingJumpEvent event) {
+ if(event.entityLiving instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) event.entityLiving;
+ int boost = EnchantmentHelper.getMaxEnchantmentLevel(LibEnchantIDs.idAscentBoost, player.inventory.armorInventory);
+
+ if(boost >= 1 && !player.isSneaking())
+ player.motionY *= (boost + 2) / 2D;
+ }
+ }
+
+ @ForgeSubscribe(priority = EventPriority.HIGHEST)
+ public void onGetHarvestSpeed(PlayerEvent.BreakSpeed event) {
+ ItemStack heldItem = event.entityPlayer.getHeldItem();
+
+ if(heldItem == null)
+ return;
+
+ int desintegrate = EnchantmentHelper.getEnchantmentLevel(LibEnchantIDs.idDesintegrate, heldItem);
+ int autoSmelt = EnchantmentHelper.getEnchantmentLevel(LibEnchantIDs.idAutoSmelt, heldItem);
+
+ boolean desintegrateApplies = desintegrate > 0 && event.block.blockHardness <= 1.5F && heldItem.getItem().getStrVsBlock(heldItem, event.block, event.metadata) != 1F;
+ boolean autoSmeltApplies = autoSmelt > 0 && event.block.blockMaterial == Material.wood;
+
+ if(desintegrateApplies || autoSmeltApplies) {
+ heldItem.damageItem(1, event.entityPlayer);
+ event.newSpeed = Float.MAX_VALUE;
+ } else if(desintegrate > 0 || autoSmelt > 0)
+ event.setCanceled(true);
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/enchantment/ModEnchantments.java b/src/main/java/vazkii/tinkerer/common/enchantment/ModEnchantments.java
new file mode 100644
index 00000000..e989f76a
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/enchantment/ModEnchantments.java
@@ -0,0 +1,42 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [4 Sep 2013, 16:57:55 (GMT)]
+ */
+package vazkii.tinkerer.common.enchantment;
+
+import net.minecraft.enchantment.Enchantment;
+import net.minecraftforge.common.MinecraftForge;
+import vazkii.tinkerer.common.lib.LibEnchantIDs;
+import vazkii.tinkerer.common.lib.LibEnchantNames;
+
+public final class ModEnchantments {
+
+ public static Enchantment ascentBoost;
+ public static Enchantment slowFall;
+ public static Enchantment autoSmelt;
+ public static Enchantment desintegrate;
+ public static Enchantment quickDraw;
+ public static Enchantment vampirism;
+
+ public static void initEnchantments() {
+ ascentBoost = new EnchantmentAscentBoost(LibEnchantIDs.idAscentBoost).setName(LibEnchantNames.ASCENT_BOOST);
+ slowFall = new EnchantmentSlowFall(LibEnchantIDs.idSlowFall).setName(LibEnchantNames.SLOW_FALL);
+ autoSmelt = new EnchantmentAutoSmelt(LibEnchantIDs.idAutoSmelt).setName(LibEnchantNames.AUTO_SMELT);
+ desintegrate = new EnchantmentDesintegrate(LibEnchantIDs.idDesintegrate).setName(LibEnchantNames.DESINTEGRATE);
+ quickDraw = new EnchantmentQuickDraw(LibEnchantIDs.idQuickDraw).setName(LibEnchantNames.QUICK_DRAW);
+ vampirism = new EnchantmentVampirism(LibEnchantIDs.idVampirism).setName(LibEnchantNames.VAMPIRISM);
+
+ MinecraftForge.EVENT_BUS.register(new ModEnchantmentHandler());
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/enchantment/core/EnchantmentData.java b/src/main/java/vazkii/tinkerer/common/enchantment/core/EnchantmentData.java
new file mode 100644
index 00000000..3fe96fec
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/enchantment/core/EnchantmentData.java
@@ -0,0 +1,38 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [14 Sep 2013, 15:08:23 (GMT)]
+ */
+package vazkii.tinkerer.common.enchantment.core;
+
+import net.minecraft.util.ResourceLocation;
+import thaumcraft.api.aspects.AspectList;
+
+public class EnchantmentData {
+
+ public final ResourceLocation texture;
+ public final AspectList aspects;
+ public final boolean vanilla;
+ public final String research;
+
+ public EnchantmentData(String texture, boolean vanilla, AspectList aspects) {
+ this(texture, vanilla, aspects, "");
+ }
+
+ public EnchantmentData(String texture, boolean vanilla, AspectList aspects, String research) {
+ this.texture = new ResourceLocation(texture);
+ this.vanilla = vanilla;
+ this.aspects = aspects;
+ this.research = research;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/enchantment/core/EnchantmentManager.java b/src/main/java/vazkii/tinkerer/common/enchantment/core/EnchantmentManager.java
new file mode 100644
index 00000000..1da984e9
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/enchantment/core/EnchantmentManager.java
@@ -0,0 +1,140 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [14 Sep 2013, 15:05:23 (GMT)]
+ */
+package vazkii.tinkerer.common.enchantment.core;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.item.ItemStack;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.common.config.Config;
+import thaumcraft.common.lib.research.ResearchManager;
+import vazkii.tinkerer.client.lib.LibResources;
+import vazkii.tinkerer.common.core.helper.MiscHelper;
+import vazkii.tinkerer.common.enchantment.ModEnchantments;
+import vazkii.tinkerer.common.enchantment.core.rule.BasicCompatibilityRule;
+import vazkii.tinkerer.common.lib.LibResearch;
+
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+
+public final class EnchantmentManager {
+
+ public static final Map> enchantmentData = new HashMap();
+
+ public static final Multimap rules = ArrayListMultimap.create();
+
+ public static void initEnchantmentData() {
+ registerExponentialCostData(Enchantment.protection, LibResources.ENCHANT_PROTECTION, true, new AspectList().add(Aspect.EARTH, 10).add(Aspect.ENTROPY, 7));
+ registerExponentialCostData(Enchantment.fireProtection, LibResources.ENCHANT_FIRE_PROTECTION, true, new AspectList().add(Aspect.FIRE, 10).add(Aspect.ENTROPY, 3).add(Aspect.WATER, 4));
+ registerExponentialCostData(Enchantment.featherFalling, LibResources.ENCHANT_FEATHER_FALLING, true, new AspectList().add(Aspect.AIR, 16).add(Aspect.ORDER, 5));
+ registerExponentialCostData(Enchantment.blastProtection, LibResources.ENCHANT_BLAST_PROTECTION, true, new AspectList().add(Aspect.EARTH, 5).add(Aspect.FIRE, 5).add(Aspect.ENTROPY, 8));
+ registerExponentialCostData(Enchantment.projectileProtection, LibResources.ENCHANT_PROJECTILE_PROTECTION, true, new AspectList().add(Aspect.AIR, 10).add(Aspect.ENTROPY, 7));
+ registerExponentialCostData(Enchantment.respiration, LibResources.ENCHANT_RESPIRATION, true, new AspectList().add(Aspect.WATER, 10).add(Aspect.AIR, 8).add(Aspect.ORDER, 5));
+ registerExponentialCostData(Enchantment.aquaAffinity, LibResources.ENCHANT_AQUA_AFFINITY, true, new AspectList().add(Aspect.WATER, 25).add(Aspect.ORDER, 20).add(Aspect.EARTH, 5));
+ registerExponentialCostData(Enchantment.thorns, LibResources.ENCHANT_THORNS, true, new AspectList().add(Aspect.EARTH, 10).add(Aspect.ENTROPY, 12));
+
+ registerExponentialCostData(Enchantment.sharpness, LibResources.ENCHANT_SHARPNESS, true, new AspectList().add(Aspect.ORDER, 10));
+ registerExponentialCostData(Enchantment.smite, LibResources.ENCHANT_SMITE, true, new AspectList().add(Aspect.ORDER, 5).add(Aspect.AIR, 5));
+ registerExponentialCostData(Enchantment.baneOfArthropods, LibResources.ENCHANT_BANE_OF_ARTHROPODS, true, new AspectList().add(Aspect.ORDER, 5).add(Aspect.FIRE, 5));
+ registerExponentialCostData(Enchantment.knockback, LibResources.ENCHANT_KNOCKBACK, true, new AspectList().add(Aspect.ENTROPY, 5).add(Aspect.AIR, 10));
+ registerExponentialCostData(Enchantment.fireAspect, LibResources.ENCHANT_FIRE_ASPECT, true, new AspectList().add(Aspect.FIRE, 15).add(Aspect.EARTH, 4));
+ registerExponentialCostData(Enchantment.looting, LibResources.ENCHANT_LOOTING, true, new AspectList().add(Aspect.AIR, 10).add(Aspect.FIRE, 10).add(Aspect.WATER, 10).add(Aspect.EARTH, 10).add(Aspect.ORDER, 15).add(Aspect.ENTROPY, 15));
+
+ registerExponentialCostData(Enchantment.efficiency, LibResources.ENCHANT_EFFICIENCY, true, new AspectList().add(Aspect.ENTROPY, 12).add(Aspect.EARTH, 4));
+ registerExponentialCostData(Enchantment.silkTouch, LibResources.ENCHANT_SILK_TOUCH, true, new AspectList().add(Aspect.ORDER, 50).add(Aspect.EARTH, 10).add(Aspect.ENTROPY, 10));
+ registerExponentialCostData(Enchantment.unbreaking, LibResources.ENCHANT_UNBREAKING, true, new AspectList().add(Aspect.ORDER, 15).add(Aspect.WATER, 8).add(Aspect.EARTH, 8));
+ registerExponentialCostData(Enchantment.fortune, LibResources.ENCHANT_FORTUNE, true, new AspectList().add(Aspect.AIR, 10).add(Aspect.FIRE, 10).add(Aspect.WATER, 10).add(Aspect.EARTH, 10).add(Aspect.ORDER, 15).add(Aspect.ENTROPY, 15));
+
+ registerExponentialCostData(Enchantment.power, LibResources.ENCHANT_POWER, true, new AspectList().add(Aspect.EARTH, 5).add(Aspect.ORDER, 10));
+ registerExponentialCostData(Enchantment.punch, LibResources.ENCHANT_PUNCH, true, new AspectList().add(Aspect.AIR, 4).add(Aspect.EARTH, 10).add(Aspect.ENTROPY, 5));
+ registerExponentialCostData(Enchantment.flame, LibResources.ENCHANT_FLAME, true, new AspectList().add(Aspect.ENTROPY, 5).add(Aspect.FIRE, 20).add(Aspect.EARTH, 5));
+ registerExponentialCostData(Enchantment.infinity, LibResources.ENCHANT_INFINITY, true, new AspectList().add(Aspect.ENTROPY, 40).add(Aspect.ORDER, 40).add(Aspect.EARTH, 10));
+
+ registerExponentialCostData(Config.enchPotency, LibResources.ENCHANT_POTENCY, true, new AspectList().add(Aspect.ORDER, 15));
+ registerExponentialCostData(Config.enchFrugal, LibResources.ENCHANT_FRUGAL, true, new AspectList().add(Aspect.WATER, 10).add(Aspect.EARTH, 10).add(Aspect.ENTROPY, 10));
+ registerExponentialCostData(Config.enchWandFortune, LibResources.ENCHANT_TREASURE, true, new AspectList().add(Aspect.AIR, 10).add(Aspect.FIRE, 10).add(Aspect.WATER, 10).add(Aspect.EARTH, 10).add(Aspect.ORDER, 15).add(Aspect.ENTROPY, 15));
+ registerExponentialCostData(Config.enchHaste, LibResources.ENCHANT_HASTE, true, new AspectList().add(Aspect.AIR, 10).add(Aspect.ENTROPY, 5).add(Aspect.EARTH, 5));
+ registerExponentialCostData(Config.enchRepair, LibResources.ENCHANT_REPAIR, true, new AspectList().add(Aspect.WATER, 20).add(Aspect.FIRE, 20).add(Aspect.EARTH, 20).add(Aspect.AIR, 20).add(Aspect.ORDER, 20).add(Aspect.ENTROPY, 5));
+
+ registerExponentialCostData(ModEnchantments.ascentBoost, LibResources.ENCHANT_ASCENT_BOOST, false, new AspectList().add(Aspect.ENTROPY, 8).add(Aspect.AIR, 10), LibResearch.KEY_ENCHANT_ASCENT_BOOST);
+ registerExponentialCostData(ModEnchantments.slowFall, LibResources.ENCHANT_SLOW_FALL, false, new AspectList().add(Aspect.ORDER, 8).add(Aspect.AIR, 10), LibResearch.KEY_ENCHANT_SLOW_FALL);
+ registerExponentialCostData(ModEnchantments.autoSmelt, LibResources.ENCHANT_AUTO_SMELT, false, new AspectList().add(Aspect.ENTROPY, 20).add(Aspect.FIRE, 30), LibResearch.KEY_ENCHANT_AUTO_SMELT);
+ registerExponentialCostData(ModEnchantments.desintegrate, LibResources.ENCHANT_DESINTEGRATE, false, new AspectList().add(Aspect.ENTROPY, 25).add(Aspect.AIR, 10).add(Aspect.EARTH, 10), LibResearch.KEY_ENCHANT_DESINTEGRATE);
+ registerExponentialCostData(ModEnchantments.quickDraw, LibResources.ENCHANT_QUICK_DRAW, false, new AspectList().add(Aspect.ORDER, 10).add(Aspect.AIR, 10).add(Aspect.WATER, 5), LibResearch.KEY_ENCHANT_QUICK_DRAW);
+ registerExponentialCostData(ModEnchantments.vampirism, LibResources.ENCHANT_VAMPIRISM, false, new AspectList().add(Aspect.ENTROPY, 8).add(Aspect.FIRE, 10).add(Aspect.WATER, 10), LibResearch.KEY_ENCHANT_VAMPIRISM);
+
+ registerCompatibilityRules();
+ registerExtraRules();
+ }
+
+ public static boolean canApply(ItemStack stack, Enchantment enchant, List currentEnchants) {
+ if(!enchant.canApply(stack) || !enchant.type.canEnchantItem(stack.getItem()) || currentEnchants.contains(enchant.effectId))
+ return false;
+
+ for(IEnchantmentRule rule : rules.get(enchant.effectId))
+ if(!rule.canApplyAlongside(currentEnchants))
+ return false;
+
+ return true;
+ }
+
+ public static boolean canEnchantmentBeUsed(String player, Enchantment enchant) {
+ if(!enchantmentData.containsKey(enchant.effectId))
+ return false;
+
+ EnchantmentData data = enchantmentData.get(enchant.effectId).get(1);
+ return data.research.isEmpty() || ResearchManager.isResearchComplete(player, data.research);
+ }
+
+ public static void registerExponentialCostData(Enchantment enchantment, String texture, boolean vanilla, AspectList level1Aspects) {
+ registerExponentialCostData(enchantment, texture, vanilla, level1Aspects, "");
+ }
+
+ public static void registerExponentialCostData(Enchantment enchantment, String texture, boolean vanilla, AspectList level1Aspects, String research) {
+ for(double i = enchantment.getMinLevel(); i <= enchantment.getMaxLevel(); i++) {
+ EnchantmentData data = new EnchantmentData(texture, vanilla, MiscHelper.multiplyAspectList(level1Aspects, i * (1D + i * 0.2)), research);
+ registerData(enchantment.effectId, (int) i, data);
+ }
+ }
+
+ private static void registerData(int enchantment, int level, EnchantmentData data) {
+ if(!enchantmentData.containsKey(enchantment))
+ enchantmentData.put(enchantment, new HashMap());
+
+ enchantmentData.get(enchantment).put(level, data);
+ }
+
+ private static void registerCompatibilityRules() {
+ for(Enchantment ench : Enchantment.enchantmentsList) {
+ if(ench != null)
+ for(Enchantment ench1 : Enchantment.enchantmentsList) {
+ if(ench1 == null || ench == ench1)
+ continue;
+
+ if(!ench.canApplyTogether(ench1) || !ench1.canApplyTogether(ench))
+ rules.put(ench.effectId, new BasicCompatibilityRule(ench1));
+ }
+ }
+
+ }
+
+ private static void registerExtraRules() {
+
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/enchantment/core/IEnchantmentRule.java b/src/main/java/vazkii/tinkerer/common/enchantment/core/IEnchantmentRule.java
new file mode 100644
index 00000000..c63d2136
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/enchantment/core/IEnchantmentRule.java
@@ -0,0 +1,23 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [14 Sep 2013, 15:14:33 (GMT)]
+ */
+package vazkii.tinkerer.common.enchantment.core;
+
+import java.util.List;
+
+public interface IEnchantmentRule {
+
+ public boolean canApplyAlongside(List otherEnchantments);
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/enchantment/core/rule/BasicCompatibilityRule.java b/src/main/java/vazkii/tinkerer/common/enchantment/core/rule/BasicCompatibilityRule.java
new file mode 100644
index 00000000..c720e6af
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/enchantment/core/rule/BasicCompatibilityRule.java
@@ -0,0 +1,35 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [14 Sep 2013, 15:15:33 (GMT)]
+ */
+package vazkii.tinkerer.common.enchantment.core.rule;
+
+import java.util.List;
+
+import net.minecraft.enchantment.Enchantment;
+import vazkii.tinkerer.common.enchantment.core.IEnchantmentRule;
+
+public class BasicCompatibilityRule implements IEnchantmentRule {
+
+ Enchantment illegal;
+
+ public BasicCompatibilityRule(Enchantment illegal) {
+ this.illegal = illegal;
+ }
+
+ @Override
+ public boolean canApplyAlongside(List enchantments) {
+ return !enchantments.contains(illegal.effectId);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/INoRemoveEnchant.java b/src/main/java/vazkii/tinkerer/common/item/INoRemoveEnchant.java
new file mode 100644
index 00000000..8fd5daa7
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/INoRemoveEnchant.java
@@ -0,0 +1,19 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 01:21:51 (GMT)]
+ */
+package vazkii.tinkerer.common.item;
+
+public interface INoRemoveEnchant {
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/ItemBlockMagnet.java b/src/main/java/vazkii/tinkerer/common/item/ItemBlockMagnet.java
new file mode 100644
index 00000000..a8b7eeeb
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/ItemBlockMagnet.java
@@ -0,0 +1,38 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 18:10:44 (GMT)]
+ */
+package vazkii.tinkerer.common.item;
+
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import vazkii.tinkerer.common.lib.LibBlockNames;
+
+public class ItemBlockMagnet extends ItemBlock {
+
+ public ItemBlockMagnet(int par1) {
+ super(par1);
+ setHasSubtypes(true);
+ }
+
+ @Override
+ public int getMetadata(int par1) {
+ return par1 == 0 ? 0 : 2;
+ }
+
+ @Override
+ public String getUnlocalizedName(ItemStack par1ItemStack) {
+ return "tile." + (par1ItemStack.getItemDamage() == 0 ? LibBlockNames.MAGNET : LibBlockNames.MOB_MAGNET);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/ItemBloodSword.java b/src/main/java/vazkii/tinkerer/common/item/ItemBloodSword.java
new file mode 100644
index 00000000..ac29ddfa
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/ItemBloodSword.java
@@ -0,0 +1,98 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Nov 24, 2013, 7:31:51 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item;
+
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.SharedMonsterAttributes;
+import net.minecraft.entity.ai.attributes.AttributeModifier;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.ItemSword;
+import net.minecraft.util.DamageSource;
+import net.minecraftforge.common.EnumHelper;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.ForgeSubscribe;
+import net.minecraftforge.event.entity.living.LivingAttackEvent;
+import thaumcraft.api.IRepairable;
+import thaumcraft.api.ThaumcraftApi;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.common.core.handler.ModCreativeTab;
+import vazkii.tinkerer.common.lib.LibObfuscation;
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
+
+import cpw.mods.fml.relauncher.ReflectionHelper;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemBloodSword extends ItemSword implements IRepairable {
+
+ private static final int DAMAGE = 10;
+
+ public ItemBloodSword(int par1) {
+ super(par1, EnumHelper.addToolMaterial("TT_BLOOD", 0, 950, 0, 0, ThaumcraftApi.toolMatThaumium.getEnchantability()));
+ MinecraftForge.EVENT_BUS.register(this);
+ setCreativeTab(ModCreativeTab.INSTANCE);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ itemIcon = IconHelper.forItem(par1IconRegister, this);
+ }
+
+ @Override
+ public Multimap getItemAttributeModifiers() {
+ Multimap multimap = HashMultimap.create();
+ multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", DAMAGE, 0));
+ multimap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", 0.25, 1));
+ return multimap;
+ }
+
+ static int handleNext = 0;
+
+ @ForgeSubscribe
+ public void onDamageTaken(LivingAttackEvent event) {
+ if(event.entity.worldObj.isRemote)
+ return;
+
+ boolean handle = handleNext == 0;
+ if(!handle)
+ handleNext--;
+
+ if(event.entityLiving instanceof EntityPlayer && handle) {
+ EntityPlayer player = (EntityPlayer) event.entityLiving;
+ ItemStack itemInUse = ReflectionHelper.getPrivateValue(EntityPlayer.class, player, LibObfuscation.ITEM_IN_USE);
+ if(itemInUse != null && itemInUse.itemID == itemID) {
+ event.setCanceled(true);
+ handleNext = 3;
+ player.attackEntityFrom(DamageSource.magic, 3);
+ }
+ }
+
+ if(handle) {
+ Entity source = event.source.getSourceOfDamage();
+ if(source != null && source instanceof EntityLivingBase) {
+ EntityLivingBase attacker = (EntityLivingBase) source;
+ ItemStack itemInUse = attacker.getCurrentItemOrArmor(0);
+ if(itemInUse != null && itemInUse.itemID == itemID)
+ attacker.attackEntityFrom(DamageSource.magic, 2);
+ }
+ }
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/ItemBrightNitor.java b/src/main/java/vazkii/tinkerer/common/item/ItemBrightNitor.java
new file mode 100644
index 00000000..1530993a
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/ItemBrightNitor.java
@@ -0,0 +1,44 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [11 Sep 2013, 17:46:38 (GMT)]
+ */
+package vazkii.tinkerer.common.item;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+import vazkii.tinkerer.common.block.ModBlocks;
+
+public class ItemBrightNitor extends ItemMod {
+
+ public ItemBrightNitor(int par1) {
+ super(par1);
+ setMaxStackSize(1);
+ }
+
+ public static int meta = 0;
+
+ @Override
+ public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
+ int x = (int) Math.floor(par3Entity.posX);
+ int y = (int) par3Entity.posY + 1;
+ int z = (int) Math.floor(par3Entity.posZ);
+
+ setBlock(x, y, z, par2World);
+ }
+
+ public static void setBlock(int x, int y, int z, World world) {
+ if((world.getBlockId(x, y, z) == 0 || world.getBlockId(x, y, z) == ModBlocks.nitorGas.blockID) && !world.isRemote)
+ world.setBlock(x, y, z, ModBlocks.nitorGas.blockID, meta, 2);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/item/ItemCleansingTalisman.java b/src/main/java/vazkii/tinkerer/common/item/ItemCleansingTalisman.java
new file mode 100644
index 00000000..0f9fa22f
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/ItemCleansingTalisman.java
@@ -0,0 +1,124 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [11 Sep 2013, 15:45:16 (GMT)]
+ */
+package vazkii.tinkerer.common.item;
+
+import java.util.Collection;
+import java.util.List;
+
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+import net.minecraft.util.Icon;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.common.core.helper.ItemNBTHelper;
+import vazkii.tinkerer.common.lib.LibFeatures;
+import vazkii.tinkerer.common.lib.LibObfuscation;
+import cpw.mods.fml.relauncher.ReflectionHelper;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemCleansingTalisman extends ItemMod {
+
+ private static final String TAG_ENABLED = "enabled";
+
+ private Icon enabledIcon;
+
+ public ItemCleansingTalisman(int par1) {
+ super(par1);
+ setMaxStackSize(1);
+ setMaxDamage(LibFeatures.CLEANSING_TALISMAN_USES);
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+ if(par3EntityPlayer.isSneaking()) {
+ flipEnabled(par1ItemStack);
+ par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F);
+ }
+
+ return par1ItemStack;
+ }
+
+ @Override
+ public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
+ if(isEnabled(par1ItemStack) && !par2World.isRemote) {
+ if(par3Entity.ticksExisted % 20 == 0) {
+ if (par3Entity instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer)par3Entity;
+ boolean removed = false;
+
+ Collection potions = player.getActivePotionEffects();
+
+ if(player.isBurning()) {
+ player.extinguish();
+ removed = true;
+ } else for(PotionEffect potion : potions) {
+ int id = potion.getPotionID();
+ if(ReflectionHelper.getPrivateValue(Potion.class, Potion.potionTypes[id], LibObfuscation.IS_BAD_EFFECT)) {
+ player.removePotionEffect(id);
+ removed = true;
+ break;
+ }
+ }
+
+ if(removed) {
+ par1ItemStack.damageItem(1, player);
+ par2World.playSoundAtEntity(player, "thaumcraft:wand", 0.3F, 0.1F);
+ }
+ }
+ }
+ }
+ }
+
+ public static boolean isEnabled(ItemStack stack) {
+ return ItemNBTHelper.getBoolean(stack, TAG_ENABLED, false);
+ }
+
+ public static void flipEnabled(ItemStack stack) {
+ ItemNBTHelper.setBoolean(stack, TAG_ENABLED, !isEnabled(stack));
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ itemIcon = IconHelper.forItem(par1IconRegister, this, 0);
+ enabledIcon = IconHelper.forItem(par1IconRegister, this, 1);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
+ if(isEnabled(par1ItemStack))
+ par3List.add(StatCollector.translateToLocal("ttmisc.active"));
+ else par3List.add(StatCollector.translateToLocal("ttmisc.inactive"));
+ }
+
+ @Override
+ public Icon getIcon(ItemStack stack, int pass) {
+ return isEnabled(stack) ? enabledIcon : itemIcon;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return EnumRarity.uncommon;
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/ItemConnector.java b/src/main/java/vazkii/tinkerer/common/item/ItemConnector.java
new file mode 100644
index 00000000..558e4c1a
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/ItemConnector.java
@@ -0,0 +1,135 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 19:35:02 (GMT)]
+ */
+package vazkii.tinkerer.common.item;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import vazkii.tinkerer.common.block.tile.transvector.TileTransvector;
+import vazkii.tinkerer.common.block.tile.transvector.TileTransvectorInterface;
+import vazkii.tinkerer.common.core.helper.ItemNBTHelper;
+import cpw.mods.fml.common.network.PacketDispatcher;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemConnector extends ItemMod {
+
+ private static final String TAG_POS_X = "posx";
+ private static final String TAG_POS_Y = "posy";
+ private static final String TAG_POS_Z = "posz";
+
+ public ItemConnector(int par1) {
+ super(par1);
+
+ setMaxStackSize(1);
+ }
+
+ @Override
+ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
+ if (par3World.isRemote)
+ return false;
+
+ TileEntity tile = par3World.getBlockTileEntity(par4, par5, par6);
+ if (getY(par1ItemStack) == -1) {
+ if (tile != null && tile instanceof TileTransvector) {
+ setX(par1ItemStack, par4);
+ setY(par1ItemStack, par5);
+ setZ(par1ItemStack, par6);
+
+ if(par3World.isRemote)
+ par2EntityPlayer.swingItem();
+
+ playSound(par3World, par4, par5, par6);
+ par2EntityPlayer.addChatMessage("ttmisc.connector.set");
+ } else
+ par2EntityPlayer.addChatMessage("ttmisc.connector.notinterf");
+ } else {
+ int x = getX(par1ItemStack);
+ int y = getY(par1ItemStack);
+ int z = getZ(par1ItemStack);
+
+ TileEntity tile1 = par3World.getBlockTileEntity(x, y, z);
+ if (tile1 == null || !(tile1 instanceof TileTransvector)) {
+ setY(par1ItemStack, -1);
+
+ par2EntityPlayer.addChatMessage("ttmisc.connector.notpresent");
+ } else {
+ TileTransvector trans = (TileTransvector) tile1;
+
+ if (tile != null && tile1 instanceof TileTransvectorInterface && tile instanceof TileTransvectorInterface) {
+ par2EntityPlayer.addChatMessage("ttmisc.connector.interffail");
+ return true;
+ }
+
+ if(Math.abs(x - par4) > trans.getMaxDistance() || Math.abs(y - par5) > trans.getMaxDistance() || Math.abs(z - par6) > trans.getMaxDistance()) {
+ par2EntityPlayer.addChatMessage("ttmisc.connector.toofar");
+ return true;
+ }
+
+ trans.x = par4;
+ trans.y = par5;
+ trans.z = par6;
+
+ setY(par1ItemStack, -1);
+
+ if(par3World.isRemote)
+ par2EntityPlayer.swingItem();
+
+ playSound(par3World, par4, par5, par6);
+ par2EntityPlayer.addChatMessage("ttmisc.connector.complete");
+ PacketDispatcher.sendPacketToAllInDimension(trans.getDescriptionPacket(), par3World.provider.dimensionId);
+ }
+ }
+
+ return true;
+ }
+
+ private void playSound(World world, int x, int y, int z) {
+ if(!world.isRemote)
+ world.playSoundEffect(x, y, z, "random.orb", 0.8F, 1F);
+ }
+
+ public static void setX(ItemStack stack, int x) {
+ ItemNBTHelper.setInt(stack, TAG_POS_X, x);
+ }
+
+ public static void setY(ItemStack stack, int y) {
+ ItemNBTHelper.setInt(stack, TAG_POS_Y, y);
+ }
+
+ public static void setZ(ItemStack stack, int z) {
+ ItemNBTHelper.setInt(stack, TAG_POS_Z, z);
+ }
+
+ public static int getX(ItemStack stack) {
+ return ItemNBTHelper.getInt(stack, TAG_POS_X, 0);
+ }
+
+ public static int getY(ItemStack stack) {
+ return ItemNBTHelper.getInt(stack, TAG_POS_Y, -1);
+ }
+
+ public static int getZ(ItemStack stack) {
+ return ItemNBTHelper.getInt(stack, TAG_POS_Z, 0);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public boolean isFull3D() {
+ return true;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/ItemGas.java b/src/main/java/vazkii/tinkerer/common/item/ItemGas.java
new file mode 100644
index 00000000..73929ad1
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/ItemGas.java
@@ -0,0 +1,53 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 22:12:14 (GMT)]
+ */
+package vazkii.tinkerer.common.item;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+
+public class ItemGas extends ItemMod {
+
+ private Block setBlock;
+
+ public ItemGas(int par1, Block setBlock) {
+ super(par1);
+ this.setBlock = setBlock;
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+ int x = (int) par3EntityPlayer.posX;
+ int y = (int) par3EntityPlayer.posY + 1;
+ int z = (int) par3EntityPlayer.posZ;
+ boolean air = par2World.isAirBlock(x, y, z);
+
+ if (!par3EntityPlayer.capabilities.isCreativeMode)
+ par1ItemStack.stackSize--;
+
+ par2World.playSoundAtEntity(par3EntityPlayer, "random.pop", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
+
+ if(air) {
+ if(!par2World.isRemote)
+ par2World.setBlock(x, y, z, setBlock.blockID, 4, 2);
+ else par3EntityPlayer.swingItem();
+ par2World.scheduleBlockUpdate(x, y, z, setBlock.blockID, 10);
+ }
+
+ return par1ItemStack;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/item/ItemGasRemover.java b/src/main/java/vazkii/tinkerer/common/item/ItemGasRemover.java
new file mode 100644
index 00000000..34e08fbb
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/ItemGasRemover.java
@@ -0,0 +1,62 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 00:02:52 (GMT)]
+ */
+package vazkii.tinkerer.common.item;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+import vazkii.tinkerer.common.block.BlockGas;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemGasRemover extends ItemMod {
+
+ public ItemGasRemover(int par1) {
+ super(par1);
+ setMaxStackSize(1);
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+ if(par3EntityPlayer.isSneaking()) {
+ int xs = (int) par3EntityPlayer.posX;
+ int ys = (int) par3EntityPlayer.posY;
+ int zs = (int) par3EntityPlayer.posZ;
+
+ for(int x = xs - 3; x < xs + 3; x++)
+ for(int y = ys - 3; y < ys + 3; y++)
+ for(int z = zs - 3; z < zs + 3; z++) {
+ int id = par2World.getBlockId(x, y, z);
+ if(Block.blocksList[id] != null && Block.blocksList[id] instanceof BlockGas) {
+ BlockGas gas = (BlockGas) Block.blocksList[id];
+ gas.placeParticle(par2World, x, y, z);
+ par2World.setBlock(x, y, z, 0, 0, 1 | 2);
+ }
+ }
+
+ par2World.playSoundAtEntity(par3EntityPlayer, "thaumcraft.wand", 0.2F, 1F);
+ }
+
+ return par1ItemStack;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return EnumRarity.uncommon;
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/ItemInfusedInkwell.java b/src/main/java/vazkii/tinkerer/common/item/ItemInfusedInkwell.java
new file mode 100644
index 00000000..e530ce2b
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/ItemInfusedInkwell.java
@@ -0,0 +1,35 @@
+package vazkii.tinkerer.common.item;
+
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Icon;
+import thaumcraft.common.config.ConfigItems;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemInfusedInkwell extends ItemMod {
+
+ public ItemInfusedInkwell(int par1) {
+ super(par1);
+
+ setMaxDamage(800);
+ maxStackSize = 1;
+ canRepair = true;
+ setHasSubtypes(false);
+
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public Icon getIconFromDamage(int par1)
+ {
+ return ConfigItems.itemInkwell.getIconFromDamage(par1);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public boolean hasEffect(ItemStack par1ItemStack, int pass) {
+ return true;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/ItemMod.java b/src/main/java/vazkii/tinkerer/common/item/ItemMod.java
new file mode 100644
index 00000000..74b6cd73
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/ItemMod.java
@@ -0,0 +1,36 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 15:44:29 (GMT)]
+ */
+package vazkii.tinkerer.common.item;
+
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.item.Item;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.common.core.handler.ModCreativeTab;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemMod extends Item {
+
+ public ItemMod(int par1) {
+ super(par1);
+ setCreativeTab(ModCreativeTab.INSTANCE);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ itemIcon = IconHelper.forItem(par1IconRegister, this);
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/ItemRevealingHelm.java b/src/main/java/vazkii/tinkerer/common/item/ItemRevealingHelm.java
new file mode 100644
index 00000000..aa3e071a
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/ItemRevealingHelm.java
@@ -0,0 +1,88 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Nov 25, 2013, 8:52:43 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item;
+
+import java.util.List;
+
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemArmor;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.StatCollector;
+import thaumcraft.api.IGoggles;
+import thaumcraft.api.IRepairable;
+import thaumcraft.api.IVisDiscounter;
+import thaumcraft.api.ThaumcraftApi;
+import thaumcraft.api.nodes.IRevealer;
+import thaumcraft.common.config.ConfigItems;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.client.lib.LibResources;
+import vazkii.tinkerer.common.core.handler.ModCreativeTab;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemRevealingHelm extends ItemArmor implements IRepairable, IRevealer, IGoggles, IVisDiscounter {
+
+ public ItemRevealingHelm(int i) {
+ super(i, ThaumcraftApi.armorMatThaumium, 2, 0);
+ setMaxDamage(500);
+ setCreativeTab(ModCreativeTab.INSTANCE);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ itemIcon = IconHelper.forItem(par1IconRegister, this);
+ }
+
+ @Override
+ public boolean showNodes(ItemStack paramItemStack, EntityLivingBase paramEntityLivingBase) {
+ return true;
+ }
+
+ @Override
+ public boolean showIngamePopups(ItemStack paramItemStack, EntityLivingBase paramEntityLivingBase) {
+ return true;
+ }
+
+ @Override
+ public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
+ list.add(StatCollector.translateToLocal("tc.visdiscount") + ": " + getVisDiscount() + "%");
+ }
+
+ @Override
+ public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
+ return LibResources.MODEL_REVEALING_HELM;
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return EnumRarity.uncommon;
+ }
+
+ @Override
+ public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) {
+ return par2ItemStack.isItemEqual(new ItemStack(ConfigItems.itemResource, 1, 2)) ? true : super.getIsRepairable(par1ItemStack, par2ItemStack);
+ }
+
+ @Override
+ public int getVisDiscount() {
+ return 5;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/ItemShareBook.java b/src/main/java/vazkii/tinkerer/common/item/ItemShareBook.java
new file mode 100644
index 00000000..c45e619d
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/ItemShareBook.java
@@ -0,0 +1,78 @@
+package vazkii.tinkerer.common.item;
+
+import java.util.List;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import thaumcraft.common.lib.research.ResearchManager;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.core.helper.ItemNBTHelper;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemShareBook extends ItemMod {
+
+ private static final String TAG_PLAYER = "player";
+ private static final String NON_ASIGNED = "[none]";
+
+ public ItemShareBook(int par1) {
+ super(par1);
+ setMaxStackSize(1);
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+ String name = getPlayerName(par1ItemStack);
+ if(name.endsWith(NON_ASIGNED)) {
+ setPlayerName(par1ItemStack, par3EntityPlayer.username);
+ if(!par2World.isRemote)
+ par3EntityPlayer.addChatMessage("ttmisc.shareTome.write");
+ } else sync : {
+ List researchesDone = ResearchManager.getResearchForPlayer(name);
+
+ if(researchesDone == null) {
+ if(!par2World.isRemote)
+ par3EntityPlayer.addChatMessage("ttmisc.shareTome.notOnline");
+ break sync;
+ }
+
+ for(String key : researchesDone)
+ ThaumicTinkerer.tcProxy.getResearchManager().completeResearch(par3EntityPlayer, key);
+
+ if(!par2World.isRemote)
+ par3EntityPlayer.addChatMessage("ttmisc.shareTome.sync");
+ }
+
+
+ return par1ItemStack;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return EnumRarity.epic;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
+ String name = getPlayerName(par1ItemStack);
+ par3List.add(name.equals(NON_ASIGNED) ? StatCollector.translateToLocal("ttmisc.shareTome.noAssign") : String.format(StatCollector.translateToLocal("ttmisc.shareTome.playerName"), name));
+ }
+
+ @Override
+ public boolean getShareTag() {
+ return true;
+ }
+
+ private String getPlayerName(ItemStack stack) {
+ return ItemNBTHelper.getString(stack, TAG_PLAYER, NON_ASIGNED);
+ }
+
+ private void setPlayerName(ItemStack stack, String playerName) {
+ ItemNBTHelper.setString(stack, TAG_PLAYER, playerName);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/item/ItemSoulMould.java b/src/main/java/vazkii/tinkerer/common/item/ItemSoulMould.java
new file mode 100644
index 00000000..30a0ba85
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/ItemSoulMould.java
@@ -0,0 +1,75 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [12 Sep 2013, 17:36:35 (GMT)]
+ */
+package vazkii.tinkerer.common.item;
+
+import java.util.List;
+
+import net.minecraft.entity.EntityList;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import vazkii.tinkerer.common.core.helper.ItemNBTHelper;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemSoulMould extends ItemMod {
+
+ private static final String TAG_PATTERN = "pattern";
+
+ public ItemSoulMould(int par1) {
+ super(par1);
+ setMaxStackSize(1);
+ }
+
+ @Override
+ public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase) {
+ if(par2EntityPlayer != null)
+ setPattern(par2EntityPlayer.getCurrentEquippedItem(), par3EntityLivingBase);
+ else setPattern(par1ItemStack, par3EntityLivingBase);
+ return true;
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+ if(par3EntityPlayer.isSneaking())
+ clearPattern(par1ItemStack);
+
+ return par1ItemStack;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
+ String name = getPatternName(par1ItemStack);
+
+ if(name.isEmpty())
+ par3List.add(StatCollector.translateToLocal("ttmisc.soulMould.nonAssigned"));
+ else par3List.add(String.format(StatCollector.translateToLocal("ttmisc.soulMould.pattern"), StatCollector.translateToLocal("entity." + name + ".name")));
+ }
+
+ private static void setPattern(ItemStack par1ItemStack, EntityLivingBase par2EntityLiving) {
+ ItemNBTHelper.setString(par1ItemStack, TAG_PATTERN, EntityList.getEntityString(par2EntityLiving));
+ }
+
+ public static String getPatternName(ItemStack par1ItemStack) {
+ return ItemNBTHelper.getString(par1ItemStack, TAG_PATTERN, "");
+ }
+
+ private static void clearPattern(ItemStack par1ItemStack) {
+ ItemNBTHelper.getNBT(par1ItemStack).removeTag(TAG_PATTERN);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/item/ItemSpellCloth.java b/src/main/java/vazkii/tinkerer/common/item/ItemSpellCloth.java
new file mode 100644
index 00000000..c79a0cce
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/ItemSpellCloth.java
@@ -0,0 +1,71 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 01:20:22 (GMT)]
+ */
+package vazkii.tinkerer.common.item;
+
+import java.awt.Color;
+
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.crafting.CraftingManager;
+import vazkii.tinkerer.common.lib.LibFeatures;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemSpellCloth extends ItemMod {
+
+ public ItemSpellCloth(int par1) {
+ super(par1);
+ setMaxDamage(LibFeatures.SPELL_CLOTH_USES);
+ setMaxStackSize(1);
+ setNoRepair();
+
+ CraftingManager.getInstance().getRecipeList().add(new SpellClothRecipe(this));
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public int getColorFromItemStack(ItemStack par1ItemStack, int par2) {
+ return Color.HSBtoRGB(0.75F, ((float) par1ItemStack.getMaxDamage() - (float) par1ItemStack.getItemDamage()) / par1ItemStack.getMaxDamage() * 0.5F, 1F);
+ }
+
+ @Override
+ public boolean hasContainerItem() {
+ return true;
+ }
+
+ @Override
+ public ItemStack getContainerItemStack(ItemStack itemStack) {
+ itemStack.setItemDamage(itemStack.getItemDamage() + 1);
+
+ return itemStack;
+ }
+
+ @Override
+ public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) {
+ return false;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public boolean hasEffect(ItemStack par1ItemStack) {
+ return false;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return EnumRarity.uncommon;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/item/ItemXPTalisman.java b/src/main/java/vazkii/tinkerer/common/item/ItemXPTalisman.java
new file mode 100644
index 00000000..d1d0bcbe
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/ItemXPTalisman.java
@@ -0,0 +1,158 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [28 Sep 2013, 18:27:56 (GMT)]
+ */
+package vazkii.tinkerer.common.item;
+
+import java.util.List;
+
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.EntityXPOrb;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.Icon;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.core.helper.ItemNBTHelper;
+import vazkii.tinkerer.common.lib.LibFeatures;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemXPTalisman extends ItemMod {
+
+ private static final String TAG_XP = "xp";
+ Icon enabledIcon;
+
+ public ItemXPTalisman(int par1) {
+ super(par1);
+ setMaxStackSize(1);
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+ if(par3EntityPlayer.isSneaking()) {
+ if(getXP(par1ItemStack) < LibFeatures.XP_TALISMAN_MAX_XP) {
+ int dmg = par1ItemStack.getItemDamage();
+ par1ItemStack.setItemDamage(~dmg & 1);
+ par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F);
+ }
+ } else if(getXP(par1ItemStack) >= LibFeatures.XP_TALISMAN_ENCHANTING_BOTTLE_COST) {
+ boolean has = par3EntityPlayer.inventory.consumeInventoryItem(Item.glassBottle.itemID);
+ if(has) {
+ if(!par3EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.expBottle, 1)) && !par2World.isRemote)
+ par3EntityPlayer.dropItem(Item.expBottle.itemID, 1);
+ int xp = getXP(par1ItemStack);
+ setXP(par1ItemStack, xp - LibFeatures.XP_TALISMAN_ENCHANTING_BOTTLE_COST);
+ par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.1F, (float) (0.1F + Math.random() / 2F));
+ for(int i = 0; par2World.isRemote && i < 6; i++)
+ ThaumicTinkerer.tcProxy.sparkle((float) (par3EntityPlayer.posX + (Math.random() - 0.5)), (float) (par3EntityPlayer.posY + Math.random() - 0.5), (float) (par3EntityPlayer.posZ + (Math.random() - 0.5)), 3);
+ }
+ }
+
+ return par1ItemStack;
+ }
+
+ @Override
+ public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
+ if(par1ItemStack.getItemDamage() == 1 && !par2World.isRemote) {
+ int r = LibFeatures.XP_TALISMAN_RANGE;
+ int currentXP = getXP(par1ItemStack);
+ int xpToAdd = 0;
+ int maxXP = LibFeatures.XP_TALISMAN_MAX_XP - currentXP; // Max, to prevent overflow.
+ if(maxXP <= 0) {
+ par1ItemStack.setItemDamage(0);
+ return; // Can't take any XP.
+ }
+
+ AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox(par3Entity.posX - r, par3Entity.posY - r, par3Entity.posZ - r, par3Entity.posX + r, par3Entity.posY + r, par3Entity.posZ + r);
+ List orbs = par2World.getEntitiesWithinAABB(EntityXPOrb.class, boundingBox);
+
+ for(EntityXPOrb orb : orbs) {
+ if(!orb.isDead) {
+ int xp = orb.getXpValue();
+ if(xpToAdd + xp <= maxXP) {
+ xpToAdd += xp;
+ consumeXPOrb(orb);
+ }
+
+ maxXP -= xpToAdd;
+
+ if(maxXP <= 0)
+ break;
+ }
+ }
+
+ setXP(par1ItemStack, Math.min(LibFeatures.XP_TALISMAN_MAX_XP, currentXP + xpToAdd));
+ }
+ }
+
+ private void consumeXPOrb(EntityXPOrb orb) {
+ orb.setDead();
+ orb.worldObj.playSoundAtEntity(orb, "thaumcraft:zap", orb.getXpValue() / 10F, 1F);
+ ThaumicTinkerer.tcProxy.wispFX(orb.worldObj, orb.posX, orb.posY, orb.posZ, orb.getXpValue() / 5F, 0.1F, 0.9F, 0.1F);
+ }
+
+ @Override
+ public boolean getShareTag() {
+ return true;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
+ par3List.add("XP: " + getXP(par1ItemStack));
+ if(getXP(par1ItemStack) >= LibFeatures.XP_TALISMAN_MAX_XP)
+ par3List.add(StatCollector.translateToLocal("ttmisc.full"));
+ else if(par1ItemStack.getItemDamage() == 0)
+ par3List.add(StatCollector.translateToLocal("ttmisc.notAbsorbing"));
+ else par3List.add(StatCollector.translateToLocal("ttmisc.absorbing"));
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ itemIcon = IconHelper.forItem(par1IconRegister, this, 0);
+ enabledIcon = IconHelper.forItem(par1IconRegister, this, 1);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public Icon getIconFromDamage(int par1) {
+ return par1 == 1 ? enabledIcon : itemIcon;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return EnumRarity.uncommon;
+ }
+
+ public static boolean hasCmp(ItemStack stack) {
+ return ItemNBTHelper.detectNBT(stack);
+ }
+
+ public static int getXP(ItemStack stack) {
+ return ItemNBTHelper.getInt(stack, TAG_XP, 0);
+ }
+
+ public static void setXP(ItemStack stack, int xp) {
+ ItemNBTHelper.setInt(stack, TAG_XP, xp);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/item/ModItems.java b/src/main/java/vazkii/tinkerer/common/item/ModItems.java
new file mode 100644
index 00000000..f827f2c1
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/ModItems.java
@@ -0,0 +1,180 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [4 Sep 2013, 16:57:28 (GMT)]
+ */
+package vazkii.tinkerer.common.item;
+
+import net.minecraft.item.EnumToolMaterial;
+import net.minecraft.item.Item;
+import net.minecraftforge.common.EnumHelper;
+import net.minecraftforge.common.MinecraftForge;
+import thaumcraft.api.wands.WandCap;
+import thaumcraft.api.wands.WandRod;
+import vazkii.tinkerer.common.block.ModBlocks;
+import vazkii.tinkerer.common.core.handler.ConfigHandler;
+import vazkii.tinkerer.common.item.foci.ItemFocusDeflect;
+import vazkii.tinkerer.common.item.foci.ItemFocusDislocation;
+import vazkii.tinkerer.common.item.foci.ItemFocusEnderChest;
+import vazkii.tinkerer.common.item.foci.ItemFocusFlight;
+import vazkii.tinkerer.common.item.foci.ItemFocusHeal;
+import vazkii.tinkerer.common.item.foci.ItemFocusSmelt;
+import vazkii.tinkerer.common.item.foci.ItemFocusTelekinesis;
+import vazkii.tinkerer.common.item.kami.ItemBlockTalisman;
+import vazkii.tinkerer.common.item.kami.ItemCatAmulet;
+import vazkii.tinkerer.common.item.kami.ItemIchorPouch;
+import vazkii.tinkerer.common.item.kami.ItemKamiResource;
+import vazkii.tinkerer.common.item.kami.ItemPlacementMirror;
+import vazkii.tinkerer.common.item.kami.ItemProtoclay;
+import vazkii.tinkerer.common.item.kami.ItemSkyPearl;
+import vazkii.tinkerer.common.item.kami.armor.ItemGemBoots;
+import vazkii.tinkerer.common.item.kami.armor.ItemGemChest;
+import vazkii.tinkerer.common.item.kami.armor.ItemGemHelm;
+import vazkii.tinkerer.common.item.kami.armor.ItemGemLegs;
+import vazkii.tinkerer.common.item.kami.armor.ItemIchorclothArmor;
+import vazkii.tinkerer.common.item.kami.foci.ItemFocusRecall;
+import vazkii.tinkerer.common.item.kami.foci.ItemFocusShadowbeam;
+import vazkii.tinkerer.common.item.kami.foci.ItemFocusXPDrain;
+import vazkii.tinkerer.common.item.kami.tool.ItemIchorAxe;
+import vazkii.tinkerer.common.item.kami.tool.ItemIchorAxeAdv;
+import vazkii.tinkerer.common.item.kami.tool.ItemIchorPick;
+import vazkii.tinkerer.common.item.kami.tool.ItemIchorPickAdv;
+import vazkii.tinkerer.common.item.kami.tool.ItemIchorShovel;
+import vazkii.tinkerer.common.item.kami.tool.ItemIchorShovelAdv;
+import vazkii.tinkerer.common.item.kami.tool.ItemIchorSword;
+import vazkii.tinkerer.common.item.kami.tool.ItemIchorSwordAdv;
+import vazkii.tinkerer.common.item.kami.wand.CapIchor;
+import vazkii.tinkerer.common.item.kami.wand.RodIchorcloth;
+import vazkii.tinkerer.common.lib.LibItemIDs;
+import vazkii.tinkerer.common.lib.LibItemNames;
+
+public final class ModItems {
+
+ public static Item darkQuartz;
+ public static Item connector;
+ public static Item gaseousLight;
+ public static Item gaseousShadow;
+ public static Item gasRemover;
+ public static Item spellCloth;
+ public static Item focusFlight;
+ public static Item focusDislocation;
+ public static Item cleansingTalisman;
+ public static Item brightNitor;
+ public static Item focusTelekinesis;
+ public static Item soulMould;
+ public static Item xpTalisman;
+ public static Item focusSmelt;
+ public static Item focusHeal;
+ public static Item focusEnderChest;
+ public static Item bloodSword;
+ public static Item revealingHelm;
+ public static Item infusedInkwell;
+ public static Item focusDeflect;
+ public static Item shareBook;
+
+ public static Item kamiResource;
+ public static Item ichorHelm;
+ public static Item ichorChest;
+ public static Item ichorLegs;
+ public static Item ichorBoots;
+ public static Item ichorHelmGem;
+ public static Item ichorChestGem;
+ public static Item ichorLegsGem;
+ public static Item ichorBootsGem;
+ public static Item catAmulet;
+ public static Item ichorPick;
+ public static Item ichorShovel;
+ public static Item ichorAxe;
+ public static Item ichorSword;
+ public static Item ichorPickGem;
+ public static Item ichorShovelGem;
+ public static Item ichorAxeGem;
+ public static Item ichorSwordGem;
+ public static Item ichorPouch;
+ public static Item blockTalisman;
+ public static Item placementMirror;
+ public static Item focusShadowbeam;
+ public static Item focusXPDrain;
+ public static Item protoclay;
+ public static Item skyPearl;
+ public static Item focusRecall;
+
+ public static WandCap capIchor;
+ public static WandRod rodIchorcloth;
+
+ public static EnumToolMaterial toolMatIchor;
+
+ public static void initItems() {
+ darkQuartz = new ItemMod(LibItemIDs.idDarkQuartz).setUnlocalizedName(LibItemNames.DARK_QUARTZ);
+ connector = new ItemConnector(LibItemIDs.idConnector).setUnlocalizedName(LibItemNames.CONNECTOR);
+ gaseousLight = new ItemGas(LibItemIDs.idGaseousLight, ModBlocks.gaseousLight).setUnlocalizedName(LibItemNames.GASEOUS_LIGHT);
+ gaseousShadow = new ItemGas(LibItemIDs.idGaseousShadow, ModBlocks.gaseousShadow).setUnlocalizedName(LibItemNames.GASEOUS_SHADOW);
+ gasRemover = new ItemGasRemover(LibItemIDs.idGasRemover).setUnlocalizedName(LibItemNames.GAS_REMOVER);
+ spellCloth = new ItemSpellCloth(LibItemIDs.idSpellCloth).setUnlocalizedName(LibItemNames.SPELL_CLOTH);
+ focusFlight = new ItemFocusFlight(LibItemIDs.idFocusFlight).setUnlocalizedName(LibItemNames.FOCUS_FLIGHT);
+ focusDislocation = new ItemFocusDislocation(LibItemIDs.idFocusDislocation).setUnlocalizedName(LibItemNames.FOCUS_DISLOCATION);
+ cleansingTalisman = new ItemCleansingTalisman(LibItemIDs.idCleansingTalisman).setUnlocalizedName(LibItemNames.CLEANSING_TALISMAN);
+ brightNitor = new ItemBrightNitor(LibItemIDs.idBrightNitor).setUnlocalizedName(LibItemNames.BRIGHT_NTIOR);
+ focusTelekinesis = new ItemFocusTelekinesis(LibItemIDs.idFocusTelekinesis).setUnlocalizedName(LibItemNames.FOCUS_TELEKINESIS);
+ soulMould = new ItemSoulMould(LibItemIDs.idSoulMould).setUnlocalizedName(LibItemNames.SOUL_MOULD);
+ xpTalisman = new ItemXPTalisman(LibItemIDs.idXPTalisman).setUnlocalizedName(LibItemNames.XP_TALISMAN);
+ focusSmelt = new ItemFocusSmelt(LibItemIDs.idFocusSmelt).setUnlocalizedName(LibItemNames.FOCUS_SMELT);
+ focusHeal = new ItemFocusHeal(LibItemIDs.idFocusHeal).setUnlocalizedName(LibItemNames.FOCUS_HEAL);
+ focusEnderChest = new ItemFocusEnderChest(LibItemIDs.idFocusEnderChest).setUnlocalizedName(LibItemNames.FOCUS_ENDER_CHEST);
+ bloodSword = new ItemBloodSword(LibItemIDs.idBloodSword).setUnlocalizedName(LibItemNames.BLOOD_SWORD);
+ revealingHelm = new ItemRevealingHelm(LibItemIDs.idRevealingHelm).setUnlocalizedName(LibItemNames.REVEALING_HELM);
+ infusedInkwell = new ItemInfusedInkwell(LibItemIDs.idInfusedInkwell).setUnlocalizedName(LibItemNames.INFUSED_INKWELL);
+ focusDeflect = new ItemFocusDeflect(LibItemIDs.idFocusDeflect).setUnlocalizedName(LibItemNames.FOCUS_DEFLECT);
+ shareBook = new ItemShareBook(LibItemIDs.idShareBook).setUnlocalizedName(LibItemNames.SHARE_BOOK);
+
+ if(ConfigHandler.enableKami) {
+ toolMatIchor = EnumHelper.addToolMaterial("ICHOR", 4, -1, 10F, 5F, 25);
+
+ kamiResource = new ItemKamiResource(LibItemIDs.idKamiResource).setUnlocalizedName(LibItemNames.KAMI_RESOURCE);
+ ichorHelm = new ItemIchorclothArmor(LibItemIDs.idIchorHelm, 0).setUnlocalizedName(LibItemNames.ICHOR_HELM);
+ ichorChest = new ItemIchorclothArmor(LibItemIDs.idIchorChest, 1).setUnlocalizedName(LibItemNames.ICHOR_CHEST);
+ ichorLegs = new ItemIchorclothArmor(LibItemIDs.idIchorLegs, 2).setUnlocalizedName(LibItemNames.ICHOR_LEGS);
+ ichorBoots = new ItemIchorclothArmor(LibItemIDs.idIchorBoots, 3).setUnlocalizedName(LibItemNames.ICHOR_BOOTS);
+ ichorHelmGem = new ItemGemHelm(LibItemIDs.idIchorHelmGem, 0).setUnlocalizedName(LibItemNames.ICHOR_HELM_GEM);
+ ichorChestGem = new ItemGemChest(LibItemIDs.idIchorChestGem, 1).setUnlocalizedName(LibItemNames.ICHOR_CHEST_GEM);
+ ichorLegsGem = new ItemGemLegs(LibItemIDs.idIchorLegsGem, 2).setUnlocalizedName(LibItemNames.ICHOR_LEGS_GEM);
+ ichorBootsGem = new ItemGemBoots(LibItemIDs.idIchorBootsGem, 3).setUnlocalizedName(LibItemNames.ICHOR_BOOTS_GEM);
+ catAmulet = new ItemCatAmulet(LibItemIDs.idCatAmulet).setUnlocalizedName(LibItemNames.CAT_AMULET);
+ ichorPick = new ItemIchorPick(LibItemIDs.idIchorPick).setUnlocalizedName(LibItemNames.ICHOR_PICK);
+ ichorShovel = new ItemIchorShovel(LibItemIDs.idIchorShovel).setUnlocalizedName(LibItemNames.ICHOR_SHOVEL);
+ ichorAxe = new ItemIchorAxe(LibItemIDs.idIchorAxe).setUnlocalizedName(LibItemNames.ICHOR_AXE);
+ ichorSword = new ItemIchorSword(LibItemIDs.idIchorSword).setUnlocalizedName(LibItemNames.ICHOR_SWORD);
+ ichorPickGem = new ItemIchorPickAdv(LibItemIDs.idIchorPickGem).setUnlocalizedName(LibItemNames.ICHOR_PICK_GEM);
+ ichorShovelGem = new ItemIchorShovelAdv(LibItemIDs.idIchorShovelGem).setUnlocalizedName(LibItemNames.ICHOR_SHOVEL_GEM);
+ ichorAxeGem = new ItemIchorAxeAdv(LibItemIDs.idIchorAxeGem).setUnlocalizedName(LibItemNames.ICHOR_AXE_GEM);
+ ichorSwordGem = new ItemIchorSwordAdv(LibItemIDs.idIchorSwordGem).setUnlocalizedName(LibItemNames.ICHOR_SWORD_GEM);
+ ichorPouch = new ItemIchorPouch(LibItemIDs.idIchorPouch).setUnlocalizedName(LibItemNames.ICHOR_POUCH);
+ blockTalisman = new ItemBlockTalisman(LibItemIDs.idBlockTalisman).setUnlocalizedName(LibItemNames.BLOCK_TALISMAN);
+ placementMirror = new ItemPlacementMirror(LibItemIDs.idPlacementMirror).setUnlocalizedName(LibItemNames.PLACEMENT_MIRROR);
+ focusShadowbeam = new ItemFocusShadowbeam(LibItemIDs.idFocusShadowbeam).setUnlocalizedName(LibItemNames.FOCUS_SHADOWBEAM);
+ focusXPDrain = new ItemFocusXPDrain(LibItemIDs.idFocusXPDrain).setUnlocalizedName(LibItemNames.FOCUS_XP_DRAIN);
+ protoclay = new ItemProtoclay(LibItemIDs.idProtoclay).setUnlocalizedName(LibItemNames.PROTOCLAY);
+ skyPearl = new ItemSkyPearl(LibItemIDs.idSkyPearl).setUnlocalizedName(LibItemNames.SKY_PEARL);
+ focusRecall = new ItemFocusRecall(LibItemIDs.idFocusRecall).setUnlocalizedName(LibItemNames.FOCUS_RECALL);
+
+ capIchor = new CapIchor();
+ rodIchorcloth = new RodIchorcloth();
+
+ MinecraftForge.setToolClass(ichorPick, "pickaxe", 4);
+ MinecraftForge.setToolClass(ichorShovel, "shovel", 4);
+ MinecraftForge.setToolClass(ichorAxe, "axe", 4);
+ MinecraftForge.setToolClass(ichorPickGem, "pickaxe", 4);
+ MinecraftForge.setToolClass(ichorShovelGem, "shovel", 4);
+ MinecraftForge.setToolClass(ichorAxeGem, "axe", 4);
+ }
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/SpellClothRecipe.java b/src/main/java/vazkii/tinkerer/common/item/SpellClothRecipe.java
new file mode 100644
index 00000000..eac7aa0c
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/SpellClothRecipe.java
@@ -0,0 +1,82 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 01:20:26 (GMT)]
+ */
+package vazkii.tinkerer.common.item;
+
+import net.minecraft.inventory.InventoryCrafting;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.crafting.IRecipe;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.world.World;
+
+public class SpellClothRecipe implements IRecipe {
+
+ Item item;
+
+ public SpellClothRecipe(Item item) {
+ this.item = item;
+ }
+
+ @Override
+ public boolean matches(InventoryCrafting var1, World var2) {
+ boolean foundCloth = false;
+ boolean foundEnchanted = false;
+ for(int i = 0; i < var1.getSizeInventory(); i++) {
+ ItemStack stack = var1.getStackInSlot(i);
+ if(stack != null) {
+ if(stack.isItemEnchanted() && !(stack.getItem() instanceof INoRemoveEnchant) && !foundEnchanted)
+ foundEnchanted = true;
+
+ else if(stack.itemID == item.itemID && !foundCloth)
+ foundCloth = true;
+
+ else return false; // Found an invalid item, breaking the recipe
+ }
+ }
+
+ return foundCloth && foundEnchanted;
+ }
+
+ @Override
+ public ItemStack getCraftingResult(InventoryCrafting var1) {
+ ItemStack stackToDisenchant = null;
+ for(int i = 0; i < var1.getSizeInventory(); i++) {
+ ItemStack stack = var1.getStackInSlot(i);
+ if(stack != null && stack.isItemEnchanted()) {
+ stackToDisenchant = stack.copy();
+ break;
+ }
+ }
+
+ if(stackToDisenchant == null)
+ return null;
+
+ NBTTagCompound cmp = (NBTTagCompound) stackToDisenchant.getTagCompound().copy();
+ cmp.removeTag("ench"); // Remove enchantments
+ stackToDisenchant.setTagCompound(cmp);
+
+ return stackToDisenchant;
+ }
+
+ @Override
+ public int getRecipeSize() {
+ return 10;
+ }
+
+ @Override
+ public ItemStack getRecipeOutput() {
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusDeflect.java b/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusDeflect.java
new file mode 100644
index 00000000..e3940105
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusDeflect.java
@@ -0,0 +1,87 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 8, 2013, 6:26:09 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.foci;
+
+import java.util.List;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.IProjectile;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.AxisAlignedBB;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.client.codechicken.core.vec.Vector3;
+import thaumcraft.common.config.Config;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+
+public class ItemFocusDeflect extends ItemModFocus {
+
+ AspectList visUsage = new AspectList().add(Aspect.ORDER, 8).add(Aspect.AIR, 4);
+
+ public ItemFocusDeflect(int par1) {
+ super(par1);
+ }
+
+ @Override
+ public void onUsingFocusTick(ItemStack stack, EntityPlayer p, int ticks) {
+ ItemWandCasting wand = (ItemWandCasting) stack.getItem();
+
+ if(wand.consumeAllVis(stack, p, getVisCost(), true))
+ protectFromProjectiles(p);
+ }
+
+ public static void protectFromProjectiles(EntityPlayer p) {
+ List projectiles = p.worldObj.getEntitiesWithinAABB(IProjectile.class, AxisAlignedBB.getBoundingBox(p.posX - 4, p.posY - 4, p.posZ - 4, p.posX + 3, p.posY + 3, p.posZ + 3));
+
+ for(Entity e : projectiles) {
+ Vector3 motionVec = new Vector3(e.motionX, e.motionY, e.motionZ).normalize().multiply(Math.sqrt((e.posX - p.posX) * (e.posX - p.posX) + (e.posY - p.posY) * (e.posY - p.posY) + (e.posZ - p.posZ) * (e.posZ - p.posZ)) * 2) ;
+
+ for(int i = 0; i < 6; i++)
+ ThaumicTinkerer.tcProxy.sparkle((float) e.posX, (float) e.posY, (float) e.posZ, 6);
+
+ e.posX += motionVec.x;
+ e.posY += motionVec.y;
+ e.posZ += motionVec.z;
+ }
+ }
+
+ @Override
+ public String getSortingHelper(ItemStack paramItemStack) {
+ return "DEFLECT";
+ }
+
+ @Override
+ public boolean isVisCostPerTick() {
+ return true;
+ }
+
+ @Override
+ public boolean acceptsEnchant(int paramInt) {
+ return paramInt == Config.enchFrugal.effectId;
+ }
+
+ @Override
+ public int getFocusColor() {
+ return 0xFFFFFF;
+ }
+
+ @Override
+ public AspectList getVisCost() {
+ return visUsage;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusDislocation.java b/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusDislocation.java
new file mode 100644
index 00000000..df798147
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusDislocation.java
@@ -0,0 +1,193 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 22:19:25 (GMT)]
+ */
+package vazkii.tinkerer.common.item.foci;
+
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.tileentity.TileEntityMobSpawner;
+import net.minecraft.util.Icon;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.world.World;
+import thaumcraft.api.ThaumcraftApi;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.common.config.Config;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.core.helper.ItemNBTHelper;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemFocusDislocation extends ItemModFocus {
+
+ private static final String TAG_AVAILABLE = "available";
+ private static final String TAG_TILE_CMP = "tileCmp";
+ private static final String TAG_BLOCK_ID = "blockID";
+ private static final String TAG_BLOCK_META = "blockMeta";
+
+ private Icon ornament;
+
+ private static final AspectList visUsage = new AspectList().add(Aspect.ENTROPY, 500).add(Aspect.ORDER, 500).add(Aspect.EARTH, 100);
+ private static final AspectList visUsageTile = new AspectList().add(Aspect.ENTROPY, 2500).add(Aspect.ORDER, 2500).add(Aspect.EARTH, 500);
+ private static final AspectList visUsageSpawner = new AspectList().add(Aspect.ENTROPY, 10000).add(Aspect.ORDER, 10000).add(Aspect.EARTH, 5000);
+
+ public ItemFocusDislocation(int i) {
+ super(i);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ super.registerIcons(par1IconRegister);
+ ornament = IconHelper.forItem(par1IconRegister, this, "Orn");
+ }
+
+ @Override
+ public ItemStack onFocusRightClick(ItemStack itemstack, World world, EntityPlayer player, MovingObjectPosition mop) {
+ if(mop == null)
+ return itemstack;
+
+ int id = world.getBlockId(mop.blockX, mop.blockY, mop.blockZ);
+ int meta = world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ);
+ TileEntity tile = world.getBlockTileEntity(mop.blockX, mop.blockY, mop.blockZ);
+ ItemWandCasting wand = (ItemWandCasting)itemstack.getItem();
+
+ if(player.canPlayerEdit(mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, itemstack)) {
+ ItemStack stack = getPickedBlock(itemstack);
+ if(stack != null) {
+ if (mop.sideHit == 0)
+ --mop.blockY;
+ if (mop.sideHit == 1)
+ ++mop.blockY;
+ if (mop.sideHit == 2)
+ --mop.blockZ;
+ if (mop.sideHit == 3)
+ ++mop.blockZ;
+ if (mop.sideHit == 4)
+ --mop.blockX;
+ if (mop.sideHit == 5)
+ ++mop.blockX;
+
+ if(Block.blocksList[stack.itemID].canPlaceBlockOnSide(world, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, stack)) {
+ if(!world.isRemote) {
+ world.setBlock(mop.blockX, mop.blockY, mop.blockZ, stack.itemID, stack.getItemDamage(), 1 | 2);
+ Block.blocksList[stack.itemID].onBlockPlacedBy(world, mop.blockX, mop.blockY, mop.blockZ, player, itemstack);
+ NBTTagCompound tileCmp = getStackTileEntity(itemstack);
+ if(tileCmp != null && !tileCmp.getTags().isEmpty()) {
+ TileEntity tile1 = TileEntity.createAndLoadEntity(tileCmp);
+ tile1.xCoord = mop.blockX;
+ tile1.yCoord = mop.blockY;
+ tile1.zCoord = mop.blockZ;
+ world.setBlockTileEntity(mop.blockX, mop.blockY, mop.blockZ, tile1);
+ }
+ } else player.swingItem();
+ clearPickedBlock(itemstack);
+
+ for(int i = 0; i < 8; i++) {
+ float x = (float) (mop.blockX + Math.random());
+ float y = (float) (mop.blockY + Math.random()) + 0.65F;
+ float z = (float) (mop.blockZ + Math.random());
+ ThaumicTinkerer.tcProxy.burst(world, x, y, z, 0.2F);
+ }
+ world.playSoundAtEntity(player, "thaumcraft:wand", 0.5F, 1F);
+ }
+ } else if(!ThaumcraftApi.portableHoleBlackList.contains(id) && Item.itemsList[id] != null && Block.blocksList[id] != null && Block.blocksList[id].getBlockHardness(world, mop.blockX, mop.blockY, mop.blockZ) != -1F && wand.consumeAllVis(itemstack, player, getCost(tile), true)) {
+ if(!world.isRemote) {
+ world.removeBlockTileEntity(mop.blockX, mop.blockY, mop.blockZ);
+ world.setBlock(mop.blockX, mop.blockY, mop.blockZ, 0, 0, 1 | 2);
+ }
+
+ storePickedBlock(itemstack, (short) id, (short) meta, tile);
+
+ for(int i = 0; i < 8; i++) {
+ float x = (float) (mop.blockX + Math.random());
+ float y = (float) (mop.blockY + Math.random());
+ float z = (float) (mop.blockZ + Math.random());
+ ThaumicTinkerer.tcProxy.burst(world, x, y, z, 0.2F);
+ }
+ world.playSoundAtEntity(player, Block.blocksList[id].stepSound.getBreakSound(), 1F, 1F);
+ world.playSoundAtEntity(player, "thaumcraft:wand", 0.5F, 1F);
+
+ if(world.isRemote)
+ player.swingItem();
+ }
+ }
+
+ return itemstack;
+ }
+
+ private static AspectList getCost(TileEntity tile) {
+ return tile == null ? visUsage : tile instanceof TileEntityMobSpawner ? visUsageSpawner : visUsageTile;
+ }
+
+ @Override
+ public String getSortingHelper(ItemStack itemstack) {
+ return "DISLOCATION";
+ }
+
+ public ItemStack getPickedBlock(ItemStack stack) {
+ return stack.hasTagCompound() && stack.getTagCompound().hasKey(TAG_AVAILABLE) && stack.getTagCompound().getBoolean(TAG_AVAILABLE) ? getPickedBlockStack(stack) : null;
+ }
+
+ public ItemStack getPickedBlockStack(ItemStack stack) {
+ int id = ItemNBTHelper.getInt(stack, TAG_BLOCK_ID, 0);
+ int meta = ItemNBTHelper.getInt(stack, TAG_BLOCK_META, 0);
+ return new ItemStack(id, 1, meta);
+ }
+
+ public NBTTagCompound getStackTileEntity(ItemStack stack) {
+ return ItemNBTHelper.getCompound(stack, TAG_TILE_CMP, true);
+ }
+
+ private void storePickedBlock(ItemStack stack, int id, short meta, TileEntity tile) {
+ ItemNBTHelper.setInt(stack, TAG_BLOCK_ID, id);
+ ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta);
+ NBTTagCompound cmp = new NBTTagCompound();
+ if(tile != null)
+ tile.writeToNBT(cmp);
+ ItemNBTHelper.setCompound(stack, TAG_TILE_CMP, cmp);
+ ItemNBTHelper.setBoolean(stack, TAG_AVAILABLE, true);
+ }
+
+ private void clearPickedBlock(ItemStack stack) {
+ ItemNBTHelper.setBoolean(stack, TAG_AVAILABLE, false);
+ }
+
+ @Override
+ public int getFocusColor() {
+ return 0xFFB200;
+ }
+
+ @Override
+ public Icon getOrnament() {
+ return ornament;
+ }
+
+ @Override
+ public AspectList getVisCost() {
+ return visUsage;
+ }
+
+ @Override
+ public boolean acceptsEnchant(int paramInt) {
+ return super.acceptsEnchant(paramInt) && paramInt != Config.enchPotency.effectId;
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusEnderChest.java b/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusEnderChest.java
new file mode 100644
index 00000000..006535d6
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusEnderChest.java
@@ -0,0 +1,71 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Nov 24, 2013, 2:49:01 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.foci;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.world.World;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.common.config.Config;
+import thaumcraft.common.items.wands.ItemWandCasting;
+
+public class ItemFocusEnderChest extends ItemModFocus {
+
+ private static final AspectList visUsage = new AspectList().add(Aspect.ENTROPY, 100).add(Aspect.ORDER, 100);
+
+ public ItemFocusEnderChest(int par1) {
+ super(par1);
+ }
+
+ @Override
+ public ItemStack onFocusRightClick(ItemStack stack, World world, EntityPlayer p, MovingObjectPosition pos) {
+ ItemWandCasting wand = (ItemWandCasting) stack.getItem();
+
+ if(wand.consumeAllVis(stack, p, visUsage, true)) {
+ p.displayGUIChest(p.getInventoryEnderChest());
+ world.playSoundAtEntity(p, "mob.endermen.portal", 1F, 1F);
+ }
+
+ return stack;
+ }
+
+ @Override
+ public boolean acceptsEnchant(int paramInt) {
+ return paramInt == Config.enchFrugal.effectId;
+ }
+
+ @Override
+ public int getFocusColor() {
+ return 0x132223;
+ }
+
+ @Override
+ protected boolean hasDepth() {
+ return true;
+ }
+
+ @Override
+ public String getSortingHelper(ItemStack paramItemStack) {
+ return "ENDERCHEST";
+ }
+
+ @Override
+ public AspectList getVisCost() {
+ return visUsage;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusFlight.java b/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusFlight.java
new file mode 100644
index 00000000..88e8a1e9
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusFlight.java
@@ -0,0 +1,79 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 19:27:13 (GMT)]
+ */
+package vazkii.tinkerer.common.item.foci;
+
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.Vec3;
+import net.minecraft.world.World;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.common.config.Config;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+
+public class ItemFocusFlight extends ItemModFocus {
+
+ private static final AspectList visUsage = new AspectList().add(Aspect.AIR, 15);
+
+ public ItemFocusFlight(int i) {
+ super(i);
+ }
+
+ @Override
+ public ItemStack onFocusRightClick(ItemStack itemstack, World world, EntityPlayer p, MovingObjectPosition movingobjectposition) {
+ ItemWandCasting wand = (ItemWandCasting)itemstack.getItem();
+
+ if (wand.consumeAllVis(itemstack, p, getVisCost(), true)) {
+ Vec3 vec = p.getLookVec();
+ double force = 1 / 1.5 * (1 + EnchantmentHelper.getEnchantmentLevel(Config.enchPotency.effectId, wand.getFocusItem(itemstack)) * 0.2);
+ p.motionX = vec.xCoord * force;
+ p.motionY = vec.yCoord * force;
+ p.motionZ = vec.zCoord * force;
+ p.fallDistance = 0F;
+
+ for(int i = 0; i < 5; i++)
+ ThaumicTinkerer.tcProxy.smokeSpiral(world, p.posX, p.posY - p.motionY, p.posZ, 2F, (int) Math.random() * 360, (int) p.posY);
+ world.playSoundAtEntity(p, "thaumcraft:wind", 0.4F, 1F);
+ }
+
+ if(world.isRemote)
+ p.swingItem();
+
+ return itemstack;
+ }
+
+ @Override
+ public String getSortingHelper(ItemStack itemstack) {
+ return "FLIGHT";
+ }
+
+ @Override
+ public int getFocusColor() {
+ return 0x9EF2FF;
+ }
+
+ @Override
+ protected boolean hasOrnament() {
+ return true;
+ }
+
+ @Override
+ public AspectList getVisCost() {
+ return visUsage;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusHeal.java b/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusHeal.java
new file mode 100644
index 00000000..d6f4ec6d
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusHeal.java
@@ -0,0 +1,101 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [26 Oct 2013, 12:04:52 (GMT)]
+ */
+package vazkii.tinkerer.common.item.foci;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.common.config.Config;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+
+public class ItemFocusHeal extends ItemModFocus {
+
+ private static final AspectList visUsage = new AspectList().add(Aspect.EARTH, 45).add(Aspect.WATER, 45);
+
+ public static Map playerHealData = new HashMap();
+
+ public ItemFocusHeal(int par1) {
+ super(par1);
+ }
+
+ @Override
+ public void onUsingFocusTick(ItemStack stack, EntityPlayer p, int time) {
+ ItemWandCasting wand = (ItemWandCasting) stack.getItem();
+ if(!wand.consumeAllVis(stack, p, visUsage, false) || !p.shouldHeal())
+ return;
+
+ int potency = EnchantmentHelper.getEnchantmentLevel(Config.enchPotency.effectId, wand.getFocusItem(stack));
+
+
+ if(!playerHealData.containsKey(p.username))
+ playerHealData.put(p.username, 0);
+
+ int progress = playerHealData.get(p.username) + 1;
+ playerHealData.put(p.username, progress);
+
+ ThaumicTinkerer.tcProxy.sparkle((float)p.posX + p.worldObj.rand.nextFloat() - 0.5F, (float)p.posY + p.worldObj.rand.nextFloat(), (float)p.posZ + p.worldObj.rand.nextFloat() - 0.5F, 0);
+
+ if(progress >= 30 - potency * 10 / 3) {
+ playerHealData.put(p.username, 0);
+
+ wand.consumeAllVis(stack, p, visUsage, true);
+ p.heal(1);
+ p.worldObj.playSoundAtEntity(p, "thaumcraft:wand", 0.5F, 1F);
+ }
+ }
+
+ @Override
+ public void onPlayerStoppedUsingFocus(ItemStack paramItemStack, World paramWorld, EntityPlayer paramEntityPlayer, int paramInt) {
+ playerHealData.put(paramEntityPlayer.username, 0);
+ }
+
+ @Override
+ protected boolean hasDepth() {
+ return true;
+ }
+
+ @Override
+ public boolean isVisCostPerTick() {
+ return false;
+ }
+
+ @Override
+ public boolean isUseItem() {
+ return true;
+ }
+
+ @Override
+ public String getSortingHelper(ItemStack paramItemStack) {
+ return "HEAL";
+ }
+
+ @Override
+ public int getFocusColor() {
+ return 0xFD00D6;
+ }
+
+ @Override
+ public AspectList getVisCost() {
+ return visUsage;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusSmelt.java b/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusSmelt.java
new file mode 100644
index 00000000..8fae2598
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusSmelt.java
@@ -0,0 +1,132 @@
+package vazkii.tinkerer.common.item.foci;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.crafting.FurnaceRecipes;
+import net.minecraft.util.MovingObjectPosition;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.common.config.Config;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import thaumcraft.common.lib.Utils;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+
+public class ItemFocusSmelt extends ItemModFocus {
+
+ public static Map playerData = new HashMap();
+
+ static class SmeltData {
+ public MovingObjectPosition pos;
+ public int progress;
+
+ public SmeltData(MovingObjectPosition pos, int progress) {
+ this.pos = pos;
+ this.progress = progress;
+ }
+
+ public boolean equalPos(MovingObjectPosition pos) {
+ return pos.blockX == this.pos.blockX && pos.blockY == this.pos.blockY && pos.blockZ == this.pos.blockZ;
+ }
+ }
+
+ private static final AspectList visUsage = new AspectList().add(Aspect.FIRE, 45).add(Aspect.ENTROPY, 12);
+
+ public ItemFocusSmelt(int par1) {
+ super(par1);
+ }
+
+ @Override
+ public boolean isUseItem() {
+ return true;
+ }
+
+ @Override
+ public void onUsingFocusTick(ItemStack stack, EntityPlayer p, int time) {
+ ItemWandCasting wand = (ItemWandCasting) stack.getItem();
+ if(!wand.consumeAllVis(stack, p, visUsage, false))
+ return;
+
+ MovingObjectPosition pos = Utils.getTargetBlock(p.worldObj, p, false);
+
+ if(pos != null) {
+ int id = p.worldObj.getBlockId(pos.blockX, pos.blockY, pos.blockZ);
+ int meta = p.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);
+
+ ItemStack blockStack = new ItemStack(id, 1, meta);
+ ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(blockStack);
+
+ if(result != null && result.getItem() instanceof ItemBlock) {
+ boolean decremented = false;
+
+ if(playerData.containsKey(p.username)) {
+ SmeltData data = playerData.get(p.username);
+
+ if(data.equalPos(pos)) {
+ data.progress--;
+ decremented = true;
+ if(data.progress <= 0) {
+ if(!p.worldObj.isRemote) {
+ p.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, result.itemID, result.getItemDamage(), 1 | 2);
+ p.worldObj.playSoundAtEntity(p, "fire.ignite", 0.6F, 1F);
+ p.worldObj.playSoundAtEntity(p, "fire.fire", 1F, 1F);
+
+ wand.consumeAllVis(stack, p, visUsage, true);
+ playerData.remove(p.username);
+ decremented = false;
+ }
+
+ for(int i = 0; i < 25; i++) {
+ double x = pos.blockX + Math.random();
+ double y = pos.blockY + Math.random();
+ double z = pos.blockZ + Math.random();
+
+ ThaumicTinkerer.tcProxy.wispFX2(p.worldObj, x, y, z, (float) Math.random() / 2F, 4, true, (float) -Math.random() / 10F);
+ }
+ }
+ }
+ }
+
+ if(!decremented) {
+ int potency = EnchantmentHelper.getEnchantmentLevel(Config.enchPotency.effectId, wand.getFocusItem(stack));
+ playerData.put(p.username, new SmeltData(pos, 20 - Math.min(3, potency) * 5));
+ } else for(int i = 0; i < 2; i++) {
+ double x = pos.blockX + Math.random();
+ double y = pos.blockY + Math.random();
+ double z = pos.blockZ + Math.random();
+ p.worldObj.playSoundAtEntity(p, "fire.fire", (float) Math.random() / 2F + 0.5F, 1F);
+
+ ThaumicTinkerer.tcProxy.wispFX2(p.worldObj, x, y, z, (float) Math.random() / 2F, 4, true, (float) -Math.random() / 10F);
+ }
+
+ if(p.worldObj.isRemote)
+ ThaumicTinkerer.tcProxy.beamCont(p.worldObj, p, pos.blockX + 0.5, pos.blockY + 0.5, pos.blockZ + 0.5, 2, 0xFF0000, true, 0F, null, 1);
+ }
+ }
+ }
+
+ @Override
+ public String getSortingHelper(ItemStack itemstack) {
+ return "SMELT";
+ }
+
+ @Override
+ protected boolean hasOrnament() {
+ return true;
+ }
+
+ @Override
+ public int getFocusColor() {
+ return 0xFF0000;
+ }
+
+ @Override
+ public AspectList getVisCost() {
+ return visUsage;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusTelekinesis.java b/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusTelekinesis.java
new file mode 100644
index 00000000..4db69e61
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/foci/ItemFocusTelekinesis.java
@@ -0,0 +1,88 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [11 Sep 2013, 23:21:21 (GMT)]
+ */
+package vazkii.tinkerer.common.item.foci;
+
+import java.util.List;
+
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.AxisAlignedBB;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.client.codechicken.core.vec.Vector3;
+import thaumcraft.common.config.Config;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.core.helper.MiscHelper;
+
+public class ItemFocusTelekinesis extends ItemModFocus {
+
+ private static final AspectList visUsage = new AspectList().add(Aspect.AIR, 5).add(Aspect.ENTROPY, 5);
+
+ public ItemFocusTelekinesis(int par1) {
+ super(par1);
+ }
+
+ @Override
+ public void onUsingFocusTick(ItemStack stack, EntityPlayer player, int ticks) {
+ ItemWandCasting wand = (ItemWandCasting) stack.getItem();
+
+ Vector3 target = Vector3.fromEntityCenter(player);
+
+ final int range = 6 + EnchantmentHelper.getEnchantmentLevel(Config.enchPotency.effectId, wand.getFocusItem(stack));
+ final double distance = range - 1;
+ if(!player.isSneaking())
+ target.add(new Vector3(player.getLookVec()).multiply(distance));
+
+ target.y += 0.5;
+
+ List entities = player.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(target.x - range, target.y - range, target.z - range, target.x + range, target.y + range, target.z + range));
+
+ if(!entities.isEmpty() && wand.consumeAllVis(stack, player, getVisCost(), true)) {
+ for(EntityItem item : entities) {
+ MiscHelper.setEntityMotionFromVector(item, target, 0.3333F);
+ ThaumicTinkerer.tcProxy.sparkle((float) item.posX, (float) item.posY, (float) item.posZ, 0);
+ }
+ }
+ }
+
+ @Override
+ public String getSortingHelper(ItemStack itemstack) {
+ return "TELEKINESIS";
+ }
+
+ @Override
+ protected boolean hasOrnament() {
+ return true;
+ }
+
+ @Override
+ public int getFocusColor() {
+ return 0x9C00BE;
+ }
+
+ @Override
+ public AspectList getVisCost() {
+ return visUsage;
+ }
+
+ @Override
+ public boolean isVisCostPerTick() {
+ return true;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/foci/ItemModFocus.java b/src/main/java/vazkii/tinkerer/common/item/foci/ItemModFocus.java
new file mode 100644
index 00000000..d9f1a947
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/foci/ItemModFocus.java
@@ -0,0 +1,151 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 19:22:59 (GMT)]
+ */
+package vazkii.tinkerer.common.item.foci;
+
+import java.util.List;
+
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Icon;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.api.wands.IWandFocus;
+import thaumcraft.common.config.Config;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.common.item.ItemMod;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public abstract class ItemModFocus extends ItemMod implements IWandFocus {
+
+ private Icon ornament, depth;
+
+ public ItemModFocus(int par1) {
+ super(par1);
+ setMaxDamage(1);
+ setNoRepair();
+ setMaxStackSize(1);
+ }
+
+ protected boolean hasOrnament() {
+ return false;
+ }
+
+ protected boolean hasDepth() {
+ return false;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ super.registerIcons(par1IconRegister);
+ if(hasOrnament())
+ ornament = IconHelper.forItem(par1IconRegister, this, "Orn");
+ if(hasDepth())
+ depth = IconHelper.forItem(par1IconRegister, this, "Depth");
+ }
+
+ @Override
+ public boolean isItemTool(ItemStack par1ItemStack){
+ return true;
+ }
+
+ @Override
+ public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
+ AspectList cost = getVisCost();
+ if(cost != null) {
+ list.add(StatCollector.translateToLocal(isVisCostPerTick() ? "item.Focus.cost2" : "item.Focus.cost1"));
+ addVisCostTooltip(cost, stack, player, list, par4);
+ }
+ }
+
+ protected void addVisCostTooltip(AspectList cost, ItemStack stack, EntityPlayer player, List list, boolean par4) {
+ for(Aspect aspect : cost.getAspectsSorted()) {
+ float amount = cost.getAmount(aspect) / 100.0F;
+ list.add(" " + '\u00a7' + aspect.getChatcolor() + aspect.getName() + '\u00a7' + "r x " + amount);
+ }
+ }
+
+ @Override
+ public int getItemEnchantability() {
+ return 5;
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack itemstack) {
+ return EnumRarity.rare;
+ }
+
+ @Override
+ public Icon getOrnament() {
+ return ornament;
+ }
+
+ @Override
+ public Icon getFocusDepthLayerIcon() {
+ return depth;
+ }
+
+ @Override
+ public WandFocusAnimation getAnimation() {
+ return WandFocusAnimation.WAVE;
+ }
+
+ @Override
+ public boolean isVisCostPerTick() {
+ return false;
+ }
+
+ public boolean isUseItem() {
+ return isVisCostPerTick();
+ }
+
+ @Override
+ public ItemStack onFocusRightClick(ItemStack paramItemStack, World paramWorld, EntityPlayer paramEntityPlayer, MovingObjectPosition paramMovingObjectPosition) {
+ if(isUseItem())
+ paramEntityPlayer.setItemInUse(paramItemStack, Integer.MAX_VALUE);
+
+ return paramItemStack;
+ }
+
+ @Override
+ public void onUsingFocusTick(ItemStack paramItemStack, EntityPlayer paramEntityPlayer, int paramInt) {
+ // NO-OP
+ }
+
+ @Override
+ public void onPlayerStoppedUsingFocus(ItemStack paramItemStack, World paramWorld, EntityPlayer paramEntityPlayer, int paramInt) {
+ // NO-OP
+ }
+
+ @Override
+ public abstract String getSortingHelper(ItemStack paramItemStack);
+
+ @Override
+ public boolean onFocusBlockStartBreak(ItemStack paramItemStack, int paramInt1, int paramInt2, int paramInt3, EntityPlayer paramEntityPlayer) {
+ return false;
+ }
+
+ @Override
+ public boolean acceptsEnchant(int paramInt) {
+ return paramInt != Config.enchWandFortune.effectId;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/ItemBlockTalisman.java b/src/main/java/vazkii/tinkerer/common/item/kami/ItemBlockTalisman.java
new file mode 100644
index 00000000..15dc1316
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/ItemBlockTalisman.java
@@ -0,0 +1,241 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 30, 2013, 12:46:22 AM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami;
+
+import java.util.Arrays;
+import java.util.List;
+
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.Icon;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.client.core.proxy.TTClientProxy;
+import vazkii.tinkerer.common.block.tile.transvector.TileTransvectorInterface;
+import vazkii.tinkerer.common.core.helper.ItemNBTHelper;
+import vazkii.tinkerer.common.item.ItemMod;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemBlockTalisman extends ItemMod {
+
+ private static final String TAG_BLOCK_ID = "blockID";
+ private static final String TAG_BLOCK_META = "blockMeta";
+ private static final String TAG_BLOCK_COUNT = "blockCount";
+
+ Icon enabledIcon;
+
+ public ItemBlockTalisman(int par1) {
+ super(par1);
+ setMaxStackSize(1);
+ setHasSubtypes(true);
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+ if(getBlockID(par1ItemStack) != 0 && par3EntityPlayer.isSneaking()) {
+ int dmg = par1ItemStack.getItemDamage();
+ par1ItemStack.setItemDamage(~dmg & 1);
+ par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F);
+ }
+ return par1ItemStack;
+ }
+
+ @Override
+ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
+ int id = par3World.getBlockId(par4, par5, par6);
+ int meta = par3World.getBlockMetadata(par4, par5, par6);
+ boolean set = setBlock(par1ItemStack, id, meta);
+
+ if(!set) {
+ int bid = getBlockID(par1ItemStack);
+ int bmeta = getBlockMeta(par1ItemStack);
+
+ TileEntity tile = par3World.getBlockTileEntity(par4, par5, par6);
+ if(tile != null && tile instanceof IInventory) {
+ IInventory inv = (IInventory) tile;
+ int[] slots = inv instanceof ISidedInventory ? ((ISidedInventory) inv).getAccessibleSlotsFromSide(par7) : TileTransvectorInterface.buildSlotsForLinearInventory(inv);
+ for(int slot : slots) {
+ ItemStack stackInSlot = inv.getStackInSlot(slot);
+ if(stackInSlot == null) {
+ ItemStack stack = new ItemStack(bid, 1, bmeta);
+ int maxSize = stack.getMaxStackSize();
+ stack.stackSize = remove(par1ItemStack, maxSize);
+ if(stack.stackSize != 0) {
+ if(inv.isItemValidForSlot(slot, stack) && (!(inv instanceof ISidedInventory) || ((ISidedInventory) inv).canInsertItem(slot, stack, par7))) {
+ inv.setInventorySlotContents(slot, stack);
+ inv.onInventoryChanged();
+ set = true;
+ }
+ }
+ } else if(stackInSlot.itemID == bid && stackInSlot.getItemDamage() == bmeta) {
+ int maxSize = stackInSlot.getMaxStackSize();
+ int missing = maxSize - stackInSlot.stackSize;
+ if(inv.isItemValidForSlot(slot, stackInSlot) && (!(inv instanceof ISidedInventory) || ((ISidedInventory) inv).canInsertItem(slot, stackInSlot, par7))) {
+ stackInSlot.stackSize += remove(par1ItemStack, missing);
+ inv.onInventoryChanged();
+ set = true;
+ }
+ }
+ }
+ } else {
+ int remove = remove(par1ItemStack, 1);
+ if(remove > 0) {
+ Item.itemsList[bid].onItemUse(new ItemStack(bid, 1, bmeta), par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
+ set = true;
+ }
+ }
+ }
+
+ par2EntityPlayer.setCurrentItemOrArmor(0, par1ItemStack);
+
+ return set;
+ }
+
+ @Override
+ public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
+ int id = getBlockID(par1ItemStack);
+ if(/*!par2World.isRemote && */par1ItemStack.getItemDamage() == 1 && id != 0 && par3Entity instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) par3Entity;
+ int meta = getBlockMeta(par1ItemStack);
+
+ int highest = -1;
+ boolean hasFreeSlot = false;
+ int[] counts = new int[player.inventory.getSizeInventory() - player.inventory.armorInventory.length];
+ Arrays.fill(counts, 0);
+
+ for(int i = 0; i < counts.length; i++) {
+ ItemStack stack = player.inventory.getStackInSlot(i);
+ if(stack == null) {
+ hasFreeSlot = true;
+ continue;
+ }
+
+ if(stack.itemID == id && stack.getItemDamage() == meta) {
+ counts[i] = stack.stackSize;
+ if(highest == -1)
+ highest = i;
+ else highest = counts[i] > counts[highest] && highest > 8 ? i : highest;
+ }
+ }
+
+ if(highest == -1) {
+ ItemStack heldItem = player.inventory.getItemStack();
+ if(hasFreeSlot && (heldItem == null || heldItem.itemID != id || heldItem.getItemDamage() != meta)) {
+ ItemStack stack = new ItemStack(id, remove(par1ItemStack, 64), meta);
+ if(stack.stackSize != 0)
+ player.inventory.addItemStackToInventory(stack);
+ }
+ } else {
+ for(int i = 0; i < counts.length; i++) {
+ int count = counts[i];
+
+ if(i == highest || count == 0)
+ continue;
+
+ add(par1ItemStack, count);
+ player.inventory.setInventorySlotContents(i, null);
+ }
+
+ int countInHighest = counts[highest];
+ int maxSize = new ItemStack(id, 1, meta).getMaxStackSize();
+ if(countInHighest < maxSize) {
+ int missing = maxSize - countInHighest;
+ ItemStack stackInHighest = player.inventory.getStackInSlot(highest);
+ stackInHighest.stackSize += remove(par1ItemStack, missing);
+ }
+ }
+ }
+ }
+
+ private boolean setBlock(ItemStack stack, int id, int meta) {
+ if(getBlockID(stack) == 0 || getBlockCount(stack) == 0) {
+ ItemNBTHelper.setInt(stack, TAG_BLOCK_ID, id);
+ ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta);
+ return true;
+ }
+ return false;
+ }
+
+ private static void setCount(ItemStack stack, int count) {
+ ItemNBTHelper.setInt(stack, TAG_BLOCK_COUNT, count);
+ }
+
+ private void add(ItemStack stack, int count) {
+ int current = getBlockCount(stack);
+ setCount(stack, current + count);
+ }
+
+ public static int remove(ItemStack stack, int count) {
+ int current = getBlockCount(stack);
+ setCount(stack, Math.max(current - count, 0));
+
+ return Math.min(current, count);
+ }
+
+ public static int getBlockID(ItemStack stack) {
+ return ItemNBTHelper.getInt(stack, TAG_BLOCK_ID, 0);
+ }
+
+ public static int getBlockMeta(ItemStack stack) {
+ return ItemNBTHelper.getInt(stack, TAG_BLOCK_META, 0);
+ }
+
+ public static int getBlockCount(ItemStack stack) {
+ return ItemNBTHelper.getInt(stack, TAG_BLOCK_COUNT, 0);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ itemIcon = IconHelper.forItem(par1IconRegister, this, 0);
+ enabledIcon = IconHelper.forItem(par1IconRegister, this, 1);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public Icon getIconFromDamage(int par1) {
+ return par1 == 1 ? enabledIcon : itemIcon;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
+ int id = getBlockID(par1ItemStack);
+ if(id != 0 && Block.blocksList[id] != null) {
+ int count = getBlockCount(par1ItemStack);
+ par3List.add(StatCollector.translateToLocal(new ItemStack(Block.blocksList[id], 1, getBlockMeta(par1ItemStack)).getUnlocalizedName() + ".name") + " (x" + count + ")");
+ }
+
+ if(par1ItemStack.getItemDamage() == 1)
+ par3List.add(StatCollector.translateToLocal("ttmisc.active"));
+ else par3List.add(StatCollector.translateToLocal("ttmisc.inactive"));
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return TTClientProxy.kamiRarity;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/ItemBlockWarpGate.java b/src/main/java/vazkii/tinkerer/common/item/kami/ItemBlockWarpGate.java
new file mode 100644
index 00000000..72082353
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/ItemBlockWarpGate.java
@@ -0,0 +1,33 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Jan 10, 2014, 4:39:07 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami;
+
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import vazkii.tinkerer.client.core.proxy.TTClientProxy;
+
+public class ItemBlockWarpGate extends ItemBlock {
+
+ public ItemBlockWarpGate(int par1) {
+ super(par1);
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return TTClientProxy.kamiRarity;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/ItemCatAmulet.java b/src/main/java/vazkii/tinkerer/common/item/kami/ItemCatAmulet.java
new file mode 100644
index 00000000..5e4d9764
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/ItemCatAmulet.java
@@ -0,0 +1,88 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 27, 2013, 7:41:50 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLiving;
+import net.minecraft.entity.ai.EntityAIAvoidEntity;
+import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
+import net.minecraft.entity.ai.EntityAITaskEntry;
+import net.minecraft.entity.item.EntityEnderCrystal;
+import net.minecraft.entity.monster.EntityCreeper;
+import net.minecraft.entity.passive.EntityOcelot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.world.World;
+import vazkii.tinkerer.client.core.proxy.TTClientProxy;
+import vazkii.tinkerer.common.item.ItemMod;
+import vazkii.tinkerer.common.lib.LibObfuscation;
+import cpw.mods.fml.relauncher.ReflectionHelper;
+
+public class ItemCatAmulet extends ItemMod {
+
+ public ItemCatAmulet(int par1) {
+ super(par1);
+ setMaxStackSize(1);
+ }
+
+ @Override
+ public void onUpdate(ItemStack par1ItemStack, World par2World, Entity e, int par4, boolean par5) {
+ int range = 10;
+ int rangeY = 4;
+ List entities = par2World.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(e.posX - range, e.posY - rangeY, e.posZ - range, e.posX + range, e.posY + rangeY, e.posZ + range));
+
+ for(EntityLiving entity : entities) {
+ List entries = new ArrayList(entity.tasks.taskEntries);
+ entries.addAll(new ArrayList(entity.targetTasks.taskEntries));
+
+ boolean avoidsOcelots = false;
+ for(EntityAITaskEntry entry : entries) {
+ if(entry.action instanceof EntityAIAvoidEntity)
+ avoidsOcelots = messWithRunAwayAI((EntityAIAvoidEntity) entry.action) || avoidsOcelots;
+
+ if(entry.action instanceof EntityAINearestAttackableTarget)
+ messWithGetTargetAI((EntityAINearestAttackableTarget) entry.action);
+ }
+
+ if(entity instanceof EntityCreeper) {
+ ReflectionHelper.setPrivateValue(EntityCreeper.class, (EntityCreeper) entity, 2, LibObfuscation.TIME_SINCE_IGNITED);
+ entity.setAttackTarget(null);
+ }
+ }
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return TTClientProxy.kamiRarity;
+ }
+
+ 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);
+ 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
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/ItemIchorPouch.java b/src/main/java/vazkii/tinkerer/common/item/kami/ItemIchorPouch.java
new file mode 100644
index 00000000..59c36936
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/ItemIchorPouch.java
@@ -0,0 +1,79 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 10:15:39 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami;
+
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.util.Icon;
+import net.minecraft.world.World;
+import thaumcraft.common.items.wands.ItemFocusPouch;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.client.core.proxy.TTClientProxy;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.core.handler.ModCreativeTab;
+import vazkii.tinkerer.common.lib.LibGuiIDs;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemIchorPouch extends ItemFocusPouch {
+
+ public ItemIchorPouch(int par1) {
+ super(par1);
+ setCreativeTab(ModCreativeTab.INSTANCE);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ itemIcon = IconHelper.forItem(par1IconRegister, this);
+ }
+
+ @Override
+ public Icon getIconFromDamage(int par1) {
+ return itemIcon;
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return TTClientProxy.kamiRarity;
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+ par3EntityPlayer.openGui(ThaumicTinkerer.instance, LibGuiIDs.GUI_ID_ICHOR_POUCH, par2World, 0, 0, 0);
+ return par1ItemStack;
+ }
+
+ @Override
+ public ItemStack[] getInventory(ItemStack item) {
+ ItemStack[] stackList = new ItemStack[13 * 9];
+ if (item.hasTagCompound()) {
+ NBTTagList var2 = item.stackTagCompound.getTagList("Inventory");
+ for (int var3 = 0; var3 < var2.tagCount(); var3++) {
+ NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
+ int var5 = var4.getByte("Slot") & 0xFF;
+ if (var5 >= 0 && var5 < stackList.length)
+ stackList[var5] = ItemStack.loadItemStackFromNBT(var4);
+ }
+ }
+
+ return stackList;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/ItemKamiResource.java b/src/main/java/vazkii/tinkerer/common/item/kami/ItemKamiResource.java
new file mode 100644
index 00000000..652cf0cb
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/ItemKamiResource.java
@@ -0,0 +1,67 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 21, 2013, 7:34:11 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami;
+
+import java.util.List;
+
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Icon;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.client.core.proxy.TTClientProxy;
+import vazkii.tinkerer.common.item.ItemMod;
+import vazkii.tinkerer.common.lib.LibItemNames;
+
+public class ItemKamiResource extends ItemMod {
+
+ final int subtypes = 8;
+ Icon[] icons;
+
+ public ItemKamiResource(int par1) {
+ super(par1);
+ setHasSubtypes(true);
+ }
+
+ @Override
+ public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) {
+ for(int i = 0; i < subtypes; i++)
+ par3List.add(new ItemStack(par1, 1, i));
+ }
+
+ @Override
+ public void registerIcons(IconRegister par1IconRegister) {
+ icons = new Icon[subtypes];
+
+ for(int i = 0; i < icons.length; i++)
+ icons[i] = IconHelper.forNameRaw(par1IconRegister, LibItemNames.KAMI_RESOURCE_NAMES[i]);
+ }
+
+ @Override
+ public Icon getIconFromDamage(int par1) {
+ return icons[Math.min(subtypes - 1, par1)];
+ }
+
+ @Override
+ public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) {
+ return par1ItemStack.getItemDamage() >= subtypes ? super.getUnlocalizedName(par1ItemStack) : "item." + LibItemNames.KAMI_RESOURCE_NAMES[par1ItemStack.getItemDamage()];
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return par1ItemStack.getItemDamage() != 7 && par1ItemStack.getItemDamage() != 6 ? TTClientProxy.kamiRarity : super.getRarity(par1ItemStack);
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/ItemPlacementMirror.java b/src/main/java/vazkii/tinkerer/common/item/kami/ItemPlacementMirror.java
new file mode 100644
index 00000000..3a12d16f
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/ItemPlacementMirror.java
@@ -0,0 +1,233 @@
+package vazkii.tinkerer.common.item.kami;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ChunkCoordinates;
+import net.minecraft.util.Icon;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import net.minecraftforge.common.ForgeDirection;
+import vazkii.tinkerer.client.core.handler.kami.ToolModeHUDHandler;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.client.core.proxy.TTClientProxy;
+import vazkii.tinkerer.common.core.helper.ItemNBTHelper;
+import vazkii.tinkerer.common.item.ItemMod;
+import vazkii.tinkerer.common.item.ModItems;
+import vazkii.tinkerer.common.item.kami.tool.ToolHandler;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemPlacementMirror extends ItemMod {
+
+ private static final String TAG_BLOCK_ID = "blockID";
+ private static final String TAG_BLOCK_META = "blockMeta";
+ private static final String TAG_SIZE = "size";
+
+ Icon[] icons = new Icon[2];
+
+ public ItemPlacementMirror(int par1) {
+ super(par1);
+ setMaxStackSize(1);
+ }
+
+ @Override
+ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
+ int id = par3World.getBlockId(par4, par5, par6);
+ int meta = par3World.getBlockMetadata(par4, par5, par6);
+
+ if(par2EntityPlayer.isSneaking()) {
+ if(Block.blocksList[id] != null && Block.blocksList[id].getRenderType() == 0)
+ setBlock(par1ItemStack, id, meta);
+ } else placeAllBlocks(par1ItemStack, par2EntityPlayer);
+
+ return true;
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+ if(par3EntityPlayer.isSneaking()) {
+ int size = getSize(par1ItemStack);
+ int newSize = size == 11 ? 3 : size + 2;
+ setSize(par1ItemStack, newSize);
+ ToolModeHUDHandler.setTooltip(newSize + " x " + newSize);
+ par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F);
+ }
+
+ return par1ItemStack;
+ }
+
+ public void placeAllBlocks(ItemStack stack, EntityPlayer player) {
+ ChunkCoordinates[] blocksToPlace = getBlocksToPlace(stack, player);
+ if(!hasBlocks(stack, player, blocksToPlace))
+ return;
+
+ ItemStack stackToPlace = new ItemStack(getBlockID(stack), 1, getBlockMeta(stack));
+ for(ChunkCoordinates coords : blocksToPlace)
+ placeBlockAndConsume(player, stackToPlace, coords);
+ player.worldObj.playSoundAtEntity(player, "thaumcraft:wand", 1F, 1F);
+ }
+
+ private void placeBlockAndConsume(EntityPlayer player, ItemStack blockToPlace, ChunkCoordinates coords) {
+ player.worldObj.setBlock(coords.posX, coords.posY, coords.posZ, blockToPlace.itemID, blockToPlace.getItemDamage(), 1 | 2);
+
+ if(player.capabilities.isCreativeMode)
+ return;
+
+ List talismansToCheck = new ArrayList();
+ for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
+ ItemStack stackInSlot = player.inventory.getStackInSlot(i);
+ if(stackInSlot != null && stackInSlot.itemID == blockToPlace.itemID && stackInSlot.getItemDamage() == blockToPlace.getItemDamage()) {
+ stackInSlot.stackSize--;
+ if(stackInSlot.stackSize == 0)
+ player.inventory.setInventorySlotContents(i, null);
+
+ return;
+ }
+
+ if(stackInSlot != null && stackInSlot.itemID == ModItems.blockTalisman.itemID)
+ talismansToCheck.add(stackInSlot);
+ }
+
+ for(ItemStack talisman : talismansToCheck) {
+ int id = ItemBlockTalisman.getBlockID(talisman);
+ int meta = ItemBlockTalisman.getBlockMeta(talisman);
+
+ if(id == blockToPlace.itemID && meta == blockToPlace.getItemDamage()) {
+ ItemBlockTalisman.remove(talisman, 1);
+ return;
+ }
+ }
+ }
+
+ public static boolean hasBlocks(ItemStack stack, EntityPlayer player, ChunkCoordinates[] blocks) {
+ if(player.capabilities.isCreativeMode)
+ return true;
+
+ int required = blocks.length;
+ int current = 0;
+
+ ItemStack reqStack = new ItemStack(getBlockID(stack), 1, getBlockMeta(stack));
+ List talismansToCheck = new ArrayList();
+ for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
+ ItemStack stackInSlot = player.inventory.getStackInSlot(i);
+ if(stackInSlot != null && stackInSlot.itemID == reqStack.itemID && stackInSlot.getItemDamage() == reqStack.getItemDamage()) {
+ current += stackInSlot.stackSize;
+ if(current >= required)
+ return true;
+ }
+ if(stackInSlot != null && stackInSlot.itemID == ModItems.blockTalisman.itemID)
+ talismansToCheck.add(stackInSlot);
+ }
+
+ for(ItemStack talisman : talismansToCheck) {
+ int id = ItemBlockTalisman.getBlockID(talisman);
+ int meta = ItemBlockTalisman.getBlockMeta(talisman);
+
+ if(id == reqStack.itemID && meta == reqStack.getItemDamage()) {
+ current += ItemBlockTalisman.getBlockCount(talisman);
+
+ if(current >= required)
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public static ChunkCoordinates[] getBlocksToPlace(ItemStack stack, EntityPlayer player) {
+ List coords = new ArrayList();
+ MovingObjectPosition pos = ToolHandler.raytraceFromEntity(player.worldObj, player, true, 5);
+ if(pos != null) {
+ int id = player.worldObj.getBlockId(pos.blockX, pos.blockY, pos.blockZ);
+ if(Block.blocksList[id] != null && Block.blocksList[id].isBlockReplaceable(player.worldObj, pos.blockX, pos.blockY, pos.blockZ))
+ pos.blockY--;
+
+ ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit);
+ int rotation = MathHelper.floor_double(player.rotationYaw * 4F / 360F + 0.5D) & 3;
+ int range = (getSize(stack) ^ 1) / 2;
+
+ boolean topOrBottom = dir == ForgeDirection.UP || dir == ForgeDirection.DOWN;
+
+ int xOff = !(dir == ForgeDirection.WEST || dir == ForgeDirection.EAST) ? topOrBottom ? player.rotationPitch > 75 || (rotation & 1) == 0 ? range : 0 : range : 0;
+ int yOff = topOrBottom ? player.rotationPitch > 75 ? 0 : range : range;
+ int zOff = !(dir == ForgeDirection.SOUTH || dir == ForgeDirection.NORTH) ? topOrBottom ? player.rotationPitch > 75 || (rotation & 1) == 1 ? range : 0 : range : 0;
+
+ for(int x = -xOff; x < xOff + 1; x++)
+ for(int y = 0; y < yOff * 2 + 1; y++) {
+ for(int z = -zOff; z < zOff + 1; z++) {
+ int xp = pos.blockX + x + dir.offsetX;
+ int yp = pos.blockY + y + dir.offsetY;
+ int zp = pos.blockZ + z + dir.offsetZ;
+
+ int id1 = player.worldObj.getBlockId(xp, yp, zp);
+ if(Block.blocksList[id1] == null || Block.blocksList[id1].isAirBlock(player.worldObj, xp, yp, zp) || Block.blocksList[id1].isBlockReplaceable(player.worldObj, xp, yp, zp))
+ coords.add(new ChunkCoordinates(xp, yp,zp));
+ }
+ }
+
+ }
+
+ return coords.toArray(new ChunkCoordinates[0]);
+ }
+
+ private void setBlock(ItemStack stack, int id, int meta) {
+ ItemNBTHelper.setInt(stack, TAG_BLOCK_ID, id);
+ ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta);
+ }
+
+ private static void setSize(ItemStack stack, int size) {
+ ItemNBTHelper.setInt(stack, TAG_SIZE, size | 1);
+ }
+
+ public static int getSize(ItemStack stack) {
+ return ItemNBTHelper.getInt(stack, TAG_SIZE, 3) | 1;
+ }
+
+ public static int getBlockID(ItemStack stack) {
+ return ItemNBTHelper.getInt(stack, TAG_BLOCK_ID, 0);
+ }
+
+ public static int getBlockMeta(ItemStack stack) {
+ return ItemNBTHelper.getInt(stack, TAG_BLOCK_META, 0);
+ }
+
+ @Override
+ public void registerIcons(IconRegister par1IconRegister) {
+ icons[0] = IconHelper.forItem(par1IconRegister, this, 0);
+ icons[1] = IconHelper.forItem(par1IconRegister, this, 1);
+ }
+
+ @Override
+ public Icon getIconFromDamageForRenderPass(int par1, int par2) {
+ return icons[par2 & 1];
+ }
+
+ @Override
+ public boolean requiresMultipleRenderPasses() {
+ return true;
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return TTClientProxy.kamiRarity;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
+ int id = getBlockID(par1ItemStack);
+ int size = getSize(par1ItemStack);
+ par3List.add(size + " x " + size);
+ if(id != 0 && Block.blocksList[id] != null)
+ par3List.add(StatCollector.translateToLocal(new ItemStack(Block.blocksList[id], 1, getBlockMeta(par1ItemStack)).getUnlocalizedName() + ".name"));
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/ItemProtoclay.java b/src/main/java/vazkii/tinkerer/common/item/kami/ItemProtoclay.java
new file mode 100644
index 00000000..3286cc21
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/ItemProtoclay.java
@@ -0,0 +1,89 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Jan 9, 2014, 10:01:41 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami;
+
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.world.World;
+import vazkii.tinkerer.client.core.proxy.TTClientProxy;
+import vazkii.tinkerer.common.item.ItemMod;
+import vazkii.tinkerer.common.item.kami.tool.IAdvancedTool;
+import vazkii.tinkerer.common.item.kami.tool.ToolHandler;
+
+public class ItemProtoclay extends ItemMod {
+
+ public ItemProtoclay(int par1) {
+ super(par1);
+ setMaxStackSize(1);
+ }
+
+ @Override
+ public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
+ if(!(par3Entity instanceof EntityPlayer))
+ return;
+
+ EntityPlayer player = (EntityPlayer) par3Entity;
+ ItemStack currentStack = player.getCurrentEquippedItem();
+ if(currentStack == null || !(currentStack.getItem() instanceof IAdvancedTool))
+ return;
+ IAdvancedTool tool = (IAdvancedTool) currentStack.getItem();
+
+ if(tool.getType().equals("sword"))
+ return;
+
+ MovingObjectPosition pos = ToolHandler.raytraceFromEntity(par2World, par3Entity, true, 4.5F);
+ String typeToFind = "";
+
+ if(player.isSwingInProgress && pos != null) {
+ int id = par2World.getBlockId(pos.blockX, pos.blockY, pos.blockZ);
+ Block block = Block.blocksList[id];
+
+ if(block != null) {
+ Material mat = block.blockMaterial;
+ if(ToolHandler.isRightMaterial(mat, ToolHandler.materialsPick))
+ typeToFind = "pick";
+ else if(ToolHandler.isRightMaterial(mat, ToolHandler.materialsShovel))
+ typeToFind = "shovel";
+ else if(ToolHandler.isRightMaterial(mat, ToolHandler.materialsAxe))
+ typeToFind = "axe";
+ }
+ }
+
+ if(tool.getType().equals(typeToFind) || typeToFind.isEmpty())
+ return;
+
+ for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
+ ItemStack stackInSlot = player.inventory.getStackInSlot(i);
+ if(stackInSlot != null && stackInSlot.getItem() instanceof IAdvancedTool && stackInSlot != currentStack) {
+ IAdvancedTool toolInSlot = (IAdvancedTool) stackInSlot.getItem();
+ if(toolInSlot.getType().equals(typeToFind)) {
+ player.inventory.setInventorySlotContents(player.inventory.currentItem, stackInSlot);
+ player.inventory.setInventorySlotContents(i, currentStack);
+ break;
+ }
+ }
+ }
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return TTClientProxy.kamiRarity;
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/ItemSkyPearl.java b/src/main/java/vazkii/tinkerer/common/item/kami/ItemSkyPearl.java
new file mode 100644
index 00000000..1441af21
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/ItemSkyPearl.java
@@ -0,0 +1,136 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Jan 10, 2014, 5:26:45 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.List;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import thaumcraft.client.codechicken.core.vec.Vector3;
+import vazkii.tinkerer.client.core.proxy.TTClientProxy;
+import vazkii.tinkerer.common.block.ModBlocks;
+import vazkii.tinkerer.common.core.helper.ItemNBTHelper;
+import vazkii.tinkerer.common.core.helper.MiscHelper;
+import vazkii.tinkerer.common.item.ItemMod;
+
+public class ItemSkyPearl extends ItemMod {
+
+ public static final String TAG_X = "x";
+ public static final String TAG_Y = "y";
+ public static final String TAG_Z = "z";
+ public static final String TAG_DIM = "dim";
+
+ public ItemSkyPearl(int par1) {
+ super(par1);
+ setMaxStackSize(1);
+ }
+
+ @Override
+ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
+ int id = par3World.getBlockId(par4, par5, par6);
+ if(id == ModBlocks.warpGate.blockID && !isAttuned(par1ItemStack)) {
+ setValues(par1ItemStack, par4, par5, par6, par2EntityPlayer.dimension);
+ par3World.playSoundAtEntity(par2EntityPlayer, "random.orb", 0.3F, 0.1F);
+ }
+
+ return true;
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+ if(par3EntityPlayer.isSneaking() && isAttuned(par1ItemStack)) {
+ par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F);
+ ItemNBTHelper.setInt(par1ItemStack, TAG_Y, -1);
+ }
+
+ return par1ItemStack;
+ }
+
+ @Override
+ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
+ addInfo(par1ItemStack, par2EntityPlayer.dimension, Vector3.fromEntityCenter(par2EntityPlayer), par3List, false);
+ }
+
+ public static void addInfo(ItemStack stack, int dim, Vector3 pos, List list, boolean simpleMode) {
+ if(isAttuned(stack)) {
+ int x = getX(stack);
+ int y = getY(stack);
+ int z = getZ(stack);
+ list.add("X: " + x);
+ if(!simpleMode)
+ list.add("Y: " + y);
+ list.add("Z: " + z);
+ if(getDim(stack) != dim) {
+ if(!simpleMode)
+ list.add(EnumChatFormatting.RED + StatCollector.translateToLocal("ttmisc.differentDim"));
+ } else list.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal("ttmisc.distance") + ": " + new BigDecimal(MiscHelper.pointDistanceSpace(x, simpleMode ? 0 : y, z, pos.x, simpleMode ? 0 : pos.y, pos.z)).setScale(2, RoundingMode.UP).toString() + "m");
+ }
+ }
+
+ @Override
+ public boolean hasEffect(ItemStack par1ItemStack) {
+ return isAttuned(par1ItemStack);
+ }
+
+ public static void setValues(ItemStack stack, int x, int y, int z, int dim) {
+ ItemNBTHelper.setInt(stack, TAG_X, x);
+ ItemNBTHelper.setInt(stack, TAG_Y, y);
+ ItemNBTHelper.setInt(stack, TAG_Z, z);
+ ItemNBTHelper.setInt(stack, TAG_DIM, dim);
+ }
+
+ public static boolean isAttuned(ItemStack stack) {
+ return ItemNBTHelper.detectNBT(stack) && ItemNBTHelper.getInt(stack, TAG_Y, -1) != -1;
+ }
+
+ public static int getX(ItemStack stack) {
+ if(!isAttuned(stack))
+ return 0;
+
+ return ItemNBTHelper.getInt(stack, TAG_X, 0);
+ }
+
+ public static int getY(ItemStack stack) {
+ if(!isAttuned(stack))
+ return 0;
+
+ return ItemNBTHelper.getInt(stack, TAG_Y, 0);
+ }
+
+ public static int getZ(ItemStack stack) {
+ if(!isAttuned(stack))
+ return 0;
+
+ return ItemNBTHelper.getInt(stack, TAG_Z, 0);
+ }
+
+ public static int getDim(ItemStack stack) {
+ if(!isAttuned(stack))
+ return 0;
+
+ return ItemNBTHelper.getInt(stack, TAG_DIM, 0);
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return TTClientProxy.kamiRarity;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemGemBoots.java b/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemGemBoots.java
new file mode 100644
index 00000000..ad4eca35
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemGemBoots.java
@@ -0,0 +1,89 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 27, 2013, 4:12:03 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.armor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+import net.minecraftforge.event.EventPriority;
+import net.minecraftforge.event.ForgeSubscribe;
+import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
+import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
+import thaumcraft.common.lib.Utils;
+
+public class ItemGemBoots extends ItemIchorclothArmorAdv {
+
+ public static List playersWith1Step = new ArrayList();
+
+ public ItemGemBoots(int par1, int par2) {
+ super(par1, par2);
+ }
+
+ @Override
+ boolean ticks() {
+ return true;
+ }
+
+ @Override
+ void tickPlayer(EntityPlayer player) {
+ player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 2, 1, true));
+
+ if(player.worldObj.isRemote)
+ player.stepHeight = player.isSneaking() ? 0.5F : 1F;
+ Utils.setWalkSpeed(player.capabilities, Utils.getWalkSpeed(player.capabilities) + 0.15F);
+ player.jumpMovementFactor = player.isSprinting() ? 0.05F : 0.04F;
+ player.fallDistance = 0F;
+
+ int x = (int) player.posX;
+ int y = (int) player.posY - 1;
+ int z = (int) player.posZ;
+ if(player.worldObj.getBlockId(x, y, z) == Block.dirt.blockID)
+ player.worldObj.setBlock(x, y, z, Block.grass.blockID, 0, 2);
+ }
+
+ @ForgeSubscribe
+ public void onPlayerJump(LivingJumpEvent event) {
+ if(event.entityLiving instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) event.entityLiving;
+ boolean hasArmor = player.getCurrentArmor(0) != null && player.getCurrentArmor(0).itemID == itemID;
+
+ if(hasArmor)
+ player.motionY += 0.3;
+ }
+ }
+
+ @ForgeSubscribe(priority = EventPriority.HIGH)
+ public void onLivingUpdate(LivingUpdateEvent event) {
+ if(event.entityLiving instanceof EntityPlayer && event.entityLiving.worldObj.isRemote) {
+ EntityPlayer player = (EntityPlayer) event.entityLiving;
+
+ boolean highStepListed = playersWith1Step.contains(player.username);
+ boolean hasHighStep = player.getCurrentArmor(0) != null && player.getCurrentArmor(0).itemID == itemID;
+
+ if(hasHighStep && !highStepListed)
+ playersWith1Step.add(player.username);
+
+ if(!hasHighStep && highStepListed) {
+ playersWith1Step.remove(player.username);
+ player.stepHeight = 0.5F;
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemGemChest.java b/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemGemChest.java
new file mode 100644
index 00000000..3cf8c0a6
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemGemChest.java
@@ -0,0 +1,92 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 26, 2013, 4:18:27 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.armor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.client.model.ModelBiped;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.event.ForgeSubscribe;
+import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
+import vazkii.tinkerer.client.model.kami.ModelWings;
+import vazkii.tinkerer.common.item.ModItems;
+import vazkii.tinkerer.common.item.foci.ItemFocusDeflect;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemGemChest extends ItemIchorclothArmorAdv {
+
+ public static List playersWithFlight = new ArrayList();
+
+ public ItemGemChest(int par1, int par2) {
+ super(par1, par2);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) {
+ return new ModelWings();
+ }
+
+ @Override
+ boolean ticks() {
+ return true;
+ }
+
+ @Override
+ void tickPlayer(EntityPlayer player) {
+ ItemFocusDeflect.protectFromProjectiles(player);
+ }
+
+ @ForgeSubscribe
+ public void updatePlayerFlyStatus(LivingUpdateEvent event) {
+ if(event.entityLiving instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) event.entityLiving;
+
+ ItemStack armor = player.getCurrentArmor(3 - armorType);
+ if(armor != null && armor.getItem() == this)
+ tickPlayer(player);
+
+ if(playersWithFlight.contains(playerStr(player))) {
+ if(shouldPlayerHaveFlight(player))
+ player.capabilities.allowFlying = true;
+ else {
+ if(!player.capabilities.isCreativeMode) {
+ player.capabilities.allowFlying = false;
+ player.capabilities.isFlying = false;
+ player.capabilities.disableDamage = false;
+ }
+ playersWithFlight.remove(playerStr(player));
+ }
+ } else if(shouldPlayerHaveFlight(player)) {
+ playersWithFlight.add(playerStr(player));
+ player.capabilities.allowFlying = true;
+ }
+ }
+ }
+
+ public static String playerStr(EntityPlayer player) {
+ return player.username + ":" + player.worldObj.isRemote;
+ }
+
+ private static boolean shouldPlayerHaveFlight(EntityPlayer player) {
+ ItemStack armor = player.getCurrentArmor(2);
+ return armor != null && armor.itemID == ModItems.ichorChestGem.itemID;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemGemHelm.java b/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemGemHelm.java
new file mode 100644
index 00000000..e286bde6
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemGemHelm.java
@@ -0,0 +1,63 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 26, 2013, 12:14:11 AM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.armor;
+
+import net.minecraft.block.material.Material;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+import thaumcraft.api.IGoggles;
+import thaumcraft.api.nodes.IRevealer;
+
+public class ItemGemHelm extends ItemIchorclothArmorAdv implements IGoggles, IRevealer {
+
+ public ItemGemHelm(int par1, int par2) {
+ super(par1, par2);
+ }
+
+ @Override
+ public boolean showNodes(ItemStack paramItemStack, EntityLivingBase paramEntityLivingBase) {
+ return true;
+ }
+
+ @Override
+ public boolean showIngamePopups(ItemStack paramItemStack, EntityLivingBase paramEntityLivingBase) {
+ return true;
+ }
+
+ @Override
+ boolean ticks() {
+ return true;
+ }
+
+ @Override
+ void tickPlayer(EntityPlayer player) {
+ if(player.isInsideOfMaterial(Material.water)) {
+ player.setAir(300);
+ PotionEffect effect = player.getActivePotionEffect(Potion.nightVision);
+
+ if(effect != null && effect.duration <= 202)
+ effect.duration = 202;
+ else player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 202, 0));
+ }
+
+ int food = player.getFoodStats().getFoodLevel();
+ if(food > 0 && food < 18 && player.shouldHeal() && player.ticksExisted % 80 == 0)
+ player.heal(1F);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemGemLegs.java b/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemGemLegs.java
new file mode 100644
index 00000000..fa69270d
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemGemLegs.java
@@ -0,0 +1,103 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 27, 2013, 1:03:05 AM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.armor;
+
+import java.util.List;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import net.minecraftforge.event.EventPriority;
+import net.minecraftforge.event.ForgeSubscribe;
+import net.minecraftforge.event.entity.living.LivingHurtEvent;
+import thaumcraft.client.codechicken.core.vec.Vector3;
+import vazkii.tinkerer.client.core.handler.kami.ToolModeHUDHandler;
+import vazkii.tinkerer.common.item.ItemBrightNitor;
+import vazkii.tinkerer.common.item.ModItems;
+
+public class ItemGemLegs extends ItemIchorclothArmorAdv {
+
+ public ItemGemLegs(int par1, int par2) {
+ super(par1, par2);
+ setHasSubtypes(true);
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+ if(par3EntityPlayer.isSneaking()) {
+ int dmg = par1ItemStack.getItemDamage();
+ par1ItemStack.setItemDamage(~dmg & 1);
+ par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F);
+
+ ToolModeHUDHandler.setTooltip(StatCollector.translateToLocal("ttmisc.light" + par1ItemStack.getItemDamage()));
+
+ return par1ItemStack;
+ }
+
+ return super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer);
+ }
+
+ @Override
+ boolean ticks() {
+ return true;
+ }
+
+ @Override
+ void tickPlayer(EntityPlayer player) {
+ ItemStack armor = player.getCurrentArmor(1);
+ if(armor.getItemDamage() == 1)
+ return;
+
+ ItemBrightNitor.meta = 1;
+ ModItems.brightNitor.onUpdate(null, player.worldObj, player, 0, false);
+ ItemBrightNitor.meta = 0;
+
+ int x = (int) Math.floor(player.posX);
+ int y = (int) player.posY + 1;
+ int z = (int) Math.floor(player.posZ);
+
+ float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw + 90F) * (float) Math.PI / 180F;
+ Vector3 lookVector = new Vector3(Math.cos(yaw), Math.sin(yaw), 0).normalize();
+ Vector3 newVector = new Vector3(lookVector.x, lookVector.y, 0);
+
+ for(int i = 0; i < 5; i++) {
+ newVector = newVector.add(lookVector);
+
+ int x1 = x + (int) newVector.x;
+ int z1 = z + (int) newVector.y;
+ ItemBrightNitor.setBlock(x1, y, z1, player.worldObj);
+ }
+ }
+
+ @ForgeSubscribe(priority = EventPriority.LOWEST)
+ public void onDamageTaken(LivingHurtEvent event) {
+ if(event.entityLiving instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) event.entityLiving;
+ if(player.getCurrentArmor(1) != null && player.getCurrentArmor(1).itemID == itemID && event.source.isFireDamage()) {
+ event.setCanceled(true);
+ player.heal(event.ammount);
+ }
+ }
+ }
+
+ @Override
+ public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
+ super.addInformation(stack, par2EntityPlayer, list, par4);
+ if(stack.getItemDamage() == 1)
+ list.add(StatCollector.translateToLocal("ttmisc.light1"));
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemIchorclothArmor.java b/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemIchorclothArmor.java
new file mode 100644
index 00000000..28330d43
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemIchorclothArmor.java
@@ -0,0 +1,94 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 24, 2013, 9:37:40 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.armor;
+
+import java.util.List;
+
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumArmorMaterial;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemArmor;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.DamageSource;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.common.EnumHelper;
+import net.minecraftforge.common.ISpecialArmor;
+import thaumcraft.api.IVisDiscounter;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.client.core.proxy.TTClientProxy;
+import vazkii.tinkerer.client.lib.LibResources;
+import vazkii.tinkerer.common.core.handler.ModCreativeTab;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemIchorclothArmor extends ItemArmor implements IVisDiscounter, ISpecialArmor {
+
+ static EnumArmorMaterial material = EnumHelper.addArmorMaterial("ICHOR", 0, new int[] { 3, 8, 6, 3 }, 20);
+
+ public ItemIchorclothArmor(int par1, int par2) {
+ super(par1, material, 0, par2);
+ setCreativeTab(ModCreativeTab.INSTANCE);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ itemIcon = IconHelper.forItem(par1IconRegister, this);
+ }
+
+ @Override
+ public String getArmorTexture(ItemStack stack, Entity entity, int slot, int layer) {
+ return slot == 2 ? LibResources.MODEL_ARMOR_ICHOR_2 : LibResources.MODEL_ARMOR_ICHOR_1;
+ }
+
+ @Override
+ public int getVisDiscount() {
+ return armorType == 3 ? 3 : 4;
+ }
+
+ @Override
+ public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
+ list.add(StatCollector.translateToLocal("tc.visdiscount") + ": " + getVisDiscount() + "%");
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return TTClientProxy.kamiRarity;
+ }
+
+ @Override
+ public boolean isItemTool(ItemStack par1ItemStack) {
+ return true;
+ }
+
+ @Override
+ public ArmorProperties getProperties(EntityLivingBase player,ItemStack armor, DamageSource source, double damage, int slot) {
+ return new ArmorProperties(0, getArmorMaterial().getDamageReductionAmount(slot) * 0.0425, Integer.MAX_VALUE);
+ }
+
+ @Override
+ public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
+ return getArmorMaterial().getDamageReductionAmount(slot);
+ }
+
+ @Override
+ public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
+ // NO-OP
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemIchorclothArmorAdv.java b/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemIchorclothArmorAdv.java
new file mode 100644
index 00000000..6b54efc8
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/armor/ItemIchorclothArmorAdv.java
@@ -0,0 +1,57 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 25, 2013, 12:20:05 AM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.armor;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.ForgeSubscribe;
+import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
+import vazkii.tinkerer.client.lib.LibResources;
+
+public class ItemIchorclothArmorAdv extends ItemIchorclothArmor {
+
+ public ItemIchorclothArmorAdv(int par1, int par2) {
+ super(par1, par2);
+ if(ticks())
+ MinecraftForge.EVENT_BUS.register(this);
+ }
+
+ @Override
+ public String getArmorTexture(ItemStack stack, Entity entity, int slot, int layer) {
+ return slot == 2 ? LibResources.MODEL_ARMOR_ICHOR_GEM_2 : LibResources.MODEL_ARMOR_ICHOR_GEM_1;
+ }
+
+ boolean ticks() {
+ return false;
+ }
+
+ @ForgeSubscribe
+ public void onEntityUpdate(LivingUpdateEvent event) {
+ if(event.entityLiving instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) event.entityLiving;
+
+ ItemStack armor = player.getCurrentArmor(3 - armorType);
+ if(armor != null && armor.getItem() == this)
+ tickPlayer(player);
+ }
+ }
+
+ void tickPlayer(EntityPlayer player) {
+ // NO-OP
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/foci/ItemFocusRecall.java b/src/main/java/vazkii/tinkerer/common/item/kami/foci/ItemFocusRecall.java
new file mode 100644
index 00000000..7948fad5
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/foci/ItemFocusRecall.java
@@ -0,0 +1,92 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Jan 10, 2014, 9:20:05 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.foci;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ChunkCoordinates;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.world.World;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import vazkii.tinkerer.common.block.tile.kami.TileWarpGate;
+import vazkii.tinkerer.common.item.foci.ItemModFocus;
+import vazkii.tinkerer.common.item.kami.ItemSkyPearl;
+
+public class ItemFocusRecall extends ItemModFocus {
+
+ AspectList cost = new AspectList().add(Aspect.AIR, 4000).add(Aspect.EARTH, 4000).add(Aspect.ORDER, 4000);
+
+ public ItemFocusRecall(int par1) {
+ super(par1);
+ }
+
+ @Override
+ protected boolean hasDepth() {
+ return true;
+ }
+
+ @Override
+ public boolean isUseItem() {
+ return true;
+ }
+
+ @Override
+ public void onUsingFocusTick(ItemStack paramItemStack, EntityPlayer paramEntityPlayer, int paramInt) {
+ ItemWandCasting wand = (ItemWandCasting) paramItemStack.getItem();
+
+ if(Integer.MAX_VALUE - paramInt > 60) {
+ ItemStack stackToCount = null;
+ for(int i = 0; i < 9; i++) {
+ ItemStack stackInSlot = paramEntityPlayer.inventory.getStackInSlot(i);
+ if(stackInSlot != null && stackInSlot.getItem() instanceof ItemSkyPearl && ItemSkyPearl.isAttuned(stackInSlot)) {
+ stackToCount = stackInSlot;
+ break;
+ }
+ }
+
+ if(stackToCount != null) {
+ int dim = ItemSkyPearl.getDim(stackToCount);
+ if(dim == paramEntityPlayer.dimension) {
+ int x = ItemSkyPearl.getX(stackToCount);
+ int y = ItemSkyPearl.getY(stackToCount);
+ int z = ItemSkyPearl.getZ(stackToCount);
+
+ if(wand.consumeAllVis(paramItemStack, paramEntityPlayer, getVisCost(), false) && TileWarpGate.teleportPlayer(paramEntityPlayer, new ChunkCoordinates(x, y, z)))
+ wand.consumeAllVis(paramItemStack, paramEntityPlayer, getVisCost(), true);
+ }
+ }
+
+ paramEntityPlayer.clearItemInUse();
+ }
+ }
+
+ @Override
+ public int getFocusColor() {
+ return 0x9CF8FF;
+ }
+
+ @Override
+ public AspectList getVisCost() {
+ return cost;
+ }
+
+ @Override
+ public String getSortingHelper(ItemStack paramItemStack) {
+ return "RECALL";
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/foci/ItemFocusShadowbeam.java b/src/main/java/vazkii/tinkerer/common/item/kami/foci/ItemFocusShadowbeam.java
new file mode 100644
index 00000000..fdc853a7
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/foci/ItemFocusShadowbeam.java
@@ -0,0 +1,189 @@
+package vazkii.tinkerer.common.item.kami.foci;
+
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.projectile.EntityThrowable;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.util.DamageSource;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.world.World;
+import net.minecraftforge.common.ForgeDirection;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.client.codechicken.core.vec.Vector3;
+import thaumcraft.client.fx.FXSparkle;
+import thaumcraft.common.config.Config;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import vazkii.tinkerer.client.core.proxy.TTClientProxy;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.item.foci.ItemModFocus;
+import cpw.mods.fml.common.registry.EntityRegistry;
+
+public class ItemFocusShadowbeam extends ItemModFocus {
+
+ AspectList cost = new AspectList().add(Aspect.ORDER, 25).add(Aspect.ENTROPY, 25).add(Aspect.AIR, 15);
+
+ public ItemFocusShadowbeam(int par1) {
+ super(par1);
+
+ EntityRegistry.registerModEntity(Beam.class, "ShadowbeamStaffBeam", 0, ThaumicTinkerer.instance, 0, 0, false);
+ }
+
+ @Override
+ public void onUsingFocusTick(ItemStack stack, EntityPlayer player, int count) {
+ ItemWandCasting wand = (ItemWandCasting) stack.getItem();
+
+ if(!player.worldObj.isRemote && wand.consumeAllVis(stack, player, getVisCost(), true)) {
+ int potency = EnchantmentHelper.getEnchantmentLevel(Config.enchPotency.effectId, wand.getFocusItem(stack));
+
+ if(player.worldObj.rand.nextInt(10) == 0)
+ player.worldObj.playSoundAtEntity(player, "thaumcraft:brain", 0.5F, 1F);
+
+ Beam beam = new Beam(player.worldObj, player, potency);
+ beam.updateUntilDead();
+ }
+ }
+
+ @Override
+ public boolean isVisCostPerTick() {
+ return true;
+ }
+
+ @Override
+ protected boolean hasOrnament() {
+ return true;
+ }
+
+ @Override
+ public int getFocusColor() {
+ return 0x4B0053;
+ }
+
+ @Override
+ public AspectList getVisCost() {
+ return cost;
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return TTClientProxy.kamiRarity;
+ }
+
+ public static class Particle extends FXSparkle {
+
+ public Particle(World world, double d, double d1, double d2, float f, int type, int m) {
+ super(world, d, d1, d2, f, type, m);
+ noClip = true;
+ }
+
+ @Override
+ public void onUpdate() {
+ super.onUpdate();
+ if(particleAge > 1)
+ setDead();
+ }
+ }
+
+ public static class Beam extends EntityThrowable {
+
+ int potency;
+ Vector3 movementVector;
+ final int maxTicks = 300;
+
+ public Beam(World par1World, EntityLivingBase par2EntityLivingBase, int potency) {
+ super(par1World, par2EntityLivingBase);
+
+ this.potency = potency;
+ setProjectileVelocity(motionX / 10, motionY / 10, motionZ / 10);
+ movementVector = new Vector3(motionX, motionY, motionZ);
+ }
+
+ // Copy of setVelocity, because that is client only for some reason
+ public void setProjectileVelocity(double par1, double par3, double par5) {
+ this.motionX = par1;
+ this.motionY = par3;
+ this.motionZ = par5;
+
+ if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
+ float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
+ this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI);
+ this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f) * 180.0D / Math.PI);
+ }
+ }
+
+ @Override
+ public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) {
+ super.setThrowableHeading(par1, par3, par5, par7, par8);
+ float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5);
+ par1 /= f2;
+ par3 /= f2;
+ par5 /= f2;
+ par1 += 0.007499999832361937 * par8;
+ par3 += 0.007499999832361937 * par8;
+ par5 += 0.007499999832361937 * par8;
+ par1 *= par7;
+ par3 *= par7;
+ par5 *= par7;
+ motionX = par1;
+ motionY = par3;
+ motionZ = par5;
+ }
+
+ @Override
+ protected void onImpact(MovingObjectPosition movingobjectposition) {
+ if(movingobjectposition == null)
+ return;
+
+ if(movingobjectposition.entityHit != null) {
+ if((MinecraftServer.getServer().isPVPEnabled() || !(movingobjectposition.entityHit instanceof EntityPlayer)) && movingobjectposition.entityHit != getThrower() && getThrower() instanceof EntityPlayer && !movingobjectposition.entityHit.worldObj.isRemote)
+ movingobjectposition.entityHit.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) getThrower()), 8 + potency);
+ return;
+ }
+
+ Vector3 movementVec = new Vector3(motionX, motionY, motionZ);
+ ForgeDirection dir = ForgeDirection.getOrientation(movingobjectposition.sideHit);
+ Vector3 normalVector = new Vector3(dir.offsetX, dir.offsetY, dir.offsetZ).normalize();
+
+ movementVector = normalVector.multiply(-2 * movementVec.dotProduct(normalVector)).add(movementVec);
+
+ motionX = movementVector.x;
+ motionY = movementVector.y;
+ motionZ = movementVector.z;
+ }
+
+ @Override
+ public void onUpdate() {
+ motionX = movementVector.x;
+ motionY = movementVector.y;
+ motionZ = movementVector.z;
+
+ super.onUpdate();
+
+ if(ticksExisted > 2)
+ ThaumicTinkerer.proxy.shadowSparkle(worldObj, (float) posX, (float) posY, (float) posZ, 6);
+
+ ++ticksExisted;
+ if(ticksExisted >= maxTicks)
+ setDead();
+ }
+
+ public void updateUntilDead() {
+ while(!isDead)
+ onUpdate();
+ }
+
+ @Override
+ protected float getGravityVelocity() {
+ return 0F;
+ }
+ }
+
+ @Override
+ public String getSortingHelper(ItemStack paramItemStack) {
+ return "SHADOWBEAM";
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/foci/ItemFocusXPDrain.java b/src/main/java/vazkii/tinkerer/common/item/kami/foci/ItemFocusXPDrain.java
new file mode 100644
index 00000000..aa7cb4cb
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/foci/ItemFocusXPDrain.java
@@ -0,0 +1,106 @@
+package vazkii.tinkerer.common.item.kami.foci;
+
+import java.awt.Color;
+import java.util.List;
+
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.common.config.Config;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import vazkii.tinkerer.client.core.proxy.TTClientProxy;
+import vazkii.tinkerer.common.ThaumicTinkerer;
+import vazkii.tinkerer.common.core.helper.ExperienceHelper;
+import vazkii.tinkerer.common.item.foci.ItemModFocus;
+
+public class ItemFocusXPDrain extends ItemModFocus {
+
+ AspectList cost = new AspectList();
+ private int lastGiven = 0;
+
+ public ItemFocusXPDrain(int par1) {
+ super(par1);
+ }
+
+ @Override
+ public boolean isVisCostPerTick() {
+ return true;
+ }
+
+ @Override
+ public void onUsingFocusTick(ItemStack paramItemStack, EntityPlayer paramEntityPlayer, int paramInt) {
+ if(paramEntityPlayer.worldObj.isRemote)
+ return;
+
+ ItemWandCasting wand = (ItemWandCasting) paramItemStack.getItem();
+ AspectList aspects = wand.getAllVis(paramItemStack);
+
+ Aspect aspectToAdd = null;
+ int takes = 0;
+
+ while(aspectToAdd == null && takes < 7) {
+ lastGiven = lastGiven == 5 ? 0 : lastGiven + 1;
+
+ Aspect aspect = Aspect.getPrimalAspects().get(lastGiven);
+
+ if(aspects.getAmount(aspect) < wand.getMaxVis(paramItemStack))
+ aspectToAdd = aspect;
+
+ ++takes;
+ }
+
+ if(aspectToAdd != null) {
+ int xpUse = getXpUse(paramItemStack);
+ if(paramEntityPlayer.experienceTotal >= xpUse) {
+ ExperienceHelper.drainPlayerXP(paramEntityPlayer, xpUse);
+ wand.storeVis(paramItemStack, aspectToAdd, Math.min(wand.getMaxVis(paramItemStack), wand.getVis(paramItemStack, aspectToAdd) + 500));
+ }
+ }
+ }
+
+ @Override
+ public int getColorFromItemStack(ItemStack par1ItemStack, int par2) {
+ return getFocusColor();
+ }
+
+ @Override
+ public int getFocusColor() {
+ EntityPlayer player = ThaumicTinkerer.proxy.getClientPlayer();
+ return player == null ? 0xFFFFFF : Color.HSBtoRGB(player.ticksExisted * 2 % 360 / 360F, 1F, 1F);
+ }
+
+ int getXpUse(ItemStack stack) {
+ return 30 - EnchantmentHelper.getEnchantmentLevel(Config.enchFrugal.effectId, stack) * 3;
+ }
+
+ @Override
+ protected void addVisCostTooltip(AspectList cost, ItemStack stack, EntityPlayer player, List list, boolean par4) {
+ list.add(" " + EnumChatFormatting.GREEN + StatCollector.translateToLocal("ttmisc.experience") + EnumChatFormatting.WHITE + " x " + getXpUse(stack));
+ }
+
+ @Override
+ public AspectList getVisCost() {
+ return cost;
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return TTClientProxy.kamiRarity;
+ }
+
+ @Override
+ public boolean acceptsEnchant(int paramInt) {
+ return paramInt == Config.enchFrugal.effectId;
+ }
+
+ @Override
+ public String getSortingHelper(ItemStack paramItemStack) {
+ return "XPDRAIN";
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/tool/IAdvancedTool.java b/src/main/java/vazkii/tinkerer/common/item/kami/tool/IAdvancedTool.java
new file mode 100644
index 00000000..146a4288
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/tool/IAdvancedTool.java
@@ -0,0 +1,21 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 6:03:41 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.tool;
+
+public interface IAdvancedTool {
+
+ public String getType();
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorAxe.java b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorAxe.java
new file mode 100644
index 00000000..c04af60d
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorAxe.java
@@ -0,0 +1,51 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 5:29:45 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.tool;
+
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemAxe;
+import net.minecraft.item.ItemStack;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.client.core.proxy.TTClientProxy;
+import vazkii.tinkerer.common.core.handler.ModCreativeTab;
+import vazkii.tinkerer.common.item.ModItems;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemIchorAxe extends ItemAxe {
+
+ public ItemIchorAxe(int par1) {
+ super(par1, ModItems.toolMatIchor);
+ setCreativeTab(ModCreativeTab.INSTANCE);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ itemIcon = IconHelper.forItem(par1IconRegister, this);
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return TTClientProxy.kamiRarity;
+ }
+
+ @Override
+ public boolean isItemTool(ItemStack par1ItemStack) {
+ return true;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorAxeAdv.java b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorAxeAdv.java
new file mode 100644
index 00000000..ca247cbc
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorAxeAdv.java
@@ -0,0 +1,133 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 8:24:43 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.tool;
+
+import java.util.List;
+
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.Icon;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.world.World;
+import net.minecraftforge.common.ForgeDirection;
+import thaumcraft.common.lib.Utils;
+import vazkii.tinkerer.client.core.handler.kami.ToolModeHUDHandler;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+
+public class ItemIchorAxeAdv extends ItemIchorAxe implements IAdvancedTool {
+
+ Icon[] specialIcons = new Icon[3];
+
+ public ItemIchorAxeAdv(int par1) {
+ super(par1);
+ setHasSubtypes(true);
+ }
+
+ @Override
+ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
+ World world = player.worldObj;
+ Material mat = world.getBlockMaterial(x, y, z);
+ if(!ToolHandler.isRightMaterial(mat, ToolHandler.materialsAxe))
+ return false;
+
+ MovingObjectPosition block = ToolHandler.raytraceFromEntity(world, player, true, 4.5);
+ if(block == null)
+ return false;
+
+ ForgeDirection direction = ForgeDirection.getOrientation(block.sideHit);
+ int fortune = EnchantmentHelper.getFortuneModifier(player);
+ boolean silk = EnchantmentHelper.getSilkTouchModifier(player);
+
+ switch(ToolHandler.getMode(stack)) {
+ case 0 : break;
+ case 1 : {
+ boolean doX = direction.offsetX == 0;
+ boolean doY = direction.offsetY == 0;
+ boolean doZ = direction.offsetZ == 0;
+
+ ToolHandler.removeBlocksInIteration(player, world, x, y, z, doX ? -2 : 0, doY ? -1 : 0, doZ ? -2 : 0, doX ? 3 : 1, doY ? 4 : 1, doZ ? 3 : 1, -1, ToolHandler.materialsAxe, silk, fortune);
+ break;
+ }
+ case 2 : {
+ int id = world.getBlockId(x, y, z);
+ if(Utils.isWoodLog(world, x, y, z)) {
+ while(id != 0) {
+ Utils.breakFurthestBlock(world, x, y, z, id, player);
+ id = world.getBlockId(x, y, z);
+ }
+
+ List items = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - 5, y - 1, z - 5, x + 5, y + 64, z + 5));
+ for(EntityItem item : items) {
+ item.setPosition(x + 0.5, y + 0.5, z + 0.5);
+ item.ticksExisted += 20;
+ }
+ }
+
+ break;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public float getStrVsBlock(ItemStack stack, Block block, int meta) {
+ return Math.max(super.getStrVsBlock(stack, block, meta), Item.shears.getStrVsBlock(stack, block, meta));
+ }
+
+ @Override
+ public void registerIcons(IconRegister par1IconRegister) {
+ super.registerIcons(par1IconRegister);
+ for(int i = 0; i < specialIcons.length; i++)
+ specialIcons[i] = IconHelper.forItem(par1IconRegister, this, i);
+ }
+
+ @Override
+ public Icon getIconFromDamage(int par1) {
+ return par1 >= specialIcons.length ? super.getIconFromDamage(par1) : specialIcons[par1];
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+ if(par3EntityPlayer.isSneaking()) {
+ ToolHandler.changeMode(par1ItemStack);
+ ToolModeHUDHandler.setTooltip(ToolHandler.getToolModeStr(this, par1ItemStack));
+ }
+
+ return par1ItemStack;
+ }
+
+ @Override
+ public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLivingBase par7EntityLivingBase) {
+ return true;
+ }
+
+ @Override
+ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
+ par3List.add(ToolHandler.getToolModeStr(this, par1ItemStack));
+ }
+
+ @Override
+ public String getType() {
+ return "axe";
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorPick.java b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorPick.java
new file mode 100644
index 00000000..615cc054
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorPick.java
@@ -0,0 +1,50 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 5:29:41 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.tool;
+
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemPickaxe;
+import net.minecraft.item.ItemStack;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.client.core.proxy.TTClientProxy;
+import vazkii.tinkerer.common.core.handler.ModCreativeTab;
+import vazkii.tinkerer.common.item.ModItems;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemIchorPick extends ItemPickaxe {
+
+ public ItemIchorPick(int par1) {
+ super(par1, ModItems.toolMatIchor);
+ setCreativeTab(ModCreativeTab.INSTANCE);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ itemIcon = IconHelper.forItem(par1IconRegister, this);
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return TTClientProxy.kamiRarity;
+ }
+
+ @Override
+ public boolean isItemTool(ItemStack par1ItemStack) {
+ return true;
+ }
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorPickAdv.java b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorPickAdv.java
new file mode 100644
index 00000000..0a175f22
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorPickAdv.java
@@ -0,0 +1,115 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 6:01:04 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.tool;
+
+import java.util.List;
+
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Icon;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.world.World;
+import net.minecraftforge.common.ForgeDirection;
+import vazkii.tinkerer.client.core.handler.kami.ToolModeHUDHandler;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+
+public class ItemIchorPickAdv extends ItemIchorPick implements IAdvancedTool {
+
+ Icon[] specialIcons = new Icon[3];
+
+ public ItemIchorPickAdv(int par1) {
+ super(par1);
+ setHasSubtypes(true);
+ }
+
+ @Override
+ public void registerIcons(IconRegister par1IconRegister) {
+ super.registerIcons(par1IconRegister);
+ for(int i = 0; i < specialIcons.length; i++)
+ specialIcons[i] = IconHelper.forItem(par1IconRegister, this, i);
+ }
+
+ @Override
+ public Icon getIconFromDamage(int par1) {
+ return par1 >= specialIcons.length ? super.getIconFromDamage(par1) : specialIcons[par1];
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+ if(par3EntityPlayer.isSneaking()) {
+ ToolHandler.changeMode(par1ItemStack);
+ ToolModeHUDHandler.setTooltip(ToolHandler.getToolModeStr(this, par1ItemStack));
+ }
+
+ return par1ItemStack;
+ }
+
+ @Override
+ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
+ World world = player.worldObj;
+ Material mat = world.getBlockMaterial(x, y, z);
+ if(!ToolHandler.isRightMaterial(mat, ToolHandler.materialsPick))
+ return false;
+
+ MovingObjectPosition block = ToolHandler.raytraceFromEntity(world, player, true, 4.5);
+ if(block == null)
+ return false;
+
+ ForgeDirection direction = ForgeDirection.getOrientation(block.sideHit);
+ int fortune = EnchantmentHelper.getFortuneModifier(player);
+ boolean silk = EnchantmentHelper.getSilkTouchModifier(player);
+
+ switch(ToolHandler.getMode(stack)) {
+ case 0 : break;
+ case 1 : {
+ boolean doX = direction.offsetX == 0;
+ boolean doY = direction.offsetY == 0;
+ boolean doZ = direction.offsetZ == 0;
+
+ ToolHandler.removeBlocksInIteration(player, world, x, y, z, doX ? -2 : 0, doY ? -1 : 0, doZ ? -2 : 0, doX ? 3 : 1, doY ? 4 : 1, doZ ? 3 : 1, -1, ToolHandler.materialsPick, silk, fortune);
+ break;
+ }
+ case 2 : {
+ int xo = -direction.offsetX;
+ int yo = -direction.offsetY;
+ int zo = -direction.offsetZ;
+
+ ToolHandler.removeBlocksInIteration(player, world, x, y, z, xo >= 0 ? 0 : -10, yo >= 0 ? 0 : -10, zo >= 0 ? 0 : -10, xo > 0 ? 10 : 1, yo > 0 ? 10 : 1, zo > 0 ? 10 : 1, -1, ToolHandler.materialsPick, silk, fortune);
+ break;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLivingBase par7EntityLivingBase) {
+ return true;
+ }
+
+ @Override
+ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
+ par3List.add(ToolHandler.getToolModeStr(this, par1ItemStack));
+ }
+
+ @Override
+ public String getType() {
+ return "pick";
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorShovel.java b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorShovel.java
new file mode 100644
index 00000000..b7e065fa
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorShovel.java
@@ -0,0 +1,51 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 5:29:36 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.tool;
+
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemSpade;
+import net.minecraft.item.ItemStack;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.client.core.proxy.TTClientProxy;
+import vazkii.tinkerer.common.core.handler.ModCreativeTab;
+import vazkii.tinkerer.common.item.ModItems;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemIchorShovel extends ItemSpade {
+
+ public ItemIchorShovel(int par1) {
+ super(par1, ModItems.toolMatIchor);
+ setCreativeTab(ModCreativeTab.INSTANCE);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ itemIcon = IconHelper.forItem(par1IconRegister, this);
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return TTClientProxy.kamiRarity;
+ }
+
+ @Override
+ public boolean isItemTool(ItemStack par1ItemStack) {
+ return true;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorShovelAdv.java b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorShovelAdv.java
new file mode 100644
index 00000000..2c2e6fe6
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorShovelAdv.java
@@ -0,0 +1,112 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 7:37:10 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.tool;
+
+import java.util.List;
+
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Icon;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.world.World;
+import net.minecraftforge.common.ForgeDirection;
+import vazkii.tinkerer.client.core.handler.kami.ToolModeHUDHandler;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+
+public class ItemIchorShovelAdv extends ItemIchorShovel implements IAdvancedTool {
+
+ Icon[] specialIcons = new Icon[3];
+
+ public ItemIchorShovelAdv(int par1) {
+ super(par1);
+ setHasSubtypes(true);
+ }
+
+ @Override
+ public void registerIcons(IconRegister par1IconRegister) {
+ super.registerIcons(par1IconRegister);
+ for(int i = 0; i < specialIcons.length; i++)
+ specialIcons[i] = IconHelper.forItem(par1IconRegister, this, i);
+ }
+
+ @Override
+ public Icon getIconFromDamage(int par1) {
+ return par1 >= specialIcons.length ? super.getIconFromDamage(par1) : specialIcons[par1];
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+ if(par3EntityPlayer.isSneaking()) {
+ ToolHandler.changeMode(par1ItemStack);
+ ToolModeHUDHandler.setTooltip(ToolHandler.getToolModeStr(this, par1ItemStack));
+ }
+
+ return par1ItemStack;
+ }
+
+ @Override
+ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
+ World world = player.worldObj;
+ Material mat = world.getBlockMaterial(x, y, z);
+ if(!ToolHandler.isRightMaterial(mat, ToolHandler.materialsShovel))
+ return false;
+
+ MovingObjectPosition block = ToolHandler.raytraceFromEntity(world, player, true, 4.5);
+ if(block == null)
+ return false;
+
+ ForgeDirection direction = ForgeDirection.getOrientation(block.sideHit);
+ int fortune = EnchantmentHelper.getFortuneModifier(player);
+ boolean silk = EnchantmentHelper.getSilkTouchModifier(player);
+
+ switch(ToolHandler.getMode(stack)) {
+ case 0 : break;
+ case 1 : {
+ boolean doX = direction.offsetX == 0;
+ boolean doY = direction.offsetY == 0;
+ boolean doZ = direction.offsetZ == 0;
+
+ ToolHandler.removeBlocksInIteration(player, world, x, y, z, doX ? -2 : 0, doY ? -1 : 0, doZ ? -2 : 0, doX ? 3 : 1, doY ? 4 : 1, doZ ? 3 : 1, -1, ToolHandler.materialsShovel, silk, fortune);
+ break;
+ }
+ case 2 : {
+ int id = world.getBlockId(x, y, z);
+ ToolHandler.removeBlocksInIteration(player, world, x, y, z, 0, -8, 0, 1, 8, 1, id, ToolHandler.materialsShovel, silk, fortune);
+ break;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLivingBase par7EntityLivingBase) {
+ return true;
+ }
+
+ @Override
+ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
+ par3List.add(ToolHandler.getToolModeStr(this, par1ItemStack));
+ }
+
+ @Override
+ public String getType() {
+ return "shovel";
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorSword.java b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorSword.java
new file mode 100644
index 00000000..ef952840
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorSword.java
@@ -0,0 +1,51 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 5:29:49 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.tool;
+
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.ItemSword;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.client.core.proxy.TTClientProxy;
+import vazkii.tinkerer.common.core.handler.ModCreativeTab;
+import vazkii.tinkerer.common.item.ModItems;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemIchorSword extends ItemSword {
+
+ public ItemIchorSword(int par1) {
+ super(par1, ModItems.toolMatIchor);
+ setCreativeTab(ModCreativeTab.INSTANCE);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ itemIcon = IconHelper.forItem(par1IconRegister, this);
+ }
+
+ @Override
+ public EnumRarity getRarity(ItemStack par1ItemStack) {
+ return TTClientProxy.kamiRarity;
+ }
+
+ @Override
+ public boolean isItemTool(ItemStack par1ItemStack) {
+ return true;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorSwordAdv.java b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorSwordAdv.java
new file mode 100644
index 00000000..300cadb7
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ItemIchorSwordAdv.java
@@ -0,0 +1,105 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 9:08:14 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.tool;
+
+import java.util.List;
+
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.Icon;
+import net.minecraft.world.World;
+import vazkii.tinkerer.client.core.handler.kami.ToolModeHUDHandler;
+import vazkii.tinkerer.client.core.helper.IconHelper;
+import vazkii.tinkerer.common.core.handler.kami.SoulHeartHandler;
+
+public class ItemIchorSwordAdv extends ItemIchorSword implements IAdvancedTool {
+
+ Icon[] specialIcons = new Icon[3];
+
+ public ItemIchorSwordAdv(int par1) {
+ super(par1);
+ setHasSubtypes(true);
+ }
+
+ @Override
+ public void registerIcons(IconRegister par1IconRegister) {
+ super.registerIcons(par1IconRegister);
+ for(int i = 0; i < specialIcons.length; i++)
+ specialIcons[i] = IconHelper.forItem(par1IconRegister, this, i);
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+ if(par3EntityPlayer.isSneaking()) {
+ ToolHandler.changeMode(par1ItemStack);
+ ToolModeHUDHandler.setTooltip(ToolHandler.getToolModeStr(this, par1ItemStack));
+
+ return par1ItemStack;
+ } else return super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer);
+ }
+
+ boolean ignoreLeftClick = false;
+
+ @Override
+ public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
+ if(!ignoreLeftClick && entity instanceof EntityLivingBase && ((EntityLivingBase) entity).hurtTime == 0 && !((EntityLivingBase) entity).isDead)
+ switch(ToolHandler.getMode(stack)) {
+ case 0 : break;
+ case 1 : {
+ int range = 3;
+ List entities = player.worldObj.getEntitiesWithinAABB(entity.getClass(), AxisAlignedBB.getBoundingBox(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range));
+ ignoreLeftClick = true;
+ for(Entity entity_ : entities)
+ player.attackTargetEntityWithCurrentItem(entity_);
+ ignoreLeftClick = false;
+
+ break;
+ }
+ case 2 : {
+ EntityLivingBase living = (EntityLivingBase) entity;
+ PotionEffect effect = new PotionEffect(Potion.resistance.id, 1, 1);
+ living.addPotionEffect(effect);
+
+ SoulHeartHandler.addHearts(player);
+
+ break;
+ }
+ }
+
+ return super.onLeftClickEntity(stack, player, entity);
+ }
+
+ @Override
+ public Icon getIconFromDamage(int par1) {
+ return par1 >= specialIcons.length ? super.getIconFromDamage(par1) : specialIcons[par1];
+ }
+
+ @Override
+ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
+ par3List.add(ToolHandler.getToolModeStr(this, par1ItemStack));
+ }
+
+ @Override
+ public String getType() {
+ return "sword";
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/tool/ToolHandler.java b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ToolHandler.java
new file mode 100644
index 00000000..ad484a1b
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/tool/ToolHandler.java
@@ -0,0 +1,132 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 29, 2013, 6:01:31 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.tool;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.StatCollector;
+import net.minecraft.util.Vec3;
+import net.minecraft.world.World;
+
+public final class ToolHandler {
+
+ public static Material[] materialsPick = new Material[] { Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil };
+ public static Material[] materialsShovel = new Material[] { Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay };
+ public static Material[] materialsAxe = new Material[] { Material.coral, Material.leaves, Material.plants, Material.wood };
+
+ public static int getMode(ItemStack tool) {
+ return tool.getItemDamage();
+ }
+
+ public static int getNextMode(int mode) {
+ return mode == 2 ? 0 : mode + 1;
+ }
+
+ public static void changeMode(ItemStack tool) {
+ int mode = getMode(tool);
+ tool.setItemDamage(getNextMode(mode));
+ }
+
+ public static boolean isRightMaterial(Material material, Material[] materialsListing) {
+ for(Material mat : materialsListing)
+ if(material == mat)
+ return true;
+
+ return false;
+ }
+
+ public static void removeBlocksInIteration(EntityPlayer player, World world, int x, int y, int z, int xs, int ys, int zs, int xe, int ye, int ze, int lockID, Material[] materialsListing, boolean silk, int fortune) {
+ for(int x1 = xs; x1 < xe; x1++)
+ for(int y1 = ys; y1 < ye; y1++)
+ for(int z1 = zs; z1 < ze; z1++)
+ if(x != x1 && y != y1 && z != z1)
+ ToolHandler.removeBlockWithDrops(player, world, x1 + x, y1 + y, z1 + z, x, y, z, lockID, materialsListing, silk, fortune);
+ }
+
+ public static void removeBlockWithDrops(EntityPlayer player, World world, int x, int y, int z, int bx, int by, int bz, int lockID, Material[] materialsListing, boolean silk, int fortune) {
+ if(!world.blockExists(x, y, z))
+ return;
+
+ int id = world.getBlockId(x, y, z);
+
+ if(lockID != -1 && id != lockID)
+ return;
+
+ int meta = world.getBlockMetadata(x, y, z);
+ Material mat = world.getBlockMaterial(x, y, z);
+ Block block = Block.blocksList[id];
+ if(block != null && !block.isAirBlock(world, x, y, z) && block.getBlockHardness(world, x, y, z) != -1) {
+ List items = new ArrayList();
+
+ if(!block.canHarvestBlock(player, meta) || !isRightMaterial(mat, materialsListing))
+ return;
+
+ if(silk && block.canSilkHarvest(world, player, x, y, z, meta))
+ items.add(new ItemStack(id, 1, meta));
+ else {
+ items.addAll(block.getBlockDropped(world, x, y, z, meta, fortune));
+ if(!player.capabilities.isCreativeMode)
+ block.dropXpOnBlockBreak(world, x, y, z, block.getExpDrop(world, meta, fortune));
+ }
+
+ block.onBlockDestroyedByPlayer(world, x, y, z, meta);
+ world.setBlockToAir(x, y, z);
+ if(!world.isRemote && !player.capabilities.isCreativeMode)
+ for(ItemStack stack : items)
+ world.spawnEntityInWorld(new EntityItem(world, bx + 0.5, by + 0.5, bz + 0.5, stack));
+ }
+ }
+
+ public static String getToolModeStr(IAdvancedTool tool, ItemStack stack) {
+ return StatCollector.translateToLocal("ttmisc.mode." + tool.getType() + "." + ToolHandler.getMode(stack));
+ }
+
+ /**
+ * @author mDiyo
+ */
+ public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range) {
+ float f = 1.0F;
+ float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
+ float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
+ double d0 = player.prevPosX + (player.posX - player.prevPosX) * f;
+ double d1 = player.prevPosY + (player.posY - player.prevPosY) * f;
+ if (!world.isRemote && player instanceof EntityPlayer)
+ d1 += 1.62D;
+ double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * f;
+ Vec3 vec3 = world.getWorldVec3Pool().getVecFromPool(d0, d1, d2);
+ float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
+ float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI);
+ float f5 = -MathHelper.cos(-f1 * 0.017453292F);
+ float f6 = MathHelper.sin(-f1 * 0.017453292F);
+ float f7 = f4 * f5;
+ float f8 = f3 * f5;
+ double d3 = range;
+ if (player instanceof EntityPlayerMP)
+ d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
+ Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3);
+ return world.rayTraceBlocks_do_do(vec3, vec31, par3, !par3);
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/wand/CapIchor.java b/src/main/java/vazkii/tinkerer/common/item/kami/wand/CapIchor.java
new file mode 100644
index 00000000..28f8df77
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/wand/CapIchor.java
@@ -0,0 +1,36 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 22, 2013, 7:10:45 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.wand;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+import thaumcraft.api.wands.WandCap;
+import vazkii.tinkerer.client.lib.LibResources;
+import vazkii.tinkerer.common.item.ModItems;
+
+public class CapIchor extends WandCap {
+
+ ResourceLocation res = new ResourceLocation(LibResources.MODEL_CAP_ICHOR);
+
+ public CapIchor() {
+ super("ichor", 0.8F, new ItemStack(ModItems.kamiResource, 1, 4), 10);
+ }
+
+ @Override
+ public ResourceLocation getTexture() {
+ return res;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/kami/wand/RodIchorcloth.java b/src/main/java/vazkii/tinkerer/common/item/kami/wand/RodIchorcloth.java
new file mode 100644
index 00000000..3e1b563a
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/kami/wand/RodIchorcloth.java
@@ -0,0 +1,37 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Dec 22, 2013, 7:40:37 PM (GMT)]
+ */
+package vazkii.tinkerer.common.item.kami.wand;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+import thaumcraft.api.wands.WandRod;
+import vazkii.tinkerer.client.lib.LibResources;
+import vazkii.tinkerer.common.item.ModItems;
+
+public class RodIchorcloth extends WandRod {
+
+ ResourceLocation res = new ResourceLocation(LibResources.MODEL_ROD_ICHORCLOTH);
+
+ public RodIchorcloth() {
+ super("ichorcloth", 1000, new ItemStack(ModItems.kamiResource, 1, 5), 10);
+ setGlowing(true);
+ }
+
+ @Override
+ public ResourceLocation getTexture() {
+ return res;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/item/quartz/ItemDarkQuartzBlock.java b/src/main/java/vazkii/tinkerer/common/item/quartz/ItemDarkQuartzBlock.java
new file mode 100644
index 00000000..ceb6f5f5
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/quartz/ItemDarkQuartzBlock.java
@@ -0,0 +1,32 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 16:12:29 (GMT)]
+ */
+package vazkii.tinkerer.common.item.quartz;
+
+import net.minecraft.item.ItemMultiTextureTile;
+import net.minecraft.item.ItemStack;
+import vazkii.tinkerer.common.block.ModBlocks;
+import vazkii.tinkerer.common.lib.LibBlockNames;
+
+public class ItemDarkQuartzBlock extends ItemMultiTextureTile {
+
+ public ItemDarkQuartzBlock(int par1) {
+ super(par1, ModBlocks.darkQuartz, new String[] { "" } );
+ }
+
+ @Override
+ public String getUnlocalizedName(ItemStack par1ItemStack) {
+ return par1ItemStack.getItemDamage() >= 3 ? "" : LibBlockNames.DARK_QUARTZ_BLOCK_NAMES[par1ItemStack.getItemDamage()];
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/item/quartz/ItemDarkQuartzSlab.java b/src/main/java/vazkii/tinkerer/common/item/quartz/ItemDarkQuartzSlab.java
new file mode 100644
index 00000000..16c1d548
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/item/quartz/ItemDarkQuartzSlab.java
@@ -0,0 +1,28 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 16:13:21 (GMT)]
+ */
+package vazkii.tinkerer.common.item.quartz;
+
+import net.minecraft.block.BlockHalfSlab;
+import net.minecraft.item.ItemSlab;
+import vazkii.tinkerer.common.block.ModBlocks;
+
+public class ItemDarkQuartzSlab extends ItemSlab {
+
+ public ItemDarkQuartzSlab(int par1) {
+ super(par1, (BlockHalfSlab) ModBlocks.darkQuartzSlab, (BlockHalfSlab) ModBlocks.darkQuartzSlabFull, par1 == ModBlocks.darkQuartzSlabFull.blockID);
+ }
+
+}
+
diff --git a/src/main/java/vazkii/tinkerer/common/lib/LibBlockIDs.java b/src/main/java/vazkii/tinkerer/common/lib/LibBlockIDs.java
new file mode 100644
index 00000000..ada79a0d
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/lib/LibBlockIDs.java
@@ -0,0 +1,38 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [4 Sep 2013, 17:47:21 (GMT)]
+ */
+package vazkii.tinkerer.common.lib;
+
+public final class LibBlockIDs {
+
+ public static int idDarkQuartz = 2615;
+ public static int idDarkQuartzSlab = 2616;
+ public static int idDarkQuartzSlabFull = 2617;
+ public static int idDarkQuartzStairs = 2618;
+ public static int idInterface = 2619;
+ public static int idGaseousLight = 2620;
+ public static int idGaseousShadow = 2621;
+ public static int idAnimationTablet = 2622;
+ public static int idNitorGas = 2623;
+ public static int idMagnet = 2624;
+ public static int idEnchanter = 2625;
+ public static int idFunnel = 2626;
+ public static int idDislocator = 2627;
+ public static int idRepairer = 2628;
+ public static int idAspectAnalyzer = 2629;
+ public static int idPlatform = 2630;
+
+ public static int idWarpGate = 2815;
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/lib/LibBlockNames.java b/src/main/java/vazkii/tinkerer/common/lib/LibBlockNames.java
new file mode 100644
index 00000000..70bde9c2
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/lib/LibBlockNames.java
@@ -0,0 +1,49 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [4 Sep 2013, 17:48:11 (GMT)]
+ */
+package vazkii.tinkerer.common.lib;
+
+import vazkii.tinkerer.client.lib.LibResources;
+
+public final class LibBlockNames {
+
+ public static final String DARK_QUARTZ = LibResources.PREFIX_MOD + "darkQuartz";
+ public static final String DARK_QUARTZ_SLAB = LibResources.PREFIX_MOD + "darkQuartzSlab";
+ public static final String DARK_QUARTZ_SLAB_FULL = LibResources.PREFIX_MOD + "darkQuartzSlabFull";
+ public static final String DARK_QUARTZ_STAIRS = LibResources.PREFIX_MOD + "darkQuartzStairs";
+ public static final String INTERFACE = LibResources.PREFIX_MOD + "interface";
+ public static final String GASEOUS_LIGHT = LibResources.PREFIX_MOD + "gaseousLight";
+ public static final String GASEOUS_SHADOW = LibResources.PREFIX_MOD + "gaseousShadow";
+ public static final String ANIMATION_TABLET = LibResources.PREFIX_MOD + "animationTablet";
+ public static final String NITOR_GAS = LibResources.PREFIX_MOD + "nitorGas";
+ public static final String MAGNET = LibResources.PREFIX_MOD + "magnet";
+ public static final String MOB_MAGNET = LibResources.PREFIX_MOD + "mobMagnet";
+ public static final String ENCHANTER = LibResources.PREFIX_MOD + "enchanter";
+ public static final String FUNNEL = LibResources.PREFIX_MOD + "funnel";
+ public static final String DISLOCATOR = LibResources.PREFIX_MOD + "dislocator";
+ public static final String REPAIRER = LibResources.PREFIX_MOD + "repairer";
+ public static final String ASPECT_ANALYZER = LibResources.PREFIX_MOD + "aspectAnalyzer";
+ public static final String PLATFORM = LibResources.PREFIX_MOD + "platform";
+
+ public static final String WARP_GATE = LibResources.PREFIX_MOD + "warpGate";
+
+ public static final String CAMO = LibResources.PREFIX_MOD + "camo";
+
+ public static final String[] DARK_QUARTZ_BLOCK_NAMES = {
+ "tile." + DARK_QUARTZ,
+ "tile." + LibResources.PREFIX_MOD + "darkQuartzChiseled",
+ "tile." + LibResources.PREFIX_MOD + "darkQuartzPillar"
+ };
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/lib/LibEnchantIDs.java b/src/main/java/vazkii/tinkerer/common/lib/LibEnchantIDs.java
new file mode 100644
index 00000000..4dd562b7
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/lib/LibEnchantIDs.java
@@ -0,0 +1,26 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [29 Sep 2013, 11:09:54 (GMT)]
+ */
+package vazkii.tinkerer.common.lib;
+
+public class LibEnchantIDs {
+
+ public static int idAscentBoost = 220;
+ public static int idSlowFall = 221;
+ public static int idAutoSmelt = 222;
+ public static int idDesintegrate = 223;
+ public static int idQuickDraw = 224;
+ public static int idVampirism = 225;
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/lib/LibEnchantNames.java b/src/main/java/vazkii/tinkerer/common/lib/LibEnchantNames.java
new file mode 100644
index 00000000..df03858b
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/lib/LibEnchantNames.java
@@ -0,0 +1,28 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [29 Sep 2013, 11:06:22 (GMT)]
+ */
+package vazkii.tinkerer.common.lib;
+
+import vazkii.tinkerer.client.lib.LibResources;
+
+public final class LibEnchantNames {
+
+ public static final String ASCENT_BOOST = LibResources.PREFIX_MOD + "ascentBoost";
+ public static final String SLOW_FALL = LibResources.PREFIX_MOD + "slowFall";
+ public static final String AUTO_SMELT = LibResources.PREFIX_MOD + "autoSmelt";
+ public static final String DESINTEGRATE = LibResources.PREFIX_MOD + "desintegrate";
+ public static final String QUICK_DRAW = LibResources.PREFIX_MOD + "quickDraw";
+ public static final String VAMPIRISM = LibResources.PREFIX_MOD + "vampirism";
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/lib/LibFeatures.java b/src/main/java/vazkii/tinkerer/common/lib/LibFeatures.java
new file mode 100644
index 00000000..5b8c2351
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/lib/LibFeatures.java
@@ -0,0 +1,38 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 19:01:53 (GMT)]
+ */
+package vazkii.tinkerer.common.lib;
+
+import thaumcraft.api.aspects.Aspect;
+
+public final class LibFeatures {
+
+ public static final Aspect[] PRIMAL_ASPECTS = new Aspect[] {
+ Aspect.AIR, Aspect.EARTH, Aspect.FIRE, Aspect.WATER, Aspect.ORDER, Aspect.ENTROPY
+ };
+
+ public static final int INTERFACE_DISTANCE = 4;
+ public static final int DISLOCATOR_DISTANCE = 16;
+
+ public static final int SPELL_CLOTH_USES = 35;
+
+ public static final int XP_TALISMAN_RANGE = 3;
+ public static final int XP_TALISMAN_MAX_XP = 1500;
+ public static final int XP_TALISMAN_ENCHANTING_BOTTLE_COST = 10;
+
+ public static final int CLEANSING_TALISMAN_USES = 100;
+
+ public static final float MOVEMENT_MODIFIER = 1F;
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/lib/LibGuiIDs.java b/src/main/java/vazkii/tinkerer/common/lib/LibGuiIDs.java
new file mode 100644
index 00000000..c09f5397
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/lib/LibGuiIDs.java
@@ -0,0 +1,28 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 16:25:27 (GMT)]
+ */
+package vazkii.tinkerer.common.lib;
+
+public final class LibGuiIDs {
+
+ public static final int GUI_ID_TABLET = 0;
+ public static final int GUI_ID_MOB_MAGNET = 1;
+ public static final int GUI_ID_ENCHANTER = 2;
+ public static final int GUI_ID_ASPECT_ANALYZER = 3;
+
+ public static final int GUI_ID_ICHOR_POUCH = 50;
+ public static final int GUI_ID_WARP_GATE = 51;
+ public static final int GUI_ID_WARP_GATE_DESTINATIONS = 52;
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/lib/LibItemIDs.java b/src/main/java/vazkii/tinkerer/common/lib/LibItemIDs.java
new file mode 100644
index 00000000..e762e009
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/lib/LibItemIDs.java
@@ -0,0 +1,68 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [4 Sep 2013, 17:43:56 (GMT)]
+ */
+package vazkii.tinkerer.common.lib;
+
+public final class LibItemIDs {
+
+ public static int idDarkQuartz = 22150;
+ public static int idConnector = 22151;
+ public static int idGaseousLight = 22152;
+ public static int idGaseousShadow = 22153;
+ public static int idGasRemover = 22154;
+ public static int idSpellCloth = 22155;
+ public static int idFocusFlight = 22156;
+ public static int idFocusDislocation = 22157;
+ public static int idCleansingTalisman = 22158;
+ public static int idBrightNitor = 22159;
+ public static int idFocusTelekinesis = 22160;
+ public static int idSoulMould = 22161;
+ public static int idXPTalisman = 22162;
+ public static int idFocusSmelt = 22163;
+ public static int idFocusHeal = 22164;
+ public static int idFocusEnderChest = 22165;
+ public static int idBloodSword = 22166;
+ public static int idRevealingHelm = 22167;
+ public static int idInfusedInkwell = 22168;
+ public static int idFocusDeflect = 22169;
+ public static int idShareBook = 22170;
+
+ public static int idKamiResource = 23150;
+ public static int idIchorHelm = 23151;
+ public static int idIchorChest = 23152;
+ public static int idIchorLegs = 23153;
+ public static int idIchorBoots = 23154;
+ public static int idIchorHelmGem = 23155;
+ public static int idIchorChestGem = 23156;
+ public static int idIchorLegsGem = 23157;
+ public static int idIchorBootsGem = 23158;
+ public static int idCatAmulet = 23159;
+ public static int idIchorPick = 23160;
+ public static int idIchorShovel = 23161;
+ public static int idIchorAxe = 23162;
+ public static int idIchorSword = 23163;
+ public static int idIchorPickGem = 23164;
+ public static int idIchorShovelGem = 23165;
+ public static int idIchorAxeGem = 23166;
+ public static int idIchorSwordGem = 23167;
+ public static int idIchorPouch = 23168;
+ public static int idBlockTalisman = 23169;
+ public static int idPlacementMirror = 23170;
+ public static int idFocusShadowbeam = 23171;
+ public static int idFocusXPDrain = 23172;
+ public static int idProtoclay = 23173;
+ public static int idSkyPearl = 23174;
+ public static int idFocusRecall = 23175;
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/lib/LibItemNames.java b/src/main/java/vazkii/tinkerer/common/lib/LibItemNames.java
new file mode 100644
index 00000000..26d075c6
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/lib/LibItemNames.java
@@ -0,0 +1,80 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [4 Sep 2013, 17:45:44 (GMT)]
+ */
+package vazkii.tinkerer.common.lib;
+
+import vazkii.tinkerer.client.lib.LibResources;
+
+public final class LibItemNames {
+
+ public static final String DARK_QUARTZ = LibResources.PREFIX_MOD + "darkQuartz";
+ public static final String CONNECTOR = LibResources.PREFIX_MOD + "connector";
+ public static final String GASEOUS_LIGHT = LibResources.PREFIX_MOD + "gaseousLight";
+ public static final String GASEOUS_SHADOW = LibResources.PREFIX_MOD + "gaseousShadow";
+ public static final String GAS_REMOVER = LibResources.PREFIX_MOD + "gasRemover";
+ public static final String SPELL_CLOTH = LibResources.PREFIX_MOD + "spellCloth";
+ public static final String FOCUS_FLIGHT = LibResources.PREFIX_MOD + "focusFlight";
+ public static final String FOCUS_DISLOCATION = LibResources.PREFIX_MOD + "focusDislocation";
+ public static final String CLEANSING_TALISMAN = LibResources.PREFIX_MOD + "cleansingTalisman";
+ public static final String BRIGHT_NTIOR = LibResources.PREFIX_MOD + "brightNitor";
+ public static final String FOCUS_TELEKINESIS = LibResources.PREFIX_MOD + "focusTelekinesis";
+ public static final String SOUL_MOULD = LibResources.PREFIX_MOD + "soulMould";
+ public static final String XP_TALISMAN = LibResources.PREFIX_MOD + "xpTalisman";
+ public static final String FOCUS_SMELT = LibResources.PREFIX_MOD + "focusSmelt";
+ public static final String FOCUS_HEAL = LibResources.PREFIX_MOD + "focusHeal";
+ public static final String FOCUS_ENDER_CHEST = LibResources.PREFIX_MOD + "focusEnderChest";
+ public static final String BLOOD_SWORD = LibResources.PREFIX_MOD + "bloodSword";
+ public static final String REVEALING_HELM = LibResources.PREFIX_MOD + "revealingHelm";
+ public static final String INFUSED_INKWELL = LibResources.PREFIX_MOD + "infusedInkwell";
+ public static final String FOCUS_DEFLECT = LibResources.PREFIX_MOD + "focusDeflect";
+ public static final String SHARE_BOOK = LibResources.PREFIX_MOD + "shareBook";
+
+ public static final String KAMI_RESOURCE = LibResources.PREFIX_MOD + "kamiResource";
+ public static final String ICHOR_HELM = LibResources.PREFIX_MOD + "ichorclothHelm";
+ public static final String ICHOR_CHEST = LibResources.PREFIX_MOD + "ichorclothChest";
+ public static final String ICHOR_LEGS = LibResources.PREFIX_MOD + "ichorclothLegs";
+ public static final String ICHOR_BOOTS = LibResources.PREFIX_MOD + "ichorclothBoots";
+ public static final String ICHOR_HELM_GEM = LibResources.PREFIX_MOD + "ichorclothHelmGem";
+ public static final String ICHOR_CHEST_GEM = LibResources.PREFIX_MOD + "ichorclothChestGem";
+ public static final String ICHOR_LEGS_GEM = LibResources.PREFIX_MOD + "ichorclothLegsGem";
+ public static final String ICHOR_BOOTS_GEM = LibResources.PREFIX_MOD + "ichorclothBootsGem";
+ public static final String CAT_AMULET = LibResources.PREFIX_MOD + "catAmulet";
+ public static final String ICHOR_PICK = LibResources.PREFIX_MOD + "ichorPick";
+ public static final String ICHOR_SHOVEL = LibResources.PREFIX_MOD + "ichorShovel";
+ public static final String ICHOR_AXE = LibResources.PREFIX_MOD + "ichorAxe";
+ public static final String ICHOR_SWORD = LibResources.PREFIX_MOD + "ichorSword";
+ public static final String ICHOR_PICK_GEM = LibResources.PREFIX_MOD + "ichorPickGem";
+ public static final String ICHOR_SHOVEL_GEM = LibResources.PREFIX_MOD + "ichorShovelGem";
+ public static final String ICHOR_AXE_GEM = LibResources.PREFIX_MOD + "ichorAxeGem";
+ public static final String ICHOR_SWORD_GEM = LibResources.PREFIX_MOD + "ichorSwordGem";
+ public static final String ICHOR_POUCH = LibResources.PREFIX_MOD + "ichorPouch";
+ public static final String BLOCK_TALISMAN = LibResources.PREFIX_MOD + "blockTalisman";
+ public static final String PLACEMENT_MIRROR = LibResources.PREFIX_MOD + "placementMirror";
+ public static final String FOCUS_SHADOWBEAM = LibResources.PREFIX_MOD + "focusShadowbeam";
+ public static final String FOCUS_XP_DRAIN = LibResources.PREFIX_MOD + "focusXPDrain";
+ public static final String PROTOCLAY = LibResources.PREFIX_MOD + "protoclay";
+ public static final String SKY_PEARL = LibResources.PREFIX_MOD + "skyPearl";
+ public static final String FOCUS_RECALL = LibResources.PREFIX_MOD + "focusRecall";
+
+ public static final String[] KAMI_RESOURCE_NAMES = new String[] {
+ LibResources.PREFIX_MOD + "ichor",
+ LibResources.PREFIX_MOD + "ichorCloth",
+ LibResources.PREFIX_MOD + "ichorium",
+ LibResources.PREFIX_MOD + "ichorNugget",
+ LibResources.PREFIX_MOD + "ichorCap",
+ LibResources.PREFIX_MOD + "ichorclothRod",
+ LibResources.PREFIX_MOD + "netherShard",
+ LibResources.PREFIX_MOD + "enderShard"
+ };
+}
diff --git a/src/main/java/vazkii/tinkerer/common/lib/LibMisc.java b/src/main/java/vazkii/tinkerer/common/lib/LibMisc.java
new file mode 100644
index 00000000..60d0f1c2
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/lib/LibMisc.java
@@ -0,0 +1,30 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [4 Sep 2013, 16:02:26 (GMT)]
+ */
+package vazkii.tinkerer.common.lib;
+
+public final class LibMisc {
+
+ public static final String MOD_ID = "ThaumicTinkerer";
+ public static final String MOD_NAME = "Thaumic Tinkerer";
+ public static final String VERSION = "ANT:VERSION-ANT:BUILD";
+
+ public static final String NETWORK_CHANNEL = MOD_ID;
+
+ public static final String DEPENDENCIES = "required-after:Thaumcraft;before:MagicBees;after:IC2;after:ThaumicTinkererKami";
+
+ public static final String COMMON_PROXY = "vazkii.tinkerer.common.core.proxy.TTCommonProxy";
+ public static final String CLIENT_PROXY = "vazkii.tinkerer.client.core.proxy.TTClientProxy";
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/lib/LibObfuscation.java b/src/main/java/vazkii/tinkerer/common/lib/LibObfuscation.java
new file mode 100644
index 00000000..6b1da598
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/lib/LibObfuscation.java
@@ -0,0 +1,34 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [Nov 25, 2013, 2:19:00 PM (GMT)]
+ */
+package vazkii.tinkerer.common.lib;
+
+public final class LibObfuscation {
+
+ /** EntityPlayer **/
+ public static final String[] ITEM_IN_USE = new String[] { "itemInUse", "field_71074_e", "f" };
+ public static final String[] ITEM_IN_USE_COUNT = new String[] { "itemInUseCount", "field_71072_f", "g" };
+
+ /** Potion **/
+ public static final String[] IS_BAD_EFFECT = new String[] { "isBadEffect", "field_76418_K", "J" };
+
+ /** EntityAIAvoidEntity **/
+ public static final String[] TARGET_ENTITY_CLASS = new String[] { "targetEntityClass", "field_75381_h", "i" };
+
+ /** EntityAINearestAttackableTarget **/
+ public static final String[] TARGET_CLASS = new String[] { "targetClass", "field_75307_b", "a" };
+
+ /** EntityCreeper **/
+ public static final String[] TIME_SINCE_IGNITED = new String[] { "timeSinceIgnited", "field_70833_d" , "bq" };
+}
diff --git a/src/main/java/vazkii/tinkerer/common/lib/LibResearch.java b/src/main/java/vazkii/tinkerer/common/lib/LibResearch.java
new file mode 100644
index 00000000..90ce050f
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/lib/LibResearch.java
@@ -0,0 +1,101 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [8 Sep 2013, 16:39:00 (GMT)]
+ */
+package vazkii.tinkerer.common.lib;
+
+public final class LibResearch {
+
+ public static final String CATEGORY_BASICS = "BASICS";
+ public static final String CATEGORY_THAUMATURGY = "THAUMATURGY";
+ public static final String CATEGORY_ALCHEMY = "ALCHEMY";
+ public static final String CATEGORY_ARTIFICE = "ARTIFICE";
+ public static final String CATEGORY_GOLEMANCY = "GOLEMANCY";
+
+ public static final String CATEGORY_ENCHANTING = "TT_ENCHANTING";
+
+ public static final String KEY_DARK_QUARTZ = "DARK_QUARTZ";
+ public static final String KEY_INTERFACE = "INTERFACE";
+ public static final String KEY_CONNECTOR = "CONNECTOR";
+ public static final String KEY_GASEOUS_LIGHT = "GASEOUS_LIGHT";
+ public static final String KEY_GASEOUS_SHADOW = "GASEOUS_SHADOW";
+ public static final String KEY_GAS_REMOVER = "GAS_REMOVER";
+ public static final String KEY_SPELL_CLOTH = "SPELL_CLOTH";
+ public static final String KEY_ANIMATION_TABLET = "ANIMATION_TABLET";
+ public static final String KEY_FOCUS_FLIGHT = "FOCUS_FLIGHT";
+ public static final String KEY_FOCUS_DISLOCATION = "FOCUS_DISLOCATION";
+ public static final String KEY_CLEANSING_TALISMAN = "CLEANSING_TALISMAN";
+ public static final String KEY_BRIGHT_NITOR = "BRIGHT_NITOR";
+ public static final String KEY_FOCUS_TELEKINESIS = "FOCUS_TELEKINESIS";
+ public static final String KEY_MAGNETS = "MAGNETS";
+ public static final String KEY_MAGNET = "MAGNET";
+ public static final String KEY_MOB_MAGNET = "MOB_MAGNET";
+ public static final String KEY_PERIPHERALS = "PERIPHERALS";
+ public static final String KEY_ENCHANTER = "ENCHANTER";
+ public static final String KEY_XP_TALISMAN = "XP_TALISMAN";
+ public static final String KEY_FUNNEL = "FUNNEL";
+ public static final String KEY_ENCHANT_ASCENT_BOOST = "TTENCH_ASCENT_BOOST";
+ public static final String KEY_ENCHANT_SLOW_FALL = "TTENCH_SLOW_FALL";
+ public static final String KEY_ENCHANT_AUTO_SMELT = "TTENCH_AUTO_SMELT";
+ public static final String KEY_ENCHANT_DESINTEGRATE = "TTENCH_DESINTEGRATE";
+ public static final String KEY_ENCHANT_QUICK_DRAW = "TTENCH_QUICK_DRAW";
+ public static final String KEY_ENCHANT_VAMPIRISM = "TTENCH_VAMPIRISM";
+ public static final String KEY_FOCUS_SMELT = "FOCUS_SMELT";
+ public static final String KEY_FOCUS_HEAL = "FOCUS_HEAL";
+ public static final String KEY_FOCUS_ENDER_CHEST = "FOCUS_ENDER_CHEST";
+ public static final String KEY_BLOOD_SWORD = "BLOOD_SWORD";
+ public static final String KEY_DISLOCATOR = "DISLOCATOR";
+ public static final String KEY_REVEALING_HELM = "REVEALING_HELM";
+ public static final String KEY_INFUSED_INKWELL = "INFUSED_INKWELL";
+ public static final String KEY_REPAIRER = "REPAIRER";
+ public static final String KEY_FOCUS_DEFLECT = "FOCUS_DEFLECT";
+ public static final String KEY_ASPECT_ANALYZER = "ASPECT_ANALYZER";
+ public static final String KEY_PLATFORM = "PLATFORM";
+ public static final String KEY_SHARE_TOME = "SHARE_TOME";
+
+ public static final String KEY_DIMENSION_SHARDS = "DIMENSION_SHARDS";
+ public static final String KEY_ICHOR = "ICHOR";
+ public static final String KEY_ICHOR_CLOTH = "ICHOR_CLOTH";
+ public static final String KEY_ICHORIUM = "ICHORIUM";
+ public static final String KEY_ICHOR_CAP = "ICHOR_CAP";
+ public static final String KEY_ICHORCLOTH_ROD = "ICHORCLOTH_ROD";
+ public static final String KEY_ICHORCLOTH_ARMOR = "ICHORCLOTH_ARMOR";
+ public static final String KEY_ICHORCLOTH_HELM = "ICHORCLOTH_HELM";
+ public static final String KEY_ICHORCLOTH_CHEST = "ICHORCLOTH_CHEST";
+ public static final String KEY_ICHORCLOTH_LEGS = "ICHORCLOTH_LEGS";
+ public static final String KEY_ICHORCLOTH_BOOTS = "ICHORCLOTH_BOOTS";
+ public static final String KEY_ICHORCLOTH_HELM_GEM = "ICHORCLOTH_HELM_GEM";
+ public static final String KEY_ICHORCLOTH_CHEST_GEM = "ICHORCLOTH_CHEST_GEM";
+ public static final String KEY_ICHORCLOTH_LEGS_GEM = "ICHORCLOTH_LEGS_GEM";
+ public static final String KEY_ICHORCLOTH_BOOTS_GEM = "ICHORCLOTH_BOOTS_GEM";
+ public static final String KEY_CAT_AMULET = "CAT_AMULET";
+ public static final String KEY_ICHOR_TOOLS = "ICHOR_TOOLS";
+ public static final String KEY_ICHOR_PICK = "ICHOR_PICK";
+ public static final String KEY_ICHOR_SHOVEL = "ICHOR_SHOVEL";
+ public static final String KEY_ICHOR_AXE = "ICHOR_AXE";
+ public static final String KEY_ICHOR_SWORD = "ICHOR_SWORD";
+ public static final String KEY_ICHOR_PICK_GEM = "ICHOR_PICK_GEM";
+ public static final String KEY_ICHOR_SHOVEL_GEM = "ICHOR_SHOVEL_GEM";
+ public static final String KEY_ICHOR_AXE_GEM = "ICHOR_AXE_GEM";
+ public static final String KEY_ICHOR_SWORD_GEM = "ICHOR_SWORD_GEM";
+ public static final String KEY_ICHOR_POUCH = "ICHOR_POUCH";
+ public static final String KEY_BLOCK_TALISMAN = "BLOCK_TALISMAN";
+ public static final String KEY_PLACEMENT_MIRROR = "PLACEMENT_MIRROR";
+ public static final String KEY_FOCUS_SHADOWBEAM = "FOCUS_SHADOWBEAM";
+ public static final String KEY_FOCUS_XP_DRAIN = "FOCUS_XP_DRAIN";
+ public static final String KEY_PROTOCLAY = "PROTOCLAY";
+ public static final String KEY_WARP_GATE = "WARP_GATE";
+ public static final String KEY_SKY_PEARL = "SKY_PEARL";
+ public static final String KEY_FOCUS_RECALL = "FOCUS_RECALL";
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/network/GuiHandler.java b/src/main/java/vazkii/tinkerer/common/network/GuiHandler.java
new file mode 100644
index 00000000..c58131c6
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/network/GuiHandler.java
@@ -0,0 +1,96 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 16:29:28 (GMT)]
+ */
+package vazkii.tinkerer.common.network;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import vazkii.tinkerer.client.gui.GuiAnimationTablet;
+import vazkii.tinkerer.client.gui.GuiAspectAnalyzer;
+import vazkii.tinkerer.client.gui.GuiEnchanting;
+import vazkii.tinkerer.client.gui.GuiMobMagnet;
+import vazkii.tinkerer.client.gui.kami.GuiIchorPouch;
+import vazkii.tinkerer.client.gui.kami.GuiWarpGate;
+import vazkii.tinkerer.client.gui.kami.GuiWarpGateDestinations;
+import vazkii.tinkerer.common.block.tile.TileAspectAnalyzer;
+import vazkii.tinkerer.common.block.tile.TileEnchanter;
+import vazkii.tinkerer.common.block.tile.TileMobMagnet;
+import vazkii.tinkerer.common.block.tile.container.ContainerAnimationTablet;
+import vazkii.tinkerer.common.block.tile.container.ContainerAspectAnalyzer;
+import vazkii.tinkerer.common.block.tile.container.ContainerEnchanter;
+import vazkii.tinkerer.common.block.tile.container.ContainerMobMagnet;
+import vazkii.tinkerer.common.block.tile.container.kami.ContainerIchorPouch;
+import vazkii.tinkerer.common.block.tile.container.kami.ContainerWarpGate;
+import vazkii.tinkerer.common.block.tile.kami.TileWarpGate;
+import vazkii.tinkerer.common.block.tile.tablet.TileAnimationTablet;
+import vazkii.tinkerer.common.lib.LibGuiIDs;
+import cpw.mods.fml.common.network.IGuiHandler;
+
+public class GuiHandler implements IGuiHandler {
+
+ @Override
+ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
+ TileEntity tile = world.getBlockTileEntity(x, y, z);
+ switch(ID) {
+ case LibGuiIDs.GUI_ID_TABLET :
+ return new ContainerAnimationTablet((TileAnimationTablet) tile, player.inventory);
+
+ case LibGuiIDs.GUI_ID_MOB_MAGNET :
+ return new ContainerMobMagnet((TileMobMagnet) tile, player.inventory);
+
+ case LibGuiIDs.GUI_ID_ENCHANTER :
+ return new ContainerEnchanter((TileEnchanter) tile, player.inventory);
+
+ case LibGuiIDs.GUI_ID_ASPECT_ANALYZER :
+ return new ContainerAspectAnalyzer((TileAspectAnalyzer) tile, player.inventory);
+
+ case LibGuiIDs.GUI_ID_ICHOR_POUCH :
+ return new ContainerIchorPouch(player);
+
+ case LibGuiIDs.GUI_ID_WARP_GATE :
+ return new ContainerWarpGate((TileWarpGate) tile, player.inventory);
+ }
+ return null;
+ }
+
+ @Override
+ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
+ TileEntity tile = world.getBlockTileEntity(x, y, z);
+ switch(ID) {
+ case LibGuiIDs.GUI_ID_TABLET :
+ return new GuiAnimationTablet((TileAnimationTablet) tile, player.inventory);
+
+ case LibGuiIDs.GUI_ID_MOB_MAGNET :
+ return new GuiMobMagnet((TileMobMagnet) tile, player.inventory);
+
+ case LibGuiIDs.GUI_ID_ENCHANTER :
+ return new GuiEnchanting((TileEnchanter) tile, player.inventory);
+
+ case LibGuiIDs.GUI_ID_ASPECT_ANALYZER :
+ return new GuiAspectAnalyzer((TileAspectAnalyzer) tile, player.inventory);
+
+ case LibGuiIDs.GUI_ID_ICHOR_POUCH :
+ return new GuiIchorPouch(new ContainerIchorPouch(player));
+
+ case LibGuiIDs.GUI_ID_WARP_GATE :
+ return new GuiWarpGate((TileWarpGate) tile, player.inventory);
+
+ case LibGuiIDs.GUI_ID_WARP_GATE_DESTINATIONS :
+ return new GuiWarpGateDestinations((TileWarpGate) tile);
+ }
+ return null;
+ }
+
+}
diff --git a/src/main/java/vazkii/tinkerer/common/network/IPacket.java b/src/main/java/vazkii/tinkerer/common/network/IPacket.java
new file mode 100644
index 00000000..adedc731
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/network/IPacket.java
@@ -0,0 +1,25 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 16:57:06 (GMT)]
+ */
+package vazkii.tinkerer.common.network;
+
+import java.io.Serializable;
+
+import net.minecraft.network.INetworkManager;
+import cpw.mods.fml.common.network.Player;
+
+public interface IPacket extends Serializable {
+
+ public void handle(INetworkManager manager, Player player);
+}
diff --git a/src/main/java/vazkii/tinkerer/common/network/PacketManager.java b/src/main/java/vazkii/tinkerer/common/network/PacketManager.java
new file mode 100644
index 00000000..67d1ed50
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/network/PacketManager.java
@@ -0,0 +1,64 @@
+/**
+ * This class was created by . It's distributed as
+ * part of the ThaumicTinkerer Mod.
+ *
+ * ThaumicTinkerer is Open Source and distributed under a
+ * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
+ * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
+ *
+ * ThaumicTinkerer is a Derivative Work on Thaumcraft 4.
+ * Thaumcraft 4 (c) Azanor 2012
+ * (http://www.minecraftforum.net/topic/1585216-)
+ *
+ * File Created @ [9 Sep 2013, 16:58:55 (GMT)]
+ */
+package vazkii.tinkerer.common.network;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import net.minecraft.network.INetworkManager;
+import net.minecraft.network.packet.Packet250CustomPayload;
+import vazkii.tinkerer.common.lib.LibMisc;
+import cpw.mods.fml.common.network.IPacketHandler;
+import cpw.mods.fml.common.network.Player;
+
+public final class PacketManager implements IPacketHandler {
+
+ @Override
+ public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
+ try {
+ ByteArrayInputStream byteStream = new ByteArrayInputStream(packet.data);
+ ObjectInputStream objStream = new ObjectInputStream(byteStream);
+ IPacket ipacket = (IPacket) objStream.readObject();
+
+ ipacket.handle(manager, player);
+ } catch(Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static Packet250CustomPayload buildPacket(IPacket ipacket) {
+ try {
+ Packet250CustomPayload payload = new Packet250CustomPayload();
+ ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+ ObjectOutputStream objStream = new ObjectOutputStream(byteStream);
+
+ objStream.writeObject(ipacket);
+
+ payload.channel = LibMisc.NETWORK_CHANNEL;
+ payload.data = byteStream.toByteArray();
+ payload.length = payload.data.length;
+
+ return payload;
+ } catch(IOException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/vazkii/tinkerer/common/network/PlayerTracker.java b/src/main/java/vazkii/tinkerer/common/network/PlayerTracker.java
new file mode 100644
index 00000000..8ff26db5
--- /dev/null
+++ b/src/main/java/vazkii/tinkerer/common/network/PlayerTracker.java
@@ -0,0 +1,49 @@
+/**
+ * This class was created by