mirror of
https://github.com/GTNewHorizons/Draconic-Evolution.git
synced 2026-11-24 22:14:51 +00:00
04/03/15
This commit is contained in:
1 parent
678ed7dd2d
commit
288b6f7cba
35 files changed
+485
-138
No files matched your search
@@ -6,6 +6,6 @@ public class CoFHAPIProps {
|
||||
|
||||
}
|
||||
|
||||
public static final String VERSION = "1.7.10R1.0.0";
|
||||
public static final String VERSION = "1.7.10R1.0.2";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public class EnergyStorage implements IEnergyStorage {
|
||||
|
||||
protected int energy;
|
||||
protected int capacity;
|
||||
protected int maxReceive;
|
||||
protected int maxExtract;
|
||||
|
||||
public EnergyStorage(int capacity) {
|
||||
|
||||
this(capacity, capacity, capacity);
|
||||
}
|
||||
|
||||
public EnergyStorage(int capacity, int maxTransfer) {
|
||||
|
||||
this(capacity, maxTransfer, maxTransfer);
|
||||
}
|
||||
|
||||
public EnergyStorage(int capacity, int maxReceive, int maxExtract) {
|
||||
|
||||
this.capacity = capacity;
|
||||
this.maxReceive = maxReceive;
|
||||
this.maxExtract = maxExtract;
|
||||
}
|
||||
|
||||
public EnergyStorage readFromNBT(NBTTagCompound nbt) {
|
||||
|
||||
this.energy = nbt.getInteger("Energy");
|
||||
|
||||
if (energy > capacity) {
|
||||
energy = capacity;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
|
||||
if (energy < 0) {
|
||||
energy = 0;
|
||||
}
|
||||
nbt.setInteger("Energy", energy);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public void setCapacity(int capacity) {
|
||||
|
||||
this.capacity = capacity;
|
||||
|
||||
if (energy > capacity) {
|
||||
energy = capacity;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxTransfer(int maxTransfer) {
|
||||
|
||||
setMaxReceive(maxTransfer);
|
||||
setMaxExtract(maxTransfer);
|
||||
}
|
||||
|
||||
public void setMaxReceive(int maxReceive) {
|
||||
|
||||
this.maxReceive = maxReceive;
|
||||
}
|
||||
|
||||
public void setMaxExtract(int maxExtract) {
|
||||
|
||||
this.maxExtract = maxExtract;
|
||||
}
|
||||
|
||||
public int getMaxReceive() {
|
||||
|
||||
return maxReceive;
|
||||
}
|
||||
|
||||
public int getMaxExtract() {
|
||||
|
||||
return maxExtract;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is included to allow for server -> client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers
|
||||
* are guaranteed to have it.
|
||||
*
|
||||
* @param energy
|
||||
*/
|
||||
public void setEnergyStored(int energy) {
|
||||
|
||||
this.energy = energy;
|
||||
|
||||
if (this.energy > capacity) {
|
||||
this.energy = capacity;
|
||||
} else if (this.energy < 0) {
|
||||
this.energy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this
|
||||
* externally, as not all IEnergyHandlers are guaranteed to have it.
|
||||
*
|
||||
* @param energy
|
||||
*/
|
||||
public void modifyEnergyStored(int energy) {
|
||||
|
||||
this.energy += energy;
|
||||
|
||||
if (this.energy > capacity) {
|
||||
this.energy = capacity;
|
||||
} else if (this.energy < 0) {
|
||||
this.energy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* IEnergyStorage */
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate) {
|
||||
|
||||
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
|
||||
|
||||
if (!simulate) {
|
||||
energy += energyReceived;
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate) {
|
||||
|
||||
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
|
||||
|
||||
if (!simulate) {
|
||||
energy -= energyExtracted;
|
||||
}
|
||||
return energyExtracted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored() {
|
||||
|
||||
return energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored() {
|
||||
|
||||
return capacity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
/**
|
||||
* Implement this interface on TileEntities which should connect to energy transportation blocks. This is intended for blocks which generate energy but do not
|
||||
* accept it; otherwise just use IEnergyHandler.
|
||||
*
|
||||
* <p>
|
||||
* Note that {@link IEnergyHandler} is an extension of this.
|
||||
*
|
||||
* @author King Lemming
|
||||
|
||||
@@ -4,7 +4,7 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Implement this interface on Item classes that support external manipulation of their internal energy storages.
|
||||
*
|
||||
* <p>
|
||||
* A reference implementation is provided {@link ItemEnergyContainer}.
|
||||
*
|
||||
* @author King Lemming
|
||||
|
||||
@@ -4,17 +4,19 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
|
||||
*
|
||||
* <p>
|
||||
* A reference implementation is provided {@link TileEnergyHandler}.
|
||||
*
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface IEnergyHandler extends IEnergyConnection {
|
||||
public interface IEnergyHandler extends IEnergyProvider, IEnergyReceiver {
|
||||
|
||||
// merely a convenience interface (remove these methods in 1.8; provided here for back-compat via compiler doing things)
|
||||
|
||||
/**
|
||||
* Add energy to an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
|
||||
*
|
||||
* Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver.
|
||||
*
|
||||
* @param from
|
||||
* Orientation the energy is received from.
|
||||
* @param maxReceive
|
||||
@@ -23,11 +25,12 @@ public interface IEnergyHandler extends IEnergyConnection {
|
||||
* If TRUE, the charge will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) received.
|
||||
*/
|
||||
@Override
|
||||
int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate);
|
||||
|
||||
/**
|
||||
* Remove energy from an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
|
||||
*
|
||||
* Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider.
|
||||
*
|
||||
* @param from
|
||||
* Orientation the energy is extracted from.
|
||||
* @param maxExtract
|
||||
@@ -36,16 +39,20 @@ public interface IEnergyHandler extends IEnergyConnection {
|
||||
* If TRUE, the extraction will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted.
|
||||
*/
|
||||
@Override
|
||||
int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the amount of energy currently stored.
|
||||
*/
|
||||
@Override
|
||||
int getEnergyStored(ForgeDirection from);
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of energy that can be stored.
|
||||
*/
|
||||
@Override
|
||||
int getMaxEnergyStored(ForgeDirection from);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which should provide energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
|
||||
* <p>
|
||||
* A reference implementation is provided {@link TileEnergyHandler}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyProvider extends IEnergyConnection {
|
||||
|
||||
/**
|
||||
* Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider.
|
||||
*
|
||||
* @param from
|
||||
* Orientation the energy is extracted from.
|
||||
* @param maxExtract
|
||||
* Maximum amount of energy to extract.
|
||||
* @param simulate
|
||||
* If TRUE, the extraction 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 the amount of energy currently stored.
|
||||
*/
|
||||
int getEnergyStored(ForgeDirection from);
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of energy that can be stored.
|
||||
*/
|
||||
int getMaxEnergyStored(ForgeDirection from);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which should receive energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
|
||||
* <p>
|
||||
* A reference implementation is provided {@link TileEnergyHandler}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyReceiver extends IEnergyConnection {
|
||||
|
||||
/**
|
||||
* Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver.
|
||||
*
|
||||
* @param from
|
||||
* Orientation the energy is received from.
|
||||
* @param maxReceive
|
||||
* Maximum amount of energy to receive.
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
/**
|
||||
* An energy internalGenBuffer is the unit of interaction with EnergyHelper inventories.
|
||||
*
|
||||
* A reference implementation can be found at {@link com.brandon3055.draconicevolution.common.utills.EnergyStorage}.
|
||||
* An energy storage is the unit of interaction with Energy inventories.<br>
|
||||
* This is not to be implemented on TileEntities. This is for internal use only.
|
||||
* <p>
|
||||
* A reference implementation can be found at {@link EnergyStorage}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
@@ -11,24 +12,24 @@ package cofh.api.energy;
|
||||
public interface IEnergyStorage {
|
||||
|
||||
/**
|
||||
* Adds energy to the internalGenBuffer. Returns quantity of energy that was accepted.
|
||||
* Adds energy to the storage. Returns quantity of energy that was accepted.
|
||||
*
|
||||
* @param maxReceive
|
||||
* Maximum amount of energy to be inserted.
|
||||
* @param simulate
|
||||
* If TRUE, the insertion will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) accepted by the internalGenBuffer.
|
||||
* @return Amount of energy that was (or would have been, if simulated) accepted by the storage.
|
||||
*/
|
||||
int receiveEnergy(int maxReceive, boolean simulate);
|
||||
|
||||
/**
|
||||
* Removes energy from the internalGenBuffer. Returns quantity of energy that was removed.
|
||||
* Removes energy from the storage. Returns quantity of energy that was removed.
|
||||
*
|
||||
* @param maxExtract
|
||||
* Maximum amount of energy to be extracted.
|
||||
* @param simulate
|
||||
* If TRUE, the extraction will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted from the internalGenBuffer.
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted from the storage.
|
||||
*/
|
||||
int extractEnergy(int maxExtract, boolean simulate);
|
||||
|
||||
|
||||
@@ -66,12 +66,12 @@ public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
|
||||
if (container.stackTagCompound == null) {
|
||||
container.stackTagCompound = new NBTTagCompound();
|
||||
}
|
||||
int energy = container.stackTagCompound.getInteger("EnergyHelper");
|
||||
int energy = container.stackTagCompound.getInteger("Energy");
|
||||
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
|
||||
|
||||
if (!simulate) {
|
||||
energy += energyReceived;
|
||||
container.stackTagCompound.setInteger("EnergyHelper", energy);
|
||||
container.stackTagCompound.setInteger("Energy", energy);
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
@@ -79,15 +79,15 @@ public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
|
||||
@Override
|
||||
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
|
||||
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) {
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
|
||||
return 0;
|
||||
}
|
||||
int energy = container.stackTagCompound.getInteger("EnergyHelper");
|
||||
int energy = container.stackTagCompound.getInteger("Energy");
|
||||
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
|
||||
|
||||
if (!simulate) {
|
||||
energy -= energyExtracted;
|
||||
container.stackTagCompound.setInteger("EnergyHelper", energy);
|
||||
container.stackTagCompound.setInteger("Energy", energy);
|
||||
}
|
||||
return energyExtracted;
|
||||
}
|
||||
@@ -95,10 +95,10 @@ public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
|
||||
@Override
|
||||
public int getEnergyStored(ItemStack container) {
|
||||
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) {
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
|
||||
return 0;
|
||||
}
|
||||
return container.stackTagCompound.getInteger("EnergyHelper");
|
||||
return container.stackTagCompound.getInteger("Energy");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.utills.EnergyStorage;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Reference implementation of {@link IEnergyHandler}. Use/extend this or implement your own.
|
||||
*
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TileEnergyHandler extends TileEntity implements IEnergyHandler {
|
||||
|
||||
@@ -29,25 +28,28 @@ public class TileEnergyHandler extends TileEntity implements IEnergyHandler {
|
||||
storage.writeToNBT(nbt);
|
||||
}
|
||||
|
||||
/* IEnergyHandler */
|
||||
/* IEnergyConnection */
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* IEnergyReceiver */
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
|
||||
return storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
/* IEnergyProvider */
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
|
||||
return storage.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
|
||||
/* IEnergyReceiver and IEnergyProvider */
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
|
||||
|
||||
@@ -19,12 +19,14 @@ import com.brandon3055.draconicevolution.common.ModBlocks;
|
||||
import com.brandon3055.draconicevolution.common.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.entity.EntityCustomDragon;
|
||||
import com.brandon3055.draconicevolution.common.entity.EntityDragonHeart;
|
||||
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.*;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.energynet.TileEnergyRelay;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.energynet.TileEnergyTransceiver;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyPylon;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyStorageCore;
|
||||
import com.brandon3055.draconicevolution.common.utills.UpdateChecker;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
@@ -104,6 +106,7 @@ public class ClientProxy extends CommonProxy {
|
||||
super.init(event);
|
||||
FMLCommonHandler.instance().bus().register(new KeyInputHandler());
|
||||
FMLCommonHandler.instance().bus().register(new ClientEventHandler());
|
||||
if (ConfigHandler.enableVersionChecker) FMLCommonHandler.instance().bus().register(new UpdateChecker());
|
||||
MinecraftForge.EVENT_BUS.register(new HudHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new ClientEventHandler());
|
||||
KeyBindings.init();
|
||||
|
||||
+14
-1
@@ -1,9 +1,12 @@
|
||||
package com.brandon3055.draconicevolution.common.blocks.itemblocks;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -57,7 +60,10 @@ public class DraconiumItemBlock extends ItemBlock implements IEnergyContainerIte
|
||||
energy += energyReceived;
|
||||
container.stackTagCompound.setInteger("Energy", energy);
|
||||
}
|
||||
if (getEnergyStored(container) == getMaxEnergyStored(container)) container.setItemDamage(2);
|
||||
if (getEnergyStored(container) == getMaxEnergyStored(container)) {
|
||||
container.setItemDamage(2);
|
||||
container.setTagCompound(null);
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
|
||||
@@ -84,4 +90,11 @@ public class DraconiumItemBlock extends ItemBlock implements IEnergyContainerIte
|
||||
if (stack.getItemDamage() == 0 && getEnergyStored(stack) == getMaxEnergyStored(stack)) stack.setItemDamage(2);
|
||||
super.onUpdate(stack, p_77663_2_, p_77663_3_, p_77663_4_, p_77663_5_);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) {
|
||||
if (stack.hasTagCompound()) list.add(getEnergyStored(stack) + " / " + getMaxEnergyStored(stack) + "RF");
|
||||
}
|
||||
}
|
||||
+10
-3
@@ -37,10 +37,10 @@ public class EntityCustomDragon extends EntityDragon {
|
||||
public float attackDamage = 10F;
|
||||
protected boolean isUber = false;
|
||||
private boolean needsRenderUpdate = true;
|
||||
private boolean initialized = false;
|
||||
|
||||
public EntityCustomDragon(World par1World) {
|
||||
super(par1World);
|
||||
this.addPotionEffect(new PotionEffect(10, 600, 10, false));
|
||||
}
|
||||
|
||||
public EntityCustomDragon(World world, double health, float attack){
|
||||
@@ -48,13 +48,12 @@ public class EntityCustomDragon extends EntityDragon {
|
||||
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(health);
|
||||
this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(health);
|
||||
this.attackDamage = attack;
|
||||
this.addPotionEffect(new PotionEffect(10, 600, 10, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
super.entityInit();
|
||||
this.dataWatcher.addObject(12, Byte.valueOf((isUber ? (byte)1 : (byte)0)));
|
||||
this.dataWatcher.addObject(12, (isUber ? (byte)1 : (byte)0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,6 +71,12 @@ public class EntityCustomDragon extends EntityDragon {
|
||||
public void onLivingUpdate() {
|
||||
float f;
|
||||
float f1;
|
||||
|
||||
if (!initialized){
|
||||
this.addPotionEffect(new PotionEffect(10, 600, 10, false));
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
if (this.worldObj.isRemote) {
|
||||
f = MathHelper.cos(this.animTime * (float) Math.PI * 2.0F);
|
||||
f1 = MathHelper.cos(this.prevAnimTime * (float) Math.PI * 2.0F);
|
||||
@@ -597,6 +602,7 @@ public class EntityCustomDragon extends EntityDragon {
|
||||
super.writeToNBT(compound);
|
||||
compound.setFloat("AttackDamage", attackDamage);
|
||||
compound.setBoolean("IsUber", isUber);
|
||||
compound.setBoolean("Initialized", initialized);
|
||||
compound.setInteger("PortalX", portalX);
|
||||
compound.setInteger("PortalY", portalY);
|
||||
compound.setInteger("PortalZ", portalZ);
|
||||
@@ -607,6 +613,7 @@ public class EntityCustomDragon extends EntityDragon {
|
||||
super.readFromNBT(compound);
|
||||
attackDamage = compound.getFloat("AttackDamage");
|
||||
isUber = compound.getBoolean("IsUber");
|
||||
initialized = compound.getBoolean("Initialized");
|
||||
this.dataWatcher.updateObject(12, isUber ? (byte)1: (byte)0);
|
||||
portalX = compound.getInteger("PortalX");
|
||||
portalY = compound.getInteger("PortalY");
|
||||
|
||||
@@ -58,9 +58,6 @@ public class ExtendedPlayer implements IExtendedEntityProperties {
|
||||
return spawnCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple method sets current mana to max mana
|
||||
*/
|
||||
public void setSpawnCount(int count) {
|
||||
spawnCount = count;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public class ConfigHandler {
|
||||
public static boolean disableOreSpawnOverworld;
|
||||
public static boolean disableOreSpawnNether;
|
||||
public static boolean enableHudDisplay;
|
||||
public static boolean enableVersionChecker;
|
||||
|
||||
//spawner
|
||||
public static String[] spawnerList;
|
||||
@@ -81,6 +82,7 @@ public class ConfigHandler {
|
||||
disableOreSpawnNether = config.get(Configuration.CATEGORY_GENERAL, "Disable Ore Spawn (Nether)", false, "Set to true to prevent draconium ore from spawning in the nether").getBoolean(false);
|
||||
disableOreSpawnOverworld = config.get(Configuration.CATEGORY_GENERAL, "Disable Ore Spawn (Overworld)", false, "Set to true to prevent draconium ore from spawning in the overworld").getBoolean(false);
|
||||
enableHudDisplay = config.get(Configuration.CATEGORY_GENERAL, "Enable HUD info", true, "Set to false to disable the HUD info for tools and blocks").getBoolean(true);
|
||||
enableVersionChecker = config.get(Configuration.CATEGORY_GENERAL, "Enable version checker", true, "Set to false to disable the version checker").getBoolean(true);
|
||||
|
||||
//Spawner
|
||||
spawnerListType = config.get("spawner", "listType", false, "Sets weather the spawner list is a white list or a black list (true = white list false = black list)").getBoolean(false);
|
||||
|
||||
@@ -93,14 +93,19 @@ public class CraftingHandler {
|
||||
addOre(ModBlocks.playerDetector, "ITI", "CEC", "IDI", 'I', "ingotIron", 'E', Items.ender_eye, 'T', Blocks.redstone_torch, 'C', Items.comparator, 'D', ModItems.draconicCore);
|
||||
addOre(new ItemStack(ModBlocks.generator, 1, 3), "NIN", "IFI", "NCN", 'N', Items.netherbrick, 'I', "ingotIron", 'F', Blocks.furnace, 'C', ModItems.draconicCore);
|
||||
addOre(ModBlocks.dissEnchanter, "PIP", "ETE", "CBC", 'P', Items.ender_eye, 'I', Items.enchanted_book, 'E', "gemEmerald", 'T', Blocks.enchanting_table, 'C', ModItems.draconicCore, 'B', Items.book);
|
||||
|
||||
addOre(new ItemStack(ModBlocks.energyCrystal, 4, 0), "IDI", "DCD", "IDI", 'I' , ModItems.draconiumIngot, 'D', "gemDiamond", 'C', ModItems.draconicCore);
|
||||
addOre(new ItemStack(ModBlocks.energyCrystal, 4, 1), "CRC", "RWR", "CRC", 'R' , new ItemStack(ModBlocks.energyCrystal, 1), 'W', ModItems.wyvernCore, 'C', ModItems.draconicCore);
|
||||
addShaplessOre(new ItemStack(ModBlocks.energyCrystal, 1, 0), new ItemStack(ModBlocks.energyCrystal, 1, 2), new ItemStack(ModBlocks.energyCrystal, 1, 2));
|
||||
addShaplessOre(new ItemStack(ModBlocks.energyCrystal, 2, 2), new ItemStack(ModBlocks.energyCrystal, 1, 0));
|
||||
addShaplessOre(new ItemStack(ModBlocks.energyCrystal, 1, 1), new ItemStack(ModBlocks.energyCrystal, 1, 3), new ItemStack(ModBlocks.energyCrystal, 1, 3));
|
||||
addShaplessOre(new ItemStack(ModBlocks.energyCrystal, 2, 3), new ItemStack(ModBlocks.energyCrystal, 1, 1));
|
||||
|
||||
//Tools
|
||||
add(ModItems.teleporterMKII, "IEI", "ETE", "IWI", 'I', ModItems.draconiumIngot, 'E', Items.ender_pearl, 'T', ModItems.teleporterMKI, 'W', ModItems.wyvernCore);
|
||||
add(ModItems.teleporterMKI, "CSC", "SMS", "CSC", 'C', Items.blaze_powder, 'S', ModItems.draconiumDust, 'M', Items.ender_eye);
|
||||
addOre(new ItemStack(ModItems.safetyMatch, 1, 1000), " O ", " S ", " ", 'O', "dyeOrange", 'S', "stickWood");
|
||||
add(ModItems.safetyMatch, "MMM", "MMM", "MMM", 'M', new ItemStack(ModItems.safetyMatch, 1, 1000));
|
||||
|
||||
addOre(ModItems.wrench, " ID", " RI", "C ", 'I' , ModItems.draconiumIngot, 'D', "gemDiamond", 'R', Items.blaze_rod, 'C', ModItems.draconicCore);
|
||||
|
||||
//Other
|
||||
addOre(ModItems.infoTablet, "SSS", "SDS", "SSS", 'S', "stone", 'D', ModItems.draconiumDust);
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.brandon3055.draconicevolution.common.items.ItemDE;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
import com.brandon3055.draconicevolution.common.utills.IHudDisplayItem;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper;
|
||||
import com.brandon3055.draconicevolution.common.utills.UpdateChecker;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -40,7 +39,8 @@ public class Wrench extends ItemDE implements IHudDisplayItem{
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
|
||||
new UpdateChecker();
|
||||
//if (world.isRemote)FMLCommonHandler.instance().bus().register(new UpdateChecker());
|
||||
//player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.BLUE + "[Draconic Evolution]" + EnumChatFormatting.RESET + " New version available:"));
|
||||
|
||||
if (player.isSneaking()) cycleMode(stack, world, player);
|
||||
else if (ItemNBTHelper.getCompound(stack).hasKey("LinkData") && ItemNBTHelper.getCompound(stack).getCompoundTag("LinkData").getBoolean("Bound")) ItemNBTHelper.getCompound(stack).getCompoundTag("LinkData").setBoolean("Bound", false);
|
||||
|
||||
-2
@@ -4,7 +4,6 @@ import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.utills.DataUtills;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemConfigField;
|
||||
import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper;
|
||||
import com.brandon3055.draconicevolution.common.utills.LogHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
@@ -68,7 +67,6 @@ public abstract class MiningTool extends ToolBase {//todo add custom information
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
ToolHandler.updateGhostBlocks(player, world);
|
||||
LogHelper.info(getDisplayData(stack));
|
||||
if (player.isSneaking())
|
||||
{
|
||||
List<ItemConfigField> fields = getFields(stack, player.inventory.currentItem);
|
||||
|
||||
@@ -6,7 +6,7 @@ package com.brandon3055.draconicevolution.common.lib;
|
||||
public class VersionHandler
|
||||
{
|
||||
public static final String VERSION = "1.0.1";
|
||||
public static final int SNAPSHOT = 4;
|
||||
public static final int SNAPSHOT = 5;
|
||||
public static final String MCVERSION = "1.7.10";
|
||||
|
||||
public static final String FULL_VERSION = VERSION + (SNAPSHOT > 0 ? "-snapshot_" + SNAPSHOT: "");
|
||||
|
||||
+2
@@ -164,6 +164,8 @@ public abstract class CustomSpawnerBaseLogic {
|
||||
par1Entity.setCurrentItemOrArmor(0, new ItemStack(Items.bow));
|
||||
}
|
||||
} else ((EntityLiving) par1Entity).onSpawnWithEgg(null);
|
||||
|
||||
((EntityLiving)par1Entity).func_110163_bv();
|
||||
this.getSpawnerWorld().spawnEntityInWorld(par1Entity);
|
||||
}
|
||||
|
||||
|
||||
+2
-8
@@ -1,7 +1,7 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import com.brandon3055.draconicevolution.common.ModBlocks;
|
||||
import com.brandon3055.draconicevolution.common.blocks.DraconiumChest;
|
||||
import com.brandon3055.draconicevolution.common.container.ContainerDraconiumChest;
|
||||
@@ -28,7 +28,7 @@ import java.util.List;
|
||||
/**
|
||||
* Created by Brandon on 27/06/2014.
|
||||
*/
|
||||
public class TileDraconiumChest extends TileEntity implements IInventory, IEnergyHandler, ICustomItemData {
|
||||
public class TileDraconiumChest extends TileEntity implements IInventory, IEnergyReceiver, ICustomItemData {
|
||||
ItemStack[] items = new ItemStack[240];
|
||||
ItemStack[] itemsCrafting = new ItemStack[10];
|
||||
private int ticksSinceSync = -1;
|
||||
@@ -601,12 +601,6 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg
|
||||
return this.energy.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
return energy.getEnergyStored();
|
||||
|
||||
+3
-8
@@ -1,9 +1,9 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergy;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
|
||||
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergy;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.utills.EnergyStorage;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -22,7 +22,7 @@ import java.util.Random;
|
||||
/**
|
||||
* Created by Brandon on 27/06/2014.
|
||||
*/
|
||||
public class TileEnergyInfuser extends TileObjectSync implements IEnergyHandler, ISidedInventory {
|
||||
public class TileEnergyInfuser extends TileObjectSync implements IEnergyReceiver, ISidedInventory {
|
||||
ItemStack[] items = new ItemStack[1];
|
||||
public EnergyStorage energy = new EnergyStorage(1000000);
|
||||
public int maxInput = 81920;
|
||||
@@ -139,11 +139,6 @@ public class TileEnergyInfuser extends TileObjectSync implements IEnergyHandler,
|
||||
return this.energy.receiveEnergy(Math.min(maxInput, maxReceive), simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {;
|
||||
return this.energy.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
return energy.getEnergyStored();
|
||||
|
||||
+5
-9
@@ -1,6 +1,7 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.utills.EnergyStorage;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -20,7 +21,7 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileGenerator extends TileObjectSync implements ISidedInventory, IEnergyHandler {
|
||||
public class TileGenerator extends TileObjectSync implements ISidedInventory, IEnergyProvider {
|
||||
//########### variables #############//
|
||||
private ItemStack[] items;
|
||||
public int burnTime = 1;
|
||||
@@ -55,8 +56,8 @@ public class TileGenerator extends TileObjectSync implements ISidedInventory, IE
|
||||
if ((storage.getEnergyStored() > 0)) {
|
||||
for (int i = 0; i < 6; i++){
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord + ForgeDirection.getOrientation(i).offsetX, yCoord + ForgeDirection.getOrientation(i).offsetY, zCoord + ForgeDirection.getOrientation(i).offsetZ);
|
||||
if (tile != null && tile instanceof IEnergyHandler) {
|
||||
storage.extractEnergy(((IEnergyHandler)tile).receiveEnergy(ForgeDirection.getOrientation(i).getOpposite(), storage.extractEnergy(storage.getMaxExtract(), true), false), false);
|
||||
if (tile != null && tile instanceof IEnergyReceiver) {
|
||||
storage.extractEnergy(((IEnergyReceiver)tile).receiveEnergy(ForgeDirection.getOrientation(i).getOpposite(), storage.extractEnergy(storage.getMaxExtract(), true), false), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -275,11 +276,6 @@ public class TileGenerator extends TileObjectSync implements ISidedInventory, IE
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
return storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
return storage.extractEnergy(maxExtract, simulate);
|
||||
|
||||
+8
-10
@@ -1,6 +1,6 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.utills.EnergyStorage;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
@@ -32,7 +32,7 @@ import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TileGrinder extends TileObjectSync implements ISidedInventory, IEnergyHandler {
|
||||
public class TileGrinder extends TileObjectSync implements ISidedInventory, IEnergyReceiver {
|
||||
//########### variables #############//
|
||||
public int meta = -1;
|
||||
List<EntityLiving> killList;
|
||||
@@ -391,8 +391,12 @@ public class TileGrinder extends TileObjectSync implements ISidedInventory, IEne
|
||||
}
|
||||
|
||||
private void detectAndSendChanges(boolean sendAnyway){
|
||||
if (disabledCach != disabled || sendAnyway) disabledCach = (Boolean)sendObject(References.BOOLEAN_ID, 0, disabled);
|
||||
if (hasPowerCach != hasPower || sendAnyway) hasPowerCach = (Boolean)sendObject(References.BOOLEAN_ID, 1, hasPower);
|
||||
if (disabledCach != disabled || sendAnyway) {
|
||||
disabledCach = (Boolean)sendObject(References.BOOLEAN_ID, 0, disabled);
|
||||
}
|
||||
if (hasPowerCach != hasPower || sendAnyway) {
|
||||
hasPowerCach = (Boolean)sendObject(References.BOOLEAN_ID, 1, hasPower);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -419,12 +423,6 @@ public class TileGrinder extends TileObjectSync implements ISidedInventory, IEne
|
||||
return externalInputBuffer.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
return externalInputBuffer.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
return externalInputBuffer.getEnergyStored();
|
||||
|
||||
+6
-5
@@ -1,6 +1,7 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities.energynet;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
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;
|
||||
@@ -36,18 +37,18 @@ public class TileEnergyTransceiver extends TileRemoteEnergyBase{
|
||||
{
|
||||
ForgeDirection direction = ForgeDirection.getOrientation(facing).getOpposite();
|
||||
TileEntity adjacentTile = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
|
||||
if (!input && adjacentTile instanceof IEnergyHandler)
|
||||
if (!input && adjacentTile instanceof IEnergyReceiver)
|
||||
{
|
||||
IEnergyHandler handler = (IEnergyHandler) adjacentTile;
|
||||
IEnergyReceiver handler = (IEnergyReceiver) adjacentTile;
|
||||
storage.extractEnergy(handler.receiveEnergy(direction.getOpposite(), storage.extractEnergy(storage.getMaxExtract(), true), false), false);
|
||||
if (transferBoost)
|
||||
{
|
||||
for (int i = 0; i < 4; i++) storage.extractEnergy(handler.receiveEnergy(direction.getOpposite(), storage.extractEnergy(storage.getMaxExtract(), true), false), false);
|
||||
}
|
||||
}
|
||||
else if (input && adjacentTile instanceof IEnergyHandler)
|
||||
else if (input && adjacentTile instanceof IEnergyProvider)
|
||||
{
|
||||
IEnergyHandler handler = (IEnergyHandler) adjacentTile;
|
||||
IEnergyProvider handler = (IEnergyProvider) adjacentTile;
|
||||
if (transferBoost)
|
||||
{
|
||||
for (int i = 0; i < 4; i++) storage.receiveEnergy(handler.extractEnergy(direction.getOpposite(), storage.receiveEnergy(storage.getMaxExtract(), true), false), false);
|
||||
|
||||
+6
-4
@@ -1,10 +1,11 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities.multiblocktiles;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
|
||||
import com.brandon3055.draconicevolution.client.render.particle.Particles;
|
||||
import com.brandon3055.draconicevolution.common.ModBlocks;
|
||||
import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper.TileLocation;
|
||||
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileObjectSync;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
@@ -53,8 +54,8 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler {
|
||||
if (active && !reciveEnergy){
|
||||
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord + d.offsetX, yCoord + d.offsetY, zCoord + d.offsetZ);
|
||||
if (tile != null && tile instanceof IEnergyHandler) {
|
||||
extractEnergy(d, ((IEnergyHandler)tile).receiveEnergy(d.getOpposite(), extractEnergy(d, Integer.MAX_VALUE, true), false), false);
|
||||
if (tile != null && tile instanceof IEnergyReceiver) {
|
||||
extractEnergy(d, ((IEnergyReceiver)tile).receiveEnergy(d.getOpposite(), extractEnergy(d, Integer.MAX_VALUE, true), false), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,7 +110,7 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void spawnParticles(){
|
||||
Random rand = new Random();
|
||||
Random rand = worldObj.rand;
|
||||
if (getMaster() == null || !getMaster().isOnline()) return;
|
||||
|
||||
int x = getMaster().xCoord;
|
||||
@@ -207,6 +208,7 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler {
|
||||
list.add(l);
|
||||
}
|
||||
coreLocatios = list;
|
||||
selectedCore = compound.getInteger("SelectedCore");
|
||||
particleRate = compound.getByte("ParticleRate");
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -6,6 +6,7 @@ import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileObjectSync;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileParticleGenerator;
|
||||
import com.brandon3055.draconicevolution.common.utills.LogHelper;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
@@ -209,6 +210,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
|
||||
}
|
||||
|
||||
if (zNeg != zPos || zNeg != yNeg || zNeg != yPos || zNeg != xNeg || zNeg != xPos) return false;
|
||||
|
||||
tier = xPos;
|
||||
if (tier > 1) tier++;
|
||||
if (tier == 1){
|
||||
@@ -579,7 +581,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
|
||||
worldObj.setBlock(x, y, z, Blocks.air);
|
||||
return true;
|
||||
}else
|
||||
return worldObj.getBlock(x, y, z).isReplaceable(worldObj, x, y, z);
|
||||
return worldObj.getBlock(x, y, z).isReplaceable(worldObj, x, y, z) || worldObj.isAirBlock(x, y, z);
|
||||
}
|
||||
|
||||
public boolean isOnline(){
|
||||
@@ -784,7 +786,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
|
||||
|
||||
private void detectAndRendChanges(){
|
||||
int diff = (int)Math.abs(lastTickCapacity - energy);
|
||||
if (diff > 100000) lastTickCapacity = (Double)sendObject(References.DOUBLE_ID, 0, energy);
|
||||
if (diff > 1000) lastTickCapacity = (Double)sendObject(References.DOUBLE_ID, 0, energy, new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 20));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package com.brandon3055.draconicevolution.common.utills;
|
||||
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.brandon3055.draconicevolution.common.lib.VersionHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StringUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -12,6 +18,8 @@ import java.net.URL;
|
||||
public class UpdateChecker
|
||||
{
|
||||
private final UpdateCheckThread thread;
|
||||
private int delay = 300;
|
||||
private boolean playerNotified = false;
|
||||
|
||||
public UpdateChecker()
|
||||
{
|
||||
@@ -20,76 +28,131 @@ public class UpdateChecker
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void tickStart(TickEvent.PlayerTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.START) return;
|
||||
if (delay > 0) {
|
||||
delay--;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playerNotified && thread.isComplete())
|
||||
{
|
||||
playerNotified = true;
|
||||
FMLCommonHandler.instance().bus().unregister(this);
|
||||
|
||||
if (!thread.getVersion().equals(VersionHandler.VERSION) || (VersionHandler.SNAPSHOT > 0 && thread.getSnapshot() == 0))
|
||||
{
|
||||
event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "[Draconic Evolution]" + EnumChatFormatting.RESET + " New version available:"));
|
||||
event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Draconic Evolution v" + thread.getVersion()));
|
||||
if (!StringUtils.isNullOrEmpty(thread.getNote())) event.player.addChatComponentMessage(new ChatComponentText(thread.getNote()));
|
||||
}
|
||||
else if (thread.getSnapshot() > VersionHandler.SNAPSHOT)
|
||||
{
|
||||
event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE + "[Draconic Evolution]" + EnumChatFormatting.RESET + " New snapshot version available:"));
|
||||
event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.BLUE + "Draconic Evolution v" + thread.getVersion() + "-snapshot_" + thread.getSnapshot()));
|
||||
if (!StringUtils.isNullOrEmpty(thread.getNote())) event.player.addChatComponentMessage(new ChatComponentText(thread.getNote()));
|
||||
}
|
||||
|
||||
} else if (thread.isFailed())
|
||||
{
|
||||
playerNotified = true;
|
||||
FMLCommonHandler.instance().bus().unregister(this);
|
||||
|
||||
event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE + "[Draconic Evolution]" + EnumChatFormatting.RED + " Version check failed"));
|
||||
if (!StringUtils.isNullOrEmpty(thread.getNote())) event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + thread.getNote()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class UpdateCheckThread extends Thread
|
||||
{
|
||||
private String version;
|
||||
private int snapshot;
|
||||
private String note;
|
||||
private boolean checkComplete = false;
|
||||
private boolean checkFaild = false;
|
||||
private String version = null;
|
||||
private int snapshot = -1;
|
||||
private String note = null;
|
||||
private boolean complete = false;
|
||||
private boolean failed = false;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LogHelper.info("Thread Run");
|
||||
|
||||
JsonReader reader;
|
||||
LogHelper.info("[Update Checker] Thread Started");
|
||||
try
|
||||
{
|
||||
|
||||
URL versionURL = new URL("https://raw.githubusercontent.com/brandon3055/Draconic-Evolution/master/VERSION.json");
|
||||
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader((versionURL).openStream()));
|
||||
|
||||
String cl;
|
||||
String line;
|
||||
|
||||
while ((cl = bufferedReader.readLine()) != null) {
|
||||
LogHelper.info(cl);
|
||||
while ((line = bufferedReader.readLine()) != null)
|
||||
{
|
||||
if (line.contains(":"))
|
||||
{
|
||||
String value = line.substring(line.indexOf(":") + 1);
|
||||
if (line.contains("Version")) version = value;
|
||||
else if (line.contains("Snapshot")) snapshot = Integer.parseInt(value);
|
||||
else if (line.contains("ReleaseNote")) note = value;
|
||||
}
|
||||
}
|
||||
|
||||
if (version != null && snapshot >= 0) complete = true;
|
||||
else {
|
||||
note = "[Invalid Response]";
|
||||
failed = true;
|
||||
}
|
||||
|
||||
// File versionFile = new File("");
|
||||
//
|
||||
// InputStream is = versionURL.openStream();
|
||||
// OutputStream os = new FileOutputStream(versionFile);
|
||||
// ByteStreams.copy(is, os);
|
||||
//
|
||||
// reader = new JsonReader(new FileReader(versionFile));
|
||||
//
|
||||
// reader.beginObject();
|
||||
// LogHelper.info(reader.nextString());
|
||||
//
|
||||
// while (reader.hasNext())
|
||||
LogHelper.info("[Update Checker] Thread Finished");
|
||||
// if (complete)
|
||||
// {
|
||||
// String name = reader.nextName();
|
||||
//
|
||||
// if (name.equals("Version"))
|
||||
// if (!getVersion().equals(VersionHandler.VERSION) || (VersionHandler.SNAPSHOT > 0 && getSnapshot() == 0))
|
||||
// {
|
||||
// LogHelper.info(reader.nextString());
|
||||
// LogHelper.info("###############################");
|
||||
// LogHelper.info("New version available:");
|
||||
// LogHelper.info("Draconic Evolution v" + thread.getVersion());
|
||||
// if (!StringUtils.isNullOrEmpty(thread.getNote())) LogHelper.info(thread.getNote());
|
||||
// LogHelper.info("###############################");
|
||||
// }
|
||||
// else if (name.equals("Snapshot"))
|
||||
// else if (getSnapshot() > VersionHandler.SNAPSHOT)
|
||||
// {
|
||||
// LogHelper.info(reader.nextInt());
|
||||
// }
|
||||
// else if (name.equals("MCVersion"))
|
||||
// {
|
||||
// LogHelper.info(reader.nextString());
|
||||
// }
|
||||
// else if (name.equals("ReleaseNote"))
|
||||
// {
|
||||
// LogHelper.info(reader.nextString());
|
||||
// LogHelper.info("###############################");
|
||||
// LogHelper.info("New snapshot version available:");
|
||||
// LogHelper.info("Draconic Evolution v" + thread.getVersion() + "-snapshot_" + thread.getSnapshot());
|
||||
// if (!StringUtils.isNullOrEmpty(thread.getNote())) LogHelper.info(thread.getNote());
|
||||
// LogHelper.info("###############################");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// reader.endObject();
|
||||
// reader.close();
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.info("[Update Checker] Check Failed");
|
||||
failed = true;
|
||||
note = e.getClass().toString();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public int getSnapshot() {
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public boolean isComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
public boolean isFailed() {
|
||||
return failed;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.brandon3055.draconicevolution.common.utills;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 25/07/2014.
|
||||
*/
|
||||
@@ -48,4 +50,14 @@ public class Utills {
|
||||
double dz = z1-z2;
|
||||
return Math.sqrt((dx*dx + dz*dz ));
|
||||
}
|
||||
|
||||
public static final boolean isSinglePlayerServer()
|
||||
{
|
||||
return FMLCommonHandler.instance().getMinecraftServerInstance() != null;
|
||||
}
|
||||
|
||||
public static final boolean isMultiPlayerServer()
|
||||
{
|
||||
return FMLCommonHandler.instance().getMinecraftServerInstance() == null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user