Added CTM integration
@@ -5,7 +5,6 @@ import com.raoulvdberge.refinedstorage.RSGui;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemBlockController;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileController;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -22,10 +21,11 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockController extends BlockBase {
|
||||
public static final PropertyEnum TYPE = PropertyEnum.create("type", ControllerType.class);
|
||||
|
||||
private static final PropertyInteger ENERGY = PropertyInteger.create("energy", 0, 7);
|
||||
public static final PropertyEnum ENERGY_TYPE = PropertyEnum.create("energy_type", ControllerEnergyType.class);
|
||||
|
||||
public BlockController() {
|
||||
super("controller");
|
||||
@@ -42,7 +42,7 @@ public class BlockController extends BlockBase {
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return createBlockStateBuilder()
|
||||
.add(TYPE)
|
||||
.add(ENERGY)
|
||||
.add(ENERGY_TYPE)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class BlockController extends BlockBase {
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return super.getActualState(state, world, pos)
|
||||
.withProperty(ENERGY, ((TileController) world.getTileEntity(pos)).getEnergyScaledForDisplay());
|
||||
.withProperty(ENERGY_TYPE, ((TileController) world.getTileEntity(pos)).getEnergyType());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,4 +111,10 @@ public class BlockController extends BlockBase {
|
||||
public Item createItem() {
|
||||
return new ItemBlockController();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Direction getDirection() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.raoulvdberge.refinedstorage.block;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum ControllerEnergyType implements IStringSerializable {
|
||||
OFF(0, "off"),
|
||||
NEARLY_OFF(1, "nearly_off"),
|
||||
NEARLY_ON(2, "nearly_on"),
|
||||
ON(3, "on");
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
|
||||
ControllerEnergyType(int id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static ControllerEnergyType getById(int id) {
|
||||
for (ControllerEnergyType type : values()) {
|
||||
if (type.id == id) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return OFF;
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMap;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
@@ -46,6 +47,7 @@ import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
@@ -274,11 +276,16 @@ public class ProxyClient extends ProxyCommon {
|
||||
});
|
||||
|
||||
// Controller
|
||||
ModelLoader.setCustomStateMapper(RSBlocks.CONTROLLER, new StateMap.Builder().ignore(BlockController.TYPE).build());
|
||||
ModelLoader.setCustomStateMapper(RSBlocks.CONTROLLER, new StateMapperBase() {
|
||||
@Override
|
||||
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
|
||||
return new ModelResourceLocation("refinedstorage:controller" + (Loader.isModLoaded("ctm") ? "_glow" : ""), "energy_type=" + state.getValue(BlockController.ENERGY_TYPE));
|
||||
}
|
||||
});
|
||||
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(RSBlocks.CONTROLLER), stack -> {
|
||||
int energy = stack.getItemDamage() == ControllerType.CREATIVE.getId() ? 7 : TileController.getEnergyScaled(ItemBlockController.getEnergyStored(stack), ItemBlockController.getEnergyCapacity(stack), 7);
|
||||
ControllerEnergyType energyType = stack.getItemDamage() == ControllerType.CREATIVE.getId() ? ControllerEnergyType.ON : TileController.getEnergyType(ItemBlockController.getEnergyStored(stack), ItemBlockController.getEnergyCapacity(stack));
|
||||
|
||||
return new ModelResourceLocation("refinedstorage:controller", "direction=north,energy=" + energy);
|
||||
return new ModelResourceLocation("refinedstorage:controller" + (Loader.isModLoaded("ctm") ? "_glow" : ""), "energy_type=" + energyType);
|
||||
});
|
||||
|
||||
// Portable Grid
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.security.SecurityManager;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheFluid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheItem;
|
||||
import com.raoulvdberge.refinedstorage.block.BlockController;
|
||||
import com.raoulvdberge.refinedstorage.block.ControllerEnergyType;
|
||||
import com.raoulvdberge.refinedstorage.block.ControllerType;
|
||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerCraftingMonitor;
|
||||
@@ -114,6 +115,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
||||
|
||||
public static final String NBT_ENERGY = "Energy";
|
||||
public static final String NBT_ENERGY_CAPACITY = "EnergyCapacity";
|
||||
public static final String NBT_ENERGY_TYPE = "EnergyType";
|
||||
|
||||
private static final String NBT_READER_WRITER_CHANNELS = "ReaderWriterChannels";
|
||||
private static final String NBT_READER_WRITER_NAME = "Name";
|
||||
@@ -136,14 +138,13 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
||||
|
||||
private EnergyForge energy = new EnergyForge(RS.INSTANCE.config.controllerCapacity);
|
||||
|
||||
private int lastEnergyDisplay;
|
||||
|
||||
private boolean couldRun;
|
||||
private int ticksSinceUpdateChanged;
|
||||
|
||||
private boolean craftingMonitorUpdateRequested;
|
||||
|
||||
private ControllerType type;
|
||||
private ControllerEnergyType energyType;
|
||||
|
||||
private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
||||
|
||||
@@ -235,10 +236,10 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
||||
ticksSinceUpdateChanged = 0;
|
||||
}
|
||||
|
||||
int energyDisplay = getEnergyScaledForDisplay();
|
||||
ControllerEnergyType energyType = getEnergyType();
|
||||
|
||||
if (lastEnergyDisplay != energyDisplay) {
|
||||
lastEnergyDisplay = energyDisplay;
|
||||
if (this.energyType != energyType) {
|
||||
this.energyType = energyType;
|
||||
|
||||
WorldUtils.updateBlock(world, pos);
|
||||
}
|
||||
@@ -635,16 +636,16 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
||||
public NBTTagCompound writeUpdate(NBTTagCompound tag) {
|
||||
super.writeUpdate(tag);
|
||||
|
||||
tag.setInteger(NBT_ENERGY_CAPACITY, energy.getMaxEnergyStored());
|
||||
tag.setInteger(NBT_ENERGY, energy.getEnergyStored());
|
||||
tag.setInteger(NBT_ENERGY_TYPE, getEnergyType().getId());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readUpdate(NBTTagCompound tag) {
|
||||
energy.setMaxEnergyStored(tag.getInteger(NBT_ENERGY_CAPACITY));
|
||||
energy.setEnergyStored(tag.getInteger(NBT_ENERGY));
|
||||
if (tag.hasKey(NBT_ENERGY_TYPE)) {
|
||||
this.energyType = ControllerEnergyType.getById(tag.getInteger(NBT_ENERGY_TYPE));
|
||||
}
|
||||
|
||||
super.readUpdate(tag);
|
||||
}
|
||||
@@ -653,8 +654,26 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
||||
return (int) ((float) stored / (float) capacity * (float) scale);
|
||||
}
|
||||
|
||||
public int getEnergyScaledForDisplay() {
|
||||
return getEnergyScaled(energy.getEnergyStored(), energy.getMaxEnergyStored(), 7);
|
||||
public static ControllerEnergyType getEnergyType(int stored, int capacity) {
|
||||
int energy = getEnergyScaled(stored, capacity, 100);
|
||||
|
||||
if (energy <= 0) {
|
||||
return ControllerEnergyType.OFF;
|
||||
} else if (energy <= 10) {
|
||||
return ControllerEnergyType.NEARLY_OFF;
|
||||
} else if (energy <= 20) {
|
||||
return ControllerEnergyType.NEARLY_ON;
|
||||
}
|
||||
|
||||
return ControllerEnergyType.ON;
|
||||
}
|
||||
|
||||
public ControllerEnergyType getEnergyType() {
|
||||
if (world.isRemote) {
|
||||
return energyType;
|
||||
}
|
||||
|
||||
return getEnergyType(energy.getEnergyStored(), energy.getMaxEnergyStored());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"model": "orientable",
|
||||
"model": "cube_all",
|
||||
"textures": {
|
||||
"particle": "refinedstorage:blocks/controller_0",
|
||||
"side": "refinedstorage:blocks/controller_0",
|
||||
"top": "refinedstorage:blocks/controller_0",
|
||||
"front": "refinedstorage:blocks/controller_0"
|
||||
"particle": "refinedstorage:blocks/controller_off",
|
||||
"all": "refinedstorage:blocks/controller_off"
|
||||
}
|
||||
},
|
||||
"variants": {
|
||||
@@ -15,80 +13,23 @@
|
||||
"transform": "forge:default-block"
|
||||
}
|
||||
],
|
||||
"energy": {
|
||||
"0": {
|
||||
"energy_type": {
|
||||
"off": {
|
||||
},
|
||||
"nearly_off": {
|
||||
"textures": {
|
||||
"front": "refinedstorage:blocks/controller_0"
|
||||
"all": "refinedstorage:blocks/controller_nearly_off"
|
||||
}
|
||||
},
|
||||
"1": {
|
||||
"nearly_on": {
|
||||
"textures": {
|
||||
"side": "refinedstorage:blocks/controller_1",
|
||||
"top": "refinedstorage:blocks/controller_1",
|
||||
"front": "refinedstorage:blocks/controller_1"
|
||||
"all": "refinedstorage:blocks/controller_nearly_on"
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"on": {
|
||||
"textures": {
|
||||
"side": "refinedstorage:blocks/controller_2",
|
||||
"top": "refinedstorage:blocks/controller_2",
|
||||
"front": "refinedstorage:blocks/controller_2"
|
||||
"all": "refinedstorage:blocks/controller_on"
|
||||
}
|
||||
},
|
||||
"3": {
|
||||
"textures": {
|
||||
"side": "refinedstorage:blocks/controller_on",
|
||||
"top": "refinedstorage:blocks/controller_on",
|
||||
"front": "refinedstorage:blocks/controller_on"
|
||||
}
|
||||
},
|
||||
"4": {
|
||||
"textures": {
|
||||
"side": "refinedstorage:blocks/controller_on",
|
||||
"top": "refinedstorage:blocks/controller_on",
|
||||
"front": "refinedstorage:blocks/controller_on"
|
||||
}
|
||||
},
|
||||
"5": {
|
||||
"textures": {
|
||||
"side": "refinedstorage:blocks/controller_on",
|
||||
"top": "refinedstorage:blocks/controller_on",
|
||||
"front": "refinedstorage:blocks/controller_on"
|
||||
}
|
||||
},
|
||||
"6": {
|
||||
"textures": {
|
||||
"side": "refinedstorage:blocks/controller_on",
|
||||
"top": "refinedstorage:blocks/controller_on",
|
||||
"front": "refinedstorage:blocks/controller_on"
|
||||
}
|
||||
},
|
||||
"7": {
|
||||
"textures": {
|
||||
"side": "refinedstorage:blocks/controller_on",
|
||||
"top": "refinedstorage:blocks/controller_on",
|
||||
"front": "refinedstorage:blocks/controller_on"
|
||||
}
|
||||
}
|
||||
},
|
||||
"direction": {
|
||||
"north": {
|
||||
"y": 0
|
||||
},
|
||||
"east": {
|
||||
"y": 90
|
||||
},
|
||||
"south": {
|
||||
"y": 180
|
||||
},
|
||||
"west": {
|
||||
"y": 270
|
||||
},
|
||||
"up": {
|
||||
"x": 270
|
||||
},
|
||||
"down": {
|
||||
"x": 90
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"model": "refinedstorage:cube_all_glow",
|
||||
"textures": {
|
||||
"particle": "refinedstorage:blocks/controller_off",
|
||||
"all": "refinedstorage:blocks/controller_off",
|
||||
"glow": "refinedstorage:blocks/none"
|
||||
}
|
||||
},
|
||||
"variants": {
|
||||
"inventory": [
|
||||
{
|
||||
"transform": "forge:default-block"
|
||||
}
|
||||
],
|
||||
"energy_type": {
|
||||
"off": {
|
||||
},
|
||||
"nearly_off": {
|
||||
"textures": {
|
||||
"all": "refinedstorage:blocks/controller_nearly_off",
|
||||
"glow": "refinedstorage:blocks/controller_nearly_off_glow"
|
||||
}
|
||||
},
|
||||
"nearly_on": {
|
||||
"textures": {
|
||||
"all": "refinedstorage:blocks/controller_nearly_on",
|
||||
"glow": "refinedstorage:blocks/controller_nearly_on_glow"
|
||||
}
|
||||
},
|
||||
"on": {
|
||||
"textures": {
|
||||
"all": "refinedstorage:blocks/controller_on",
|
||||
"glow": "refinedstorage:blocks/controller_on_glow"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"parent": "block/cube_all",
|
||||
"ambientocclusion": false,
|
||||
"elements": [
|
||||
{
|
||||
"from": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"to": [
|
||||
16,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"faces": {
|
||||
"down": {
|
||||
"texture": "#all",
|
||||
"cullface": "down"
|
||||
},
|
||||
"up": {
|
||||
"texture": "#all",
|
||||
"cullface": "up"
|
||||
},
|
||||
"north": {
|
||||
"texture": "#all",
|
||||
"cullface": "north"
|
||||
},
|
||||
"south": {
|
||||
"texture": "#all",
|
||||
"cullface": "south"
|
||||
},
|
||||
"west": {
|
||||
"texture": "#all",
|
||||
"cullface": "west"
|
||||
},
|
||||
"east": {
|
||||
"texture": "#all",
|
||||
"cullface": "east"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"to": [
|
||||
16,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"shade": false,
|
||||
"faces": {
|
||||
"down": {
|
||||
"texture": "#glow",
|
||||
"cullface": "down"
|
||||
},
|
||||
"up": {
|
||||
"texture": "#glow",
|
||||
"cullface": "up"
|
||||
},
|
||||
"north": {
|
||||
"texture": "#glow",
|
||||
"cullface": "north"
|
||||
},
|
||||
"south": {
|
||||
"texture": "#glow",
|
||||
"cullface": "south"
|
||||
},
|
||||
"west": {
|
||||
"texture": "#glow",
|
||||
"cullface": "west"
|
||||
},
|
||||
"east": {
|
||||
"texture": "#glow",
|
||||
"cullface": "east"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"animation": {
|
||||
"frametime": 2,
|
||||
"frametime": 2,
|
||||
"frames": [
|
||||
0,
|
||||
1,
|
||||
|
||||
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"animation": {
|
||||
"frametime": 1,
|
||||
"frametime": 1,
|
||||
"frames": [
|
||||
0,
|
||||
1,
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"ctm": {
|
||||
"ctm_version": 1,
|
||||
"layer": "CUTOUT",
|
||||
"extra": {
|
||||
"light": 15
|
||||
}
|
||||
},
|
||||
"animation": {
|
||||
"frametime": 1,
|
||||
"frames": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"animation": {
|
||||
"frametime": 2,
|
||||
"frametime": 2,
|
||||
"frames": [
|
||||
0,
|
||||
1,
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"ctm": {
|
||||
"ctm_version": 1,
|
||||
"layer": "CUTOUT",
|
||||
"extra": {
|
||||
"light": 15
|
||||
}
|
||||
},
|
||||
"animation": {
|
||||
"frametime": 2,
|
||||
"frames": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"animation": {
|
||||
"frametime": 2,
|
||||
"frametime": 2,
|
||||
"frames": [
|
||||
0,
|
||||
1,
|
||||
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"ctm": {
|
||||
"ctm_version": 1,
|
||||
"layer": "CUTOUT",
|
||||
"extra": {
|
||||
"light": 15
|
||||
}
|
||||
},
|
||||
"animation": {
|
||||
"frametime": 2,
|
||||
"frames": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.8 KiB |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"animation": {
|
||||
"frametime": 1,
|
||||
"frametime": 1,
|
||||
"frames": [
|
||||
0,
|
||||
1,
|
||||
@@ -14,14 +14,14 @@
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 198 B |
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ctm": {
|
||||
"ctm_version": 1,
|
||||
"layer": "CUTOUT",
|
||||
"extra": {
|
||||
"light": 15
|
||||
}
|
||||
}
|
||||
}
|
||||