Change solderer texure behaviour

This commit is contained in:
Raoul Van den Berge
2016-04-30 20:25:13 +02:00
parent 4dd3dd44b3
commit 54eb612a37
6 changed files with 54 additions and 30 deletions

View File

@@ -1,5 +1,8 @@
package refinedstorage.block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -7,12 +10,16 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileDetector;
import refinedstorage.tile.TileSolderer;
public class BlockSolderer extends BlockMachine {
public static final PropertyBool WORKING = PropertyBool.create("working");
public BlockSolderer() {
super("solderer");
}
@@ -30,4 +37,19 @@ public class BlockSolderer extends BlockMachine {
return true;
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, new IProperty[]{
DIRECTION,
CONNECTED,
WORKING
});
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
return super.getActualState(state, world, pos)
.withProperty(WORKING, ((TileSolderer) world.getTileEntity(pos)).isWorking());
}
}

View File

@@ -122,7 +122,6 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
public void receiveContainerData(ByteBuf buf) {
super.receiveContainerData(buf);
working = buf.readBoolean();
progress = buf.readInt();
duration = buf.readInt();
}
@@ -131,11 +130,30 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
public void sendContainerData(ByteBuf buf) {
super.sendContainerData(buf);
buf.writeBoolean(working);
buf.writeInt(progress);
buf.writeInt(recipe != null ? recipe.getDuration() : 0);
}
@Override
public void receiveData(ByteBuf buf) {
super.receiveData(buf);
boolean lastWorking = working;
working = buf.readBoolean();
if (working != lastWorking) {
worldObj.notifyBlockUpdate(pos, worldObj.getBlockState(pos), worldObj.getBlockState(pos), 2 | 4);
}
}
@Override
public void sendData(ByteBuf buf) {
super.sendData(buf);
buf.writeBoolean(working);
}
@Override
public Class<? extends Container> getContainer() {
return ContainerSolderer.class;
@@ -145,18 +163,10 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
return working;
}
public int getProgress() {
return progress;
}
public int getProgressScaled(int i) {
return (int) ((float) progress / (float) duration * (float) i);
}
public int getDuration() {
return duration;
}
@Override
public IInventory getDroppedInventory() {
return inventory;