Electric charger is now a multipart
This commit is contained in:
parent
b0e77b7a40
commit
53124c1800
13 changed files with 351 additions and 293 deletions
|
@ -6,7 +6,6 @@ import net.minecraft.world.World;
|
|||
import resonantinduction.electrical.battery.RenderBattery;
|
||||
import resonantinduction.electrical.battery.TileBattery;
|
||||
import resonantinduction.electrical.charger.RenderCharger;
|
||||
import resonantinduction.electrical.charger.TileCharger;
|
||||
import resonantinduction.electrical.encoder.TileEncoder;
|
||||
import resonantinduction.electrical.encoder.gui.GuiEncoderInventory;
|
||||
import resonantinduction.electrical.generator.solar.RenderSolarPanel;
|
||||
|
@ -39,11 +38,11 @@ public class ClientProxy extends CommonProxy
|
|||
GlobalItemRenderer.register(Electrical.blockBattery.blockID, RenderBattery.INSTANCE);
|
||||
GlobalItemRenderer.register(Electrical.itemMultimeter.itemID, RenderMultimeter.INSTANCE);
|
||||
GlobalItemRenderer.register(Electrical.itemTransformer.itemID, RenderTransformer.INSTANCE);
|
||||
GlobalItemRenderer.register(Electrical.itemCharger.itemID, RenderCharger.INSTANCE);
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileTesla.class, new RenderTesla());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileLevitator.class, new RenderLevitator());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileBattery.class, new RenderBattery());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileSolarPanel.class, new RenderSolarPanel());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileCharger.class, new RenderCharger());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,8 +14,7 @@ import resonantinduction.core.TabRI;
|
|||
import resonantinduction.electrical.battery.BlockBattery;
|
||||
import resonantinduction.electrical.battery.ItemBlockBattery;
|
||||
import resonantinduction.electrical.battery.TileBattery;
|
||||
import resonantinduction.electrical.charger.BlockCharger;
|
||||
import resonantinduction.electrical.charger.TileCharger;
|
||||
import resonantinduction.electrical.charger.ItemCharger;
|
||||
import resonantinduction.electrical.encoder.ItemDisk;
|
||||
import resonantinduction.electrical.generator.BlockGenerator;
|
||||
import resonantinduction.electrical.generator.TileGenerator;
|
||||
|
@ -76,6 +75,7 @@ public class Electrical
|
|||
public static Item itemWire;
|
||||
public static Item itemMultimeter;
|
||||
public static Item itemTransformer;
|
||||
public static Item itemCharger;
|
||||
public static Block blockTesla;
|
||||
public static Block blockBattery;
|
||||
public static Block blockEncoder;
|
||||
|
@ -85,9 +85,6 @@ public class Electrical
|
|||
public static Block blockGenerator;
|
||||
public static Block blockThermopile;
|
||||
|
||||
// Machines
|
||||
public static Block blockCharger;
|
||||
|
||||
// Transport
|
||||
public static Block blockEMLevitator;
|
||||
public static Block blockArmbot;
|
||||
|
@ -104,6 +101,7 @@ public class Electrical
|
|||
itemWire = contentRegistry.createItem(ItemWire.class);
|
||||
itemMultimeter = contentRegistry.createItem(ItemMultimeter.class);
|
||||
itemTransformer = contentRegistry.createItem(ItemTransformer.class);
|
||||
itemCharger = contentRegistry.createItem(ItemCharger.class);
|
||||
blockTesla = contentRegistry.createTile(BlockTesla.class, TileTesla.class);
|
||||
blockBattery = contentRegistry.createBlock(BlockBattery.class, ItemBlockBattery.class, TileBattery.class);
|
||||
|
||||
|
@ -118,8 +116,6 @@ public class Electrical
|
|||
blockGenerator = contentRegistry.createTile(BlockGenerator.class, TileGenerator.class);
|
||||
blockThermopile = contentRegistry.createTile(BlockThermopile.class, TileThermopile.class);
|
||||
|
||||
blockCharger = contentRegistry.createTile(BlockCharger.class, TileCharger.class);
|
||||
|
||||
Settings.save();
|
||||
|
||||
OreDictionary.registerOre("wire", itemWire);
|
||||
|
@ -179,7 +175,7 @@ public class Electrical
|
|||
GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.SUPERCONDUCTOR.getWire(3), "MMM", 'M', "ingotSuperconductor"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.SUPERCONDUCTOR.getWire(3), "MMM", "MEM", "MMM", 'M', Item.ingotGold, 'E', Item.eyeOfEnder));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockCharger, "WWW", "ICI", 'W', "wire", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'C', UniversalRecipe.CIRCUIT_T1.get()));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(itemCharger, "WWW", "ICI", 'W', "wire", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'C', UniversalRecipe.CIRCUIT_T1.get()));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(itemTransformer, "WWW", "WWW", "III", 'W', "wire", 'I', UniversalRecipe.PRIMARY_METAL.get()));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockEMLevitator, " G ", "SDS", "SWS", 'W', "wire", 'G', Block.glass, 'D', Block.blockDiamond, 'S', UniversalRecipe.PRIMARY_METAL.get()));
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package resonantinduction.electrical;
|
||||
|
||||
import resonantinduction.electrical.charger.PartCharger;
|
||||
import resonantinduction.electrical.multimeter.PartMultimeter;
|
||||
import resonantinduction.electrical.transformer.PartTransformer;
|
||||
import resonantinduction.electrical.wire.flat.PartFlatSwitchWire;
|
||||
|
@ -15,7 +16,7 @@ public class MultipartElectrical implements IPartFactory
|
|||
{
|
||||
public static MultipartElectrical INSTANCE;
|
||||
|
||||
public static final String[] PART_TYPES = { "resonant_induction_wire", "resonant_induction_switch_wire", "resonant_induction_flat_wire", "resonant_induction_flat_switch_wire", "resonant_induction_multimeter", "resonant_induction_transformer" };
|
||||
public static final String[] PART_TYPES = { "resonant_induction_wire", "resonant_induction_switch_wire", "resonant_induction_flat_wire", "resonant_induction_flat_switch_wire", "resonant_induction_multimeter", "resonant_induction_transformer", "resonant_induction_charger" };
|
||||
|
||||
public MultipartElectrical()
|
||||
{
|
||||
|
@ -29,29 +30,19 @@ public class MultipartElectrical implements IPartFactory
|
|||
public TMultiPart createPart(String name, boolean client)
|
||||
{
|
||||
if (name.equals("resonant_induction_wire"))
|
||||
{
|
||||
return new PartFramedWire();
|
||||
}
|
||||
else if (name.equals("resonant_induction_switch_wire"))
|
||||
{
|
||||
return new PartFramedSwitchWire();
|
||||
}
|
||||
else if (name.equals("resonant_induction_flat_wire"))
|
||||
{
|
||||
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();
|
||||
}
|
||||
else if (name.equals("resonant_induction_transformer"))
|
||||
{
|
||||
return new PartTransformer();
|
||||
}
|
||||
else if (name.equals("resonant_induction_charger"))
|
||||
return new PartCharger();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
package resonantinduction.electrical.charger;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.core.Reference;
|
||||
import universalelectricity.api.UniversalElectricity;
|
||||
import calclavia.lib.prefab.block.BlockTile;
|
||||
|
||||
/**
|
||||
* Block that is used to charge an item on its surface
|
||||
*
|
||||
* @author Darkguardsman
|
||||
*/
|
||||
public class BlockCharger extends BlockTile
|
||||
{
|
||||
public BlockCharger(int id)
|
||||
{
|
||||
super(id, UniversalElectricity.machine);
|
||||
setTextureName(Reference.PREFIX + "material_metal_side");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, side, 3);
|
||||
return side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsForItemRender()
|
||||
{
|
||||
this.setBlockBounds(.6f, 0f, 0f, 1f, 1f, 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
if (tile instanceof TileCharger)
|
||||
{
|
||||
switch (((TileCharger) tile).getDirection())
|
||||
{
|
||||
case DOWN:
|
||||
this.setBlockBounds(0f, .6f, 0f, 1f, 1f, 1f);
|
||||
break;
|
||||
case WEST:
|
||||
this.setBlockBounds(.6f, 0f, 0f, 1f, 1f, 1f);
|
||||
break;
|
||||
case SOUTH:
|
||||
this.setBlockBounds(0f, 0f, 0f, 1f, 1f, .4f);
|
||||
break;
|
||||
case NORTH:
|
||||
this.setBlockBounds(0f, 0f, .6f, 1f, 1f, 1f);
|
||||
break;
|
||||
case UP:
|
||||
this.setBlockBounds(0f, 0f, 0f, 1f, .4f, 1f);
|
||||
break;
|
||||
case EAST:
|
||||
this.setBlockBounds(0f, 0f, 0f, .4f, 1f, 1f);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
if (player != null && tile instanceof TileCharger)
|
||||
{
|
||||
return this.interactCurrentItem((TileCharger) tile, 0, player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileCharger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int par1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package resonantinduction.electrical.charger;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.core.prefab.part.IHighlight;
|
||||
import resonantinduction.electrical.wire.EnumWireMaterial;
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import codechicken.microblock.FacePlacementGrid$;
|
||||
import codechicken.multipart.JItemMultiPart;
|
||||
import codechicken.multipart.MultiPartRegistry;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
|
||||
public class ItemCharger extends JItemMultiPart implements IHighlight
|
||||
{
|
||||
public ItemCharger(int id)
|
||||
{
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TMultiPart newPart(ItemStack itemStack, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 hit)
|
||||
{
|
||||
side = FacePlacementGrid$.MODULE$.getHitSlot(hit, side);
|
||||
PartCharger part = (PartCharger) MultiPartRegistry.createPart("resonant_induction_charger", false);
|
||||
|
||||
if (part != null)
|
||||
{
|
||||
int l = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
int facing = l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0)));
|
||||
part.preparePlacement(side, facing);
|
||||
}
|
||||
|
||||
return part;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,266 @@
|
|||
package resonantinduction.electrical.charger;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.core.prefab.part.PartFace;
|
||||
import resonantinduction.electrical.Electrical;
|
||||
import scala.xml.persistent.SetStorage;
|
||||
import universalelectricity.api.CompatibilityModule;
|
||||
import universalelectricity.api.energy.IEnergyInterface;
|
||||
import calclavia.lib.utility.WorldUtility;
|
||||
import calclavia.lib.utility.inventory.ExternalInventory;
|
||||
import calclavia.lib.utility.inventory.IExternalInventory;
|
||||
import calclavia.lib.utility.inventory.IExternalInventoryBox;
|
||||
import calclavia.lib.utility.inventory.InventoryUtility;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartCharger extends PartFace implements IExternalInventory, ISidedInventory, IEnergyInterface
|
||||
{
|
||||
private long lastPacket;
|
||||
|
||||
@Override
|
||||
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
if (getStackInSlot(0) == null)
|
||||
{
|
||||
setInventorySlotContents(0, item);
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (getStackInSlot(0) != null)
|
||||
{
|
||||
InventoryUtility.dropItemStack(player.worldObj, new universalelectricity.api.vector.Vector3(player), getStackInSlot(0), 0);
|
||||
setInventorySlotContents(0, null);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction, Object obj)
|
||||
{
|
||||
return obj instanceof IEnergyInterface && direction == getFacing().getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
||||
{
|
||||
long energyUsed = 0;
|
||||
long energyLeft = receive;
|
||||
for (int i = 0; i < this.getSizeInventory(); i++)
|
||||
{
|
||||
long input = CompatibilityModule.chargeItem(this.getStackInSlot(i), energyLeft, true);
|
||||
energyUsed += input;
|
||||
energyLeft -= input;
|
||||
if (energyLeft <= 0)
|
||||
break;
|
||||
}
|
||||
if (energyUsed > 0 && System.currentTimeMillis() - this.lastPacket >= 50)
|
||||
{
|
||||
this.lastPacket = System.currentTimeMillis();
|
||||
sendDescUpdate();
|
||||
}
|
||||
return energyUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderDynamic(Vector3 pos, float frame, int pass)
|
||||
{
|
||||
if (pass == 0)
|
||||
{
|
||||
RenderCharger.INSTANCE.render(this, pos.x, pos.y, pos.z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getItem()
|
||||
{
|
||||
return new ItemStack(Electrical.itemCharger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "resonant_induction_charger";
|
||||
}
|
||||
|
||||
/**
|
||||
* Save and load
|
||||
*/
|
||||
@Override
|
||||
public void load(NBTTagCompound nbt)
|
||||
{
|
||||
super.load(nbt);
|
||||
this.getInventory().load(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(NBTTagCompound nbt)
|
||||
{
|
||||
super.save(nbt);
|
||||
this.getInventory().save(nbt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inventory Methods
|
||||
*/
|
||||
protected IExternalInventoryBox inventory;
|
||||
protected int maxSlots = 1;
|
||||
|
||||
@Override
|
||||
public IExternalInventoryBox getInventory()
|
||||
{
|
||||
if (inventory == null)
|
||||
{
|
||||
inventory = new ExternalInventory(null, this, this.maxSlots);
|
||||
}
|
||||
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return this.getInventory().getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i)
|
||||
{
|
||||
return this.getInventory().getStackInSlot(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j)
|
||||
{
|
||||
return this.getInventory().decrStackSize(i, j);
|
||||
}
|
||||
|
||||
public void incrStackSize(int slot, ItemStack itemStack)
|
||||
{
|
||||
if (this.getStackInSlot(slot) == null)
|
||||
{
|
||||
setInventorySlotContents(slot, itemStack.copy());
|
||||
}
|
||||
else if (this.getStackInSlot(slot).isItemEqual(itemStack))
|
||||
{
|
||||
getStackInSlot(slot).stackSize += itemStack.stackSize;
|
||||
}
|
||||
|
||||
onInventoryChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i)
|
||||
{
|
||||
return this.getInventory().getStackInSlotOnClosing(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
{
|
||||
this.getInventory().setInventorySlotContents(i, itemstack);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return this.getInventory().getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||
{
|
||||
return this.getInventory().isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
this.getInventory().openChest();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
this.getInventory().closeChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return this.getInventory().isItemValidForSlot(i, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int var1)
|
||||
{
|
||||
return this.getInventory().getAccessibleSlotsFromSide(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return this.getInventory().canInsertItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return this.getInventory().canExtractItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRemove(ItemStack stack, int slot, ForgeDirection side)
|
||||
{
|
||||
if (slot >= this.getSizeInventory())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package resonantinduction.electrical.charger;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
|
@ -10,11 +11,13 @@ import org.lwjgl.opengl.GL11;
|
|||
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.render.RenderItemOverlayTile;
|
||||
import resonantinduction.electrical.levitator.TileLevitator;
|
||||
import universalelectricity.api.CompatibilityModule;
|
||||
import universalelectricity.api.energy.UnitDisplay;
|
||||
import universalelectricity.api.energy.UnitDisplay.Unit;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.render.RenderUtility;
|
||||
import calclavia.lib.render.item.ISimpleItemRenderer;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
|
||||
/**
|
||||
|
@ -22,53 +25,47 @@ import cpw.mods.fml.client.FMLClientHandler;
|
|||
*
|
||||
* @author DarkGuardsman
|
||||
*/
|
||||
public class RenderCharger extends RenderItemOverlayTile
|
||||
public class RenderCharger implements ISimpleItemRenderer
|
||||
{
|
||||
public static final RenderCharger INSTANCE = new RenderCharger();
|
||||
|
||||
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "charger.tcn");
|
||||
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "charger.png");
|
||||
/*
|
||||
|
||||
public void render(PartCharger part, double x, double y, double z)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
|
||||
RenderUtility.rotateFaceBlockToSide(part.placementSide);
|
||||
RenderUtility.rotateBlockBasedOnDirection(part.getFacing());
|
||||
|
||||
RenderUtility.rotateFaceToSideNoTranslate(part.placementSide);
|
||||
|
||||
RenderUtility.bind(TEXTURE);
|
||||
MODEL.renderAll();
|
||||
GL11.glPopMatrix();
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f)
|
||||
{
|
||||
if (tile instanceof TileCharger)
|
||||
if (part.getStackInSlot(0) != null)
|
||||
{
|
||||
Vector3 d = new Vector3();
|
||||
switch (((TileCharger) tile).getDirection())
|
||||
RenderItemOverlayTile.renderItem(part.world(), part.placementSide, part.getStackInSlot(0), new Vector3(0.09, -0.4, -0.09), 0, 4);
|
||||
|
||||
/**
|
||||
* Render item and tool tip
|
||||
*/
|
||||
if (CompatibilityModule.getMaxEnergyItem(part.getStackInSlot(0)) > 0)
|
||||
{
|
||||
case NORTH:
|
||||
d.translate(0, 0, .58);
|
||||
break;
|
||||
case SOUTH:
|
||||
d.translate(0, 0, -.58);
|
||||
break;
|
||||
case WEST:
|
||||
d.translate(.58, 0, 0);
|
||||
break;
|
||||
case EAST:
|
||||
d.translate(-.58, 0, 0);
|
||||
break;
|
||||
}
|
||||
this.renderItemSingleSide(tile, x + d.x, y + d.y, z + d.z, ((TileCharger) tile).getStackInSlot(0), ((TileCharger) tile).getDirection(), "IDLE");
|
||||
if (CompatibilityModule.getMaxEnergyItem(((TileCharger) tile).getStackInSlot(0)) > 0)
|
||||
{
|
||||
long energy = CompatibilityModule.getEnergyItem(((TileCharger) tile).getStackInSlot(0));
|
||||
long maxEnergy = CompatibilityModule.getMaxEnergyItem(((TileCharger) tile).getStackInSlot(0));
|
||||
RenderUtility.renderText(UnitDisplay.getDisplay(energy, Unit.JOULES, 2, true) + "/" + UnitDisplay.getDisplay(maxEnergy, Unit.JOULES, 2, true), ((TileCharger) tile).getDirection(), 0.02f, x + d.x, y + d.y + 0.4, z + d.z);
|
||||
long energy = CompatibilityModule.getEnergyItem(part.getStackInSlot(0));
|
||||
long maxEnergy = CompatibilityModule.getMaxEnergyItem(part.getStackInSlot(0));
|
||||
GL11.glTranslatef(0, 0.1F, 0);
|
||||
GL11.glRotatef(90, 1, 0, 0);
|
||||
RenderUtility.renderText(UnitDisplay.getDisplay(energy, Unit.JOULES, 2, true) + "/" + UnitDisplay.getDisplay(maxEnergy, Unit.JOULES, 2, true), 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryItem(ItemStack itemStack)
|
||||
{
|
||||
RenderUtility.bind(TEXTURE);
|
||||
MODEL.renderAll();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,133 +0,0 @@
|
|||
package resonantinduction.electrical.charger;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import universalelectricity.api.CompatibilityModule;
|
||||
import universalelectricity.api.energy.IEnergyInterface;
|
||||
import calclavia.lib.network.IPacketReceiverWithID;
|
||||
import calclavia.lib.network.PacketHandler;
|
||||
import calclavia.lib.prefab.tile.IRotatable;
|
||||
import calclavia.lib.prefab.tile.TileExternalInventory;
|
||||
import calclavia.lib.utility.inventory.ExternalInventory;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
/** @author Darkguardsman */
|
||||
public class TileCharger extends TileExternalInventory implements IRotatable, IEnergyInterface, IPacketReceiverWithID
|
||||
{
|
||||
public ChargerMode currentMode = ChargerMode.SINGLE;
|
||||
private long lastPacket = 0;
|
||||
|
||||
public static enum ChargerMode
|
||||
{
|
||||
SINGLE(1), DUAL(2), MULTI(4);
|
||||
public final int limit;
|
||||
|
||||
private ChargerMode(int limit)
|
||||
{
|
||||
this.limit = limit;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getDirection()
|
||||
{
|
||||
return ForgeDirection.getOrientation(this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection(ForgeDirection direction)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction, Object obj)
|
||||
{
|
||||
return obj instanceof IEnergyInterface && direction == this.getDirection().getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
||||
{
|
||||
long energyUsed = 0;
|
||||
long energyLeft = receive;
|
||||
for (int i = 0; i < this.getSizeInventory(); i++)
|
||||
{
|
||||
long input = CompatibilityModule.chargeItem(this.getStackInSlot(i), energyLeft, true);
|
||||
energyUsed += input;
|
||||
energyLeft -= input;
|
||||
if (energyLeft <= 0)
|
||||
break;
|
||||
}
|
||||
if (energyUsed > 0 && System.currentTimeMillis() - this.lastPacket >= 50)
|
||||
{
|
||||
this.lastPacket = System.currentTimeMillis();
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
return energyUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
this.writeToNBT(nbt);
|
||||
return ResonantInduction.PACKET_TILE.getPacketWithID(0, this, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id == 0)
|
||||
{
|
||||
this.readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||
return true;
|
||||
}
|
||||
else if (id == 1)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
this.currentMode = ChargerMode.values()[nbt.getInteger("chargerMode")];
|
||||
this.inventory = new ExternalInventory(this, this.currentMode.limit);
|
||||
super.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("chargerMode", this.currentMode.ordinal());
|
||||
}
|
||||
|
||||
}
|
|
@ -5,17 +5,17 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.core.prefab.part.IHighlight;
|
||||
import resonantinduction.electrical.wire.EnumWireMaterial;
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import codechicken.microblock.FacePlacementGrid$;
|
||||
import codechicken.multipart.JItemMultiPart;
|
||||
import codechicken.multipart.MultiPartRegistry;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
|
||||
public class ItemTransformer extends JItemMultiPart
|
||||
public class ItemTransformer extends JItemMultiPart implements IHighlight
|
||||
{
|
||||
private Icon[] icons = new Icon[EnumWireMaterial.values().length];
|
||||
|
||||
public ItemTransformer(int id)
|
||||
{
|
||||
super(id);
|
||||
|
@ -24,6 +24,7 @@ public class ItemTransformer extends JItemMultiPart
|
|||
@Override
|
||||
public TMultiPart newPart(ItemStack itemStack, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 hit)
|
||||
{
|
||||
side = FacePlacementGrid$.MODULE$.getHitSlot(hit, side);
|
||||
PartTransformer part = (PartTransformer) MultiPartRegistry.createPart("resonant_induction_transformer", false);
|
||||
|
||||
if (part != null)
|
||||
|
|
|
@ -35,7 +35,7 @@ public class PartTransformer extends PartFace implements JNormalOcclusion, TFace
|
|||
|
||||
public void preparePlacement(int side, int facing)
|
||||
{
|
||||
this.placementSide = ForgeDirection.getOrientation((byte) (side ^ 1));
|
||||
this.placementSide = ForgeDirection.getOrientation(side);
|
||||
this.facing = (byte) (facing - 2);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public abstract class PartFace extends JCuboidPart implements JNormalOcclusion,
|
|||
|
||||
public void preparePlacement(int side, int facing)
|
||||
{
|
||||
this.placementSide = ForgeDirection.getOrientation((byte) (side ^ 1));
|
||||
this.placementSide = ForgeDirection.getOrientation( side);
|
||||
this.facing = (byte) (facing - 2);
|
||||
}
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer
|
|||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11 * scale, var12 * scale);
|
||||
}
|
||||
|
||||
private static void renderItem(World world, ForgeDirection dir, ItemStack itemStack, Vector3 position, float rotationYaw, int angle)
|
||||
public static void renderItem(World world, ForgeDirection dir, ItemStack itemStack, Vector3 position, float rotationYaw, int angle)
|
||||
{
|
||||
if (itemStack != null)
|
||||
{
|
||||
|
@ -206,7 +206,7 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer
|
|||
entityItem.getEntityItem().stackSize = 1;
|
||||
entityItem.hoverStart = 0.0F;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(-0.453125F * dir.offsetX + position.x, position.y, -0.453125F * dir.offsetZ + position.z);
|
||||
GL11.glTranslated( position.x, position.y, - position.z);
|
||||
GL11.glRotatef(180.0F + rotationYaw, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(90 * angle, 1, 0, 0);
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ tile.resonantinduction\:levitator.name=Electromagnetic Levitator
|
|||
tile.resonantinduction\:battery.name=Battery
|
||||
tile.resonantinduction\:armbot.name=Armbot
|
||||
tile.resonantinduction\:encoder.name=Encoder
|
||||
tile.resonantinduction\:charger.name=Charging Plate
|
||||
item.resonantinduction\:charger.name=Charging Plate
|
||||
|
||||
## Generators
|
||||
tile.resonantinduction\:solarPanel.name=Solar Panel
|
||||
|
|
Loading…
Add table
Reference in a new issue