Merge branch 'master' of https://bitbucket.org/calclavia/resonant-induction
This commit is contained in:
commit
44e1bd3d07
4 changed files with 141 additions and 7 deletions
|
@ -2,6 +2,7 @@ package resonantinduction;
|
|||
|
||||
import resonantinduction.multimeter.PartMultimeter;
|
||||
import resonantinduction.transformer.PartTransformer;
|
||||
import resonantinduction.wire.part.PartFlatSwitchWire;
|
||||
import resonantinduction.wire.part.PartFlatWire;
|
||||
import codechicken.multipart.MultiPartRegistry;
|
||||
import codechicken.multipart.MultiPartRegistry.IPartFactory;
|
||||
|
@ -14,7 +15,7 @@ public class MultipartRI implements IPartFactory
|
|||
|
||||
public MultipartRI()
|
||||
{
|
||||
MultiPartRegistry.registerParts(this, new String[] { "resonant_induction_flat_wire", "resonant_induction_multimeter", "resonant_induction_transformer" });
|
||||
MultiPartRegistry.registerParts(this, new String[] { "resonant_induction_flat_wire", "resonant_induction_flat_switch_wire", "resonant_induction_multimeter", "resonant_induction_transformer" });
|
||||
MultipartGenerator.registerTrait("universalelectricity.api.energy.IConductor", "resonantinduction.wire.part.TraitConductor");
|
||||
MultipartGenerator.registerTrait("cofh.api.energy.IEnergyHandler", "resonantinduction.wire.part.TraitEnergyHandler");
|
||||
MultipartGenerator.registerTrait("ic2.api.energy.tile.IEnergySink", "resonantinduction.wire.part.TraitEnergySink");
|
||||
|
@ -27,6 +28,10 @@ public class MultipartRI implements IPartFactory
|
|||
{
|
||||
return new PartFlatWire();
|
||||
}
|
||||
else if(name.equals("resonant_induction_flat_switch_wire"))
|
||||
{
|
||||
return new PartFlatSwitchWire();
|
||||
}
|
||||
else if (name.equals("resonant_induction_multimeter"))
|
||||
{
|
||||
return new PartMultimeter();
|
||||
|
|
|
@ -8,7 +8,6 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.BlockColored;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemShears;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -16,7 +15,6 @@ import net.minecraft.util.MovingObjectPosition;
|
|||
import resonantinduction.Utility;
|
||||
import resonantinduction.wire.EnumWireMaterial;
|
||||
import universalelectricity.api.CompatibilityModule;
|
||||
import universalelectricity.api.UniversalElectricity;
|
||||
import universalelectricity.api.energy.IConductor;
|
||||
import calclavia.lib.prefab.CustomDamageSource;
|
||||
import codechicken.lib.data.MCDataInput;
|
||||
|
@ -217,7 +215,7 @@ public abstract class PartAdvancedWire extends PartConductor
|
|||
}
|
||||
else if (itemStack.getItem() instanceof ItemShears && isInsulated())
|
||||
{
|
||||
if (!world().isRemote)
|
||||
if (!world().isRemote && !player.capabilities.isCreativeMode)
|
||||
{
|
||||
tile().dropItems(Collections.singletonList(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(color))));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
package resonantinduction.wire.part;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
import codechicken.multipart.IRedstonePart;
|
||||
import codechicken.multipart.MultiPartRegistry;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
|
||||
public class PartFlatSwitchWire extends PartFlatWire
|
||||
{
|
||||
@Override
|
||||
public boolean canConnectTo(Object obj)
|
||||
{
|
||||
if (this.world().isBlockIndirectlyGettingPowered(x(), y(), z()))
|
||||
{
|
||||
return super.canConnectTo(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (TMultiPart tp : tile().jPartList())
|
||||
{
|
||||
if (tp instanceof IRedstonePart)
|
||||
{
|
||||
IRedstonePart rp = (IRedstonePart)tp;
|
||||
if ((Math.max(rp.strongPowerLevel(this.side ^ 0x1), rp.weakPowerLevel(this.side ^ 0x1)) << 4) > 0)
|
||||
{
|
||||
return super.canConnectTo(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "resonant_induction_flat_switch_wire";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
|
||||
{
|
||||
TileMultipart tile = tile();
|
||||
World w = world();
|
||||
|
||||
if (item.getItem().itemID == Block.lever.blockID)
|
||||
{
|
||||
if (!w.isRemote)
|
||||
{
|
||||
PartFlatWire wire = (PartFlatWire) MultiPartRegistry.createPart("resonant_induction_flat_wire", false);
|
||||
wire.copyFrom(this);
|
||||
|
||||
if (tile.canReplacePart(this, wire))
|
||||
{
|
||||
tile.remPart(this);
|
||||
TileMultipart.addPart(w, new BlockCoord(tile), wire);
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
tile.dropItems(Collections.singletonList(new ItemStack(Block.lever, 1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.activate(player, part, item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drop()
|
||||
{
|
||||
tile().dropItems(Collections.singletonList(new ItemStack(Block.lever, 1)));
|
||||
super.drop();
|
||||
}
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ package resonantinduction.wire.part;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -9,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
@ -29,6 +31,7 @@ import codechicken.lib.vec.Cuboid6;
|
|||
import codechicken.lib.vec.Rotation;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import codechicken.multipart.JNormalOcclusion;
|
||||
import codechicken.multipart.MultiPartRegistry;
|
||||
import codechicken.multipart.NormalOcclusionTest;
|
||||
import codechicken.multipart.PartMap;
|
||||
import codechicken.multipart.TFacePart;
|
||||
|
@ -271,15 +274,39 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
|
|||
super.onNeighborChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
|
||||
{
|
||||
if (!world().isRemote)
|
||||
{
|
||||
System.out.println(this.getNetwork());
|
||||
}
|
||||
|
||||
return super.activate(player, part, item);
|
||||
TileMultipart tile = tile();
|
||||
World w = world();
|
||||
|
||||
if (item.getItem().itemID == Block.lever.blockID)
|
||||
{
|
||||
if (!w.isRemote)
|
||||
{
|
||||
PartFlatSwitchWire wire = (PartFlatSwitchWire) MultiPartRegistry.createPart("resonant_induction_flat_switch_wire", false);
|
||||
wire.copyFrom(this);
|
||||
|
||||
if (tile.canReplacePart(this, wire))
|
||||
{
|
||||
tile.remPart(this);
|
||||
TileMultipart.addPart(w, new BlockCoord(tile), wire);
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.activate(player, part, item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -867,4 +894,20 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
|
|||
CCRenderState.reset();
|
||||
RenderFlatWire.renderBreakingOverlay(renderBlocks.overrideBlockTexture, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to aid in initializing this or subclasses, usually when you need to change the wire to another type
|
||||
* @param otherCable the wire to copy from
|
||||
*/
|
||||
public void copyFrom(PartFlatWire otherCable)
|
||||
{
|
||||
this.isInsulated = otherCable.isInsulated;
|
||||
this.color = otherCable.color;
|
||||
this.connections = otherCable.connections;
|
||||
this.material = otherCable.material;
|
||||
this.side = otherCable.side;
|
||||
this.connMap = otherCable.connMap;
|
||||
this.setNetwork(otherCable.getNetwork());
|
||||
this.getNetwork().setBufferFor(this, otherCable.getNetwork().getBufferOf(otherCable));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue