Bump to 1.6. Remove bunch of integrations.
This commit is contained in:
18
build.gradle
18
build.gradle
@@ -16,7 +16,7 @@ apply plugin: 'maven'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
|
||||
version = "1.5.35"
|
||||
version = "1.6"
|
||||
group = "refinedstorage"
|
||||
archivesBaseName = "refinedstorage"
|
||||
|
||||
@@ -24,25 +24,19 @@ sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
minecraft {
|
||||
version = "1.12.2-14.23.1.2577"
|
||||
version = "1.12.2-14.23.4.2703"
|
||||
runDir = "run"
|
||||
useDepAts = true
|
||||
mappings = "snapshot_20171217"
|
||||
mappings = "snapshot_20180526"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url "http://dvs1.progwml6.com/files/maven"
|
||||
}
|
||||
maven {
|
||||
url "http://maven.amadornes.com"
|
||||
}
|
||||
maven {
|
||||
url "http://maven.cil.li"
|
||||
}
|
||||
maven {
|
||||
url "https://dl.bintray.com/jaquadro/dev"
|
||||
}
|
||||
maven {
|
||||
name = "CurseForge"
|
||||
url = "https://minecraft.curseforge.com/api/maven/"
|
||||
@@ -50,11 +44,9 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
deobfCompile "mezz.jei:jei_1.12.2:4.8.5.136:api"
|
||||
runtime "mezz.jei:jei_1.12.2:4.8.5.136"
|
||||
deobfCompile "MCMultiPart2:MCMultiPart:2.4.1"
|
||||
deobfCompile "mezz.jei:jei_1.12.2:4.9.1.191:api"
|
||||
runtime "mezz.jei:jei_1.12.2:4.9.1.191"
|
||||
deobfCompile "li.cil.oc:OpenComputers:MC1.12.1-1.7.1.43:api"
|
||||
deobfCompile "com.jaquadro.minecraft.storagedrawers:StorageDrawers:1.12.1-5.3.3:api"
|
||||
compile "inventory-tweaks:InventoryTweaks:1.63:api"
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,7 @@ public final class RS {
|
||||
}
|
||||
|
||||
public static final String ID = "refinedstorage";
|
||||
public static final String VERSION = "1.5.35";
|
||||
public static final String VERSION = "1.6";
|
||||
public static final String DEPENDENCIES = "required-after:forge@[14.23.1.2555,);after:mcmultipart@[2.4.1,);after:storagedrawers@[1.12-5.2.2,);";
|
||||
public static final String GUI_FACTORY = "com.raoulvdberge.refinedstorage.gui.config.ModGuiFactory";
|
||||
public static final String UPDATE_JSON = "https://refinedstorage.raoulvdberge.com/update";
|
||||
|
@@ -5,8 +5,6 @@ import com.raoulvdberge.refinedstorage.api.network.INetworkNodeVisitor;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IWrenchable;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.IntegrationMCMP;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.RSMCMPAddon;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
@@ -215,7 +213,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor,
|
||||
|
||||
// @todo: Move this data to the network node.
|
||||
public void resetDirection() {
|
||||
EnumFacing direction = ((TileBase) (IntegrationMCMP.isLoaded() ? RSMCMPAddon.unwrapTile(world, pos) : world.getTileEntity(pos))).getDirection();
|
||||
EnumFacing direction = ((TileBase) world.getTileEntity(pos)).getDirection();
|
||||
if (!direction.equals(this.direction)) {
|
||||
this.direction = direction;
|
||||
onDirectionChanged();
|
||||
|
@@ -1,16 +1,9 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||
import com.raoulvdberge.refinedstorage.block.BlockCable;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.IntegrationMCMP;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.RSMCMPAddon;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class NetworkNodeCable extends NetworkNode {
|
||||
public static final String ID = "cable";
|
||||
|
||||
@@ -27,13 +20,4 @@ public class NetworkNodeCable extends NetworkNode {
|
||||
public String getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConduct(@Nullable EnumFacing direction) {
|
||||
if (IntegrationMCMP.isLoaded() && direction != null) {
|
||||
return BlockCable.hasConnectionWith(world, pos, RSBlocks.CABLE, IntegrationMCMP.isLoaded() ? RSMCMPAddon.unwrapTile(world, pos) : world.getTileEntity(pos), direction);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -4,8 +4,6 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilter;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.IntegrationMCMP;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.RSMCMPAddon;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
|
||||
@@ -134,18 +132,8 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
|
||||
}
|
||||
}
|
||||
|
||||
private WorldServer getWorldServer() {
|
||||
World world = this.world;
|
||||
|
||||
if (IntegrationMCMP.isLoaded()) {
|
||||
world = RSMCMPAddon.unwrapWorld(world);
|
||||
}
|
||||
|
||||
return (WorldServer) world;
|
||||
}
|
||||
|
||||
private boolean canPlace(BlockPos pos, IBlockState state) {
|
||||
BlockEvent.PlaceEvent e = new BlockEvent.PlaceEvent(new BlockSnapshot(world, pos, state), world.getBlockState(pos), FakePlayerFactory.getMinecraft(getWorldServer()), EnumHand.MAIN_HAND);
|
||||
BlockEvent.PlaceEvent e = new BlockEvent.PlaceEvent(new BlockSnapshot(world, pos, state), world.getBlockState(pos), FakePlayerFactory.getMinecraft((WorldServer) world), EnumHand.MAIN_HAND);
|
||||
|
||||
return !MinecraftForge.EVENT_BUS.post(e);
|
||||
}
|
||||
@@ -161,7 +149,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
|
||||
IBlockState state = SlotFilter.getBlockState(world, front, took);
|
||||
|
||||
if (state != null && world.isAirBlock(front) && state.getBlock().canPlaceBlockAt(world, front)) {
|
||||
state = state.getBlock().getStateForPlacement(world, front, getDirection(), 0.5F, 0.5F, 0.5F, took.getMetadata(), FakePlayerFactory.getMinecraft(getWorldServer()), EnumHand.MAIN_HAND);
|
||||
state = state.getBlock().getStateForPlacement(world, front, getDirection(), 0.5F, 0.5F, 0.5F, took.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) world), EnumHand.MAIN_HAND);
|
||||
|
||||
if (!canPlace(front, state)) {
|
||||
return;
|
||||
@@ -173,7 +161,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
|
||||
if (item.getItem() instanceof ItemBlock) {
|
||||
((ItemBlock) item.getItem()).placeBlockAt(
|
||||
took,
|
||||
FakePlayerFactory.getMinecraft(getWorldServer()),
|
||||
FakePlayerFactory.getMinecraft((WorldServer) world),
|
||||
world,
|
||||
front,
|
||||
getDirection(),
|
||||
@@ -185,7 +173,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
|
||||
} else {
|
||||
world.setBlockState(front, state, 1 | 2);
|
||||
|
||||
state.getBlock().onBlockPlacedBy(world, front, state, FakePlayerFactory.getMinecraft(getWorldServer()), took);
|
||||
state.getBlock().onBlockPlacedBy(world, front, state, FakePlayerFactory.getMinecraft((WorldServer) world), took);
|
||||
}
|
||||
|
||||
// From ItemBlock#onItemUse
|
||||
|
@@ -2,8 +2,6 @@ package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.IntegrationMCMP;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.RSMCMPAddon;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
|
||||
@@ -74,16 +72,6 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
|
||||
return RS.INSTANCE.config.destructorUsage + upgrades.getEnergyUsage();
|
||||
}
|
||||
|
||||
private WorldServer getWorldServer() {
|
||||
World world = this.world;
|
||||
|
||||
if (IntegrationMCMP.isLoaded()) {
|
||||
world = RSMCMPAddon.unwrapWorld(world);
|
||||
}
|
||||
|
||||
return (WorldServer) world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
@@ -142,7 +130,7 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
|
||||
}
|
||||
}
|
||||
|
||||
BlockEvent.BreakEvent e = new BlockEvent.BreakEvent(world, front, frontBlockState, FakePlayerFactory.getMinecraft(getWorldServer()));
|
||||
BlockEvent.BreakEvent e = new BlockEvent.BreakEvent(world, front, frontBlockState, FakePlayerFactory.getMinecraft((WorldServer) world));
|
||||
|
||||
if (!MinecraftForge.EVENT_BUS.post(e)) {
|
||||
world.playEvent(null, 2001, front, Block.getStateId(frontBlockState));
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
@@ -12,9 +11,6 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheFluid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheItem;
|
||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.integration.projecte.IntegrationProjectE;
|
||||
import com.raoulvdberge.refinedstorage.integration.projecte.StorageItemTransmutationTable;
|
||||
import com.raoulvdberge.refinedstorage.integration.storagedrawers.StorageItemItemRepository;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
|
||||
@@ -29,8 +25,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -39,9 +33,6 @@ import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class NetworkNodeExternalStorage extends NetworkNode implements IStorageProvider, IGuiStorage, IComparable, IFilterable, IPrioritizable, IType, IAccessType {
|
||||
@CapabilityInject(IDrawerGroup.class)
|
||||
private static final Capability<IDrawerGroup> DRAWER_GROUP_CAPABILITY = null;
|
||||
|
||||
public static final String ID = "external_storage";
|
||||
|
||||
private static final String NBT_PRIORITY = "Priority";
|
||||
@@ -203,23 +194,13 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
|
||||
TileEntity facing = getFacingTile();
|
||||
|
||||
if (type == IType.ITEMS) {
|
||||
if (facing != null) {
|
||||
if (DRAWER_GROUP_CAPABILITY != null && facing.hasCapability(DRAWER_GROUP_CAPABILITY, getDirection().getOpposite())) {
|
||||
itemStorages.add(new StorageItemItemRepository(this, () -> {
|
||||
TileEntity f = getFacingTile();
|
||||
|
||||
return (f != null && f.hasCapability(DRAWER_GROUP_CAPABILITY, getDirection().getOpposite())) ? f.getCapability(DRAWER_GROUP_CAPABILITY, getDirection().getOpposite()) : null;
|
||||
}));
|
||||
} else if (!(facing.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, getDirection().getOpposite()) && facing.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, getDirection().getOpposite()).getNode() instanceof IStorageProvider)) {
|
||||
if (facing != null && !(facing.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, getDirection().getOpposite()) && facing.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, getDirection().getOpposite()).getNode() instanceof IStorageProvider)) {
|
||||
IItemHandler itemHandler = WorldUtils.getItemHandler(facing, getDirection().getOpposite());
|
||||
|
||||
if (itemHandler != null) {
|
||||
itemStorages.add(new StorageItemItemHandler(this, () -> WorldUtils.getItemHandler(getFacingTile(), getDirection().getOpposite())));
|
||||
}
|
||||
}
|
||||
} else if (IntegrationProjectE.isLoaded() && world.getBlockState(pos.offset(getDirection())).getBlock().getUnlocalizedName().equals("tile.pe_transmutation_stone")) {
|
||||
itemStorages.add(new StorageItemTransmutationTable(this));
|
||||
}
|
||||
} else if (type == IType.FLUIDS) {
|
||||
IFluidHandler fluidHandler = WorldUtils.getFluidHandler(facing, getDirection().getOpposite());
|
||||
|
||||
|
@@ -6,8 +6,6 @@ import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerBase;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.IntegrationMCMP;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.RSMCMPAddon;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemBlockBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
@@ -89,7 +87,7 @@ public abstract class BlockBase extends Block {
|
||||
@SuppressWarnings("deprecation")
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
if (getDirection() != null) {
|
||||
TileEntity tile = IntegrationMCMP.isLoaded() ? RSMCMPAddon.unwrapTile(world, pos) : world.getTileEntity(pos);
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileBase) {
|
||||
return state.withProperty(getDirection().getProperty(), ((TileBase) tile).getDirection());
|
||||
@@ -138,7 +136,7 @@ public abstract class BlockBase extends Block {
|
||||
}
|
||||
|
||||
protected void dropContents(World world, BlockPos pos) {
|
||||
TileEntity tile = IntegrationMCMP.isLoaded() ? RSMCMPAddon.unwrapTile(world, pos) : world.getTileEntity(pos);
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileBase && ((TileBase) tile).getDrops() != null) {
|
||||
IItemHandler handler = ((TileBase) tile).getDrops();
|
||||
|
@@ -1,8 +1,6 @@
|
||||
package com.raoulvdberge.refinedstorage.block;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.IntegrationMCMP;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.RSMCMPAddon;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileCable;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
@@ -75,7 +73,7 @@ public class BlockCable extends BlockNode {
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
TileEntity tile = IntegrationMCMP.isLoaded() ? RSMCMPAddon.unwrapTile(world, pos) : world.getTileEntity(pos);
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
state = super.getActualState(state, world, pos)
|
||||
.withProperty(NORTH, hasConnectionWith(world, pos, this, tile, EnumFacing.NORTH))
|
||||
@@ -114,11 +112,6 @@ public class BlockCable extends BlockNode {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IntegrationMCMP.isLoaded()) {
|
||||
return !RSMCMPAddon.hasObstructingMultipart(tile, Collections.singletonList(BlockCable.getCableExtensionAABB(direction)))
|
||||
&& !RSMCMPAddon.hasObstructingMultipart(otherTile, Collections.singletonList(BlockCable.getCableExtensionAABB(direction.getOpposite())));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -238,22 +231,4 @@ public class BlockCable extends BlockNode {
|
||||
public Direction getDirection() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static AxisAlignedBB getCableExtensionAABB(EnumFacing facing) {
|
||||
if (facing == EnumFacing.NORTH) {
|
||||
return NORTH_AABB;
|
||||
} else if (facing == EnumFacing.EAST) {
|
||||
return EAST_AABB;
|
||||
} else if (facing == EnumFacing.SOUTH) {
|
||||
return SOUTH_AABB;
|
||||
} else if (facing == EnumFacing.WEST) {
|
||||
return WEST_AABB;
|
||||
} else if (facing == EnumFacing.UP) {
|
||||
return UP_AABB;
|
||||
} else if (facing == EnumFacing.DOWN) {
|
||||
return DOWN_AABB;
|
||||
}
|
||||
|
||||
return NORTH_AABB;
|
||||
}
|
||||
}
|
||||
|
@@ -3,8 +3,6 @@ package com.raoulvdberge.refinedstorage.block;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.IntegrationMCMP;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.RSMCMPAddon;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
@@ -92,7 +90,7 @@ public abstract class BlockNode extends BlockBase {
|
||||
state = super.getActualState(state, world, pos);
|
||||
|
||||
if (hasConnectivityState()) {
|
||||
TileEntity tile = IntegrationMCMP.isLoaded() ? RSMCMPAddon.unwrapTile(world, pos) : world.getTileEntity(pos);
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileNode) {
|
||||
return state.withProperty(CONNECTED, ((TileNode) tile).getNode().isActive());
|
||||
|
@@ -6,8 +6,6 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.IGuiReaderWriter;
|
||||
import com.raoulvdberge.refinedstorage.container.*;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.IntegrationMCMP;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.RSMCMPAddon;
|
||||
import com.raoulvdberge.refinedstorage.tile.*;
|
||||
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor;
|
||||
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.WirelessCraftingMonitor;
|
||||
@@ -89,12 +87,12 @@ public class GuiHandler implements IGuiHandler {
|
||||
return getCraftingMonitorContainer(player, x, y);
|
||||
}
|
||||
|
||||
return getContainer(ID, player, IntegrationMCMP.isLoaded() ? RSMCMPAddon.unwrapTile(world, new BlockPos(x, y, z)) : world.getTileEntity(new BlockPos(x, y, z)));
|
||||
return getContainer(ID, player, world.getTileEntity(new BlockPos(x, y, z)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity tile = IntegrationMCMP.isLoaded() ? RSMCMPAddon.unwrapTile(world, new BlockPos(x, y, z)) : world.getTileEntity(new BlockPos(x, y, z));
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
|
||||
|
||||
switch (ID) {
|
||||
case RSGui.CONTROLLER:
|
||||
|
@@ -33,8 +33,6 @@ public class SideButtonGridViewType extends SideButton {
|
||||
type = IGrid.VIEW_TYPE_CRAFTABLES;
|
||||
} else if (type == IGrid.VIEW_TYPE_CRAFTABLES) {
|
||||
type = IGrid.VIEW_TYPE_NORMAL;
|
||||
} else {
|
||||
type = IGrid.VIEW_TYPE_NORMAL; // @todo: Remove in 1.13 (1.5.24 -> 1.5.26 conversion, removed detailed grid view type)
|
||||
}
|
||||
|
||||
grid.onViewTypeChanged(type);
|
||||
|
@@ -9,7 +9,6 @@ import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
@@ -85,7 +84,7 @@ public class GridStackItem implements IGridStack {
|
||||
|
||||
@Override
|
||||
public String getModId() {
|
||||
return Item.REGISTRY.getNameForObject(stack.getItem()).getResourceDomain();
|
||||
return stack.getItem().getCreatorModId(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,9 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.integration.mcmp;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
public final class IntegrationMCMP {
|
||||
public static boolean isLoaded() {
|
||||
return Loader.isModLoaded("mcmultipart");
|
||||
}
|
||||
}
|
@@ -1,57 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.integration.mcmp;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.block.BlockCable;
|
||||
import mcmultipart.api.container.IPartInfo;
|
||||
import mcmultipart.api.multipart.IMultipart;
|
||||
import mcmultipart.api.slot.EnumCenterSlot;
|
||||
import mcmultipart.api.slot.IPartSlot;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PartCable implements IMultipart {
|
||||
private BlockCable block;
|
||||
|
||||
public PartCable(BlockCable block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartSlot getSlotForPlacement(World world, BlockPos pos, IBlockState state, EnumFacing facing, float hitX, float hitY, float hitZ, EntityLivingBase placer) {
|
||||
return EnumCenterSlot.CENTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartSlot getSlotFromWorld(IBlockAccess world, BlockPos pos, IBlockState state) {
|
||||
return EnumCenterSlot.CENTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AxisAlignedBB> getOcclusionBoxes(IPartInfo part) {
|
||||
List<AxisAlignedBB> boxes = new ArrayList<>();
|
||||
|
||||
boxes.add(BlockCable.CORE_AABB);
|
||||
boxes.addAll(block.getNonUnionizedCollisionBoxes(part.getState()));
|
||||
|
||||
return boxes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPartChanged(IPartInfo part, IPartInfo otherPart) {
|
||||
API.instance().discoverNode(part.getActualWorld(), part.getContainer().getPartPos());
|
||||
}
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.integration.mcmp;
|
||||
|
||||
import mcmultipart.api.container.IPartInfo;
|
||||
import mcmultipart.api.multipart.IMultipartTile;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class PartCableTile implements IMultipartTile {
|
||||
private TileEntity tile;
|
||||
private IPartInfo info;
|
||||
|
||||
public PartCableTile(TileEntity tile) {
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPartInfo(IPartInfo info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity() {
|
||||
return tile;
|
||||
}
|
||||
|
||||
public IPartInfo getInfo() {
|
||||
return info;
|
||||
}
|
||||
}
|
@@ -1,166 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.integration.mcmp;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||
import com.raoulvdberge.refinedstorage.block.BlockCable;
|
||||
import com.raoulvdberge.refinedstorage.tile.*;
|
||||
import mcmultipart.api.addon.IMCMPAddon;
|
||||
import mcmultipart.api.addon.MCMPAddon;
|
||||
import mcmultipart.api.container.IPartInfo;
|
||||
import mcmultipart.api.multipart.IMultipart;
|
||||
import mcmultipart.api.multipart.IMultipartRegistry;
|
||||
import mcmultipart.api.multipart.IMultipartTile;
|
||||
import mcmultipart.api.multipart.MultipartOcclusionHelper;
|
||||
import mcmultipart.api.ref.MCMPCapabilities;
|
||||
import mcmultipart.api.slot.EnumCenterSlot;
|
||||
import mcmultipart.block.BlockMultipartContainer;
|
||||
import mcmultipart.block.TileMultipartContainer;
|
||||
import mcmultipart.util.MCMPWorldWrapper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@MCMPAddon
|
||||
public class RSMCMPAddon implements IMCMPAddon {
|
||||
@Override
|
||||
public void registerParts(IMultipartRegistry registry) {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
register(registry, RSBlocks.CABLE);
|
||||
register(registry, RSBlocks.CONSTRUCTOR);
|
||||
register(registry, RSBlocks.DESTRUCTOR);
|
||||
register(registry, RSBlocks.IMPORTER);
|
||||
register(registry, RSBlocks.EXPORTER);
|
||||
register(registry, RSBlocks.EXTERNAL_STORAGE);
|
||||
register(registry, RSBlocks.READER);
|
||||
register(registry, RSBlocks.WRITER);
|
||||
}
|
||||
|
||||
private void register(IMultipartRegistry registry, BlockCable block) {
|
||||
registry.registerPartWrapper(block, new PartCable(block));
|
||||
registry.registerStackWrapper(Item.getItemFromBlock(block), s -> true, block);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onAttachCapability(AttachCapabilitiesEvent<TileEntity> e) {
|
||||
TileEntity tile = e.getObject();
|
||||
|
||||
if (tile instanceof TileCable) {
|
||||
register(e, "cable");
|
||||
} else if (tile instanceof TileConstructor) {
|
||||
register(e, "constructor");
|
||||
} else if (tile instanceof TileDestructor) {
|
||||
register(e, "destructor");
|
||||
} else if (tile instanceof TileImporter) {
|
||||
register(e, "importer");
|
||||
} else if (tile instanceof TileExporter) {
|
||||
register(e, "exporter");
|
||||
} else if (tile instanceof TileExternalStorage) {
|
||||
register(e, "external_storage");
|
||||
} else if (tile instanceof TileReader) {
|
||||
register(e, "reader");
|
||||
} else if (tile instanceof TileWriter) {
|
||||
register(e, "writer");
|
||||
}
|
||||
}
|
||||
|
||||
private void register(AttachCapabilitiesEvent<TileEntity> e, String id) {
|
||||
e.addCapability(new ResourceLocation("refinedstorage:" + id), new ICapabilityProvider() {
|
||||
private PartCableTile tile;
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == MCMPCapabilities.MULTIPART_TILE;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == MCMPCapabilities.MULTIPART_TILE) {
|
||||
if (tile == null) {
|
||||
tile = new PartCableTile(e.getObject());
|
||||
}
|
||||
|
||||
return MCMPCapabilities.MULTIPART_TILE.cast(tile);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean hasObstructingMultipart(TileEntity tile, List<AxisAlignedBB> testBoxes) {
|
||||
if (tile != null && tile.hasCapability(MCMPCapabilities.MULTIPART_TILE, null)) {
|
||||
IMultipartTile multipartTile = tile.getCapability(MCMPCapabilities.MULTIPART_TILE, null);
|
||||
|
||||
if (multipartTile instanceof PartCableTile && ((PartCableTile) multipartTile).getInfo() != null) {
|
||||
for (IPartInfo info : ((PartCableTile) multipartTile).getInfo().getContainer().getParts().values()) {
|
||||
IMultipart multipart = info.getPart();
|
||||
|
||||
if (!(multipart instanceof PartCable) && MultipartOcclusionHelper.testBoxIntersection(testBoxes, multipart.getOcclusionBoxes(info))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static TileEntity unwrapTile(IBlockAccess world, BlockPos pos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileMultipartContainer) {
|
||||
Optional<IMultipartTile> multipartTile = ((TileMultipartContainer) tile).getPartTile(EnumCenterSlot.CENTER);
|
||||
|
||||
if (multipartTile.isPresent()) {
|
||||
return multipartTile.get().getTileEntity();
|
||||
}
|
||||
}
|
||||
|
||||
return tile;
|
||||
}
|
||||
|
||||
public static World unwrapWorld(World world) {
|
||||
if (world instanceof MCMPWorldWrapper) {
|
||||
return ((MCMPWorldWrapper) world).getActualWorld();
|
||||
}
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
public static Block unwrapBlock(IBlockAccess world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
if (state.getBlock() instanceof BlockMultipartContainer) {
|
||||
Optional<TileMultipartContainer> multipartContainer = BlockMultipartContainer.getTile(world, pos);
|
||||
|
||||
if (multipartContainer.isPresent()) {
|
||||
Optional<IPartInfo> info = multipartContainer.get().get(EnumCenterSlot.CENTER);
|
||||
|
||||
if (info.isPresent()) {
|
||||
return info.get().getPart().getBlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return state.getBlock();
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.integration.projecte;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import moze_intel.projecte.api.ProjectEAPI;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class IntegrationProjectE {
|
||||
private static final String ID = "projecte";
|
||||
|
||||
public static boolean isLoaded() {
|
||||
return Loader.isModLoaded(ID);
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
for (ISoldererRecipe recipe : API.instance().getSoldererRegistry().getRecipes()) {
|
||||
if (!recipe.isProjectERecipe()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Map<Object, Integer> ingredients = new HashMap<>();
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
NonNullList<ItemStack> items = recipe.getRow(i);
|
||||
|
||||
if (!items.isEmpty()) {
|
||||
ingredients.put(items.get(0), items.get(0).getCount());
|
||||
}
|
||||
}
|
||||
|
||||
ProjectEAPI.getConversionProxy().addConversion(recipe.getResult().getCount(), recipe.getResult(), ingredients);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,162 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.integration.projecte;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage.NetworkNodeExternalStorage;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage.StorageItemExternal;
|
||||
import moze_intel.projecte.api.ProjectEAPI;
|
||||
import moze_intel.projecte.api.capabilities.IKnowledgeProvider;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class StorageItemTransmutationTable extends StorageItemExternal {
|
||||
private NetworkNodeExternalStorage externalStorage;
|
||||
|
||||
public StorageItemTransmutationTable(NetworkNodeExternalStorage externalStorage) {
|
||||
this.externalStorage = externalStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getStacks() {
|
||||
if (externalStorage.getOwner() != null) {
|
||||
IKnowledgeProvider provider = ProjectEAPI.getTransmutationProxy().getKnowledgeProviderFor(externalStorage.getOwner());
|
||||
|
||||
// @todo: https://github.com/sinkillerj/ProjectE/issues/1591
|
||||
if (!provider.getClass().getName().equals("moze_intel.projecte.impl.TransmutationOffline$1")) {
|
||||
List<ItemStack> stored = new LinkedList<>();
|
||||
|
||||
for (ItemStack knowledge : provider.getKnowledge()) {
|
||||
stored.add(ItemHandlerHelper.copyStackWithSize(knowledge, (int) Math.floor(provider.getEmc() / (double) ProjectEAPI.getEMCProxy().getValue(knowledge))));
|
||||
}
|
||||
|
||||
return stored;
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack insert(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
ItemStack actualStack = ItemHandlerHelper.copyStackWithSize(stack, size);
|
||||
|
||||
if (externalStorage.getOwner() != null) {
|
||||
IKnowledgeProvider provider = ProjectEAPI.getTransmutationProxy().getKnowledgeProviderFor(externalStorage.getOwner());
|
||||
|
||||
// @todo: https://github.com/sinkillerj/ProjectE/issues/1591
|
||||
if (!provider.getClass().getName().equals("moze_intel.projecte.impl.TransmutationOffline$1")) {
|
||||
int emc = ProjectEAPI.getEMCProxy().getValue(actualStack) * size;
|
||||
|
||||
if (emc == 0) {
|
||||
return actualStack;
|
||||
}
|
||||
|
||||
if (!simulate) {
|
||||
provider.setEmc(provider.getEmc() + emc);
|
||||
|
||||
handleKnowledge(provider, stack.copy());
|
||||
|
||||
EntityPlayer player = externalStorage.getWorld().getPlayerEntityByUUID(externalStorage.getOwner());
|
||||
|
||||
if (player != null) {
|
||||
provider.sync((EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return actualStack;
|
||||
}
|
||||
|
||||
// @todo: https://github.com/sinkillerj/ProjectE/issues/1592
|
||||
private void handleKnowledge(IKnowledgeProvider provider, ItemStack stack) {
|
||||
if (stack.getCount() > 1) {
|
||||
stack.setCount(1);
|
||||
}
|
||||
|
||||
if (!stack.getHasSubtypes() && stack.getMaxDamage() != 0) {
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
|
||||
if (!provider.hasKnowledge(stack)) {
|
||||
stack.setTagCompound(null);
|
||||
|
||||
provider.addKnowledge(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack extract(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
if (externalStorage.getOwner() != null) {
|
||||
IKnowledgeProvider provider = ProjectEAPI.getTransmutationProxy().getKnowledgeProviderFor(externalStorage.getOwner());
|
||||
|
||||
// @todo: https://github.com/sinkillerj/ProjectE/issues/1591
|
||||
if (!provider.getClass().getName().equals("moze_intel.projecte.impl.TransmutationOffline$1") && provider.hasKnowledge(stack)) {
|
||||
double singleEmc = ProjectEAPI.getEMCProxy().getValue(stack);
|
||||
|
||||
// If we have the Tome of Knowledge, IKnowledgeProvider#hasKnowledge will always return true, even if the item has no EMC assigned
|
||||
if (singleEmc == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int maxExtract = (int) Math.floor(provider.getEmc() / singleEmc);
|
||||
|
||||
if (size > maxExtract) {
|
||||
size = maxExtract;
|
||||
}
|
||||
|
||||
if (size <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack result = ItemHandlerHelper.copyStackWithSize(stack, size);
|
||||
|
||||
if (!simulate) {
|
||||
provider.setEmc(provider.getEmc() - (singleEmc * size));
|
||||
|
||||
EntityPlayer player = externalStorage.getWorld().getPlayerEntityByUUID(externalStorage.getOwner());
|
||||
|
||||
if (player != null) {
|
||||
provider.sync((EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStored() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return externalStorage.getPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessType getAccessType() {
|
||||
return externalStorage.getAccessType();
|
||||
}
|
||||
}
|
@@ -1,125 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.integration.storagedrawers;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage.NetworkNodeExternalStorage;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage.StorageItemExternal;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class StorageItemItemRepository extends StorageItemExternal {
|
||||
@CapabilityInject(IItemRepository.class)
|
||||
private static final Capability<IItemRepository> ITEM_REPOSITORY_CAPABILITY = null;
|
||||
|
||||
private NetworkNodeExternalStorage externalStorage;
|
||||
private Supplier<IDrawerGroup> groupSupplier;
|
||||
|
||||
public StorageItemItemRepository(NetworkNodeExternalStorage externalStorage, Supplier<IDrawerGroup> groupSupplier) {
|
||||
this.externalStorage = externalStorage;
|
||||
this.groupSupplier = groupSupplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getStacks() {
|
||||
IItemRepository repository = getRepositoryFromSupplier();
|
||||
|
||||
if (repository == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return repository.getAllItems().stream().map(r -> ItemHandlerHelper.copyStackWithSize(r.itemPrototype, r.count)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack insert(@Nonnull ItemStack stack, int size, boolean simulate) {
|
||||
IItemRepository repository = getRepositoryFromSupplier();
|
||||
|
||||
if (repository == null) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
return StackUtils.emptyToNull(repository.insertItem(ItemHandlerHelper.copyStackWithSize(stack, size), simulate));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack extract(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
IItemRepository repository = getRepositoryFromSupplier();
|
||||
|
||||
if (repository == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return StackUtils.emptyToNull(repository.extractItem(stack, size, simulate, s -> API.instance().getComparer().isEqual(stack, s, flags)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStored() {
|
||||
IItemRepository repository = getRepositoryFromSupplier();
|
||||
|
||||
if (repository == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return repository.getAllItems().stream().mapToInt(r -> r.count).sum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return externalStorage.getPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessType getAccessType() {
|
||||
return externalStorage.getAccessType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
IDrawerGroup group = groupSupplier.get();
|
||||
|
||||
if (group == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
long capacity = 0;
|
||||
|
||||
for (int slot : group.getAccessibleDrawerSlots()) {
|
||||
IDrawer drawer = group.getDrawer(slot);
|
||||
|
||||
if (drawer.isEnabled()) {
|
||||
capacity += drawer.getMaxCapacity();
|
||||
}
|
||||
}
|
||||
|
||||
if (capacity >= Integer.MAX_VALUE) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
return (int) capacity;
|
||||
}
|
||||
|
||||
private IItemRepository getRepositoryFromSupplier() {
|
||||
IDrawerGroup group = groupSupplier.get();
|
||||
|
||||
if (group == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return group.getCapability(ITEM_REPOSITORY_CAPABILITY, null);
|
||||
}
|
||||
}
|
@@ -9,8 +9,6 @@ import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
||||
import com.raoulvdberge.refinedstorage.block.*;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiCraftingPreview;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiCraftingStart;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.IntegrationMCMP;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.RSMCMPAddon;
|
||||
import com.raoulvdberge.refinedstorage.item.*;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageGridCraftingPreviewResponse;
|
||||
import com.raoulvdberge.refinedstorage.render.*;
|
||||
@@ -331,7 +329,7 @@ public class ProxyClient extends ProxyCommon {
|
||||
|
||||
BlockPos pos = e.getTarget().getBlockPos();
|
||||
|
||||
Block block = IntegrationMCMP.isLoaded() ? RSMCMPAddon.unwrapBlock(player.getEntityWorld(), pos) : player.getEntityWorld().getBlockState(pos).getBlock();
|
||||
Block block = player.getEntityWorld().getBlockState(pos).getBlock();
|
||||
|
||||
if (!(block instanceof BlockCable)) {
|
||||
return;
|
||||
|
@@ -30,7 +30,6 @@ import com.raoulvdberge.refinedstorage.integration.funkylocomotion.MoveFactoryRe
|
||||
import com.raoulvdberge.refinedstorage.integration.inventorysorter.IntegrationInventorySorter;
|
||||
import com.raoulvdberge.refinedstorage.integration.oc.DriverNetwork;
|
||||
import com.raoulvdberge.refinedstorage.integration.oc.IntegrationOC;
|
||||
import com.raoulvdberge.refinedstorage.integration.projecte.IntegrationProjectE;
|
||||
import com.raoulvdberge.refinedstorage.network.*;
|
||||
import com.raoulvdberge.refinedstorage.tile.*;
|
||||
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor;
|
||||
@@ -263,10 +262,6 @@ public class ProxyCommon {
|
||||
if (IntegrationCraftingTweaks.isLoaded()) {
|
||||
IntegrationCraftingTweaks.register();
|
||||
}
|
||||
|
||||
if (IntegrationProjectE.isLoaded()) {
|
||||
IntegrationProjectE.register();
|
||||
}
|
||||
}
|
||||
|
||||
public void postInit(FMLPostInitializationEvent e) {
|
||||
@@ -327,7 +322,7 @@ public class ProxyCommon {
|
||||
}
|
||||
|
||||
private void registerTile(Class<? extends TileBase> tile, String id) {
|
||||
GameRegistry.registerTileEntity(tile, RS.ID + ":" + id);
|
||||
GameRegistry.registerTileEntity(tile, new ResourceLocation(RS.ID, id));
|
||||
|
||||
try {
|
||||
TileBase tileInstance = tile.newInstance();
|
||||
|
@@ -1,21 +0,0 @@
|
||||
package moze_intel.projecte.api;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
public final class PESounds {
|
||||
|
||||
public static final SoundEvent WIND = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("projecte", "item.pewindmagic"));
|
||||
public static final SoundEvent WATER = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("projecte", "item.pewatermagic"));
|
||||
public static final SoundEvent POWER = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("projecte", "item.pepower"));
|
||||
public static final SoundEvent HEAL = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("projecte", "item.peheal"));
|
||||
public static final SoundEvent DESTRUCT = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("projecte", "item.pedestruct"));
|
||||
public static final SoundEvent CHARGE = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("projecte", "item.pecharge"));
|
||||
public static final SoundEvent UNCHARGE = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("projecte", "item.peuncharge"));
|
||||
public static final SoundEvent TRANSMUTE = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("projecte", "item.petransmute"));
|
||||
|
||||
private PESounds() {
|
||||
}
|
||||
|
||||
}
|
@@ -1,101 +0,0 @@
|
||||
package moze_intel.projecte.api;
|
||||
|
||||
import moze_intel.projecte.api.capabilities.IAlchBagProvider;
|
||||
import moze_intel.projecte.api.capabilities.IKnowledgeProvider;
|
||||
import moze_intel.projecte.api.proxy.IBlacklistProxy;
|
||||
import moze_intel.projecte.api.proxy.IConversionProxy;
|
||||
import moze_intel.projecte.api.proxy.IEMCProxy;
|
||||
import moze_intel.projecte.api.proxy.ITransmutationProxy;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
public final class ProjectEAPI {
|
||||
private static IEMCProxy emcProxy;
|
||||
private static ITransmutationProxy transProxy;
|
||||
private static IBlacklistProxy blacklistProxy;
|
||||
private static IConversionProxy recipeProxy;
|
||||
|
||||
private ProjectEAPI() {
|
||||
}
|
||||
|
||||
/**
|
||||
* The capability object for IAlchBagProvider
|
||||
*/
|
||||
@CapabilityInject(IAlchBagProvider.class)
|
||||
public static final Capability<IAlchBagProvider> ALCH_BAG_CAPABILITY = null;
|
||||
|
||||
/**
|
||||
* The capability object for IKnowledgeProvider
|
||||
*/
|
||||
@CapabilityInject(IKnowledgeProvider.class)
|
||||
public static final Capability<IKnowledgeProvider> KNOWLEDGE_CAPABILITY = null;
|
||||
|
||||
/**
|
||||
* Retrieves the proxy for EMC-based API queries.
|
||||
*
|
||||
* @return The proxy for EMC-based API queries
|
||||
*/
|
||||
public static IEMCProxy getEMCProxy() {
|
||||
if (emcProxy == null) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName("moze_intel.projecte.impl.EMCProxyImpl");
|
||||
emcProxy = (IEMCProxy) clazz.getField("instance").get(null);
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
FMLLog.warning("[ProjectEAPI] Error retrieving EMCProxyImpl, ProjectE may be absent, damaged, or outdated.");
|
||||
}
|
||||
}
|
||||
return emcProxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the proxy for EMC-Recipe-Calculation-based API queries.
|
||||
*
|
||||
* @return The proxy for EMC-Recipe-Calculation-based API queries
|
||||
*/
|
||||
public static IConversionProxy getConversionProxy() {
|
||||
if (recipeProxy == null) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName("moze_intel.projecte.impl.ConversionProxyImpl");
|
||||
recipeProxy = (IConversionProxy) clazz.getField("instance").get(null);
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
FMLLog.warning("[ProjectEAPI] Error retrieving ConversionProxyImpl, ProjectE may be absent, damaged, or outdated.");
|
||||
}
|
||||
}
|
||||
return recipeProxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the proxy for Transmutation-based API queries.
|
||||
*
|
||||
* @return The proxy for Transmutation-based API queries
|
||||
*/
|
||||
public static ITransmutationProxy getTransmutationProxy() {
|
||||
if (transProxy == null) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName("moze_intel.projecte.impl.TransmutationProxyImpl");
|
||||
transProxy = (ITransmutationProxy) clazz.getField("instance").get(null);
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
FMLLog.warning("[ProjectEAPI] Error retrieving TransmutationProxyImpl, ProjectE may be absent, damaged, or outdated.");
|
||||
}
|
||||
}
|
||||
return transProxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the proxy for black/whitelist-based API queries.
|
||||
*
|
||||
* @return The proxy for black/whitelist-based API queries
|
||||
*/
|
||||
public static IBlacklistProxy getBlacklistProxy() {
|
||||
if (blacklistProxy == null) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName("moze_intel.projecte.impl.BlacklistProxyImpl");
|
||||
blacklistProxy = (IBlacklistProxy) clazz.getField("instance").get(null);
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
FMLLog.warning("[ProjectEAPI] Error retrieving BlacklistProxyImpl, ProjectE may be absent, damaged, or outdated.");
|
||||
}
|
||||
}
|
||||
return blacklistProxy;
|
||||
}
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
package moze_intel.projecte.api.capabilities;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.INBTSerializable;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* This interface defines the contract for some object that exposes sixteen colored inventories,
|
||||
* for the purpose of usage as Alchemical Bags.
|
||||
* This is exposed through the Capability system.
|
||||
* Acquire an instance of this using {@link net.minecraft.entity.Entity#getCapability(Capability, EnumFacing)}.
|
||||
*/
|
||||
public interface IAlchBagProvider extends INBTSerializable<NBTTagCompound> {
|
||||
|
||||
/**
|
||||
* Note: modifying this clientside is not advised
|
||||
*
|
||||
* @param color The bag color to acquire
|
||||
* @return The inventory representing this alchemical bag
|
||||
*/
|
||||
@Nonnull
|
||||
IItemHandler getBag(@Nonnull EnumDyeColor color);
|
||||
|
||||
/**
|
||||
* Syncs the bag inventory associated with this color to the player provided (usually the owner of this capability instance)
|
||||
*
|
||||
* @param color The bag color to sync. If null, syncs every color.
|
||||
* @param player The player to sync the bags to.
|
||||
*/
|
||||
void sync(@Nonnull EnumDyeColor color, @Nonnull EntityPlayerMP player);
|
||||
|
||||
}
|
@@ -1,81 +0,0 @@
|
||||
package moze_intel.projecte.api.capabilities;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.INBTSerializable;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This interface defines the contract for some object that exposes transmutation knowledge through the Capability system.
|
||||
* Acquire an instance of this using {@link net.minecraft.entity.Entity#getCapability(Capability, EnumFacing)}.
|
||||
*/
|
||||
public interface IKnowledgeProvider extends INBTSerializable<NBTTagCompound> {
|
||||
|
||||
/**
|
||||
* @return Whether the player has the "tome" flag set, meaning all knowledge checks automatically return true
|
||||
*/
|
||||
boolean hasFullKnowledge();
|
||||
|
||||
/**
|
||||
* @param fullKnowledge Whether the player has the "tome" flag set, meaning all knowledge checks automatically return true
|
||||
*/
|
||||
void setFullKnowledge(boolean fullKnowledge);
|
||||
|
||||
/**
|
||||
* Clears all knowledge. Additionally, clears the "tome" flag.
|
||||
*/
|
||||
void clearKnowledge();
|
||||
|
||||
/**
|
||||
* @param stack The stack to query
|
||||
* @return Whether the player has transmutation knowledge for this stack
|
||||
*/
|
||||
boolean hasKnowledge(@Nullable ItemStack stack);
|
||||
|
||||
/**
|
||||
* @param stack The stack to add to knowledge
|
||||
* @return Whether the operation was successful
|
||||
*/
|
||||
boolean addKnowledge(@Nonnull ItemStack stack);
|
||||
|
||||
/**
|
||||
* @param stack The stack to remove from knowledge
|
||||
* @return Whether the operation was successful
|
||||
*/
|
||||
boolean removeKnowledge(@Nonnull ItemStack stack);
|
||||
|
||||
/**
|
||||
* @return An unmodifiable but live view of the knowledge list.
|
||||
*/
|
||||
@Nonnull
|
||||
List<ItemStack> getKnowledge();
|
||||
|
||||
/**
|
||||
* @return The player's input and lock slots
|
||||
*/
|
||||
@Nonnull
|
||||
IItemHandler getInputAndLocks();
|
||||
|
||||
/**
|
||||
* @return The emc in this player's transmutation tablet network
|
||||
*/
|
||||
double getEmc();
|
||||
|
||||
/**
|
||||
* @param emc The emc to set in this player's transmutation tablet network
|
||||
*/
|
||||
void setEmc(double emc);
|
||||
|
||||
/**
|
||||
* @param player The player to sync to.
|
||||
*/
|
||||
void sync(@Nonnull EntityPlayerMP player);
|
||||
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
package moze_intel.projecte.api.event;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
/**
|
||||
* This event is fired after all EMC values are recalculated
|
||||
* This event is not cancelable, and has no result
|
||||
* This event is fired on MinecraftForge#EVENT_BUS
|
||||
*/
|
||||
public class EMCRemapEvent extends Event {
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
package moze_intel.projecte.api.event;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This event is fired after a players transmutation knowledge is changed
|
||||
* This event is not cancelable, and has no result
|
||||
* This event is fired on MinecraftForge#EVENT_BUS
|
||||
*/
|
||||
public class PlayerKnowledgeChangeEvent extends Event {
|
||||
private final UUID playerUUID;
|
||||
|
||||
public PlayerKnowledgeChangeEvent(@Nonnull EntityPlayer entityPlayer) {
|
||||
playerUUID = entityPlayer.getUniqueID();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public UUID getPlayerUUID() {
|
||||
return playerUUID;
|
||||
}
|
||||
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
package moze_intel.projecte.api.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* This interfaces specifies items that perform a specific function every tick when inside an Alchemical Bag, on a player
|
||||
*
|
||||
* @author williewillus
|
||||
*/
|
||||
public interface IAlchBagItem {
|
||||
/**
|
||||
* Called on both client and server every time the alchemical bag ticks this item
|
||||
*
|
||||
* @param inv The inventory of the bag
|
||||
* @param player The player whose bag is being ticked
|
||||
* @param stack The ItemStack being ticked
|
||||
* @return Whether the inventory was changed by this item ticking
|
||||
*/
|
||||
boolean updateInAlchBag(@Nonnull IItemHandler inv, @Nonnull EntityPlayer player, @Nonnull ItemStack stack);
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
package moze_intel.projecte.api.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* This interface specifies items that perform a specific function every tick when inside an Alchemical Chest
|
||||
*
|
||||
* @author williewillus
|
||||
*/
|
||||
public interface IAlchChestItem {
|
||||
/**
|
||||
* Called on both client and server every time the alchemical chest ticks this item
|
||||
* Implementers that modify the chest inventory (serverside) MUST call markDirty() on the tile entity.
|
||||
* If you do not, your changes may not be saved when the world/chunk unloads!
|
||||
*
|
||||
* @param world The World
|
||||
* @param stack The ItemStack being ticked
|
||||
*/
|
||||
void updateInAlchChest(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull ItemStack stack);
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
package moze_intel.projecte.api.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This interface specifies items that perform a specific function when the Extra Function key is activated (default C)
|
||||
*/
|
||||
public interface IExtraFunction {
|
||||
/**
|
||||
* Called serverside when the server receives a Extra Function key packet
|
||||
*
|
||||
* @param stack The ItemStack performing this function
|
||||
* @param player The player performing this function
|
||||
* @param hand The hand this stack was in, or null if the call was not from the player's hands
|
||||
* @return Whether the operation succeeded
|
||||
*/
|
||||
boolean doExtraFunction(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nullable EnumHand hand);
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
package moze_intel.projecte.api.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This interface specifies items that have a charge that changes when the respective keybinding is activated (default V)
|
||||
*/
|
||||
public interface IItemCharge {
|
||||
/**
|
||||
* Returns the current charge on the given ItemStack
|
||||
*
|
||||
* @param stack Stack whose charge we want
|
||||
* @return The charge on the stack
|
||||
*/
|
||||
byte getCharge(@Nonnull ItemStack stack);
|
||||
|
||||
/**
|
||||
* Called serverside when the player presses the charge keybinding; reading sneaking state is up to you
|
||||
*
|
||||
* @param player The player
|
||||
* @param stack The item being charged
|
||||
* @param hand The hand this stack was in, or null if the call was not from the player's hands
|
||||
* @return Whether the operation succeeded
|
||||
*/
|
||||
boolean changeCharge(@Nonnull EntityPlayer player, @Nonnull ItemStack stack, @Nullable EnumHand hand);
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
package moze_intel.projecte.api.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* This interface defines the contract for items that wish to expose their internal EMC storage for external manipulation
|
||||
*
|
||||
* @author williewillus
|
||||
*/
|
||||
public interface IItemEmc {
|
||||
/**
|
||||
* Adds EMC to the itemstack
|
||||
*
|
||||
* @param stack The itemstack to add to
|
||||
* @param toAdd The maximum amount to add
|
||||
* @return The amount that was actually added
|
||||
*/
|
||||
double addEmc(@Nonnull ItemStack stack, double toAdd);
|
||||
|
||||
/**
|
||||
* Extracts EMC from the itemstack
|
||||
*
|
||||
* @param stack The itemstack to remove from
|
||||
* @param toRemove The maximum amount to remove
|
||||
* @return The amount that was actually extracted
|
||||
*/
|
||||
double extractEmc(@Nonnull ItemStack stack, double toRemove);
|
||||
|
||||
/**
|
||||
* Gets the current EMC this stack is showing to the public
|
||||
*
|
||||
* @param stack The stack to query
|
||||
* @return The current publicly-accessible EMC stored in this stack
|
||||
*/
|
||||
double getStoredEmc(@Nonnull ItemStack stack);
|
||||
|
||||
/**
|
||||
* Gets the maximum EMC that is allowed to be stored in this stack
|
||||
*
|
||||
* @param stack The stack to query
|
||||
* @return The maximum amount of publicly-accessible EMC that can be stored in this stack
|
||||
*/
|
||||
double getMaximumEmc(@Nonnull ItemStack stack);
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
package moze_intel.projecte.api.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This interface specifies items that switch between modes when the mode switch keybind is activated (default G)
|
||||
*/
|
||||
public interface IModeChanger {
|
||||
/**
|
||||
* Gets the mode from this ItemStack
|
||||
*
|
||||
* @param stack The stack we want the mode of
|
||||
* @return The mode of this ItemStack
|
||||
*/
|
||||
byte getMode(@Nonnull ItemStack stack);
|
||||
|
||||
/**
|
||||
* Called serverside when the player presses change mode
|
||||
*
|
||||
* @param player The player pressing the change mode key
|
||||
* @param stack The stack whose mode we are changing
|
||||
* @param hand The hand this stack was in, or null if the call was not from the player's hands
|
||||
* @return Whether the operation succeeded
|
||||
*/
|
||||
boolean changeMode(@Nonnull EntityPlayer player, @Nonnull ItemStack stack, @Nullable EnumHand hand);
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
package moze_intel.projecte.api.item;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This interface specifies items that perform a specific function every tick when inside an activated Dark Matter Pedestal
|
||||
*
|
||||
* @author williewillus
|
||||
*/
|
||||
public interface IPedestalItem {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
String TOOLTIPDISABLED = TextFormatting.RED + I18n.format("pe.pedestal.item_disabled");
|
||||
|
||||
/***
|
||||
* Called on both client and server each time an active DMPedestalTile ticks with this item inside
|
||||
*/
|
||||
void updateInPedestal(@Nonnull World world, @Nonnull BlockPos pos);
|
||||
|
||||
/***
|
||||
* Called clientside when inside the pedestal gui to add special function descriptions
|
||||
* @return Brief strings describing the item's function in an activated pedestal
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Nonnull
|
||||
List<String> getPedestalDescription();
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
package moze_intel.projecte.api.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This interface specifies items that fire a projectile when the Shoot Projectile keybind is activated (default R)
|
||||
*/
|
||||
public interface IProjectileShooter {
|
||||
/**
|
||||
* Called serverside when the player presses the Fire Projectile Button
|
||||
*
|
||||
* @param player The player pressing the key
|
||||
* @param stack The stack we are using to shoot
|
||||
* @param hand The hand this stack was in, or null if the call was not from the player's hands
|
||||
* @return If the projectile was actually fired
|
||||
*/
|
||||
boolean shootProjectile(@Nonnull EntityPlayer player, @Nonnull ItemStack stack, @Nullable EnumHand hand);
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* Increment apiVersion every time the API changes.
|
||||
* (Adding methods, removing methods, changing method signatures, etc.)
|
||||
*/
|
||||
@API(owner = "ProjectE", apiVersion = "1.10.2-1.0.0", provides = "ProjectEAPI")
|
||||
package moze_intel.projecte.api;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
@@ -1,42 +0,0 @@
|
||||
package moze_intel.projecte.api.proxy;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public interface IBlacklistProxy {
|
||||
/**
|
||||
* Blacklist an Entity class from being repelled by the Interdiction Torch
|
||||
* Call this during the postinit phase
|
||||
*
|
||||
* @param clazz The entity class to blacklist
|
||||
*/
|
||||
void blacklistInterdiction(@Nonnull Class<? extends Entity> clazz);
|
||||
|
||||
/**
|
||||
* Blacklist an Entity class from being repelled by the SWRG's repel mode
|
||||
* Call this during the postinit phase
|
||||
*
|
||||
* @param clazz The entity class to blacklist
|
||||
*/
|
||||
void blacklistSwiftwolf(@Nonnull Class<? extends Entity> clazz);
|
||||
|
||||
/**
|
||||
* Prevent the Watch of Flowing Time from speeding up this TileEntity
|
||||
* Modders: Use this only to prevent things from breaking badly - leave balance to the modpacker and player
|
||||
* Call this during the postinit phase
|
||||
*
|
||||
* @param clazz The TileEntity to blacklist
|
||||
*/
|
||||
void blacklistTimeWatch(@Nonnull Class<? extends TileEntity> clazz);
|
||||
|
||||
/**
|
||||
* Whitelist an ItemStack, allowing stacks of its kind to dupe NBT during Transmutation and Condensation
|
||||
* Call this during the postinit phase
|
||||
*
|
||||
* @param stack The stack to whitelist
|
||||
*/
|
||||
void whitelistNBT(@Nonnull ItemStack stack);
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
package moze_intel.projecte.api.proxy;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IConversionProxy {
|
||||
/**
|
||||
* Add a Conversion to the EMC Calculation.
|
||||
* <p>
|
||||
* Adding a Conversion allows ProjectE to calculate the EMC value for the output based on the specified ingredients.
|
||||
* These do not need to be actually Conversions. You can use it to make the EMC value of an item relative to the EMC value of other items.
|
||||
* ProjectE will automatically select the Conversion with the lowest EMC value.
|
||||
* <p>
|
||||
* Has to be called after {@code FMLInitializationEvent} and before {@code FMLServerStartingEvent}.
|
||||
* <p>
|
||||
* You can use the following things for the {@code output}-Parameter and the keys in the {@code ingredients} Map:
|
||||
* <ul>
|
||||
* <li>{@link ItemStack} - The ItemId and Metadata will be used to identify this ItemStack (May contain a {@code Block} or {@code Item}). You can use {@link net.minecraftforge.oredict.OreDictionary#WILDCARD_VALUE} as metadata.</li>
|
||||
* <li>{@link Block} - Same as calling it with {@code new ItemStack(block)}. Uses the Id and metadata = 0</li>
|
||||
* <li>{@link Item} - Same as calling it with {@code new ItemStack(item)}. Uses the Id and metadata = 0</li>
|
||||
* <li>{@link FluidStack} - {@link FluidStack#getFluid()} and {@link Fluid#getName()} will be used to identify this Fluid.</li>
|
||||
* <li>{@link String} - will be interpreted as an OreDictionary name.</li>
|
||||
* <li>{@link Object} - (No subclasses of {@code Object} - only {@code Object}!) can be used as a intermediate fake object for complex conversion.</li>
|
||||
* </ul>
|
||||
* All {@code Object}s will be assumed to be a single instance. No stacksize will be used.
|
||||
* <p>
|
||||
* Use the {@code amount} parameter to specify how many {@code output}s are created.
|
||||
* Use the value in the {@code ingredients}-Map to specify how much of an ingredient is required.
|
||||
* (Use Millibuckets for Fluids)
|
||||
* <p>
|
||||
* Examples:
|
||||
* <p>
|
||||
* <pre>{@code
|
||||
* //Furnace Crafting Recipe:
|
||||
* addConversion(1, Blocks.FURNACE, ImmutableMap.of((Object)Blocks.COBBLESTONE, 8));
|
||||
* //alternatively:
|
||||
* addConversion(1, Blocks.FURNACE, ImmutableMap.<Object, Integer>of(Blocks.COBBLESTONE, 8));
|
||||
*
|
||||
* //Bed Crafting Recipe with OreDictionary Names:
|
||||
* //3 "plankWood" and 3 "blockWool" turn into 1 Blocks.BED
|
||||
* addConversion(1, Blocks.BED, ImmutableMap.<Object, Integer>of("plankWood", 3, "blockWool", 3));
|
||||
*
|
||||
* //For Recipes that have multiple possible Ingredients, that don't belong to a known OreDict entry you can use a fake-item Object:
|
||||
* Object blackOrWhite = new Object();
|
||||
* //1 White Wool can be turned into 1 'blackOrWhite'
|
||||
* addConversion(1, blackOrWhite, ImmutableMap.of((Object)new ItemStack(Blocks.WOOL, 1, 0), 1));
|
||||
* //1 Black Wool can be turned into 1 'blackOrWhite'
|
||||
* addConversion(1, blackOrWhite, ImmutableMap.of((Object)new ItemStack(Blocks.WOOL, 1, 15), 1));
|
||||
* //Bed created with black or white wool only
|
||||
* addConversion(1, Blocks.BED, ImmutableMap.of(blackOrWhite, 3, "plankWood", 3));
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @param amount
|
||||
* @param output
|
||||
* @param ingredients
|
||||
*/
|
||||
void addConversion(int amount, @Nonnull Object output, @Nonnull Map<Object, Integer> ingredients);
|
||||
}
|
@@ -1,96 +0,0 @@
|
||||
package moze_intel.projecte.api.proxy;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IEMCProxy {
|
||||
/**
|
||||
* Registers a custom EMC value for this ItemStack
|
||||
* Call this during any of the main loading phases (Preinit, Init, Postinit)
|
||||
*
|
||||
* @param stack The stack we want to define EMC for
|
||||
* @param value The value to define. Values below 0 are changed to 0
|
||||
*/
|
||||
void registerCustomEMC(@Nonnull ItemStack stack, int value);
|
||||
|
||||
/**
|
||||
* Register a custom EMC value for emc calculation that is used in Recipes.
|
||||
* You can use the following things for the {@code o}-Parameter:
|
||||
* <ul>
|
||||
* <li>{@link ItemStack} - The Modname:unlocalizedName and Metadata will be used to identify this ItemStack (May contain a {@code Block} or {@code Item})</li>
|
||||
* <li>{@link String} - will be interpreted as an OreDictionary name.</li>
|
||||
* <li>{@link Object} - (No subclasses of {@code Object} - only {@code Object}!) can be used as a intermediate fake object for complex recipes.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param o
|
||||
* @param value
|
||||
* @see IConversionProxy#addConversion(int, Object, Map)
|
||||
*/
|
||||
void registerCustomEMC(@Nonnull Object o, int value);
|
||||
|
||||
/**
|
||||
* Queries the EMC value registry if the given block has an EMC value
|
||||
* Can be called at any time, but will only return valid results if a world is loaded
|
||||
* Can be called on both sides
|
||||
*
|
||||
* @param block The block we want to query
|
||||
* @return Whether the block has an emc value
|
||||
*/
|
||||
boolean hasValue(@Nonnull Block block);
|
||||
|
||||
/**
|
||||
* Queries the EMC value registry if the given item with a damage value of 0 has an EMC value
|
||||
* Can be called at any time, but will only return valid results if a world is loaded
|
||||
* Can be called on both sides
|
||||
*
|
||||
* @param item The item we want to query
|
||||
* @return Whether the item has an emc value
|
||||
*/
|
||||
boolean hasValue(@Nonnull Item item);
|
||||
|
||||
/**
|
||||
* Queries the EMC value registry if the given ItemStack has an EMC value
|
||||
* This will also use the damage value to check if the Item has an EMC value
|
||||
* Can be called at any time, but will only return valid results if a world is loaded
|
||||
* Can be called on both sides
|
||||
*
|
||||
* @param stack The stack we want to query
|
||||
* @return Whether the ItemStack has an emc value
|
||||
*/
|
||||
boolean hasValue(@Nonnull ItemStack stack);
|
||||
|
||||
/**
|
||||
* Queries the EMC value for the provided block
|
||||
* Can be called at any time, but will only return valid results if a world is loaded
|
||||
* Can be called on both sides
|
||||
*
|
||||
* @param block The block we want to query
|
||||
* @return The block's EMC value, or 0 if there is none
|
||||
*/
|
||||
int getValue(@Nonnull Block block);
|
||||
|
||||
/**
|
||||
* Queries the EMC value for the provided item
|
||||
* Can be called at any time, but will only return valid results if a world is loaded
|
||||
* Can be called on both sides
|
||||
*
|
||||
* @param item The item we want to query
|
||||
* @return The item's EMC value, or 0 if there is none
|
||||
*/
|
||||
int getValue(@Nonnull Item item);
|
||||
|
||||
/**
|
||||
* Queries the EMC value for the provided stack
|
||||
* Can be called at any time, but will only return valid results if a world is loaded
|
||||
* Can be called on both sides
|
||||
* This takes into account bonuses such as stored emc in power items and enchantments
|
||||
*
|
||||
* @param stack The stack we want to query
|
||||
* @return The stack's EMC value, or 0 if there is none
|
||||
*/
|
||||
int getValue(@Nonnull ItemStack stack);
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
package moze_intel.projecte.api.proxy;
|
||||
|
||||
import moze_intel.projecte.api.capabilities.IKnowledgeProvider;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface ITransmutationProxy {
|
||||
/**
|
||||
* Register a world transmutation with the Philosopher's Stone
|
||||
* Calls this during the postinit phase
|
||||
*
|
||||
* @param origin Original blockstate when targeting world transmutation
|
||||
* @param result1 First result blockstate
|
||||
* @param result2 Alternate result blockstate (when sneaking). You may pass null, in which there will be no alternate transmutation
|
||||
* @return Whether the registration succeeded. It may fail if transmutations already exist for block origin
|
||||
*/
|
||||
boolean registerWorldTransmutation(@Nonnull IBlockState origin, @Nonnull IBlockState result1, @Nullable IBlockState result2);
|
||||
|
||||
/**
|
||||
* Gets an {@link IKnowledgeProvider} representing the UUID provided.
|
||||
* <p>
|
||||
* If the provided UUID is offline, note that the returned {@link IKnowledgeProvider} is immutable!
|
||||
* If called clientside, {@param playerUUID} is ignored and the client player is used instead.
|
||||
* If called serverside, this must be called after the server has reached state SERVER_STARTED.
|
||||
* <p>
|
||||
* If the provided UUID could not be found both on or offline, an {@link IKnowledgeProvider} with no knowledge is returned.
|
||||
*
|
||||
* @param playerUUID The UUID to query
|
||||
* @return an {@link IKnowledgeProvider} representing the UUID provided, or an {@link IKnowledgeProvider} representing no knowledge if
|
||||
* the requested UUID could not be found
|
||||
*/
|
||||
@Nonnull
|
||||
IKnowledgeProvider getKnowledgeProviderFor(@Nonnull UUID playerUUID);
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
package moze_intel.projecte.api.state;
|
||||
|
||||
import moze_intel.projecte.api.state.enums.EnumFuelType;
|
||||
import moze_intel.projecte.api.state.enums.EnumMatterType;
|
||||
import net.minecraft.block.BlockHorizontal;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public final class PEStateProps {
|
||||
|
||||
public static final IProperty<EnumFacing> FACING = BlockHorizontal.FACING;
|
||||
public static final IProperty<EnumFuelType> FUEL_PROP = PropertyEnum.create("fueltype", EnumFuelType.class);
|
||||
public static final IProperty<EnumMatterType> TIER_PROP = PropertyEnum.create("tier", EnumMatterType.class);
|
||||
|
||||
private PEStateProps() {
|
||||
}
|
||||
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
package moze_intel.projecte.api.state.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public enum EnumFuelType implements IStringSerializable {
|
||||
ALCHEMICAL_COAL("alchemical_coal"),
|
||||
MOBIUS_FUEL("mobius_fuel"),
|
||||
AETERNALIS_FUEL("aeternalis_fuel");
|
||||
|
||||
private final String name;
|
||||
|
||||
EnumFuelType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
package moze_intel.projecte.api.state.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public enum EnumMatterType implements IStringSerializable {
|
||||
DARK_MATTER("dark_matter"),
|
||||
RED_MATTER("red_matter");
|
||||
|
||||
private final String name;
|
||||
|
||||
EnumMatterType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
package moze_intel.projecte.api.tile;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Implement this interface to specify that "EMC can be given to this Tile Entity from an external source"
|
||||
* The contract of this interface is only the above statement
|
||||
* However, ProjectE implements an "active-push" system, where providers automatically send EMC to acceptors. You are recommended to follow this convention
|
||||
* Reference implementation provided in TileEmcHandler
|
||||
*
|
||||
* @author williewillus
|
||||
*/
|
||||
public interface IEmcAcceptor extends IEmcStorage {
|
||||
/**
|
||||
* Accept, at most, the given amount of EMC from the given side
|
||||
*
|
||||
* @param side The side to accept EMC from
|
||||
* @param toAccept The maximum amount to accept
|
||||
* @return The amount actually accepted
|
||||
*/
|
||||
double acceptEMC(@Nonnull EnumFacing side, double toAccept);
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
package moze_intel.projecte.api.tile;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Implement this interface to specify that "EMC can be taken from this Tile Entity from an external source"
|
||||
* The contract of this interface is limited to only the above statement
|
||||
* However, ProjectE implements an "active-push" system, where providers automatically send EMC to acceptors. You are recommended to follow this convention
|
||||
* Reference implementation provided in TileEmcHandler
|
||||
*
|
||||
* @author williewillus
|
||||
*/
|
||||
public interface IEmcProvider extends IEmcStorage {
|
||||
/**
|
||||
* Extract, at most, the given amount of EMC from the given side
|
||||
*
|
||||
* @param side The side to extract EMC from
|
||||
* @param toExtract The maximum amount to extract
|
||||
* @return The amount actually extracted
|
||||
*/
|
||||
double provideEMC(@Nonnull EnumFacing side, double toExtract);
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
package moze_intel.projecte.api.tile;
|
||||
|
||||
/**
|
||||
* Defines the contract for arbitrary objects that can store EMC
|
||||
* You usually do not want to use this directly
|
||||
* Use extensions IEMCAcceptor and IEMCProvider, or the provided reference implementations instead
|
||||
*
|
||||
* @author williewillus
|
||||
*/
|
||||
public interface IEmcStorage {
|
||||
/**
|
||||
* Gets the current amount of EMC in this IEMCStorage
|
||||
*
|
||||
* @return The current EMC stored
|
||||
*/
|
||||
double getStoredEmc();
|
||||
|
||||
/**
|
||||
* Gets the maximum amount of EMC this IEMCStorage is allowed to contain
|
||||
*
|
||||
* @return The maximum EMC allowed
|
||||
*/
|
||||
double getMaximumEmc();
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
package moze_intel.projecte.api.tile;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Reference implementation of IEMCAcceptor
|
||||
*
|
||||
* @author williewillus
|
||||
*/
|
||||
public class TileEmcAcceptor extends TileEmcBase implements IEmcAcceptor {
|
||||
@Override
|
||||
public double acceptEMC(@Nonnull EnumFacing side, double toAccept) {
|
||||
double toAdd = Math.min(maximumEMC - currentEMC, toAccept);
|
||||
addEMC(toAdd);
|
||||
return toAdd;
|
||||
}
|
||||
}
|
@@ -1,80 +0,0 @@
|
||||
package moze_intel.projecte.api.tile;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Base class for the reference implementations TileEmcProvider, TileEmcAcceptor, and TileEmcHandler
|
||||
* Usually you want to use one of three derived reference implementations
|
||||
* Extend this if you want fine-grained control over all aspects of how your tile provides or accepts EMC
|
||||
*
|
||||
* @author williewillus
|
||||
*/
|
||||
public class TileEmcBase extends TileEntity implements IEmcStorage {
|
||||
protected double maximumEMC;
|
||||
protected double currentEMC = 0;
|
||||
|
||||
protected TileEmcBase() {
|
||||
setMaximumEMC(Double.MAX_VALUE);
|
||||
}
|
||||
|
||||
public final void setMaximumEMC(double max) {
|
||||
maximumEMC = max;
|
||||
if (currentEMC > maximumEMC) {
|
||||
currentEMC = maximumEMC;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getStoredEmc() {
|
||||
return currentEMC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaximumEmc() {
|
||||
return maximumEMC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add EMC directly into the internal buffer. Use for internal implementation of your tile
|
||||
*/
|
||||
protected void addEMC(double toAdd) {
|
||||
currentEMC += toAdd;
|
||||
if (currentEMC > maximumEMC) {
|
||||
currentEMC = maximumEMC;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes EMC directly into the internal buffer. Use for internal implementation of your tile
|
||||
*/
|
||||
protected void removeEMC(double toRemove) {
|
||||
currentEMC -= toRemove;
|
||||
if (currentEMC < 0) {
|
||||
currentEMC = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
tag = super.writeToNBT(tag);
|
||||
if (currentEMC > maximumEMC) {
|
||||
currentEMC = maximumEMC;
|
||||
}
|
||||
tag.setDouble("EMC", currentEMC);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
double set = tag.getDouble("EMC");
|
||||
if (set > maximumEMC) {
|
||||
set = maximumEMC;
|
||||
}
|
||||
currentEMC = set;
|
||||
}
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
package moze_intel.projecte.api.tile;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Reference implementation of both IEMCAcceptor and IEMCProvider
|
||||
*
|
||||
* @author williewillus
|
||||
*/
|
||||
public class TileEmcHandler extends TileEmcBase implements IEmcAcceptor, IEmcProvider {
|
||||
public TileEmcHandler() {
|
||||
this.maximumEMC = Double.MAX_VALUE;
|
||||
}
|
||||
|
||||
public TileEmcHandler(double max) {
|
||||
this.maximumEMC = max;
|
||||
}
|
||||
|
||||
// -- IEMCAcceptor -- //
|
||||
@Override
|
||||
public double acceptEMC(@Nonnull EnumFacing side, double toAccept) {
|
||||
double toAdd = Math.min(maximumEMC - currentEMC, toAccept);
|
||||
currentEMC += toAdd;
|
||||
return toAdd;
|
||||
}
|
||||
|
||||
// -- IEMCProvider -- //
|
||||
@Override
|
||||
public double provideEMC(@Nonnull EnumFacing side, double toExtract) {
|
||||
double toRemove = Math.min(currentEMC, toExtract);
|
||||
currentEMC -= toRemove;
|
||||
return toRemove;
|
||||
}
|
||||
|
||||
// -- IEMCStorage --//
|
||||
@Override
|
||||
public double getStoredEmc() {
|
||||
return currentEMC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaximumEmc() {
|
||||
return maximumEMC;
|
||||
}
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
package moze_intel.projecte.api.tile;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Reference implementation for IEMCProvider
|
||||
*
|
||||
* @author williewillus
|
||||
*/
|
||||
public class TileEmcProvider extends TileEmcBase implements IEmcProvider {
|
||||
@Override
|
||||
public double provideEMC(@Nonnull EnumFacing side, double toExtract) {
|
||||
double toRemove = Math.min(currentEMC, toExtract);
|
||||
removeEMC(toRemove);
|
||||
return toRemove;
|
||||
}
|
||||
}
|
@@ -3,7 +3,7 @@
|
||||
"modid": "refinedstorage",
|
||||
"name": "Refined Storage",
|
||||
"description": "An elegant solution to your hoarding problem",
|
||||
"version": "1.5.35",
|
||||
"version": "1.6",
|
||||
"mcversion": "1.12.2",
|
||||
"url": "https://refinedstorage.raoulvdberge.com",
|
||||
"updateUrl": "",
|
||||
|
Reference in New Issue
Block a user