Added Project E integration, fixes #425
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -14,5 +14,4 @@ run/
|
||||
.idea/
|
||||
out/
|
||||
translation-diff.diff
|
||||
src/main/java/mcmultipart/*
|
||||
src/main/resources/assets/mcmultiparttest/*
|
||||
src/main/java/moze_intel/*
|
@@ -1,5 +1,9 @@
|
||||
# Refined Storage Changelog
|
||||
|
||||
### 1.5.18
|
||||
- Added Project E integration for the External Storage on the Transmutation Table (raoulvdberge)
|
||||
- Added Project E integration for the energy values of Solderer items (raoulvdberge)
|
||||
|
||||
### 1.5.17
|
||||
- Re-added support for OpenComputers (raoulvdberge)
|
||||
- Fixed crash with Grid (raoulvdberge)
|
||||
|
@@ -32,4 +32,11 @@ public interface ISoldererRecipe {
|
||||
* @return the duration in ticks that this recipe takes to give the result back
|
||||
*/
|
||||
int getDuration();
|
||||
|
||||
/**
|
||||
* @return whether this recipe can be used to calculate the EMC value of the resulting item in the Project E mod
|
||||
*/
|
||||
default boolean isProjectERecipe() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -194,6 +194,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor,
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TileEntity getFacingTile() {
|
||||
return world.getTileEntity(pos.offset(getDirection()));
|
||||
}
|
||||
|
@@ -12,6 +12,8 @@ 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;
|
||||
@@ -200,11 +202,8 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
|
||||
|
||||
TileEntity facing = getFacingTile();
|
||||
|
||||
if (facing == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -218,6 +217,9 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
|
||||
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());
|
||||
|
||||
|
@@ -45,6 +45,7 @@ public class SoldererRecipeFactory {
|
||||
|
||||
final ItemStack result = CraftingHelper.getItemStack(JsonUtils.getJsonObject(json, "result"), context);
|
||||
final int duration = JsonUtils.getInt(json, "duration");
|
||||
final boolean projectERecipe = JsonUtils.getBoolean(json, "projecte", true);
|
||||
|
||||
return new ISoldererRecipe() {
|
||||
@Override
|
||||
@@ -68,6 +69,11 @@ public class SoldererRecipeFactory {
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProjectERecipe() {
|
||||
return projectERecipe;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,39 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,132 @@
|
||||
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.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() {
|
||||
List<ItemStack> stored = new LinkedList<>();
|
||||
|
||||
if (externalStorage.getOwner() != null) {
|
||||
IKnowledgeProvider provider = ProjectEAPI.getTransmutationProxy().getKnowledgeProviderFor(externalStorage.getOwner());
|
||||
|
||||
for (ItemStack knowledge : provider.getKnowledge()) {
|
||||
stored.add(ItemHandlerHelper.copyStackWithSize(knowledge, (int) Math.floor(provider.getEmc() / (double) ProjectEAPI.getEMCProxy().getValue(knowledge))));
|
||||
}
|
||||
}
|
||||
|
||||
return stored;
|
||||
}
|
||||
|
||||
@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());
|
||||
|
||||
int emc = ProjectEAPI.getEMCProxy().getValue(actualStack) * size;
|
||||
|
||||
if (emc == 0) {
|
||||
return actualStack;
|
||||
}
|
||||
|
||||
if (!simulate) {
|
||||
provider.setEmc(provider.getEmc() + emc);
|
||||
|
||||
if (!provider.hasKnowledge(stack)) {
|
||||
provider.addKnowledge(stack);
|
||||
}
|
||||
|
||||
EntityPlayer player = externalStorage.getWorld().getPlayerEntityByUUID(externalStorage.getOwner());
|
||||
|
||||
if (player != null) {
|
||||
provider.sync((EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return actualStack;
|
||||
}
|
||||
|
||||
@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());
|
||||
|
||||
if (provider.hasKnowledge(stack)) {
|
||||
double singleEmc = ProjectEAPI.getEMCProxy().getValue(stack);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
@@ -26,6 +26,7 @@ import com.raoulvdberge.refinedstorage.integration.craftingtweaks.IntegrationCra
|
||||
import com.raoulvdberge.refinedstorage.integration.forgeenergy.ReaderWriterHandlerForgeEnergy;
|
||||
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;
|
||||
@@ -252,6 +253,10 @@ public class ProxyCommon {
|
||||
if (IntegrationCraftingTweaks.isLoaded()) {
|
||||
IntegrationCraftingTweaks.register();
|
||||
}
|
||||
|
||||
if (IntegrationProjectE.isLoaded()) {
|
||||
IntegrationProjectE.register();
|
||||
}
|
||||
}
|
||||
|
||||
public void postInit(FMLPostInitializationEvent e) {
|
||||
|
@@ -12,5 +12,6 @@
|
||||
"ore": "blockDiamond"
|
||||
},
|
||||
null
|
||||
]
|
||||
],
|
||||
"projecte": false
|
||||
}
|
@@ -12,5 +12,6 @@
|
||||
"ore": "blockIron"
|
||||
},
|
||||
null
|
||||
]
|
||||
],
|
||||
"projecte": false
|
||||
}
|
@@ -12,5 +12,6 @@
|
||||
"ore": "blockGold"
|
||||
},
|
||||
null
|
||||
]
|
||||
],
|
||||
"projecte": false
|
||||
}
|
Reference in New Issue
Block a user