made rotation work with mechanical converters
added recipes for the mechanical converters changed them to accept forge energy as well as IF
This commit is contained in:
parent
d3c571d60c
commit
04e25e300c
|
@ -21,8 +21,10 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import blusunrize.immersiveengineering.api.tool.AssemblerHandler;
|
||||
import blusunrize.immersiveengineering.api.tool.AssemblerHandler.IRecipeAdapter;
|
||||
import blusunrize.immersiveengineering.api.tool.AssemblerHandler.RecipeQuery;
|
||||
import blusunrize.immersiveengineering.common.IEContent;
|
||||
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0;
|
||||
import blusunrize.immersiveengineering.common.blocks.stone.BlockTypes_StoneDecoration;
|
||||
import ic2.api.item.IC2Items;
|
||||
import malte0811.industrialWires.blocks.converter.BlockMechanicalConverter;
|
||||
|
@ -60,7 +62,7 @@ public class IndustrialWires {
|
|||
public static BlockMechanicalConverter mechConv;
|
||||
public static ItemIC2Coil coil;
|
||||
public static CreativeTabs creativeTab = new CreativeTabs(MODID) {
|
||||
|
||||
|
||||
@Override
|
||||
public Item getTabIconItem() {
|
||||
return null;
|
||||
|
@ -112,35 +114,51 @@ public class IndustrialWires {
|
|||
for (int i = 0;i<IC2Wiretype.IC2_TYPES.length;i++) {
|
||||
GameRegistry.addRecipe(new RecipeCoilLength(i));
|
||||
}
|
||||
AssemblerHandler.registerRecipeAdapter(RecipeCoilLength.class, new AssemblerHandler.IRecipeAdapter<RecipeCoilLength>() {
|
||||
|
||||
@Override
|
||||
public RecipeQuery[] getQueriedInputs(RecipeCoilLength recipe, ItemStack[] in) {
|
||||
List<RecipeQuery> ret = new ArrayList<>();
|
||||
for (int i = 0;i<in.length-1;i++) {
|
||||
boolean added = false;
|
||||
for (int j = 0;j<ret.size();j++) {
|
||||
if (ItemStack.areItemStacksEqual((ItemStack)ret.get(j).query, in[i])) {
|
||||
ret.get(j).querySize++;
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!added) {
|
||||
ret.add(new RecipeQuery(in[i], 1));
|
||||
}
|
||||
}
|
||||
return ret.toArray(new RecipeQuery[ret.size()]);
|
||||
}
|
||||
@Override
|
||||
public RecipeQuery[] getQueriedInputs(RecipeCoilLength arg0) {
|
||||
return new RecipeQuery[0];
|
||||
}
|
||||
|
||||
});
|
||||
AssemblerHandler.registerRecipeAdapter(RecipeCoilLength.class, new CoilLengthAdapter());
|
||||
// MECH CONVERTERS
|
||||
ItemStack shaftIron = IC2Items.getItem("crafting", "iron_shaft");
|
||||
ItemStack shaftSteel = IC2Items.getItem("crafting", "steel_shaft");
|
||||
ItemStack ironMechComponent = new ItemStack(IEContent.itemMaterial, 1, 8);
|
||||
ItemStack steelMechComponent = new ItemStack(IEContent.itemMaterial, 1, 9);
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(mechConv, 1, 0), " s ", "ici", "mum", 's', "stickIron",
|
||||
'i', "ingotIron", 'c', new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.COIL_LV.getMeta()),
|
||||
'u', "ingotCopper", 'm', ironMechComponent));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(mechConv, 1, 2), "iIi", "sbS", "mrm", 's', "blockSheetmetalIron",
|
||||
'i', "plateIron", 'I', shaftIron,
|
||||
'b', "ingotBronze", 'm', steelMechComponent,
|
||||
'S', "blockSheetmetalSteel", 'r', "stickSteel"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(mechConv, 1, 1), "mrm", "sbS", "iIi", 's', "blockSheetmetalIron",
|
||||
'i', "plateSteel", 'I', shaftSteel,
|
||||
'b', "ingotBronze", 'm', ironMechComponent,
|
||||
'S', "blockSheetmetalSteel", 'r', "stickIron"));
|
||||
|
||||
}
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent e) {
|
||||
proxy.postInit();
|
||||
}
|
||||
private class CoilLengthAdapter implements IRecipeAdapter<RecipeCoilLength> {
|
||||
@Override
|
||||
public RecipeQuery[] getQueriedInputs(RecipeCoilLength recipe, ItemStack[] in) {
|
||||
List<RecipeQuery> ret = new ArrayList<>();
|
||||
for (int i = 0;i<in.length-1;i++) {
|
||||
boolean added = false;
|
||||
for (int j = 0;j<ret.size();j++) {
|
||||
if (ItemStack.areItemStacksEqual((ItemStack)ret.get(j).query, in[i])) {
|
||||
ret.get(j).querySize++;
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!added) {
|
||||
ret.add(new RecipeQuery(in[i], 1));
|
||||
}
|
||||
}
|
||||
return ret.toArray(new RecipeQuery[ret.size()]);
|
||||
}
|
||||
@Override
|
||||
public RecipeQuery[] getQueriedInputs(RecipeCoilLength arg0) {
|
||||
return new RecipeQuery[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package malte0811.industrialWires.blocks;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxConnection;
|
||||
import blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxProvider;
|
||||
import blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxReceiver;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
public class EnergyAdapter implements IEnergyStorage {
|
||||
/**
|
||||
* 3 different copies of the same thing, the TE this adapter is mirroring.
|
||||
* rec and prov are null if the TE does not implement them
|
||||
*/
|
||||
IFluxConnection tile;
|
||||
IFluxReceiver rec;
|
||||
IFluxProvider prov;
|
||||
|
||||
EnumFacing dir;
|
||||
public EnergyAdapter(IFluxConnection te, EnumFacing f) {
|
||||
tile = te;
|
||||
dir = f;
|
||||
if (te instanceof IFluxReceiver) {
|
||||
rec = (IFluxReceiver) te;
|
||||
}
|
||||
if (te instanceof IFluxProvider) {
|
||||
prov = (IFluxProvider) te;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate) {
|
||||
if (rec==null) {
|
||||
return 0;
|
||||
} else {
|
||||
return rec.receiveEnergy(dir, maxReceive, simulate);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate) {
|
||||
if (prov==null) {
|
||||
return 0;
|
||||
} else {
|
||||
return prov.extractEnergy(dir, maxExtract, simulate);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored() {
|
||||
if (prov!=null) {
|
||||
return prov.getEnergyStored(dir);
|
||||
} else if (rec!=null) {
|
||||
return rec.getEnergyStored(dir);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored() {
|
||||
if (prov!=null) {
|
||||
return prov.getMaxEnergyStored(dir);
|
||||
} else if (rec!=null) {
|
||||
return rec.getMaxEnergyStored(dir);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtract() {
|
||||
return prov!=null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceive() {
|
||||
return rec!=null;
|
||||
}
|
||||
}
|
|
@ -172,4 +172,15 @@ public class BlockMechanicalConverter extends Block implements IMetaEnum, ITileE
|
|||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param) {
|
||||
boolean def = super.eventReceived(state, worldIn, pos, id, param);
|
||||
if ((id&255)==255) {
|
||||
IBlockState s = worldIn.getBlockState(pos);
|
||||
worldIn.notifyBlockUpdate(pos, s, s, 3);
|
||||
return true;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import blusunrize.immersiveengineering.api.energy.immersiveflux.FluxStorage;
|
|||
import blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxReceiver;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import malte0811.industrialWires.IWConfig.MechConversion;
|
||||
import malte0811.industrialWires.blocks.EnergyAdapter;
|
||||
import malte0811.industrialWires.blocks.TileEntityIWBase;
|
||||
import malte0811.industrialWires.util.ConversionUtil;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
@ -30,6 +31,8 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
|
||||
public class TileEntityIEMotor extends TileEntityIWBase implements ITickable, IFluxReceiver, IDirectionalTile {
|
||||
public final double bufferMax = 2*MechConversion.maxIfToMech*ConversionUtil.rotPerIf();
|
||||
|
@ -81,11 +84,11 @@ public class TileEntityIEMotor extends TileEntityIWBase implements ITickable, IF
|
|||
// Flux energy
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from) {
|
||||
return from==dir.getOpposite();
|
||||
return from==dir.getOpposite()||from==null;
|
||||
}
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int energyIn, boolean simulate) {
|
||||
if (from!=dir) {
|
||||
if (canConnectEnergy(from)) {
|
||||
int ret = energy.receiveEnergy(energyIn, simulate);
|
||||
markDirty();
|
||||
return ret;
|
||||
|
@ -125,4 +128,19 @@ public class TileEntityIEMotor extends TileEntityIWBase implements ITickable, IF
|
|||
public boolean canHammerRotate(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase entity) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (capability==CapabilityEnergy.ENERGY&&canConnectEnergy(facing)) {
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (capability==CapabilityEnergy.ENERGY&&canConnectEnergy(facing)) {
|
||||
return (T) new EnergyAdapter(this, facing);
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -154,9 +153,9 @@ public class ClientProxy extends CommonProxy {
|
|||
new ManualPages.CraftingMulti(m, "industrialWires.wires2", (Object[])wireRecipes)
|
||||
);
|
||||
m.addEntry("industrialWires.mechConv", "industrialWires",
|
||||
new ManualPages.Crafting(m, "industrialWires.mechConv0", new ItemStack(Items.DIAMOND_PICKAXE)),
|
||||
new ManualPages.Crafting(m, "industrialWires.mechConv1", new ItemStack(Items.DIAMOND_PICKAXE)),
|
||||
new ManualPages.Crafting(m, "industrialWires.mechConv2", new ItemStack(Items.DIAMOND_PICKAXE))
|
||||
new ManualPages.Crafting(m, "industrialWires.mechConv0", new ItemStack(IndustrialWires.mechConv, 1, 1)),
|
||||
new ManualPages.Crafting(m, "industrialWires.mechConv1", new ItemStack(IndustrialWires.mechConv, 1, 2)),
|
||||
new ManualPages.Crafting(m, "industrialWires.mechConv2", new ItemStack(IndustrialWires.mechConv, 1, 0))
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ ie.manual.entry.industrialWires.wires1=attaching a connector to a power source t
|
|||
ie.manual.entry.industrialWires.wires2=tin cables can be replaced by uninsulated copper, gold or HV cables or by glass fiber cable to craft the other coils.
|
||||
|
||||
ie.manual.entry.industrialWires.mechConv.name=Mechanical Converters
|
||||
ie.manual.entry.industrialWires.mechConv.subtext=
|
||||
ie.manual.entry.industrialWires.mechConv.subtext=I made rotational energy for this!
|
||||
ie.manual.entry.industrialWires.mechConv0=Both the IC2 and IE company produce products that run on kinetic energy of some sort. The new converters from IndustrialWires allow you to convert between these two forms of energy!<br>To use the "Converter: Rotational To Kinetic" attach a source of IE rotational energy
|
||||
ie.manual.entry.industrialWires.mechConv1=like a waterwheel or a motor (see page 3) to the side marked with a gear and a consumer of IC2 kinetic energy to the opposite side. The "Converter: Kinetic To Rotational" is used in a similar way (Rotational and kinetic energy have to be swapped).<br>Unfortunately some energy is
|
||||
ie.manual.entry.industrialWires.mechConv2=lost with each conversion.<br>As a little extra the "Mechanical converter" product series also contains a Rotational Motor: It consumes IF to produce IE rotational energy. As with the converters this is not a lossless process.
|
Loading…
Reference in a new issue