About to give up. Here is what ive got.
This commit is contained in:
parent
34530fa6ca
commit
0749385e49
14 changed files with 41 additions and 131 deletions
|
@ -3,6 +3,9 @@ package techreborn.api.recipe;
|
|||
import ic2.api.energy.prefab.BasicSink;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import techreborn.packets.PacketHandler;
|
||||
import techreborn.tiles.TileMachineBase;
|
||||
import techreborn.util.Inventory;
|
||||
import techreborn.util.ItemUtils;
|
||||
|
@ -80,7 +83,7 @@ public class RecipeCrafter {
|
|||
|
||||
public IBaseRecipeType currentRecipe;
|
||||
public int currentTickTime = 0;
|
||||
public int currentNeededTicks = 0;
|
||||
public int currentNeededTicks = 1;//Set to 1 to stop rare crashes
|
||||
double lastEnergy;
|
||||
public boolean isactive = false;
|
||||
|
||||
|
@ -107,7 +110,6 @@ public class RecipeCrafter {
|
|||
* Call this on the tile tick
|
||||
*/
|
||||
public void updateEntity() {
|
||||
speedMultiplier = 0.9;
|
||||
if(parentTile.getWorldObj().isRemote){
|
||||
return;
|
||||
}
|
||||
|
@ -126,6 +128,7 @@ public class RecipeCrafter {
|
|||
currentRecipe = recipe;//Sets the current recipe then syncs
|
||||
this.currentNeededTicks = (int)(currentRecipe.tickTime() * (1.0 - speedMultiplier));
|
||||
this.currentTickTime = 0;
|
||||
syncIsActive();
|
||||
} else {
|
||||
this.currentTickTime = 0;
|
||||
}
|
||||
|
@ -135,6 +138,7 @@ public class RecipeCrafter {
|
|||
if (!hasAllInputs()) {//If it doesn't have all the inputs reset
|
||||
currentRecipe = null;
|
||||
currentTickTime = -1;
|
||||
syncIsActive();
|
||||
}
|
||||
if (currentRecipe != null && currentTickTime >= currentNeededTicks) {//If it has reached the recipe tick time
|
||||
boolean canGiveInvAll = true;
|
||||
|
@ -154,6 +158,7 @@ public class RecipeCrafter {
|
|||
useAllInputs();//this uses all the inputs
|
||||
currentRecipe = null;//resets
|
||||
currentTickTime = 0;
|
||||
syncIsActive();
|
||||
}
|
||||
} else if (currentRecipe != null && currentTickTime < currentNeededTicks) {
|
||||
if (energy.useEnergy(getEuPerTick())) {//This uses the power
|
||||
|
@ -246,9 +251,15 @@ public class RecipeCrafter {
|
|||
public void readFromNBT(NBTTagCompound tag) {
|
||||
NBTTagCompound data = tag.getCompoundTag("Crater");
|
||||
|
||||
currentTickTime = data.getInteger("currentTickTime");
|
||||
if(data.hasKey("currentTickTime"))
|
||||
currentTickTime = data.getInteger("currentTickTime");
|
||||
|
||||
isactive = data.getBoolean("isActive");
|
||||
if(parentTile.getWorldObj().isRemote){
|
||||
System.out.println(isactive);
|
||||
parentTile.getWorldObj().markBlockForUpdate(parentTile.xCoord, parentTile.yCoord, parentTile.zCoord);
|
||||
parentTile.getWorldObj().markBlockRangeForRenderUpdate(parentTile.xCoord, parentTile.yCoord, parentTile.zCoord, parentTile.xCoord, parentTile.yCoord, parentTile.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
|
@ -261,6 +272,7 @@ public class RecipeCrafter {
|
|||
tag.setTag("Crater", data);
|
||||
}
|
||||
|
||||
|
||||
private boolean isActiveServer() {
|
||||
return currentRecipe != null;
|
||||
}
|
||||
|
@ -297,4 +309,19 @@ public class RecipeCrafter {
|
|||
public double getEuPerTick(){
|
||||
return currentRecipe.euPerTick() * powerMultiplier;
|
||||
}
|
||||
|
||||
|
||||
public void syncIsActive() {
|
||||
if (!parentTile.getWorldObj().isRemote) {
|
||||
PacketHandler.sendPacketToAllPlayers(parentTile.getDescriptionPacket(),
|
||||
parentTile.getWorldObj());
|
||||
}
|
||||
}
|
||||
|
||||
public Packet getSyncPacket() {
|
||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||
writeToNBT(nbtTag);
|
||||
return new S35PacketUpdateTileEntity(this.parentTile.xCoord, this.parentTile.yCoord,
|
||||
this.parentTile.zCoord, 1, nbtTag);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,13 +91,6 @@ public class TileAlloySmelter extends TileMachineBase implements IWrenchable, IE
|
|||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeSyncToNBT(tagCompound);
|
||||
energy.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate(){
|
||||
energy.invalidate();
|
||||
|
|
|
@ -102,14 +102,6 @@ public class TileAssemblingMachine extends TileMachineBase implements IWrenchabl
|
|||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeSyncToNBT(tagCompound);
|
||||
energy.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
|
|
|
@ -109,14 +109,6 @@ public class TileCentrifuge extends TileMachineBase implements IWrenchable, IEn
|
|||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeSyncToNBT(tagCompound);
|
||||
energy.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
|
|
|
@ -102,14 +102,6 @@ public class TileChemicalReactor extends TileMachineBase implements IWrenchable,
|
|||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeSyncToNBT(tagCompound);
|
||||
energy.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
|
|
|
@ -98,16 +98,7 @@ public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergy
|
|||
tank.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeSyncToNBT(tagCompound);
|
||||
energy.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
tank.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
energy.invalidate();
|
||||
|
|
|
@ -123,13 +123,6 @@ public class TileHeatGenerator extends TileMachineBase implements IWrenchable, I
|
|||
energy.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeSyncToNBT(tagCompound);
|
||||
energy.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addWailaInfo(List<String> info)
|
||||
{
|
||||
|
|
|
@ -95,14 +95,6 @@ public class TileImplosionCompressor extends TileMachineBase implements IWrencha
|
|||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeSyncToNBT(tagCompound);
|
||||
energy.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addWailaInfo(List<String> info)
|
||||
{
|
||||
|
|
|
@ -100,14 +100,6 @@ public class TileIndustrialElectrolyzer extends TileMachineBase implements IWren
|
|||
energy.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeSyncToNBT(tagCompound);
|
||||
energy.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
|
|
|
@ -104,14 +104,6 @@ public class TileIndustrialSawmill extends TileMachineBase implements IWrenchabl
|
|||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeSyncToNBT(tagCompound);
|
||||
energy.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
|
|
|
@ -101,14 +101,6 @@ public class TileLathe extends TileMachineBase implements IWrenchable, IEnergyTi
|
|||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeSyncToNBT(tagCompound);
|
||||
energy.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
|
|
|
@ -11,42 +11,24 @@ import techreborn.packets.PacketHandler;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class TileMachineBase extends TileEntity {
|
||||
public abstract class TileMachineBase extends TileEntity {
|
||||
|
||||
public boolean needsSync = false;
|
||||
public int ticksSinceLastSync = 0;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
//Force a sync evey 10 seconds
|
||||
if(needsSync && !worldObj.isRemote){
|
||||
syncWithAll();
|
||||
@Deprecated
|
||||
/**
|
||||
* Try not to use this
|
||||
*/
|
||||
public void syncWithAll() {
|
||||
if (!worldObj.isRemote) {
|
||||
PacketHandler.sendPacketToAllPlayers(getDescriptionPacket(),
|
||||
worldObj);
|
||||
}
|
||||
ticksSinceLastSync ++;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addWailaInfo(List<String> info) {
|
||||
|
||||
}
|
||||
|
||||
public void syncWithAll() {
|
||||
if (!worldObj.isRemote) {
|
||||
PacketHandler.sendPacketToAllPlayers(getSyncPacket(),
|
||||
worldObj);
|
||||
}
|
||||
needsSync = false;
|
||||
ticksSinceLastSync = 0;
|
||||
}
|
||||
|
||||
public Packet getSyncPacket() {
|
||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||
writeSyncToNBT(nbtTag);
|
||||
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord,
|
||||
this.zCoord, 1, nbtTag);
|
||||
}
|
||||
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||
writeToNBT(nbtTag);
|
||||
|
@ -61,9 +43,4 @@ public class TileMachineBase extends TileEntity {
|
|||
readFromNBT(packet.func_148857_g());
|
||||
}
|
||||
|
||||
public void writeSyncToNBT(NBTTagCompound tagCompound) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -83,13 +83,6 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable
|
|||
energy.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeSyncToNBT(tagCompound);
|
||||
energy.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
|
|
|
@ -101,14 +101,6 @@ public class TilePlateCuttingMachine extends TileMachineBase implements IWrencha
|
|||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeSyncToNBT(tagCompound);
|
||||
energy.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addWailaInfo(List<String> info)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue