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; 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.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -7,12 +10,16 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import refinedstorage.RefinedStorage; import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui; import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileDetector;
import refinedstorage.tile.TileSolderer; import refinedstorage.tile.TileSolderer;
public class BlockSolderer extends BlockMachine { public class BlockSolderer extends BlockMachine {
public static final PropertyBool WORKING = PropertyBool.create("working");
public BlockSolderer() { public BlockSolderer() {
super("solderer"); super("solderer");
} }
@@ -30,4 +37,19 @@ public class BlockSolderer extends BlockMachine {
return true; 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) { public void receiveContainerData(ByteBuf buf) {
super.receiveContainerData(buf); super.receiveContainerData(buf);
working = buf.readBoolean();
progress = buf.readInt(); progress = buf.readInt();
duration = buf.readInt(); duration = buf.readInt();
} }
@@ -131,11 +130,30 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
public void sendContainerData(ByteBuf buf) { public void sendContainerData(ByteBuf buf) {
super.sendContainerData(buf); super.sendContainerData(buf);
buf.writeBoolean(working);
buf.writeInt(progress); buf.writeInt(progress);
buf.writeInt(recipe != null ? recipe.getDuration() : 0); 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 @Override
public Class<? extends Container> getContainer() { public Class<? extends Container> getContainer() {
return ContainerSolderer.class; return ContainerSolderer.class;
@@ -145,18 +163,10 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
return working; return working;
} }
public int getProgress() {
return progress;
}
public int getProgressScaled(int i) { public int getProgressScaled(int i) {
return (int) ((float) progress / (float) duration * (float) i); return (int) ((float) progress / (float) duration * (float) i);
} }
public int getDuration() {
return duration;
}
@Override @Override
public IInventory getDroppedInventory() { public IInventory getDroppedInventory() {
return inventory; return inventory;

View File

@@ -1,18 +1,15 @@
{ {
"forge_marker": 1, "forge_marker": 1,
"defaults": { "defaults": {
"model": "orientable", "model": "cube_all",
"textures": { "textures": {
"side": "refinedstorage:blocks/side", "all": "refinedstorage:blocks/crafter"
"top": "refinedstorage:blocks/side",
"front": "refinedstorage:blocks/crafter"
} }
}, },
"variants": { "variants": {
"inventory": [ "inventory": [
{ {
"transform": "forge:default-block", "transform": "forge:default-block"
"y": 0
} }
], ],
"connected": { "connected": {
@@ -23,22 +20,16 @@
}, },
"direction": { "direction": {
"north": { "north": {
"y": 0
}, },
"east": { "east": {
"y": 90
}, },
"south": { "south": {
"y": 180
}, },
"west": { "west": {
"y": 270
}, },
"up": { "up": {
"x": 270
}, },
"down": { "down": {
"x": 90
} }
} }
} }

View File

@@ -4,29 +4,30 @@
"model": "orientable", "model": "orientable",
"textures": { "textures": {
"side": "refinedstorage:blocks/side", "side": "refinedstorage:blocks/side",
"top": "refinedstorage:blocks/side" "top": "refinedstorage:blocks/side",
"front": "refinedstorage:blocks/solderer"
} }
}, },
"variants": { "variants": {
"inventory": [ "inventory": [
{ {
"y": 0, "y": 0,
"textures": {
"front": "refinedstorage:blocks/solderer_disconnected"
},
"transform": "forge:default-block" "transform": "forge:default-block"
} }
], ],
"connected": { "connected": {
"true": {
},
"false": {
}
},
"working": {
"true": { "true": {
"textures": { "textures": {
"front": "refinedstorage:blocks/solderer_connected" "front": "refinedstorage:blocks/solderer_working"
} }
}, },
"false": { "false": {
"textures": {
"front": "refinedstorage:blocks/solderer_disconnected"
}
} }
}, },
"direction": { "direction": {