Decreased amount of block updates significantly

This commit is contained in:
Raoul Van den Berge
2016-07-08 14:43:40 +02:00
parent 35e2f1d9cf
commit 33ef02f13c
22 changed files with 57 additions and 80 deletions

View File

@@ -11,6 +11,7 @@
**Features**
- Re-added Controllers exploding when two of them are connected to the same network
- Limited some blocks to only have a direction on the x-axis
- Decreased amount of block updates significantly
### 0.8.5
**Bugfixes**

View File

@@ -11,11 +11,6 @@ public interface INetworkNode {
*/
void updateNode();
/**
* @return If this node can send a connectivity update
*/
boolean canSendConnectivityUpdate();
/**
* @return The energy usage of this node
*/

View File

@@ -35,7 +35,7 @@ public class BlockCable extends BlockNode {
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer.Builder(this)
return createBlockStateBuilder()
.add(NORTH)
.add(EAST)
.add(SOUTH)
@@ -47,7 +47,8 @@ public class BlockCable extends BlockNode {
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
return state.withProperty(NORTH, hasConnectionWith(world, pos.north()))
return super.getActualState(state, world, pos)
.withProperty(NORTH, hasConnectionWith(world, pos.north()))
.withProperty(EAST, hasConnectionWith(world, pos.east()))
.withProperty(SOUTH, hasConnectionWith(world, pos.south()))
.withProperty(WEST, hasConnectionWith(world, pos.west()))

View File

@@ -35,4 +35,8 @@ public class BlockCrafter extends BlockNode {
public EnumDirectionType getDirectionType() {
return EnumDirectionType.ANY;
}
public boolean canRetrieveConnectivityUpdate() {
return true;
}
}

View File

@@ -30,4 +30,8 @@ public class BlockCraftingMonitor extends BlockNode {
return true;
}
public boolean canRetrieveConnectivityUpdate() {
return true;
}
}

View File

@@ -70,4 +70,8 @@ public class BlockGrid extends BlockNode {
public Item createItem() {
return new ItemBlockBase(this, true);
}
public boolean canRetrieveConnectivityUpdate() {
return true;
}
}

View File

@@ -25,9 +25,19 @@ public abstract class BlockNode extends BlockBase {
return true;
}
public boolean canRetrieveConnectivityUpdate() {
return false;
}
@Override
protected BlockStateContainer.Builder createBlockStateBuilder() {
return super.createBlockStateBuilder().add(CONNECTED);
BlockStateContainer.Builder builder = super.createBlockStateBuilder();
if (canRetrieveConnectivityUpdate()) {
builder.add(CONNECTED);
}
return builder;
}
@Override
@@ -37,8 +47,11 @@ public abstract class BlockNode extends BlockBase {
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
return super.getActualState(state, world, pos)
.withProperty(CONNECTED, ((TileNode) world.getTileEntity(pos)).isConnected());
if (canRetrieveConnectivityUpdate()) {
return super.getActualState(state, world, pos).withProperty(CONNECTED, ((TileNode) world.getTileEntity(pos)).isConnected());
}
return super.getActualState(state, world, pos);
}
@Override

View File

@@ -35,4 +35,8 @@ public class BlockRelay extends BlockNode {
public EnumDirectionType getDirectionType() {
return null;
}
public boolean canRetrieveConnectivityUpdate() {
return true;
}
}

View File

@@ -29,6 +29,8 @@ public class BlockStorage extends BlockNode {
public BlockStorage() {
super("storage");
setHardness(2.8F);
}
@Override

View File

@@ -30,4 +30,8 @@ public class BlockWirelessTransmitter extends BlockNode {
return true;
}
public boolean canRetrieveConnectivityUpdate() {
return true;
}
}

View File

@@ -3,7 +3,6 @@ package refinedstorage.proxy;
import net.minecraft.client.Minecraft;
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.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
@@ -102,11 +101,6 @@ public class ClientProxy extends CommonProxy {
ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_STACK, new ModelResourceLocation("refinedstorage:stack_upgrade", "inventory"));
// Blocks
ModelLoader.setCustomStateMapper(RefinedStorageBlocks.STORAGE, (new StateMap.Builder())
.ignore(RefinedStorageBlocks.STORAGE.CONNECTED)
.build()
);
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RefinedStorageBlocks.CABLE), 0, new ModelResourceLocation("refinedstorage:cable", "inventory"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RefinedStorageBlocks.GRID), EnumGridType.NORMAL.getId(), new ModelResourceLocation("refinedstorage:grid", "inventory"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RefinedStorageBlocks.GRID), EnumGridType.CRAFTING.getId(), new ModelResourceLocation("refinedstorage:grid", "inventory"));

