Fixed a minor problem with redudant calls to world.getBlockState(pos) (#1835)
* Fixed minor performance issue with world.getBlockState(pos) * Removed redundant cast call * Update TilePortableGrid.java Unnecessary blank line removed * Removed some more redundant cast call * Removed Changelog entry * Undo Casts * Update BlockBase.java Undo casts * Undo Changes - CapabilityProviderEnergy
This commit is contained in:
@@ -29,6 +29,7 @@ import com.raoulvdberge.refinedstorage.item.ItemPattern;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.*;
|
||||
@@ -208,8 +209,11 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware {
|
||||
}
|
||||
|
||||
public GridType getType() {
|
||||
if (type == null && world.getBlockState(pos).getBlock() == RSBlocks.GRID) {
|
||||
type = (GridType) world.getBlockState(pos).getValue(BlockGrid.TYPE);
|
||||
if (type == null) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() == RSBlocks.GRID) {
|
||||
type = (GridType) state.getValue(BlockGrid.TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
return type == null ? GridType.NORMAL : type;
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.raoulvdberge.refinedstorage.tile.config.IPrioritizable;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import com.raoulvdberge.refinedstorage.util.AccessTypeUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -172,8 +173,11 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
|
||||
}
|
||||
|
||||
public FluidStorageType getType() {
|
||||
if (type == null && world != null && world.getBlockState(pos).getBlock() == RSBlocks.FLUID_STORAGE) {
|
||||
type = (FluidStorageType) world.getBlockState(pos).getValue(BlockFluidStorage.TYPE);
|
||||
if (type == null && world != null) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() == RSBlocks.FLUID_STORAGE) {
|
||||
type = (FluidStorageType) state.getValue(BlockFluidStorage.TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
return type == null ? FluidStorageType.TYPE_64K : type;
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.raoulvdberge.refinedstorage.tile.config.IPrioritizable;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import com.raoulvdberge.refinedstorage.util.AccessTypeUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -172,8 +173,11 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
|
||||
}
|
||||
|
||||
public ItemStorageType getType() {
|
||||
if (type == null && world != null && world.getBlockState(pos).getBlock() == RSBlocks.STORAGE) {
|
||||
type = (ItemStorageType) world.getBlockState(pos).getValue(BlockStorage.TYPE);
|
||||
if (type == null && world != null) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() == RSBlocks.STORAGE) {
|
||||
type = (ItemStorageType) state.getValue(BlockStorage.TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
return type == null ? ItemStorageType.TYPE_1K : type;
|
||||
|
||||
@@ -638,8 +638,11 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
||||
}
|
||||
|
||||
public ControllerType getType() {
|
||||
if (type == null && world.getBlockState(pos).getBlock() == RSBlocks.CONTROLLER) {
|
||||
this.type = (ControllerType) world.getBlockState(pos).getValue(BlockController.TYPE);
|
||||
if (type == null) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() == RSBlocks.CONTROLLER) {
|
||||
this.type = (ControllerType) state.getValue(BlockController.TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
return type == null ? ControllerType.NORMAL : type;
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.InventoryCraftResult;
|
||||
@@ -184,8 +185,11 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
||||
}
|
||||
|
||||
public PortableGridType getPortableType() {
|
||||
if (type == null && world.getBlockState(pos).getBlock() == RSBlocks.PORTABLE_GRID) {
|
||||
this.type = (PortableGridType) world.getBlockState(pos).getValue(BlockPortableGrid.TYPE);
|
||||
if (type == null) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() == RSBlocks.PORTABLE_GRID) {
|
||||
this.type = (PortableGridType) state.getValue(BlockPortableGrid.TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
return type == null ? PortableGridType.NORMAL : type;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.raoulvdberge.refinedstorage.util;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
@@ -22,7 +23,8 @@ import javax.annotation.Nullable;
|
||||
public final class WorldUtils {
|
||||
public static void updateBlock(@Nullable World world, BlockPos pos) {
|
||||
if (world != null) {
|
||||
world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 1 | 2);
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
world.notifyBlockUpdate(pos, state, state, 1 | 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user