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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue