Implement covers for importers, exporters and external storage.
This commit is contained in:
@@ -13,6 +13,7 @@ NOTE: Worlds that used Refined Storage 1.5.x are fully compatible with Refined S
|
|||||||
- Removed "compare oredict" buttons on Exporter, Importer, etc. (raoulvdberge)
|
- Removed "compare oredict" buttons on Exporter, Importer, etc. (raoulvdberge)
|
||||||
- Added the Cutting Tool (raoulvdberge)
|
- Added the Cutting Tool (raoulvdberge)
|
||||||
- Renamed "Printed Processors" to "Cut Processors" (raoulvdberge)
|
- Renamed "Printed Processors" to "Cut Processors" (raoulvdberge)
|
||||||
|
- Added covers (raoulvdberge)
|
||||||
- Rewrote autocrafting (raoulvdberge)
|
- Rewrote autocrafting (raoulvdberge)
|
||||||
- Rewrote network energy storage (samtrion)
|
- Rewrote network energy storage (samtrion)
|
||||||
- Autocrafting tasks that take longer than 5 seconds to CALCULATE (NOT execute) are automatically stopped to avoid server strain (raoulvdberge)
|
- Autocrafting tasks that take longer than 5 seconds to CALCULATE (NOT execute) are automatically stopped to avoid server strain (raoulvdberge)
|
||||||
|
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
|||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
|
||||||
@@ -17,17 +18,19 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
public class NetworkNodeExporter extends NetworkNode implements IComparable, IType {
|
public class NetworkNodeExporter extends NetworkNode implements IComparable, IType, ICoverable {
|
||||||
public static final String ID = "exporter";
|
public static final String ID = "exporter";
|
||||||
|
|
||||||
private static final String NBT_COMPARE = "Compare";
|
private static final String NBT_COMPARE = "Compare";
|
||||||
private static final String NBT_TYPE = "Type";
|
private static final String NBT_TYPE = "Type";
|
||||||
|
private static final String NBT_COVERS = "Covers";
|
||||||
|
|
||||||
private ItemHandlerBase itemFilters = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
private ItemHandlerBase itemFilters = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
||||||
private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, new ItemHandlerListenerNetworkNode(this));
|
private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, new ItemHandlerListenerNetworkNode(this));
|
||||||
@@ -37,6 +40,8 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
|
|||||||
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
|
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
|
||||||
private int type = IType.ITEMS;
|
private int type = IType.ITEMS;
|
||||||
|
|
||||||
|
private CoverManager coverManager = new CoverManager(this).setCanPlaceCoversOnFace(false);
|
||||||
|
|
||||||
private int filterSlot;
|
private int filterSlot;
|
||||||
|
|
||||||
public NetworkNodeExporter(World world, BlockPos pos) {
|
public NetworkNodeExporter(World world, BlockPos pos) {
|
||||||
@@ -149,12 +154,6 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
|
|||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(NBTTagCompound tag) {
|
|
||||||
super.read(tag);
|
|
||||||
|
|
||||||
StackUtils.readItems(upgrades, 1, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
@@ -167,6 +166,8 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
|
|||||||
|
|
||||||
StackUtils.writeItems(upgrades, 1, tag);
|
StackUtils.writeItems(upgrades, 1, tag);
|
||||||
|
|
||||||
|
tag.setTag(NBT_COVERS, coverManager.writeToNbt());
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,6 +184,17 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
|
|||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(NBTTagCompound tag) {
|
||||||
|
super.read(tag);
|
||||||
|
|
||||||
|
StackUtils.readItems(upgrades, 1, tag);
|
||||||
|
|
||||||
|
if (tag.hasKey(NBT_COVERS)) {
|
||||||
|
coverManager.readFromNbt(tag.getTagList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readConfiguration(NBTTagCompound tag) {
|
public void readConfiguration(NBTTagCompound tag) {
|
||||||
super.readConfiguration(tag);
|
super.readConfiguration(tag);
|
||||||
@@ -224,4 +236,9 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
|
|||||||
public IItemHandler getFilterInventory() {
|
public IItemHandler getFilterInventory() {
|
||||||
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CoverManager getCoverManager() {
|
||||||
|
return coverManager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@ import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStor
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
|
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheFluid;
|
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheFluid;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheItem;
|
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheItem;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
|
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
|
||||||
@@ -27,19 +28,21 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
public class NetworkNodeExternalStorage extends NetworkNode implements IStorageProvider, IGuiStorage, IComparable, IFilterable, IPrioritizable, IType, IAccessType, IExternalStorageContext {
|
public class NetworkNodeExternalStorage extends NetworkNode implements IStorageProvider, IGuiStorage, IComparable, IFilterable, IPrioritizable, IType, IAccessType, IExternalStorageContext, ICoverable {
|
||||||
public static final String ID = "external_storage";
|
public static final String ID = "external_storage";
|
||||||
|
|
||||||
private static final String NBT_PRIORITY = "Priority";
|
private static final String NBT_PRIORITY = "Priority";
|
||||||
private static final String NBT_COMPARE = "Compare";
|
private static final String NBT_COMPARE = "Compare";
|
||||||
private static final String NBT_MODE = "Mode";
|
private static final String NBT_MODE = "Mode";
|
||||||
private static final String NBT_TYPE = "Type";
|
private static final String NBT_TYPE = "Type";
|
||||||
|
private static final String NBT_COVERS = "Covers";
|
||||||
|
|
||||||
private ItemHandlerBase itemFilters = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
private ItemHandlerBase itemFilters = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
||||||
private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, new ItemHandlerListenerNetworkNode(this));
|
private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, new ItemHandlerListenerNetworkNode(this));
|
||||||
@@ -51,6 +54,8 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
|
|||||||
private AccessType accessType = AccessType.INSERT_EXTRACT;
|
private AccessType accessType = AccessType.INSERT_EXTRACT;
|
||||||
private int networkTicks;
|
private int networkTicks;
|
||||||
|
|
||||||
|
private CoverManager coverManager = new CoverManager(this).setCanPlaceCoversOnFace(false);
|
||||||
|
|
||||||
private List<IStorageExternal<ItemStack>> itemStorages = new CopyOnWriteArrayList<>();
|
private List<IStorageExternal<ItemStack>> itemStorages = new CopyOnWriteArrayList<>();
|
||||||
private List<IStorageExternal<FluidStack>> fluidStorages = new CopyOnWriteArrayList<>();
|
private List<IStorageExternal<FluidStack>> fluidStorages = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
@@ -96,6 +101,24 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
|
|||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(NBTTagCompound tag) {
|
||||||
|
super.read(tag);
|
||||||
|
|
||||||
|
if (tag.hasKey(NBT_COVERS)) {
|
||||||
|
coverManager.readFromNbt(tag.getTagList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NBTTagCompound write(NBTTagCompound tag) {
|
||||||
|
super.write(tag);
|
||||||
|
|
||||||
|
tag.setTag(NBT_COVERS, coverManager.writeToNbt());
|
||||||
|
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||||
super.writeConfiguration(tag);
|
super.writeConfiguration(tag);
|
||||||
@@ -318,4 +341,9 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
|
|||||||
public List<IStorageExternal<FluidStack>> getFluidStorages() {
|
public List<IStorageExternal<FluidStack>> getFluidStorages() {
|
||||||
return fluidStorages;
|
return fluidStorages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CoverManager getCoverManager() {
|
||||||
|
return coverManager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
|||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
|
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
|
||||||
@@ -21,17 +22,19 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
public class NetworkNodeImporter extends NetworkNode implements IComparable, IFilterable, IType {
|
public class NetworkNodeImporter extends NetworkNode implements IComparable, IFilterable, IType, ICoverable {
|
||||||
public static final String ID = "importer";
|
public static final String ID = "importer";
|
||||||
|
|
||||||
private static final String NBT_COMPARE = "Compare";
|
private static final String NBT_COMPARE = "Compare";
|
||||||
private static final String NBT_MODE = "Mode";
|
private static final String NBT_MODE = "Mode";
|
||||||
private static final String NBT_TYPE = "Type";
|
private static final String NBT_TYPE = "Type";
|
||||||
|
private static final String NBT_COVERS = "Covers";
|
||||||
|
|
||||||
private ItemHandlerBase itemFilters = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
private ItemHandlerBase itemFilters = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
||||||
private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, new ItemHandlerListenerNetworkNode(this));
|
private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, new ItemHandlerListenerNetworkNode(this));
|
||||||
@@ -42,6 +45,8 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
|
|||||||
private int mode = IFilterable.BLACKLIST;
|
private int mode = IFilterable.BLACKLIST;
|
||||||
private int type = IType.ITEMS;
|
private int type = IType.ITEMS;
|
||||||
|
|
||||||
|
private CoverManager coverManager = new CoverManager(this).setCanPlaceCoversOnFace(false);
|
||||||
|
|
||||||
private int currentSlot;
|
private int currentSlot;
|
||||||
|
|
||||||
public NetworkNodeImporter(World world, BlockPos pos) {
|
public NetworkNodeImporter(World world, BlockPos pos) {
|
||||||
@@ -147,6 +152,10 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
|
|||||||
super.read(tag);
|
super.read(tag);
|
||||||
|
|
||||||
StackUtils.readItems(upgrades, 1, tag);
|
StackUtils.readItems(upgrades, 1, tag);
|
||||||
|
|
||||||
|
if (tag.hasKey(NBT_COVERS)) {
|
||||||
|
coverManager.readFromNbt(tag.getTagList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -160,6 +169,8 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
|
|||||||
|
|
||||||
StackUtils.writeItems(upgrades, 1, tag);
|
StackUtils.writeItems(upgrades, 1, tag);
|
||||||
|
|
||||||
|
tag.setTag(NBT_COVERS, coverManager.writeToNbt());
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,4 +235,9 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
|
|||||||
public IItemHandler getFilterInventory() {
|
public IItemHandler getFilterInventory() {
|
||||||
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CoverManager getCoverManager() {
|
||||||
|
return coverManager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,7 @@ import com.raoulvdberge.refinedstorage.RSItems;
|
|||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemCover;
|
import com.raoulvdberge.refinedstorage.item.ItemCover;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
@@ -26,9 +27,10 @@ public class CoverManager {
|
|||||||
private static final String NBT_ITEM = "Item";
|
private static final String NBT_ITEM = "Item";
|
||||||
|
|
||||||
private Map<EnumFacing, ItemStack> covers = new HashMap<>();
|
private Map<EnumFacing, ItemStack> covers = new HashMap<>();
|
||||||
private INetworkNode node;
|
private NetworkNode node;
|
||||||
|
private boolean canPlaceCoversOnFace = true;
|
||||||
|
|
||||||
public CoverManager(INetworkNode node) {
|
public CoverManager(NetworkNode node) {
|
||||||
this.node = node;
|
this.node = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,6 +58,10 @@ public class CoverManager {
|
|||||||
|
|
||||||
public boolean setCover(EnumFacing facing, ItemStack stack) {
|
public boolean setCover(EnumFacing facing, ItemStack stack) {
|
||||||
if (isValidCover(stack) && !hasCover(facing)) {
|
if (isValidCover(stack) && !hasCover(facing)) {
|
||||||
|
if (facing == node.getDirection() && !canPlaceCoversOnFace) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
covers.put(facing, stack);
|
covers.put(facing, stack);
|
||||||
|
|
||||||
node.markDirty();
|
node.markDirty();
|
||||||
@@ -70,6 +76,12 @@ public class CoverManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CoverManager setCanPlaceCoversOnFace(boolean canPlaceCoversOnFace) {
|
||||||
|
this.canPlaceCoversOnFace = canPlaceCoversOnFace;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public void readFromNbt(NBTTagList list) {
|
public void readFromNbt(NBTTagList list) {
|
||||||
for (int i = 0; i < list.tagCount(); ++i) {
|
for (int i = 0; i < list.tagCount(); ++i) {
|
||||||
NBTTagCompound tag = list.getCompoundTagAt(i);
|
NBTTagCompound tag = list.getCompoundTagAt(i);
|
||||||
|
@@ -4,10 +4,12 @@ import com.raoulvdberge.refinedstorage.RS;
|
|||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable;
|
||||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
||||||
import com.raoulvdberge.refinedstorage.container.ContainerBase;
|
import com.raoulvdberge.refinedstorage.container.ContainerBase;
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemBlockBase;
|
import com.raoulvdberge.refinedstorage.item.ItemBlockBase;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
||||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
@@ -107,7 +109,13 @@ public abstract class BlockBase extends Block {
|
|||||||
if (!world.isRemote && getDirection() != null) {
|
if (!world.isRemote && getDirection() != null) {
|
||||||
TileBase tile = (TileBase) world.getTileEntity(pos);
|
TileBase tile = (TileBase) world.getTileEntity(pos);
|
||||||
|
|
||||||
tile.setDirection(getDirection().cycle(tile.getDirection()));
|
EnumFacing newDirection = getDirection().cycle(tile.getDirection());
|
||||||
|
|
||||||
|
if (tile instanceof TileNode && ((TileNode) tile).getNode() instanceof ICoverable && ((ICoverable) ((TileNode) tile).getNode()).getCoverManager().hasCover(newDirection)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
tile.setDirection(newDirection);
|
||||||
|
|
||||||
WorldUtils.updateBlock(world, pos);
|
WorldUtils.updateBlock(world, pos);
|
||||||
|
|
||||||
|
@@ -166,13 +166,25 @@ public class BlockCable extends BlockNode {
|
|||||||
protected boolean hitCablePart(IBlockState state, World world, BlockPos pos, float hitX, float hitY, float hitZ) {
|
protected boolean hitCablePart(IBlockState state, World world, BlockPos pos, float hitX, float hitY, float hitZ) {
|
||||||
state = getActualState(state, world, pos);
|
state = getActualState(state, world, pos);
|
||||||
|
|
||||||
return RenderUtils.isInBounds(CORE_AABB, hitX, hitY, hitZ) ||
|
if ((RenderUtils.isInBounds(CORE_AABB, hitX, hitY, hitZ)) ||
|
||||||
(state.getValue(NORTH) && RenderUtils.isInBounds(NORTH_AABB, hitX, hitY, hitZ)) ||
|
(state.getValue(NORTH) && RenderUtils.isInBounds(NORTH_AABB, hitX, hitY, hitZ)) ||
|
||||||
(state.getValue(EAST) && RenderUtils.isInBounds(EAST_AABB, hitX, hitY, hitZ)) ||
|
(state.getValue(EAST) && RenderUtils.isInBounds(EAST_AABB, hitX, hitY, hitZ)) ||
|
||||||
(state.getValue(SOUTH) && RenderUtils.isInBounds(SOUTH_AABB, hitX, hitY, hitZ)) ||
|
(state.getValue(SOUTH) && RenderUtils.isInBounds(SOUTH_AABB, hitX, hitY, hitZ)) ||
|
||||||
(state.getValue(WEST) && RenderUtils.isInBounds(WEST_AABB, hitX, hitY, hitZ)) ||
|
(state.getValue(WEST) && RenderUtils.isInBounds(WEST_AABB, hitX, hitY, hitZ)) ||
|
||||||
(state.getValue(UP) && RenderUtils.isInBounds(UP_AABB, hitX, hitY, hitZ)) ||
|
(state.getValue(UP) && RenderUtils.isInBounds(UP_AABB, hitX, hitY, hitZ)) ||
|
||||||
(state.getValue(DOWN) && RenderUtils.isInBounds(DOWN_AABB, hitX, hitY, hitZ));
|
(state.getValue(DOWN) && RenderUtils.isInBounds(DOWN_AABB, hitX, hitY, hitZ))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<AxisAlignedBB> coverAabbs = getCoverCollisions(world.getTileEntity(pos));
|
||||||
|
|
||||||
|
for (AxisAlignedBB coverAabb : coverAabbs) {
|
||||||
|
if (RenderUtils.isInBounds(coverAabb, hitX, hitY, hitZ)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AxisAlignedBB> getCombinedCollisionBoxes(IBlockState state) {
|
public List<AxisAlignedBB> getCombinedCollisionBoxes(IBlockState state) {
|
||||||
@@ -208,6 +220,10 @@ public class BlockCable extends BlockNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<AxisAlignedBB> getCollisionBoxes(TileEntity tile, IBlockState state) {
|
public List<AxisAlignedBB> getCollisionBoxes(TileEntity tile, IBlockState state) {
|
||||||
|
return getCoverCollisions(tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<AxisAlignedBB> getCoverCollisions(TileEntity tile) {
|
||||||
List<AxisAlignedBB> boxes = new ArrayList<>();
|
List<AxisAlignedBB> boxes = new ArrayList<>();
|
||||||
|
|
||||||
if (tile instanceof TileNode && ((TileNode) tile).getNode() instanceof ICoverable) {
|
if (tile instanceof TileNode && ((TileNode) tile).getNode() instanceof ICoverable) {
|
||||||
|
@@ -13,7 +13,6 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BlockExporter extends BlockCable {
|
public class BlockExporter extends BlockCable {
|
||||||
@@ -42,7 +41,7 @@ public class BlockExporter extends BlockCable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AxisAlignedBB> getCollisionBoxes(TileEntity tile, IBlockState state) {
|
public List<AxisAlignedBB> getCollisionBoxes(TileEntity tile, IBlockState state) {
|
||||||
List<AxisAlignedBB> boxes = new ArrayList<>();
|
List<AxisAlignedBB> boxes = super.getCollisionBoxes(tile, state);
|
||||||
|
|
||||||
switch (state.getValue(getDirection().getProperty())) {
|
switch (state.getValue(getDirection().getProperty())) {
|
||||||
case NORTH:
|
case NORTH:
|
||||||
|
@@ -15,7 +15,6 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BlockExternalStorage extends BlockCable {
|
public class BlockExternalStorage extends BlockCable {
|
||||||
@@ -32,7 +31,7 @@ public class BlockExternalStorage extends BlockCable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AxisAlignedBB> getCollisionBoxes(TileEntity tile, IBlockState state) {
|
public List<AxisAlignedBB> getCollisionBoxes(TileEntity tile, IBlockState state) {
|
||||||
List<AxisAlignedBB> boxes = new ArrayList<>();
|
List<AxisAlignedBB> boxes = super.getCollisionBoxes(tile, state);
|
||||||
|
|
||||||
switch (state.getValue(getDirection().getProperty())) {
|
switch (state.getValue(getDirection().getProperty())) {
|
||||||
case NORTH:
|
case NORTH:
|
||||||
|
@@ -13,7 +13,6 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BlockImporter extends BlockCable {
|
public class BlockImporter extends BlockCable {
|
||||||
@@ -42,7 +41,7 @@ public class BlockImporter extends BlockCable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AxisAlignedBB> getCollisionBoxes(TileEntity tile, IBlockState state) {
|
public List<AxisAlignedBB> getCollisionBoxes(TileEntity tile, IBlockState state) {
|
||||||
List<AxisAlignedBB> boxes = new ArrayList<>();
|
List<AxisAlignedBB> boxes = super.getCollisionBoxes(tile, state);
|
||||||
|
|
||||||
switch (state.getValue(getDirection().getProperty())) {
|
switch (state.getValue(getDirection().getProperty())) {
|
||||||
case NORTH:
|
case NORTH:
|
||||||
|
@@ -372,7 +372,7 @@ public class ProxyClient extends ProxyCommon {
|
|||||||
if (model.getResourceDomain().equals(RS.ID)) {
|
if (model.getResourceDomain().equals(RS.ID)) {
|
||||||
if (model.getResourcePath().equals("pattern")) {
|
if (model.getResourcePath().equals("pattern")) {
|
||||||
e.getModelRegistry().putObject(model, new BakedModelPattern(e.getModelRegistry().getObject(model)));
|
e.getModelRegistry().putObject(model, new BakedModelPattern(e.getModelRegistry().getObject(model)));
|
||||||
} else if (model.getResourcePath().equals("cable")) {
|
} else if (model.getResourcePath().equals("cable") || model.getResourcePath().equals("exporter") || model.getResourcePath().equals("importer") || model.getResourcePath().equals("external_storage")) {
|
||||||
e.getModelRegistry().putObject(model, new BakedModelCableCover(e.getModelRegistry().getObject(model)));
|
e.getModelRegistry().putObject(model, new BakedModelCableCover(e.getModelRegistry().getObject(model)));
|
||||||
} else if (model.getResourcePath().equals("cover")) {
|
} else if (model.getResourcePath().equals("cover")) {
|
||||||
e.getModelRegistry().putObject(model, new BakedModelCover(e.getModelRegistry().getObject(model), null));
|
e.getModelRegistry().putObject(model, new BakedModelCover(e.getModelRegistry().getObject(model), null));
|
||||||
|
Reference in New Issue
Block a user