mirror of
https://github.com/GTNewHorizons/Draconic-Evolution.git
synced 2026-11-19 19:59:34 +00:00
Getting ready to merge the config overhall pull request
This commit is contained in:
1 parent
aef2fd8d1c
commit
a3e89cb900
16 files changed
+515
-436
No files matched your search
+2
-1
@@ -13,6 +13,7 @@ import com.brandon3055.draconicevolution.common.items.weapons.DraconicBow;
|
||||
import com.brandon3055.draconicevolution.common.items.weapons.WyvernBow;
|
||||
import com.brandon3055.draconicevolution.common.network.MountUpdatePacket;
|
||||
import com.brandon3055.draconicevolution.common.utills.LogHelper;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -98,7 +99,7 @@ public class ClientEventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public void fovUpdate(FOVUpdateEvent event){
|
||||
|
||||
//region Bow FOV Update
|
||||
|
||||
+3
@@ -6,6 +6,8 @@ import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelp
|
||||
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorCore;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorEnergyInjector;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorStabilizer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -15,6 +17,7 @@ import org.lwjgl.opengl.GL11;
|
||||
/**
|
||||
* Created by Brandon on 17/7/2015.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ParticleReactorBeam extends EntityFX {
|
||||
/**
|
||||
* Particle Type 0 = Energy Ring, 1 = single particle
|
||||
|
||||
@@ -20,6 +20,10 @@ public class ChaosShardAtmos extends BlockAir {
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, int x, int y, int z, Random random) {
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (random.nextInt(25) == 0) {
|
||||
for (int searchX = x-15; searchX < x+15; searchX++){
|
||||
for (int searchZ = z-15; searchZ < z+15; searchZ++){
|
||||
|
||||
+6
-4
@@ -169,8 +169,9 @@ public class MinecraftForgeEventHandler {
|
||||
{
|
||||
EntityItem item = new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, new ItemStack(ModItems.dragonHeart));
|
||||
event.entity.worldObj.spawnEntityInWorld(new EntityDragonHeart(event.entity.worldObj, ((int) event.entity.posX) + 0.5, event.entity.posY, ((int) event.entity.posZ) + 0.5));
|
||||
if (event.entity instanceof EntityCustomDragon && ((EntityCustomDragon) event.entity).getIsUber())
|
||||
event.entity.worldObj.spawnEntityInWorld(new EntityDragonHeart(event.entity.worldObj, event.entity.posX, event.entity.posY + 2, event.entity.posZ));
|
||||
if (event.entity instanceof EntityCustomDragon && ((EntityCustomDragon) event.entity).getIsUber()){
|
||||
event.entity.worldObj.spawnEntityInWorld(new EntityDragonHeart(event.entity.worldObj, event.entity.posX, event.entity.posY + 2, event.entity.posZ));
|
||||
}
|
||||
|
||||
for (Object o : event.entity.worldObj.playerEntities)
|
||||
{
|
||||
@@ -216,8 +217,9 @@ public class MinecraftForgeEventHandler {
|
||||
ItemStack soul = new ItemStack(ModItems.mobSoul);
|
||||
String name = EntityList.getEntityString(entity);
|
||||
ItemNBTHelper.setString(soul, "Name", name);
|
||||
if (entity instanceof EntitySkeleton)
|
||||
ItemNBTHelper.setInteger(soul, "SkeletonType", ((EntitySkeleton) entity).getSkeletonType());
|
||||
if (entity instanceof EntitySkeleton){
|
||||
ItemNBTHelper.setInteger(soul, "SkeletonType", ((EntitySkeleton) entity).getSkeletonType());
|
||||
}
|
||||
world.spawnEntityInWorld(new EntityItem(world, entity.posX, entity.posY, entity.posZ, soul));
|
||||
Achievements.triggerAchievement((EntityPlayer) attacker, "draconicevolution.soul");
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.brandon3055.draconicevolution.common.inventory;
|
||||
|
||||
import com.brandon3055.brandonscore.common.utills.ItemNBTHelper;
|
||||
import com.brandon3055.draconicevolution.common.container.ContainerAdvTool;
|
||||
import com.brandon3055.draconicevolution.common.utills.IInventoryTool;
|
||||
import com.brandon3055.brandonscore.common.utills.ItemNBTHelper;
|
||||
import com.brandon3055.draconicevolution.common.utills.LogHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -10,7 +10,6 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -118,7 +117,6 @@ public class InventoryTool implements IInventory {
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
//if (player.getCommandSenderName().equals("brandon3055")) player.addChatComponentMessage(new ChatComponentText("markDirty " + (player.worldObj.isRemote ? ":client" : ":server")));
|
||||
|
||||
for (int i = 0; i < getSizeInventory(); ++i)
|
||||
{
|
||||
@@ -126,7 +124,6 @@ public class InventoryTool implements IInventory {
|
||||
inventoryStacks[i] = null;
|
||||
}
|
||||
}
|
||||
if (player.getCommandSenderName().equals("brandon3055")) player.addChatComponentMessage(new ChatComponentText("markDirty " + getItem() + (player.worldObj.isRemote ? ":client" : ":server")));
|
||||
|
||||
if (getItem() != null) {
|
||||
writeToNBT(ItemNBTHelper.getCompound(getItem()));
|
||||
@@ -134,7 +131,6 @@ public class InventoryTool implements IInventory {
|
||||
}
|
||||
else {
|
||||
LogHelper.error("[InventoryItem] storage item == null This is not a good thing...");
|
||||
if (player.getCommandSenderName().equals("brandon3055")) player.addChatComponentMessage(new ChatComponentText("[InventoryItem] storage item == null " + (player.worldObj.isRemote ? ":client" : ":server")));
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +149,6 @@ public class InventoryTool implements IInventory {
|
||||
}
|
||||
else {
|
||||
LogHelper.error("Error getting inventory item [InventoryTool#getItem() - "+ slot +"]");
|
||||
if (player.getCommandSenderName().equalsIgnoreCase("brandon3055")) player.addChatComponentMessage(new ChatComponentText("Error getting inventory item [InventoryTool#getItem() - "+ slot +"] server:" + !player.worldObj.isRemote));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -213,12 +208,10 @@ public class InventoryTool implements IInventory {
|
||||
// }
|
||||
|
||||
if (compound.hasKey("ench") && compound.getTagList("ench", 10).tagCount() == 0) compound.removeTag("ench");
|
||||
if (player.getCommandSenderName().equals("brandon3055")) player.addChatComponentMessage(new ChatComponentText("writeToNBT " + (player.worldObj.isRemote ? ":client" : ":server") + " Tag:" + compound));
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
{
|
||||
if (player.getCommandSenderName().equals("brandon3055")) player.addChatComponentMessage(new ChatComponentText("readFromNBT " + (player.worldObj.isRemote ? ":client" : ":server") + " Tag:" + compound));
|
||||
NBTTagCompound[] tag = new NBTTagCompound[size];
|
||||
NBTTagList enchList = null;
|
||||
if (compound.hasKey("ench")) enchList = compound.getTagList("ench", 10);
|
||||
|
||||
+9
-9
@@ -124,15 +124,15 @@ public class DraconiumFluxCapacitor extends RFItemBase implements IUpgradableIte
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (player.isSneaking()){
|
||||
int mode = ItemNBTHelper.getShort(stack, "Mode", (short)0);
|
||||
int newMode = mode == 3 ? 0 : mode + 1;
|
||||
ItemNBTHelper.setShort(stack, "Mode", (short) newMode);
|
||||
if (world.isRemote) player.addChatComponentMessage(new ChatComponentTranslation(InfoHelper.ITC()+StatCollector.translateToLocal("info.de.capacitorMode.txt")+": "+InfoHelper.HITC()+StatCollector.translateToLocal("info.de.capacitorMode"+ItemNBTHelper.getShort(stack, "Mode", (short)0)+".txt")));
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (player.isSneaking()){
|
||||
int mode = ItemNBTHelper.getShort(stack, "Mode", (short)0);
|
||||
int newMode = mode == 3 ? 0 : mode + 1;
|
||||
ItemNBTHelper.setShort(stack, "Mode", (short) newMode);
|
||||
if (world.isRemote) player.addChatComponentMessage(new ChatComponentTranslation(InfoHelper.ITC()+StatCollector.translateToLocal("info.de.capacitorMode.txt")+": "+InfoHelper.HITC()+StatCollector.translateToLocal("info.de.capacitorMode"+ItemNBTHelper.getShort(stack, "Mode", (short)0)+".txt")));
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Override
|
||||
|
||||
+13
-1
@@ -9,7 +9,10 @@ import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 14/08/2014.
|
||||
@@ -56,7 +59,16 @@ public class PlacedItemPacket implements IMessage
|
||||
int z = message.blockZ+dir.offsetZ;
|
||||
World world = ctx.getServerHandler().playerEntity.worldObj;
|
||||
EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
if (!world.isAirBlock(x, y, z) || player.getHeldItem() == null) return null;
|
||||
|
||||
if (!world.isAirBlock(x, y, z) || player.getHeldItem() == null || !ModBlocks.isEnabled(ModBlocks.placedItem)) return null;
|
||||
|
||||
BlockEvent.PlaceEvent event = new BlockEvent.PlaceEvent(new BlockSnapshot(world, x, y, z, ModBlocks.placedItem, 0), world.getBlock(message.blockX, message.blockY, message.blockZ), player);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (event.isCanceled()){
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack stack = player.getHeldItem();
|
||||
|
||||
world.setBlock(x, y, z, ModBlocks.placedItem, message.side, 2);
|
||||
|
||||
+61
-49
@@ -1,6 +1,8 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities.energynet;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyBeam;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
@@ -8,61 +10,71 @@ import net.minecraft.world.World;
|
||||
/**
|
||||
* Created by Brandon on 11/02/2015.
|
||||
*/
|
||||
public class LinkedEnergyDevice
|
||||
{
|
||||
public ParticleEnergyBeam beam;
|
||||
/**Energy Flow to this device (range: 0D - 100D)*/
|
||||
public double energyFlow = 0;
|
||||
public double lastTickEnergyFlow = 0;
|
||||
public int xCoord;
|
||||
public int yCoord;
|
||||
public int zCoord;
|
||||
public class LinkedEnergyDevice {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ParticleEnergyBeam beam;
|
||||
/**
|
||||
* Energy Flow to this device (range: 0D - 100D)
|
||||
*/
|
||||
public double energyFlow = 0;
|
||||
public double lastTickEnergyFlow = 0;
|
||||
public int xCoord;
|
||||
public int yCoord;
|
||||
public int zCoord;
|
||||
|
||||
public LinkedEnergyDevice() {}
|
||||
public LinkedEnergyDevice() {
|
||||
}
|
||||
|
||||
public LinkedEnergyDevice(int xCoord, int yCoord, int zCoord, ParticleEnergyBeam beam)
|
||||
{
|
||||
this.xCoord = xCoord;
|
||||
this.yCoord = yCoord;
|
||||
this.zCoord = zCoord;
|
||||
this.beam = beam;
|
||||
}
|
||||
public LinkedEnergyDevice(int xCoord, int yCoord, int zCoord, ParticleEnergyBeam beam) {
|
||||
this.xCoord = xCoord;
|
||||
this.yCoord = yCoord;
|
||||
this.zCoord = zCoord;
|
||||
this.beam = beam;
|
||||
}
|
||||
|
||||
public TileEntity getTile(World world)
|
||||
{
|
||||
return world.getTileEntity(xCoord, yCoord, zCoord);
|
||||
}
|
||||
public TileEntity getTile(World world) {
|
||||
return world.getTileEntity(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public IRemoteEnergyHandler getEnergyTile(World world)
|
||||
{
|
||||
return getTile(world) instanceof IRemoteEnergyHandler ? (IRemoteEnergyHandler) getTile(world) : null;
|
||||
}
|
||||
public IRemoteEnergyHandler getEnergyTile(World world) {
|
||||
return getTile(world) instanceof IRemoteEnergyHandler ? (IRemoteEnergyHandler) getTile(world) : null;
|
||||
}
|
||||
|
||||
public LinkedEnergyDevice writeToNBT(NBTTagCompound compound, String key)
|
||||
{
|
||||
compound.setInteger("X_" + key, xCoord);
|
||||
compound.setInteger("Y_" + key, yCoord);
|
||||
compound.setInteger("Z_" + key, zCoord);
|
||||
if (beam != null) compound.setShort("Flow_" + key, (short)beam.getFlow());
|
||||
return this;
|
||||
}
|
||||
public LinkedEnergyDevice writeToNBT(NBTTagCompound compound, String key) {
|
||||
compound.setInteger("X_" + key, xCoord);
|
||||
compound.setInteger("Y_" + key, yCoord);
|
||||
compound.setInteger("Z_" + key, zCoord);
|
||||
try {
|
||||
if (beam != null) {
|
||||
compound.setShort("Flow_" + key, (short) beam.getFlow());
|
||||
}
|
||||
}
|
||||
catch (Throwable e) {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LinkedEnergyDevice readFromNBT(NBTTagCompound compound, String key)
|
||||
{
|
||||
xCoord = compound.getInteger("X_" + key);
|
||||
yCoord = compound.getInteger("Y_" + key);
|
||||
zCoord = compound.getInteger("Z_" + key);
|
||||
if (beam != null) beam.setFlow(compound.getShort("Flow" + key));
|
||||
return this;
|
||||
}
|
||||
public LinkedEnergyDevice readFromNBT(NBTTagCompound compound, String key) {
|
||||
xCoord = compound.getInteger("X_" + key);
|
||||
yCoord = compound.getInteger("Y_" + key);
|
||||
zCoord = compound.getInteger("Z_" + key);
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[x: "+xCoord + " y: " + yCoord + " z: " + zCoord + "]";
|
||||
}
|
||||
try {
|
||||
if (beam != null) {
|
||||
beam.setFlow(compound.getShort("Flow" + key));
|
||||
}
|
||||
}
|
||||
catch (Throwable e) {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isValid(World world)
|
||||
{
|
||||
return getEnergyTile(world) != null;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[x: " + xCoord + " y: " + yCoord + " z: " + zCoord + "]";
|
||||
}
|
||||
|
||||
public boolean isValid(World world) {
|
||||
return getEnergyTile(world) != null;
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -2,13 +2,16 @@ package com.brandon3055.draconicevolution.common.tileentities.energynet;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyField;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 10/02/2015.
|
||||
*/
|
||||
public class TileEnergyRelay extends TileRemoteEnergyBase {
|
||||
private ParticleEnergyField ring;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private ParticleEnergyField ring;
|
||||
|
||||
public TileEnergyRelay(){}
|
||||
|
||||
|
||||
+4
-1
@@ -5,6 +5,8 @@ import cofh.api.energy.IEnergyReceiver;
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyField;
|
||||
import com.brandon3055.draconicevolution.common.items.tools.Wrench;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -19,7 +21,8 @@ public class TileEnergyTransceiver extends TileRemoteEnergyBase{
|
||||
public int facing = 0;//0=up, 1=down, 3=north, 2=south, 4=east, 5=west
|
||||
private boolean input = false;
|
||||
public boolean transferBoost = false;
|
||||
private ParticleEnergyField particle;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private ParticleEnergyField particle;
|
||||
|
||||
public TileEnergyTransceiver() {}
|
||||
|
||||
|
||||
+3
-1
@@ -23,7 +23,9 @@ import java.util.List;
|
||||
* Created by Brandon on 10/02/2015.
|
||||
*/
|
||||
public class TileWirelessEnergyTransceiver extends TileRemoteEnergyBase {
|
||||
private ParticleEnergyField ring;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private ParticleEnergyField ring;
|
||||
|
||||
public List<LinkedReceiver> receiverList = new ArrayList<LinkedReceiver>();
|
||||
|
||||
|
||||
+15
-4
@@ -7,6 +7,8 @@ import com.brandon3055.draconicevolution.client.render.particle.ParticleReactorB
|
||||
import com.brandon3055.draconicevolution.common.blocks.multiblock.IReactorPart;
|
||||
import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper;
|
||||
import com.brandon3055.draconicevolution.integration.computers.IDEPeripheral;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
@@ -29,8 +31,11 @@ public class TileReactorEnergyInjector extends TileEntity implements IReactorPar
|
||||
public MultiblockHelper.TileLocation masterLocation = new MultiblockHelper.TileLocation();
|
||||
public boolean isValid = false;
|
||||
public int tick = 0;
|
||||
private ParticleReactorBeam beam = null;
|
||||
private TileReactorCore core = null;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private ParticleReactorBeam beam;
|
||||
|
||||
private TileReactorCore core = null;
|
||||
private int redstoneMode = 0;
|
||||
private int rs = -1;
|
||||
private int rsCach = -1;
|
||||
@@ -38,7 +43,7 @@ public class TileReactorEnergyInjector extends TileEntity implements IReactorPar
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (worldObj.isRemote && isValid){
|
||||
beam = DraconicEvolution.proxy.reactorBeam(this, beam, true);
|
||||
updateBeam();
|
||||
}
|
||||
|
||||
TileEntity master = masterLocation.getTileEntity(worldObj);
|
||||
@@ -48,7 +53,13 @@ public class TileReactorEnergyInjector extends TileEntity implements IReactorPar
|
||||
rsCach = rs;
|
||||
Utills.updateNeabourBlocks(worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void updateBeam(){
|
||||
beam = DraconicEvolution.proxy.reactorBeam(this, beam, true);
|
||||
}
|
||||
|
||||
public void onPlaced() {
|
||||
checkForMaster();
|
||||
|
||||
+215
-209
@@ -8,6 +8,8 @@ import com.brandon3055.draconicevolution.client.render.particle.ParticleReactorB
|
||||
import com.brandon3055.draconicevolution.common.blocks.multiblock.IReactorPart;
|
||||
import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper.TileLocation;
|
||||
import com.brandon3055.draconicevolution.integration.computers.IDEPeripheral;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
@@ -24,243 +26,247 @@ import java.util.Map;
|
||||
*/
|
||||
public class TileReactorStabilizer extends TileEntity implements IReactorPart, IEnergyProvider, IDEPeripheral {
|
||||
|
||||
public float coreRotation = 0F;
|
||||
public float ringRotation = 0F;
|
||||
public float coreSpeed = 1F;
|
||||
public float ringSpeed = 1F;
|
||||
public float modelIllumination = 0F;
|
||||
public int facingDirection = ForgeDirection.UP.ordinal();
|
||||
public TileLocation masterLocation = new TileLocation();
|
||||
public boolean isValid = false;
|
||||
public int tick = 0;
|
||||
private int redstoneMode = 0;
|
||||
private ParticleReactorBeam beam = null;
|
||||
private int rs = -1;
|
||||
private int rsCach = -1;
|
||||
public float coreRotation = 0F;
|
||||
public float ringRotation = 0F;
|
||||
public float coreSpeed = 1F;
|
||||
public float ringSpeed = 1F;
|
||||
public float modelIllumination = 0F;
|
||||
public int facingDirection = ForgeDirection.UP.ordinal();
|
||||
public TileLocation masterLocation = new TileLocation();
|
||||
public boolean isValid = false;
|
||||
public int tick = 0;
|
||||
private int redstoneMode = 0;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
tick++;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private ParticleReactorBeam beam;
|
||||
|
||||
if (worldObj.isRemote) {
|
||||
if (!(masterLocation.getTileEntity(worldObj) instanceof TileReactorCore)){
|
||||
coreSpeed = 0;
|
||||
ringSpeed = 0;
|
||||
modelIllumination = 0;
|
||||
return;
|
||||
}
|
||||
TileReactorCore core = (TileReactorCore)masterLocation.getTileEntity(worldObj);
|
||||
coreRotation += coreSpeed;
|
||||
ringRotation += ringSpeed;
|
||||
coreSpeed = 30F * core.renderSpeed;
|
||||
ringSpeed = 5F * core.renderSpeed;
|
||||
modelIllumination = core.renderSpeed;
|
||||
if (tick % 100 == 0) beam = null;
|
||||
if (isValid) beam = DraconicEvolution.proxy.reactorBeam(this, beam, true);
|
||||
return;
|
||||
}
|
||||
private int rs = -1;
|
||||
private int rsCach = -1;
|
||||
|
||||
TileEntity master = masterLocation.getTileEntity(worldObj);
|
||||
if (master instanceof TileReactorCore && ((TileReactorCore) master).reactorState == TileReactorCore.STATE_ONLINE){
|
||||
ForgeDirection back = ForgeDirection.getOrientation(facingDirection).getOpposite();
|
||||
TileEntity output = worldObj.getTileEntity(xCoord + back.offsetX, yCoord + back.offsetY, zCoord + back.offsetZ);
|
||||
if (output instanceof IEnergyReceiver)
|
||||
{
|
||||
int sent = ((IEnergyReceiver) output).receiveEnergy(back.getOpposite(), Math.min(((TileReactorCore) master).energySaturation, ((TileReactorCore) master).maxEnergySaturation / 100), false);
|
||||
((TileReactorCore) master).energySaturation -= sent;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
tick++;
|
||||
|
||||
if (!worldObj.isRemote && master instanceof TileReactorCore){
|
||||
rs = ((TileReactorCore) master).getComparatorOutput(redstoneMode);
|
||||
if (rs != rsCach){
|
||||
rsCach = rs;
|
||||
Utills.updateNeabourBlocks(worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
if (worldObj.isRemote) {
|
||||
updateBeam();
|
||||
}
|
||||
|
||||
}
|
||||
TileEntity master = masterLocation.getTileEntity(worldObj);
|
||||
if (master instanceof TileReactorCore && ((TileReactorCore) master).reactorState == TileReactorCore.STATE_ONLINE) {
|
||||
ForgeDirection back = ForgeDirection.getOrientation(facingDirection).getOpposite();
|
||||
TileEntity output = worldObj.getTileEntity(xCoord + back.offsetX, yCoord + back.offsetY, zCoord + back.offsetZ);
|
||||
if (output instanceof IEnergyReceiver) {
|
||||
int sent = ((IEnergyReceiver) output).receiveEnergy(back.getOpposite(), Math.min(((TileReactorCore) master).energySaturation, ((TileReactorCore) master).maxEnergySaturation / 100), false);
|
||||
((TileReactorCore) master).energySaturation -= sent;
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlaced() {
|
||||
if (!worldObj.isRemote && master instanceof TileReactorCore) {
|
||||
rs = ((TileReactorCore) master).getComparatorOutput(redstoneMode);
|
||||
if (rs != rsCach) {
|
||||
rsCach = rs;
|
||||
Utills.updateNeabourBlocks(worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
checkForMaster();
|
||||
}
|
||||
}
|
||||
|
||||
public void onBroken() {
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void updateBeam() {
|
||||
if (worldObj.isRemote) {
|
||||
if (!(masterLocation.getTileEntity(worldObj) instanceof TileReactorCore)) {
|
||||
coreSpeed = 0;
|
||||
ringSpeed = 0;
|
||||
modelIllumination = 0;
|
||||
return;
|
||||
}
|
||||
TileReactorCore core = (TileReactorCore) masterLocation.getTileEntity(worldObj);
|
||||
coreRotation += coreSpeed;
|
||||
ringRotation += ringSpeed;
|
||||
coreSpeed = 30F * core.renderSpeed;
|
||||
ringSpeed = 5F * core.renderSpeed;
|
||||
modelIllumination = core.renderSpeed;
|
||||
if (tick % 100 == 0) beam = null;
|
||||
if (isValid) beam = DraconicEvolution.proxy.reactorBeam(this, beam, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void onPlaced() {
|
||||
|
||||
public boolean checkForMaster(){
|
||||
for (int i = 1; i < 10; i++) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(facingDirection);
|
||||
int x = xCoord + (dir.offsetX*i);
|
||||
int y = yCoord + (dir.offsetY*i);
|
||||
int z = zCoord + (dir.offsetZ*i);
|
||||
if (!worldObj.isAirBlock(x, y, z))
|
||||
{
|
||||
TileEntity tile = worldObj.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileReactorCore && ((TileReactorCore) tile).stabilizerLocations.size() < 4) //todo add check reactor side to make sure this aligns with other stabilizers
|
||||
{
|
||||
((TileReactorCore) tile).stabilizerLocations.add(new TileLocation(xCoord, yCoord, zCoord));
|
||||
masterLocation.set(x, y, z);
|
||||
isValid = true;
|
||||
((TileReactorCore) tile).validateStructure();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
return true;
|
||||
}else {
|
||||
isValid = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
isValid = false;
|
||||
return false;
|
||||
}
|
||||
checkForMaster();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return isValid;
|
||||
}
|
||||
public void onBroken() {
|
||||
|
||||
@Override
|
||||
public String getRedstoneModeString() {
|
||||
return StatCollector.translateToLocal("msg.de.reactorRSMode." + redstoneMode + ".txt");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeRedstoneMode() {
|
||||
if (redstoneMode == IReactorPart.RMODE_FUEL_INV) redstoneMode = 0;
|
||||
else redstoneMode++;
|
||||
}
|
||||
public boolean checkForMaster() {
|
||||
for (int i = 1; i < 10; i++) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(facingDirection);
|
||||
int x = xCoord + (dir.offsetX * i);
|
||||
int y = yCoord + (dir.offsetY * i);
|
||||
int z = zCoord + (dir.offsetZ * i);
|
||||
if (!worldObj.isAirBlock(x, y, z)) {
|
||||
TileEntity tile = worldObj.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileReactorCore && ((TileReactorCore) tile).stabilizerLocations.size() < 4) //todo add check reactor side to make sure this aligns with other stabilizers
|
||||
{
|
||||
((TileReactorCore) tile).stabilizerLocations.add(new TileLocation(xCoord, yCoord, zCoord));
|
||||
masterLocation.set(x, y, z);
|
||||
isValid = true;
|
||||
((TileReactorCore) tile).validateStructure();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
return true;
|
||||
} else {
|
||||
isValid = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
isValid = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneMode() {
|
||||
return redstoneMode;
|
||||
}
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return isValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutDown(){
|
||||
isValid = false;
|
||||
masterLocation = new TileLocation();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
@Override
|
||||
public String getRedstoneModeString() {
|
||||
return StatCollector.translateToLocal("msg.de.reactorRSMode." + redstoneMode + ".txt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
masterLocation.writeToNBT(compound, "Master");
|
||||
compound.setInteger("Facing", facingDirection);
|
||||
compound.setBoolean("IsValid", isValid);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, compound);
|
||||
}
|
||||
@Override
|
||||
public void changeRedstoneMode() {
|
||||
if (redstoneMode == IReactorPart.RMODE_FUEL_INV) redstoneMode = 0;
|
||||
else redstoneMode++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
NBTTagCompound compound = pkt.func_148857_g();
|
||||
masterLocation.readFromNBT(compound, "Master");
|
||||
facingDirection = compound.getInteger("Facing");
|
||||
isValid = compound.getBoolean("IsValid");
|
||||
super.onDataPacket(net, pkt);
|
||||
}
|
||||
@Override
|
||||
public int getRedstoneMode() {
|
||||
return redstoneMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
super.writeToNBT(compound);
|
||||
masterLocation.writeToNBT(compound, "Master");
|
||||
compound.setInteger("Facing", facingDirection);
|
||||
compound.setBoolean("IsValid", isValid);
|
||||
compound.setInteger("RedstoneMode", redstoneMode);
|
||||
}
|
||||
@Override
|
||||
public void shutDown() {
|
||||
isValid = false;
|
||||
masterLocation = new TileLocation();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
super.readFromNBT(compound);
|
||||
masterLocation.readFromNBT(compound, "Master");
|
||||
facingDirection = compound.getInteger("Facing");
|
||||
isValid = compound.getBoolean("IsValid");
|
||||
redstoneMode = compound.getInteger("RedstoneMode");
|
||||
}
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
masterLocation.writeToNBT(compound, "Master");
|
||||
compound.setInteger("Facing", facingDirection);
|
||||
compound.setBoolean("IsValid", isValid);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileLocation getMaster() {
|
||||
return masterLocation;
|
||||
}
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
NBTTagCompound compound = pkt.func_148857_g();
|
||||
masterLocation.readFromNBT(compound, "Master");
|
||||
facingDirection = compound.getInteger("Facing");
|
||||
isValid = compound.getBoolean("IsValid");
|
||||
super.onDataPacket(net, pkt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
super.writeToNBT(compound);
|
||||
masterLocation.writeToNBT(compound, "Master");
|
||||
compound.setInteger("Facing", facingDirection);
|
||||
compound.setBoolean("IsValid", isValid);
|
||||
compound.setInteger("RedstoneMode", redstoneMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
super.readFromNBT(compound);
|
||||
masterLocation.readFromNBT(compound, "Master");
|
||||
facingDirection = compound.getInteger("Facing");
|
||||
isValid = compound.getBoolean("IsValid");
|
||||
redstoneMode = compound.getInteger("RedstoneMode");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public TileLocation getMaster() {
|
||||
return masterLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
return from == ForgeDirection.getOrientation(facingDirection).getOpposite();
|
||||
}
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 40960.0D;
|
||||
}
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "draconic_reactor";
|
||||
}
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getMethodNames() {
|
||||
return new String[] {"getReactorInfo", "chargeReactor", "activateReactor", "stopReactor"};
|
||||
}
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
return from == ForgeDirection.getOrientation(facingDirection).getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod(String method, Object... args) {
|
||||
if (!(getMaster().getTileEntity(worldObj) instanceof TileReactorCore)) return null;
|
||||
TileReactorCore reactor = (TileReactorCore)getMaster().getTileEntity(worldObj);
|
||||
@Override
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 40960.0D;
|
||||
}
|
||||
|
||||
if (args.length > 0) throw new IllegalArgumentException("This method dose not accept arguments");
|
||||
@Override
|
||||
public String getName() {
|
||||
return "draconic_reactor";
|
||||
}
|
||||
|
||||
if (method.equals("getReactorInfo")){
|
||||
Map<Object, Object> map = new HashMap<Object, Object>();
|
||||
map.put("temperature", Utills.round(reactor.reactionTemperature, 100));
|
||||
map.put("fieldStrength", Utills.round(reactor.fieldCharge, 100));
|
||||
map.put("maxFieldStrength", Utills.round(reactor.maxFieldCharge, 100));
|
||||
map.put("energySaturation", reactor.energySaturation);
|
||||
map.put("maxEnergySaturation", reactor.maxEnergySaturation);
|
||||
map.put("fuelConversion", Utills.round((double)reactor.convertedFuel + reactor.conversionUnit, 1000));
|
||||
map.put("maxFuelConversion", reactor.reactorFuel + reactor.convertedFuel);
|
||||
map.put("generationRate", (int)reactor.generationRate);
|
||||
map.put("fieldDrainRate", reactor.fieldDrain);
|
||||
map.put("fuelConversionRate", (int)Math.round(reactor.fuelUseRate * 1000000D));
|
||||
map.put("status", reactor.reactorState == 0 ? "offline" : reactor.reactorState == 1 && !reactor.canStart() ? "charging" : reactor.reactorState == 1 && reactor.canStart() ? "charged" : reactor.reactorState == 2 ? "online" : reactor.reactorState == 3 ? "stopping" : "invalid");
|
||||
return new Object[]{ map };
|
||||
}
|
||||
else if (method.equals("chargeReactor")){
|
||||
if (reactor.canCharge()) {
|
||||
reactor.reactorState = TileReactorCore.STATE_START;
|
||||
return new Object[] { true };
|
||||
} else return new Object[] { false };
|
||||
}
|
||||
else if (method.equals("activateReactor")){
|
||||
if (reactor.canStart()) {
|
||||
reactor.reactorState = TileReactorCore.STATE_ONLINE;
|
||||
return new Object[] { true };
|
||||
} else return new Object[] { false };
|
||||
}
|
||||
else if (method.equals("stopReactor")){
|
||||
if (reactor.canStop()) {
|
||||
reactor.reactorState = TileReactorCore.STATE_STOP;
|
||||
return new Object[] { true };
|
||||
} else return new Object[] { false };
|
||||
}
|
||||
return new Object[] {};
|
||||
}
|
||||
@Override
|
||||
public String[] getMethodNames() {
|
||||
return new String[]{"getReactorInfo", "chargeReactor", "activateReactor", "stopReactor"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod(String method, Object... args) {
|
||||
if (!(getMaster().getTileEntity(worldObj) instanceof TileReactorCore)) return null;
|
||||
TileReactorCore reactor = (TileReactorCore) getMaster().getTileEntity(worldObj);
|
||||
|
||||
if (args.length > 0) throw new IllegalArgumentException("This method dose not accept arguments");
|
||||
|
||||
if (method.equals("getReactorInfo")) {
|
||||
Map<Object, Object> map = new HashMap<Object, Object>();
|
||||
map.put("temperature", Utills.round(reactor.reactionTemperature, 100));
|
||||
map.put("fieldStrength", Utills.round(reactor.fieldCharge, 100));
|
||||
map.put("maxFieldStrength", Utills.round(reactor.maxFieldCharge, 100));
|
||||
map.put("energySaturation", reactor.energySaturation);
|
||||
map.put("maxEnergySaturation", reactor.maxEnergySaturation);
|
||||
map.put("fuelConversion", Utills.round((double) reactor.convertedFuel + reactor.conversionUnit, 1000));
|
||||
map.put("maxFuelConversion", reactor.reactorFuel + reactor.convertedFuel);
|
||||
map.put("generationRate", (int) reactor.generationRate);
|
||||
map.put("fieldDrainRate", reactor.fieldDrain);
|
||||
map.put("fuelConversionRate", (int) Math.round(reactor.fuelUseRate * 1000000D));
|
||||
map.put("status", reactor.reactorState == 0 ? "offline" : reactor.reactorState == 1 && !reactor.canStart() ? "charging" : reactor.reactorState == 1 && reactor.canStart() ? "charged" : reactor.reactorState == 2 ? "online" : reactor.reactorState == 3 ? "stopping" : "invalid");
|
||||
return new Object[]{map};
|
||||
} else if (method.equals("chargeReactor")) {
|
||||
if (reactor.canCharge()) {
|
||||
reactor.reactorState = TileReactorCore.STATE_START;
|
||||
return new Object[]{true};
|
||||
} else return new Object[]{false};
|
||||
} else if (method.equals("activateReactor")) {
|
||||
if (reactor.canStart()) {
|
||||
reactor.reactorState = TileReactorCore.STATE_ONLINE;
|
||||
return new Object[]{true};
|
||||
} else return new Object[]{false};
|
||||
} else if (method.equals("stopReactor")) {
|
||||
if (reactor.canStop()) {
|
||||
reactor.reactorState = TileReactorCore.STATE_STOP;
|
||||
return new Object[]{true};
|
||||
} else return new Object[]{false};
|
||||
}
|
||||
return new Object[]{};
|
||||
}
|
||||
}
|
||||
+173
-147
@@ -14,180 +14,206 @@ import java.util.List;
|
||||
*/
|
||||
public interface IUpgradableItem {
|
||||
|
||||
/**@return a list of upgrades for this item.*/
|
||||
public List<EnumUpgrade> getUpgrades(ItemStack itemstack);
|
||||
/**
|
||||
* @return a list of upgrades for this item.
|
||||
*/
|
||||
public List<EnumUpgrade> getUpgrades(ItemStack itemstack);
|
||||
|
||||
/**@return the maximum number of upgrades for this item*/
|
||||
public int getUpgradeCap(ItemStack itemstack);
|
||||
/**
|
||||
* @return the maximum number of upgrades for this item
|
||||
*/
|
||||
public int getUpgradeCap(ItemStack itemstack);
|
||||
|
||||
/**@return the max upgrade tier allowed for this item
|
||||
* 0 = Draconic Core
|
||||
* 1 = Wyvern Core
|
||||
* 2 = Awakened Core
|
||||
* 3 = Chaotic Core*/
|
||||
public int getMaxTier(ItemStack itemstack);
|
||||
/**
|
||||
* @return the max upgrade tier allowed for this item
|
||||
* 0 = Draconic Core
|
||||
* 1 = Wyvern Core
|
||||
* 2 = Awakened Core
|
||||
* 3 = Chaotic Core
|
||||
*/
|
||||
public int getMaxTier(ItemStack itemstack);
|
||||
|
||||
public int getMaxUpgradePoints(int upgradeIndex);
|
||||
public int getMaxUpgradePoints(int upgradeIndex);
|
||||
|
||||
public int getBaseUpgradePoints(int upgradeIndex);
|
||||
public int getBaseUpgradePoints(int upgradeIndex);
|
||||
|
||||
public List<String> getUpgradeStats(ItemStack itemstack);
|
||||
public List<String> getUpgradeStats(ItemStack itemstack);
|
||||
|
||||
public static enum EnumUpgrade {
|
||||
RF_CAPACITY (0, 1, "RFCapacity"){
|
||||
@Override
|
||||
public void onRemovedFromItem(ItemStack itemStack) {
|
||||
if (itemStack != null && itemStack.getItem() instanceof IEnergyContainerItem){
|
||||
IEnergyContainerItem item = (IEnergyContainerItem)itemStack.getItem();
|
||||
for (int i = 0; i < 500 && item.getEnergyStored(itemStack) > item.getMaxEnergyStored(itemStack); i++){
|
||||
item.extractEnergy(itemStack, item.getEnergyStored(itemStack)-item.getMaxEnergyStored(itemStack), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
DIG_SPEED (1, 1, "DigSpeed"),
|
||||
DIG_AOE (2, 4, "DigAOE"){
|
||||
@Override
|
||||
public void onRemovedFromItem(ItemStack itemStack) {
|
||||
int profile = ItemNBTHelper.getInteger(itemStack, "ConfigProfile", 0);
|
||||
public static enum EnumUpgrade {
|
||||
RF_CAPACITY(0, 1, "RFCapacity") {
|
||||
@Override
|
||||
public void onRemovedFromItem(ItemStack itemStack) {
|
||||
if (itemStack != null && itemStack.getItem() instanceof IEnergyContainerItem) {
|
||||
IEnergyContainerItem item = (IEnergyContainerItem) itemStack.getItem();
|
||||
for (int i = 0; i < 500 && item.getEnergyStored(itemStack) > item.getMaxEnergyStored(itemStack); i++) {
|
||||
item.extractEnergy(itemStack, item.getEnergyStored(itemStack) - item.getMaxEnergyStored(itemStack), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
DIG_SPEED(1, 1, "DigSpeed"),
|
||||
DIG_AOE(2, 4, "DigAOE") {
|
||||
@Override
|
||||
public void onRemovedFromItem(ItemStack itemStack) {
|
||||
int profile = ItemNBTHelper.getInteger(itemStack, "ConfigProfile", 0);
|
||||
|
||||
for (int i = 0; i < 5; i++){
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", i);
|
||||
if (IConfigurableItem.ProfileHelper.getInteger(itemStack, References.DIG_AOE, 0) > getUpgradePoints(itemStack)) IConfigurableItem.ProfileHelper.setInteger(itemStack, References.DIG_AOE, getUpgradePoints(itemStack));
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", i);
|
||||
if (IConfigurableItem.ProfileHelper.getInteger(itemStack, References.DIG_AOE, 0) > getUpgradePoints(itemStack))
|
||||
IConfigurableItem.ProfileHelper.setInteger(itemStack, References.DIG_AOE, getUpgradePoints(itemStack));
|
||||
}
|
||||
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", profile);
|
||||
}
|
||||
},
|
||||
DIG_DEPTH (3, 2, "DigDepth"){
|
||||
@Override
|
||||
public void onRemovedFromItem(ItemStack itemStack) {
|
||||
int profile = ItemNBTHelper.getInteger(itemStack, "ConfigProfile", 0);
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", profile);
|
||||
}
|
||||
},
|
||||
DIG_DEPTH(3, 2, "DigDepth") {
|
||||
@Override
|
||||
public void onRemovedFromItem(ItemStack itemStack) {
|
||||
int profile = ItemNBTHelper.getInteger(itemStack, "ConfigProfile", 0);
|
||||
|
||||
for (int i = 0; i < 5; i++){
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", i);
|
||||
if (IConfigurableItem.ProfileHelper.getInteger(itemStack, References.DIG_DEPTH, 0) > getUpgradePoints(itemStack)) IConfigurableItem.ProfileHelper.setInteger(itemStack, References.DIG_DEPTH, getUpgradePoints(itemStack));
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", i);
|
||||
if (IConfigurableItem.ProfileHelper.getInteger(itemStack, References.DIG_DEPTH, 0) > getUpgradePoints(itemStack))
|
||||
IConfigurableItem.ProfileHelper.setInteger(itemStack, References.DIG_DEPTH, getUpgradePoints(itemStack));
|
||||
}
|
||||
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", profile);
|
||||
}
|
||||
},
|
||||
ATTACK_DAMAGE (4, 1, "AttackDamage"),
|
||||
ATTACK_AOE (5, 2, "AttackAOE"){
|
||||
@Override
|
||||
public void onRemovedFromItem(ItemStack itemStack) {
|
||||
int profile = ItemNBTHelper.getInteger(itemStack, "ConfigProfile", 0);
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", profile);
|
||||
}
|
||||
},
|
||||
ATTACK_DAMAGE(4, 1, "AttackDamage"),
|
||||
ATTACK_AOE(5, 2, "AttackAOE") {
|
||||
@Override
|
||||
public void onRemovedFromItem(ItemStack itemStack) {
|
||||
int profile = ItemNBTHelper.getInteger(itemStack, "ConfigProfile", 0);
|
||||
|
||||
for (int i = 0; i < 5; i++){
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", i);
|
||||
if (IConfigurableItem.ProfileHelper.getInteger(itemStack, References.ATTACK_AOE, 0) > getUpgradePoints(itemStack)) IConfigurableItem.ProfileHelper.setInteger(itemStack, References.ATTACK_AOE, getUpgradePoints(itemStack));
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", i);
|
||||
if (IConfigurableItem.ProfileHelper.getInteger(itemStack, References.ATTACK_AOE, 0) > getUpgradePoints(itemStack))
|
||||
IConfigurableItem.ProfileHelper.setInteger(itemStack, References.ATTACK_AOE, getUpgradePoints(itemStack));
|
||||
}
|
||||
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", profile);
|
||||
}
|
||||
},
|
||||
ARROW_DAMAGE (6, 1, "ArrowDamage"){
|
||||
@Override
|
||||
public void onRemovedFromItem(ItemStack itemStack) {
|
||||
int profile = ItemNBTHelper.getInteger(itemStack, "ConfigProfile", 0);
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", profile);
|
||||
}
|
||||
},
|
||||
ARROW_DAMAGE(6, 1, "ArrowDamage") {
|
||||
@Override
|
||||
public void onRemovedFromItem(ItemStack itemStack) {
|
||||
int profile = ItemNBTHelper.getInteger(itemStack, "ConfigProfile", 0);
|
||||
|
||||
for (int i = 0; i < 5; i++){
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", i);
|
||||
if (IConfigurableItem.ProfileHelper.getInteger(itemStack, "BowArrowDamage", 0) > getUpgradePoints(itemStack)) IConfigurableItem.ProfileHelper.setInteger(itemStack, "BowArrowDamage", getUpgradePoints(itemStack));
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", i);
|
||||
if (IConfigurableItem.ProfileHelper.getInteger(itemStack, "BowArrowDamage", 0) > getUpgradePoints(itemStack))
|
||||
IConfigurableItem.ProfileHelper.setInteger(itemStack, "BowArrowDamage", getUpgradePoints(itemStack));
|
||||
}
|
||||
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", profile);
|
||||
}
|
||||
},
|
||||
DRAW_SPEED (7, 2, "DrawSpeed"),
|
||||
ARROW_SPEED (8, 2, "ArrowSpeed"){
|
||||
@Override
|
||||
public void onRemovedFromItem(ItemStack itemStack) {
|
||||
int profile = ItemNBTHelper.getInteger(itemStack, "ConfigProfile", 0);
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", profile);
|
||||
}
|
||||
},
|
||||
DRAW_SPEED(7, 2, "DrawSpeed"),
|
||||
ARROW_SPEED(8, 2, "ArrowSpeed") {
|
||||
@Override
|
||||
public void onRemovedFromItem(ItemStack itemStack) {
|
||||
int profile = ItemNBTHelper.getInteger(itemStack, "ConfigProfile", 0);
|
||||
|
||||
for (int i = 0; i < 5; i++){
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", i);
|
||||
if (IConfigurableItem.ProfileHelper.getInteger(itemStack, "BowArrowSpeedModifier", 0) > getUpgradePoints(itemStack)) IConfigurableItem.ProfileHelper.setInteger(itemStack, "BowArrowSpeedModifier", getUpgradePoints(itemStack));
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", i);
|
||||
if (IConfigurableItem.ProfileHelper.getInteger(itemStack, "BowArrowSpeedModifier", 0) > getUpgradePoints(itemStack))
|
||||
IConfigurableItem.ProfileHelper.setInteger(itemStack, "BowArrowSpeedModifier", getUpgradePoints(itemStack));
|
||||
}
|
||||
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", profile);
|
||||
}
|
||||
},
|
||||
SHIELD_CAPACITY (9, 1, "ShieldCapacity"),
|
||||
SHIELD_RECOVERY (10, 1, "ShieldRecovery"),
|
||||
MOVE_SPEED (11, 1, "MoveSpeed"),
|
||||
JUMP_BOOST (12, 1, "JumpBoost");
|
||||
ItemNBTHelper.setInteger(itemStack, "ConfigProfile", profile);
|
||||
}
|
||||
},
|
||||
SHIELD_CAPACITY(9, 1, "ShieldCapacity"),
|
||||
SHIELD_RECOVERY(10, 1, "ShieldRecovery"),
|
||||
MOVE_SPEED(11, 1, "MoveSpeed"),
|
||||
JUMP_BOOST(12, 1, "JumpBoost");
|
||||
|
||||
public int index;
|
||||
/**How many core points dose it take to add 1 upgrade point*/
|
||||
public int pointConversion;
|
||||
public String name;
|
||||
private final String COMPOUND_NAME = "Upgrades";
|
||||
public int index;
|
||||
/**
|
||||
* How many core points dose it take to add 1 upgrade point
|
||||
*/
|
||||
public int pointConversion;
|
||||
public String name;
|
||||
private final String COMPOUND_NAME = "Upgrades";
|
||||
|
||||
private EnumUpgrade(int index, int pointConversion, String name) {
|
||||
this.index = index;
|
||||
this.pointConversion = pointConversion;
|
||||
this.name = name;
|
||||
}
|
||||
private EnumUpgrade(int index, int pointConversion, String name) {
|
||||
this.index = index;
|
||||
this.pointConversion = pointConversion;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**Get the number of cores applied to this upgrade
|
||||
* @return an int[4] containing the number of cores that have been applied
|
||||
* in order from index 0 which is the number od draconic cores to index 3 which is the number of chaotic cores
|
||||
* with wyvern and awakened in between*/
|
||||
public int[] getCoresApplied(ItemStack stack){
|
||||
if (stack == null) return new int[] {0, 0, 0, 0};
|
||||
NBTTagCompound compound = ItemNBTHelper.getCompound(stack);
|
||||
if (!compound.hasKey(COMPOUND_NAME)) return new int[] {0, 0, 0, 0};
|
||||
NBTTagCompound upgrades = compound.getCompoundTag(COMPOUND_NAME);
|
||||
if (upgrades.hasKey(name) && upgrades.getIntArray(name).length == 4) return upgrades.getIntArray(name);
|
||||
return new int[] {0, 0, 0, 0};
|
||||
}
|
||||
/**
|
||||
* Get the number of cores applied to this upgrade
|
||||
*
|
||||
* @return an int[4] containing the number of cores that have been applied
|
||||
* in order from index 0 which is the number od draconic cores to index 3 which is the number of chaotic cores
|
||||
* with wyvern and awakened in between
|
||||
*/
|
||||
public int[] getCoresApplied(ItemStack stack) {
|
||||
if (stack == null) return new int[]{0, 0, 0, 0};
|
||||
NBTTagCompound compound = ItemNBTHelper.getCompound(stack);
|
||||
if (!compound.hasKey(COMPOUND_NAME)) return new int[]{0, 0, 0, 0};
|
||||
NBTTagCompound upgrades = compound.getCompoundTag(COMPOUND_NAME);
|
||||
if (upgrades.hasKey(name) && upgrades.getIntArray(name).length == 4) return upgrades.getIntArray(name);
|
||||
return new int[]{0, 0, 0, 0};
|
||||
}
|
||||
|
||||
/**Sets the number of each core type applied
|
||||
* takes an ItemStack and an int[4]*/
|
||||
public void setCoresApplied(ItemStack stack, int[] cores){
|
||||
if (cores.length != 4){
|
||||
LogHelper.error("[EnumUpgrade] Error applying upgrades to stack.");
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Sets the number of each core type applied
|
||||
* takes an ItemStack and an int[4]
|
||||
*/
|
||||
public void setCoresApplied(ItemStack stack, int[] cores) {
|
||||
if (cores.length != 4) {
|
||||
LogHelper.error("[EnumUpgrade] Error applying upgrades to stack.");
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagCompound compound = ItemNBTHelper.getCompound(stack);
|
||||
NBTTagCompound upgrades;
|
||||
if (compound.hasKey(COMPOUND_NAME)) upgrades = compound.getCompoundTag(COMPOUND_NAME);
|
||||
else upgrades = new NBTTagCompound();
|
||||
upgrades.setIntArray(name, cores);
|
||||
compound.setTag(COMPOUND_NAME, upgrades);
|
||||
}
|
||||
NBTTagCompound compound = ItemNBTHelper.getCompound(stack);
|
||||
NBTTagCompound upgrades;
|
||||
if (compound.hasKey(COMPOUND_NAME)) upgrades = compound.getCompoundTag(COMPOUND_NAME);
|
||||
else upgrades = new NBTTagCompound();
|
||||
upgrades.setIntArray(name, cores);
|
||||
compound.setTag(COMPOUND_NAME, upgrades);
|
||||
}
|
||||
|
||||
public String getLocalizedName() { return StatCollector.translateToLocal("gui.de."+name+".txt"); }
|
||||
public String getLocalizedName() {
|
||||
return StatCollector.translateToLocal("gui.de." + name + ".txt");
|
||||
}
|
||||
|
||||
public static EnumUpgrade getUpgradeByIndex(int index) {
|
||||
for (EnumUpgrade upgrade : EnumUpgrade.values()) {
|
||||
if (upgrade.index == index) return upgrade;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static EnumUpgrade getUpgradeByIndex(int index) {
|
||||
for (EnumUpgrade upgrade : EnumUpgrade.values()) {
|
||||
if (upgrade.index == index) return upgrade;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**Returns the combined upgrade points from all cores applied to this upgrade */
|
||||
public int getUpgradePoints(ItemStack itemStack){
|
||||
int[] applied = getCoresApplied(itemStack);
|
||||
int totalPoints = applied[0] + (applied[1] * 2) + (applied[2] * 4) + (applied[3] * 8);
|
||||
if (itemStack != null && itemStack.getItem() instanceof IUpgradableItem){
|
||||
int points = ((IUpgradableItem)itemStack.getItem()).getBaseUpgradePoints(index) + (totalPoints / pointConversion);
|
||||
return Math.min(points, ((IUpgradableItem)itemStack.getItem()).getMaxUpgradePoints(index));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Returns the combined upgrade points from all cores applied to this upgrade
|
||||
*/
|
||||
public int getUpgradePoints(ItemStack itemStack) {
|
||||
int[] applied = getCoresApplied(itemStack);
|
||||
int totalPoints = applied[0] + (applied[1] * 2) + (applied[2] * 4) + (applied[3] * 8);
|
||||
if (itemStack != null && itemStack.getItem() instanceof IUpgradableItem) {
|
||||
int points = ((IUpgradableItem) itemStack.getItem()).getBaseUpgradePoints(index) + (totalPoints / pointConversion);
|
||||
return Math.min(points, ((IUpgradableItem) itemStack.getItem()).getMaxUpgradePoints(index));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**Called when this upgrade is applied to an item*/
|
||||
public void onAppliedToItem(ItemStack itemStack){
|
||||
/**
|
||||
* Called when this upgrade is applied to an item
|
||||
*/
|
||||
public void onAppliedToItem(ItemStack itemStack) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**Called when this upgrade is removed from an item*/
|
||||
public void onRemovedFromItem(ItemStack itemStack){
|
||||
/**
|
||||
* Called when this upgrade is removed from an item
|
||||
*/
|
||||
public void onRemovedFromItem(ItemStack itemStack) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,7 +10,7 @@ import li.cil.oc.api.prefab.ManagedEnvironment;
|
||||
/**
|
||||
* Created by brandon3055 on 22/9/2015.
|
||||
*/
|
||||
public class DEManagedPeripheral extends ManagedEnvironment implements ManagedPeripheral, NamedBlock{
|
||||
public class DEManagedPeripheral extends ManagedEnvironment implements ManagedPeripheral, NamedBlock {
|
||||
private IDEPeripheral peripheral;
|
||||
|
||||
public DEManagedPeripheral(IDEPeripheral peripheral){
|
||||
|
||||
Reference in new issue
Block a user