Fixes for rendering
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package refinedstorage.block;
|
||||
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
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 +9,15 @@ 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.TileDiskDrive;
|
||||
|
||||
public class BlockDiskDrive extends BlockNode {
|
||||
public static final PropertyInteger STORED = PropertyInteger.create("stored", 0, 7);
|
||||
|
||||
public BlockDiskDrive() {
|
||||
super("disk_drive");
|
||||
}
|
||||
@@ -22,6 +27,19 @@ public class BlockDiskDrive extends BlockNode {
|
||||
return new TileDiskDrive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateContainer createBlockState() {
|
||||
return createBlockStateBuilder()
|
||||
.add(STORED)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return super.getActualState(state, world, pos)
|
||||
.withProperty(STORED, ((TileDiskDrive) world.getTileEntity(pos)).getStoredForDisplay());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (!world.isRemote) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package refinedstorage.block;
|
||||
|
||||
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;
|
||||
@@ -16,8 +14,6 @@ import refinedstorage.RefinedStorageGui;
|
||||
import refinedstorage.tile.TileSolderer;
|
||||
|
||||
public class BlockSolderer extends BlockNode {
|
||||
public static final PropertyBool WORKING = PropertyBool.create("working");
|
||||
|
||||
public BlockSolderer() {
|
||||
super("solderer");
|
||||
}
|
||||
@@ -37,15 +33,12 @@ public class BlockSolderer extends BlockNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return createBlockStateBuilder()
|
||||
.add(WORKING)
|
||||
.build();
|
||||
public boolean isBlockSolid(IBlockAccess worldIn, BlockPos pos, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return super.getActualState(state, world, pos)
|
||||
.withProperty(WORKING, ((TileSolderer) world.getTileEntity(pos)).isWorking());
|
||||
public EnumPlacementType getPlacementType() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ public class TileDiskDrive extends TileNode implements IStorageProvider, IStorag
|
||||
private static final String NBT_PRIORITY = "Priority";
|
||||
private static final String NBT_COMPARE = "Compare";
|
||||
private static final String NBT_MODE = "Mode";
|
||||
private static final String NBT_STORED = "Stored";
|
||||
|
||||
private BasicItemHandler disks = new BasicItemHandler(8, this, new BasicItemValidator(RefinedStorageItems.STORAGE_DISK)) {
|
||||
@Override
|
||||
@@ -84,6 +85,20 @@ public class TileDiskDrive extends TileNode implements IStorageProvider, IStorag
|
||||
private int priority = 0;
|
||||
private int compare = 0;
|
||||
private int mode = ModeConstants.WHITELIST;
|
||||
private int stored = 0;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!worldObj.isRemote) {
|
||||
if (stored != getStoredForDisplayServer()) {
|
||||
stored = getStoredForDisplayServer();
|
||||
|
||||
RefinedStorageUtils.updateBlock(worldObj, pos);
|
||||
}
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
@@ -166,6 +181,22 @@ public class TileDiskDrive extends TileNode implements IStorageProvider, IStorag
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeUpdate(NBTTagCompound tag) {
|
||||
super.writeUpdate(tag);
|
||||
|
||||
tag.setInteger(NBT_STORED, stored);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readUpdate(NBTTagCompound tag) {
|
||||
stored = tag.getInteger(NBT_STORED);
|
||||
|
||||
super.readUpdate(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeContainerData(ByteBuf buf) {
|
||||
super.writeContainerData(buf);
|
||||
@@ -213,6 +244,30 @@ public class TileDiskDrive extends TileNode implements IStorageProvider, IStorag
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public int getStoredForDisplayServer() {
|
||||
float stored = 0;
|
||||
float storedMax = 0;
|
||||
|
||||
for (int i = 0; i < disks.getSlots(); ++i) {
|
||||
ItemStack disk = disks.getStackInSlot(i);
|
||||
|
||||
if (disk != null) {
|
||||
stored += NBTStorage.getStoredFromNBT(disk.getTagCompound());
|
||||
storedMax += EnumStorageType.getById(disk.getItemDamage()).getCapacity();
|
||||
}
|
||||
}
|
||||
|
||||
if (storedMax == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) Math.floor((stored / storedMax) * 7f);
|
||||
}
|
||||
|
||||
public int getStoredForDisplay() {
|
||||
return stored;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTitle() {
|
||||
return "block.refinedstorage:disk_drive.name";
|
||||
|
||||
@@ -155,10 +155,10 @@ public abstract class TileNode extends TileBase implements INetworkNode, ISynchr
|
||||
}
|
||||
|
||||
public void readUpdate(NBTTagCompound tag) {
|
||||
super.readUpdate(tag);
|
||||
|
||||
if (canSendConnectivityUpdate()) {
|
||||
connected = tag.getBoolean(NBT_CONNECTED);
|
||||
}
|
||||
|
||||
super.readUpdate(tag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,22 +138,6 @@ public class TileSolderer extends TileNode {
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeUpdate(NBTTagCompound tag) {
|
||||
super.writeUpdate(tag);
|
||||
|
||||
tag.setBoolean(NBT_WORKING, working);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readUpdate(NBTTagCompound tag) {
|
||||
working = tag.getBoolean(NBT_WORKING);
|
||||
|
||||
super.readUpdate(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readContainerData(ByteBuf buf) {
|
||||
super.readContainerData(buf);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"textures": {
|
||||
"side": "refinedstorage:blocks/side",
|
||||
"top": "refinedstorage:blocks/side",
|
||||
"front": "refinedstorage:blocks/disk_drive"
|
||||
"front": "refinedstorage:blocks/disk_drive_0"
|
||||
}
|
||||
},
|
||||
"variants": {
|
||||
@@ -15,6 +15,48 @@
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"stored": {
|
||||
"0": {
|
||||
"textures": {
|
||||
"front": "refinedstorage:blocks/disk_drive_0"
|
||||
}
|
||||
},
|
||||
"1": {
|
||||
"textures": {
|
||||
"front": "refinedstorage:blocks/disk_drive_1"
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"textures": {
|
||||
"front": "refinedstorage:blocks/disk_drive_2"
|
||||
}
|
||||
},
|
||||
"3": {
|
||||
"textures": {
|
||||
"front": "refinedstorage:blocks/disk_drive_3"
|
||||
}
|
||||
},
|
||||
"4": {
|
||||
"textures": {
|
||||
"front": "refinedstorage:blocks/disk_drive_4"
|
||||
}
|
||||
},
|
||||
"5": {
|
||||
"textures": {
|
||||
"front": "refinedstorage:blocks/disk_drive_5"
|
||||
}
|
||||
},
|
||||
"6": {
|
||||
"textures": {
|
||||
"front": "refinedstorage:blocks/disk_drive_6"
|
||||
}
|
||||
},
|
||||
"7": {
|
||||
"textures": {
|
||||
"front": "refinedstorage:blocks/disk_drive_7"
|
||||
}
|
||||
}
|
||||
},
|
||||
"direction": {
|
||||
"north": {
|
||||
"y": 0
|
||||
|
||||
@@ -1,48 +1,21 @@
|
||||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"model": "orientable",
|
||||
"textures": {
|
||||
"side": "refinedstorage:blocks/side",
|
||||
"top": "refinedstorage:blocks/side",
|
||||
"front": "refinedstorage:blocks/solderer"
|
||||
}
|
||||
"particle": "refinedstorage:blocks/quartz_enriched_iron_block"
|
||||
},
|
||||
"model": "refinedstorage:solderer",
|
||||
"uvlock": true
|
||||
},
|
||||
"variants": {
|
||||
"inventory": [
|
||||
{
|
||||
"y": 0,
|
||||
"model": "refinedstorage:solderer",
|
||||
"transform": "forge:default-block"
|
||||
}
|
||||
],
|
||||
"working": {
|
||||
"true": {
|
||||
"textures": {
|
||||
"front": "refinedstorage:blocks/solderer_working"
|
||||
}
|
||||
},
|
||||
"false": {
|
||||
}
|
||||
},
|
||||
"direction": {
|
||||
"north": {
|
||||
"y": 0
|
||||
},
|
||||
"east": {
|
||||
"y": 90
|
||||
},
|
||||
"south": {
|
||||
"y": 180
|
||||
},
|
||||
"west": {
|
||||
"y": 270
|
||||
},
|
||||
"up": {
|
||||
"x": 270
|
||||
},
|
||||
"down": {
|
||||
"x": 90
|
||||
}
|
||||
"normal": {
|
||||
"model": "refinedstorage:solderer"
|
||||
}
|
||||
}
|
||||
}
|
||||
8
src/main/resources/assets/refinedstorage/models/block/solderer.json
Normal file → Executable file
8
src/main/resources/assets/refinedstorage/models/block/solderer.json
Normal file → Executable file
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
|
||||
"textures": {
|
||||
"0": "refinedstorage:blocks/quartz_enriched_iron_block.pngquartz_enriched_iron_block",
|
||||
"1": "refinedstorage:blocks/side.pngside",
|
||||
"2": "blocks/quartz_enriched_iron_block",
|
||||
"3": "blocks/redstone_block.pngredstone_block",
|
||||
"0": "refinedstorage:blocks/quartz_enriched_iron_block",
|
||||
"1": "refinedstorage:blocks/side",
|
||||
"2": "refinedstorage:blocks/quartz_enriched_iron_block",
|
||||
"3": "blocks/redstone_block",
|
||||
"4": "blocks/redstone_block"
|
||||
},
|
||||
"elements": [
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 448 B After Width: | Height: | Size: 714 B |
Reference in New Issue
Block a user