View File

@@ -14,11 +14,6 @@ public class TileCable extends TileNode {
// NO OP
}
@Override
public boolean canSendConnectivityUpdate() {
return false;
}
@Override
public Class<? extends Container> getContainer() {
return null;

View File

@@ -1,11 +1,13 @@
package refinedstorage.tile;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import refinedstorage.RefinedStorageUtils;
import refinedstorage.api.network.INetworkMaster;
import refinedstorage.api.network.INetworkNode;
import refinedstorage.block.BlockNode;
import refinedstorage.tile.config.IRedstoneModeConfig;
import refinedstorage.tile.config.RedstoneMode;
@@ -28,9 +30,10 @@ public abstract class TileNode extends TileBase implements INetworkNode, ISynchr
return isConnected() && canUpdate();
}
@Override
public boolean canSendConnectivityUpdate() {
return true;
private boolean canRetrieveConnectivityUpdate() {
Block block = getBlockType();
return block instanceof BlockNode ? ((BlockNode) block).canRetrieveConnectivityUpdate() : false;
}
@Override
@@ -42,7 +45,7 @@ public abstract class TileNode extends TileBase implements INetworkNode, ISynchr
onConnectionChange(network, update);
}
if (active != isActive() && canSendConnectivityUpdate()) {
if (active != isActive() && canRetrieveConnectivityUpdate()) {
RefinedStorageUtils.updateBlock(worldObj, pos);
active = isActive();
@@ -144,7 +147,9 @@ public abstract class TileNode extends TileBase implements INetworkNode, ISynchr
public NBTTagCompound writeUpdate(NBTTagCompound tag) {
super.writeUpdate(tag);
tag.setBoolean(NBT_CONNECTED, isActive());
if (canRetrieveConnectivityUpdate()) {
tag.setBoolean(NBT_CONNECTED, isActive());
}
return tag;
}
@@ -152,6 +157,8 @@ public abstract class TileNode extends TileBase implements INetworkNode, ISynchr
public void readUpdate(NBTTagCompound tag) {
super.readUpdate(tag);
connected = tag.getBoolean(NBT_CONNECTED);
if (canRetrieveConnectivityUpdate()) {
connected = tag.getBoolean(NBT_CONNECTED);
}
}
}

View File

@@ -15,12 +15,6 @@
"transform": "forge:default-block"
}
],
"connected": {
"true": {
},
"false": {
}
},
"direction": {
"north": {
"y": 0

View File

@@ -15,12 +15,6 @@
"transform": "forge:default-block"
}
],
"connected": {
"true": {
},
"false": {
}
},
"direction": {
"north": {
"y": 0

View File

@@ -15,12 +15,6 @@
"transform": "forge:default-block"
}
],
"connected": {
"true": {
},
"false": {
}
},
"powered": {
"true": {
"textures": {

View File

@@ -15,12 +15,6 @@
"y": 0
}
],
"connected": {
"true": {
},
"false": {
}
},
"direction": {
"north": {
"y": 0

View File

@@ -15,12 +15,6 @@
"transform": "forge:default-block"
}
],
"connected": {
"true": {
},
"false": {
}
},
"direction": {
"north": {
"y": 0

View File

@@ -15,12 +15,6 @@
"transform": "forge:default-block"
}
],
"connected": {
"true": {
},
"false": {
}
},
"direction": {
"north": {
"y": 0

View File

@@ -15,12 +15,6 @@
"transform": "forge:default-block"
}
],
"connected": {
"true": {
},
"false": {
}
},
"direction": {
"north": {
"y": 0

View File

@@ -12,11 +12,8 @@
"transform": "forge:default-block"
}
],
"connected": {
"true": {
},
"false": {
}
"normal": {
"model": "cube_all"
}
}
}

View File

@@ -15,12 +15,6 @@
"transform": "forge:default-block"
}
],
"connected": {
"true": {
},
"false": {
}
},
"working": {
"true": {
"textures": {