Started work on the farm, some changes to the idsu, its still broken
This commit is contained in:
parent
be33bdc148
commit
c160abf176
26 changed files with 626 additions and 194 deletions
45
src/main/java/techreborn/tiles/TileFarm.java
Normal file
45
src/main/java/techreborn/tiles/TileFarm.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import techreborn.api.farm.IFarmLogicContainer;
|
||||
import techreborn.api.farm.IFarmLogicDevice;
|
||||
import techreborn.farm.FarmTree;
|
||||
import techreborn.util.Inventory;
|
||||
|
||||
public class TileFarm extends TileMachineBase {
|
||||
|
||||
public Inventory inventory= new Inventory(14, "TileFarm", 64);
|
||||
|
||||
IFarmLogicDevice logicDevice;
|
||||
|
||||
public TileFarm() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
inventory.readFromNBT(tagCompound);
|
||||
super.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
inventory.writeToNBT(tagCompound);
|
||||
super.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if(inventory.hasChanged){
|
||||
if(inventory.getStackInSlot(0) != null && inventory.getStackInSlot(0).getItem() instanceof IFarmLogicContainer){
|
||||
IFarmLogicContainer device = (IFarmLogicContainer) inventory.getStackInSlot(0).getItem();
|
||||
logicDevice = device.getLogicFromStack(inventory.getStackInSlot(0));
|
||||
} else {
|
||||
logicDevice = null;
|
||||
}
|
||||
}
|
||||
if(logicDevice != null){
|
||||
logicDevice.tick(this);
|
||||
}
|
||||
super.updateEntity();
|
||||
}
|
||||
}
|
|
@ -85,13 +85,13 @@ public class IDSUManager {
|
|||
}
|
||||
}
|
||||
|
||||
public PacketSendIDSUManager getPacket(World world, EntityPlayer player) {
|
||||
public PacketSendIDSUManager getPacket(World world) {
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(getWorldDataFormWorld(world).idsuValues);
|
||||
if (getWorldDataFormWorld(world).idsuValues.isEmpty()) {
|
||||
json = "EMPTY";
|
||||
}
|
||||
return new PacketSendIDSUManager(json, player);
|
||||
return new PacketSendIDSUManager(json);
|
||||
}
|
||||
|
||||
public void loadFromString(String json, World world) {
|
||||
|
|
|
@ -9,12 +9,14 @@ import ic2.api.tile.IEnergyStorage;
|
|||
import ic2.core.IC2;
|
||||
import ic2.core.block.TileEntityBlock;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import techreborn.Core;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.packets.PacketHandler;
|
||||
|
@ -29,8 +31,8 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
|||
IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, channel).name = name;
|
||||
IDSUManager.INSTANCE.getWorldDataFormWorld(worldObj).save();
|
||||
if (worldObj.isRemote) {
|
||||
PacketHandler.sendPacketToPlayer(IDSUManager.INSTANCE.getPacket(worldObj, player), player);
|
||||
}
|
||||
Core.packetPipeline.sendTo(IDSUManager.INSTANCE.getPacket(worldObj), (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,6 +63,10 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
|||
this.maxStorage = maxStorage1;
|
||||
}
|
||||
|
||||
public TileIDSU(){
|
||||
this(5, 2048, 100000000);
|
||||
}
|
||||
|
||||
public float getChargeLevel() {
|
||||
float ret = (float) this.getEnergy() / (float) this.maxStorage;
|
||||
if (ret > 1.0F) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue