Made electromagnetic levitator multipart
This commit is contained in:
parent
b72fb66ea8
commit
642806b5c5
12 changed files with 3156 additions and 38 deletions
|
@ -11,7 +11,6 @@ import resonantinduction.electrical.encoder.gui.GuiEncoderInventory;
|
|||
import resonantinduction.electrical.generator.solar.RenderSolarPanel;
|
||||
import resonantinduction.electrical.generator.solar.TileSolarPanel;
|
||||
import resonantinduction.electrical.levitator.RenderLevitator;
|
||||
import resonantinduction.electrical.levitator.TileLevitator;
|
||||
import resonantinduction.electrical.multimeter.GuiMultimeter;
|
||||
import resonantinduction.electrical.multimeter.PartMultimeter;
|
||||
import resonantinduction.electrical.multimeter.RenderMultimeter;
|
||||
|
@ -39,8 +38,8 @@ public class ClientProxy extends CommonProxy
|
|||
GlobalItemRenderer.register(Electrical.itemMultimeter.itemID, RenderMultimeter.INSTANCE);
|
||||
GlobalItemRenderer.register(Electrical.itemTransformer.itemID, RenderTransformer.INSTANCE);
|
||||
GlobalItemRenderer.register(Electrical.itemCharger.itemID, RenderCharger.INSTANCE);
|
||||
GlobalItemRenderer.register(Electrical.itemLevitator.itemID, RenderLevitator.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());
|
||||
}
|
||||
|
|
|
@ -22,8 +22,7 @@ import resonantinduction.electrical.generator.solar.BlockSolarPanel;
|
|||
import resonantinduction.electrical.generator.solar.TileSolarPanel;
|
||||
import resonantinduction.electrical.generator.thermopile.BlockThermopile;
|
||||
import resonantinduction.electrical.generator.thermopile.TileThermopile;
|
||||
import resonantinduction.electrical.levitator.BlockLevitator;
|
||||
import resonantinduction.electrical.levitator.TileLevitator;
|
||||
import resonantinduction.electrical.levitator.ItemLevitator;
|
||||
import resonantinduction.electrical.multimeter.ItemMultimeter;
|
||||
import resonantinduction.electrical.tesla.BlockTesla;
|
||||
import resonantinduction.electrical.tesla.TileTesla;
|
||||
|
@ -86,7 +85,7 @@ public class Electrical
|
|||
public static Block blockThermopile;
|
||||
|
||||
// Transport
|
||||
public static Block blockEMLevitator;
|
||||
public static Item itemLevitator;
|
||||
public static Block blockArmbot;
|
||||
public static Item itemDisk;
|
||||
|
||||
|
@ -106,7 +105,7 @@ public class Electrical
|
|||
blockBattery = contentRegistry.createBlock(BlockBattery.class, ItemBlockBattery.class, TileBattery.class);
|
||||
|
||||
// Transport
|
||||
blockEMLevitator = contentRegistry.createTile(BlockLevitator.class, TileLevitator.class);
|
||||
itemLevitator = contentRegistry.createItem(ItemLevitator.class);
|
||||
// blockArmbot = contentRegistry.createTile(BlockArmbot.class, TileArmbot.class);
|
||||
// blockEncoder = contentRegistry.createTile(BlockEncoder.class, TileEncoder.class);
|
||||
itemDisk = contentRegistry.createItem(ItemDisk.class);
|
||||
|
@ -177,7 +176,7 @@ public class Electrical
|
|||
|
||||
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()));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(itemLevitator, " G ", "SDS", "SWS", 'W', "wire", 'G', Block.glass, 'D', Block.blockDiamond, 'S', UniversalRecipe.PRIMARY_METAL.get()));
|
||||
|
||||
/** Generators **/
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockSolarPanel, "CCC", "WWW", "III", 'W', "wire", 'C', Item.coal, 'I', UniversalRecipe.PRIMARY_METAL.get()));
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package resonantinduction.electrical;
|
||||
|
||||
import resonantinduction.electrical.charger.PartCharger;
|
||||
import resonantinduction.electrical.levitator.PartLevitator;
|
||||
import resonantinduction.electrical.multimeter.PartMultimeter;
|
||||
import resonantinduction.electrical.transformer.PartTransformer;
|
||||
import resonantinduction.electrical.wire.flat.PartFlatSwitchWire;
|
||||
|
@ -16,7 +17,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", "resonant_induction_charger" };
|
||||
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", "resonant_induction_levitator" };
|
||||
|
||||
public MultipartElectrical()
|
||||
{
|
||||
|
@ -43,6 +44,8 @@ public class MultipartElectrical implements IPartFactory
|
|||
return new PartTransformer();
|
||||
else if (name.equals("resonant_induction_charger"))
|
||||
return new PartCharger();
|
||||
else if (name.equals("resonant_induction_levitator"))
|
||||
return new PartLevitator();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class PartCharger extends PartFace implements IExternalInventory, ISidedI
|
|||
{
|
||||
if (WrenchUtility.isUsableWrench(player, player.inventory.getCurrentItem(), x(), y(), z()))
|
||||
{
|
||||
if (!this.world().isRemote)
|
||||
if (!world().isRemote)
|
||||
{
|
||||
WrenchUtility.damageWrench(player, player.inventory.getCurrentItem(), x(), y(), z());
|
||||
facing = (byte) ((facing + 1) % 4);
|
||||
|
@ -87,7 +87,8 @@ public class PartCharger extends PartFace implements IExternalInventory, ISidedI
|
|||
{
|
||||
InventoryUtility.dropItemStack(world(), new universalelectricity.api.vector.Vector3(player), getStackInSlot(0), 0);
|
||||
setInventorySlotContents(0, null);
|
||||
sendDescUpdate();
|
||||
if (!world().isRemote)
|
||||
sendDescUpdate();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package resonantinduction.electrical.levitator;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.core.prefab.part.IHighlight;
|
||||
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 ItemLevitator extends JItemMultiPart implements IHighlight
|
||||
{
|
||||
public ItemLevitator(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);
|
||||
PartLevitator part = (PartLevitator) MultiPartRegistry.createPart("resonant_induction_levitator", 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,662 @@
|
|||
package resonantinduction.electrical.levitator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFluid;
|
||||
import net.minecraft.block.BlockLadder;
|
||||
import net.minecraft.block.BlockSnow;
|
||||
import net.minecraft.block.BlockVine;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import resonantinduction.core.MultipartUtility;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.Settings;
|
||||
import resonantinduction.core.prefab.part.PartFace;
|
||||
import resonantinduction.electrical.Electrical;
|
||||
import resonantinduction.electrical.tesla.TileTesla;
|
||||
import resonantinduction.electrical.transformer.RenderTransformer;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import universalelectricity.api.vector.VectorWorld;
|
||||
import calclavia.components.tool.ToolModeLink;
|
||||
import calclavia.lib.prefab.block.ILinkable;
|
||||
import calclavia.lib.render.EnumColor;
|
||||
import calclavia.lib.utility.WrenchUtility;
|
||||
import calclavia.lib.utility.inventory.InventoryUtility;
|
||||
import codechicken.lib.data.MCDataInput;
|
||||
import codechicken.lib.data.MCDataOutput;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartLevitator extends PartFace implements ILinkable
|
||||
{
|
||||
private int pushDelay;
|
||||
|
||||
private AxisAlignedBB operationBounds;
|
||||
private AxisAlignedBB suckBounds;
|
||||
|
||||
/**
|
||||
* true = suck, false = push
|
||||
*/
|
||||
public boolean suck = true;
|
||||
|
||||
/**
|
||||
* Pathfinding
|
||||
*/
|
||||
private ThreadEMPathfinding thread;
|
||||
private PathfinderEMContractor pathfinder;
|
||||
private Set<EntityItem> pathfindingTrackers = new HashSet<EntityItem>();
|
||||
// TODO: WeakReference
|
||||
private PartLevitator linked;
|
||||
private int lastCalcTime = 0;
|
||||
|
||||
/** Color of beam */
|
||||
private int dyeID = TileTesla.DEFAULT_COLOR;
|
||||
|
||||
/**
|
||||
* Linking
|
||||
*/
|
||||
private byte linkSide;
|
||||
private Vector3 tempLinkVector;
|
||||
|
||||
/**
|
||||
* Client Side Only
|
||||
*/
|
||||
public float renderRotation = 0;
|
||||
|
||||
private int ticks;
|
||||
|
||||
@Override
|
||||
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack itemStack)
|
||||
{
|
||||
if (WrenchUtility.isWrench(itemStack))
|
||||
{
|
||||
if (onLink(player, ToolModeLink.getLink(itemStack)))
|
||||
{
|
||||
ToolModeLink.clearLink(itemStack);
|
||||
}
|
||||
else
|
||||
{
|
||||
ToolModeLink.setLink(itemStack, new VectorWorld(world(), x(), y(), z()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player.getCurrentEquippedItem() != null)
|
||||
{
|
||||
if (player.getCurrentEquippedItem().itemID == Item.dyePowder.itemID)
|
||||
{
|
||||
setDye(player.getCurrentEquippedItem().getItemDamage());
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
suck = !suck;
|
||||
updatePath();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getItem()
|
||||
{
|
||||
return new ItemStack(Electrical.itemLevitator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "resonant_induction_levitator";
|
||||
}
|
||||
|
||||
public void initiate()
|
||||
{
|
||||
updateBounds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
super.update();
|
||||
|
||||
if (ticks++ == 0)
|
||||
{
|
||||
initiate();
|
||||
}
|
||||
|
||||
pushDelay = Math.max(0, pushDelay - 1);
|
||||
|
||||
if (tempLinkVector != null)
|
||||
{
|
||||
TMultiPart part = MultipartUtility.getMultipart(world(), tempLinkVector, linkSide);
|
||||
|
||||
if (part instanceof PartLevitator)
|
||||
{
|
||||
setLink((PartLevitator) part, true);
|
||||
}
|
||||
|
||||
tempLinkVector = null;
|
||||
}
|
||||
|
||||
if (canFunction())
|
||||
{
|
||||
TileEntity inventoryTile = getLatched();
|
||||
IInventory inventory = (IInventory) inventoryTile;
|
||||
|
||||
if (!suck)
|
||||
{
|
||||
renderRotation = Math.max(0, renderRotation - 0.8f);
|
||||
if (pushDelay == 0)
|
||||
{
|
||||
ItemStack retrieved = InventoryUtility.takeTopItemFromInventory(inventory, placementSide.getOpposite().getOpposite().ordinal());
|
||||
|
||||
if (retrieved != null)
|
||||
{
|
||||
EntityItem item = getItemWithPosition(retrieved);
|
||||
|
||||
if (!world().isRemote)
|
||||
{
|
||||
world().spawnEntityInWorld(item);
|
||||
}
|
||||
|
||||
pushDelay = Settings.LEVITATOR_PUSH_DELAY;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (suck)
|
||||
{
|
||||
renderRotation = Math.min(20, renderRotation + 0.8f);
|
||||
if (suckBounds != null)
|
||||
{
|
||||
if (!world().isRemote)
|
||||
{
|
||||
for (EntityItem item : (List<EntityItem>) world().getEntitiesWithinAABB(EntityItem.class, suckBounds))
|
||||
{
|
||||
ItemStack remains = InventoryUtility.putStackInInventory(inventory, item.getEntityItem(), placementSide.getOpposite().getOpposite().ordinal(), false);
|
||||
|
||||
if (remains == null)
|
||||
{
|
||||
item.setDead();
|
||||
}
|
||||
else
|
||||
{
|
||||
item.setEntityItemStack(remains);
|
||||
}
|
||||
|
||||
// TODO: Add redstone pulse?
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (thread != null)
|
||||
{
|
||||
PathfinderEMContractor newPath = thread.getPath();
|
||||
|
||||
if (newPath != null)
|
||||
{
|
||||
pathfinder = newPath;
|
||||
thread = null;
|
||||
}
|
||||
}
|
||||
|
||||
final int renderFrequency = 1;
|
||||
final boolean renderBeam = ticks % renderFrequency == 0 && hasLink() && linked.suck != suck;
|
||||
|
||||
if (hasLink())
|
||||
{
|
||||
if (!suck)
|
||||
{
|
||||
if (renderBeam)
|
||||
Electrical.proxy.renderElectricShock(world(), getPosition().translate(0.5), getPosition().translate(new Vector3(placementSide.getOpposite())).translate(0.5), EnumColor.DYES[dyeID].toColor(), false);
|
||||
|
||||
// Push entity along path.
|
||||
if (pathfinder != null)
|
||||
{
|
||||
List<Vector3> results = pathfinder.results;
|
||||
|
||||
for (int i = 0; i < results.size(); i++)
|
||||
{
|
||||
Vector3 result = results.get(i).clone();
|
||||
|
||||
if (PartLevitator.canBePath(world(), result))
|
||||
{
|
||||
if (i - 1 >= 0)
|
||||
{
|
||||
Vector3 prevResult = results.get(i - 1).clone();
|
||||
|
||||
Vector3 difference = prevResult.clone().difference(result);
|
||||
final ForgeDirection direction = difference.toForgeDirection();
|
||||
|
||||
if (renderBeam)
|
||||
{
|
||||
Electrical.proxy.renderElectricShock(world(), prevResult.clone().translate(0.5), result.clone().translate(0.5), EnumColor.DYES[dyeID].toColor(), false);
|
||||
}
|
||||
|
||||
AxisAlignedBB bounds = AxisAlignedBB.getAABBPool().getAABB(result.x, result.y, result.z, result.x + 1, result.y + 1, result.z + 1);
|
||||
List<EntityItem> entities = world().getEntitiesWithinAABB(EntityItem.class, bounds);
|
||||
|
||||
for (EntityItem entityItem : entities)
|
||||
{
|
||||
moveEntity(entityItem, direction, result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
updatePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updatePath();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (renderBeam)
|
||||
{
|
||||
Electrical.proxy.renderElectricShock(world(), getPosition().translate(0.5), getPosition().translate(new Vector3(placementSide.getOpposite())).translate(0.5), EnumColor.DYES[dyeID].toColor(), false);
|
||||
}
|
||||
|
||||
pathfinder = null;
|
||||
|
||||
Vector3 searchVec = getPosition().translate(placementSide.getOpposite());
|
||||
AxisAlignedBB searchBounds = AxisAlignedBB.getAABBPool().getAABB(searchVec.x, searchVec.y, searchVec.z, searchVec.x + 1, searchVec.y + 1, searchVec.z + 1);
|
||||
|
||||
if (searchBounds != null)
|
||||
{
|
||||
for (EntityItem entityItem : (List<EntityItem>) world().getEntitiesWithinAABB(EntityItem.class, searchBounds))
|
||||
{
|
||||
moveEntity(entityItem, placementSide.getOpposite(), getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!hasLink())
|
||||
{
|
||||
for (EntityItem entityItem : (List<EntityItem>) world().getEntitiesWithinAABB(EntityItem.class, operationBounds))
|
||||
{
|
||||
if (ticks % renderFrequency == 0)
|
||||
Electrical.proxy.renderElectricShock(world(), getPosition().translate(0.5), new Vector3(entityItem), EnumColor.DYES[dyeID].toColor(), false);
|
||||
moveEntity(entityItem, placementSide.getOpposite(), getPosition());
|
||||
}
|
||||
}
|
||||
|
||||
if (linked != null)
|
||||
{
|
||||
linked = null;
|
||||
}
|
||||
|
||||
lastCalcTime--;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canBePath(World world, Vector3 position)
|
||||
{
|
||||
Block block = Block.blocksList[position.getBlockID(world)];
|
||||
return block == null || (block instanceof BlockSnow || block instanceof BlockVine || block instanceof BlockLadder || ((block instanceof BlockFluid || block instanceof IFluidBlock) && block.blockID != Block.lavaMoving.blockID && block.blockID != Block.lavaStill.blockID));
|
||||
}
|
||||
|
||||
private boolean hasLink()
|
||||
{
|
||||
return linked != null && linked.linked == this;
|
||||
}
|
||||
|
||||
private void moveEntity(EntityItem entityItem, ForgeDirection direction, Vector3 lockVector)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case DOWN:
|
||||
entityItem.setPosition(lockVector.x + 0.5, entityItem.posY, lockVector.z + 0.5);
|
||||
|
||||
entityItem.motionX = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
||||
if (!suck)
|
||||
{
|
||||
entityItem.motionY = Math.max(-Settings.LEVITATOR_MAX_SPEED, entityItem.motionY - Settings.LEVITATOR_ACCELERATION);
|
||||
}
|
||||
else
|
||||
{
|
||||
entityItem.motionY = Math.min(Settings.LEVITATOR_MAX_SPEED, entityItem.motionY + .04 + Settings.LEVITATOR_ACCELERATION);
|
||||
}
|
||||
|
||||
break;
|
||||
case UP:
|
||||
|
||||
entityItem.setPosition(lockVector.x + 0.5, entityItem.posY, lockVector.z + 0.5);
|
||||
|
||||
entityItem.motionX = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
||||
if (!suck)
|
||||
{
|
||||
entityItem.motionY = Math.min(Settings.LEVITATOR_MAX_SPEED, entityItem.motionY + .04 + Settings.LEVITATOR_ACCELERATION);
|
||||
}
|
||||
else
|
||||
{
|
||||
entityItem.motionY = Math.max(-Settings.LEVITATOR_MAX_SPEED, entityItem.motionY - Settings.LEVITATOR_ACCELERATION);
|
||||
}
|
||||
|
||||
break;
|
||||
case NORTH:
|
||||
|
||||
entityItem.setPosition(lockVector.x + 0.5, lockVector.y + 0.5, entityItem.posZ);
|
||||
|
||||
entityItem.motionX = 0;
|
||||
entityItem.motionY = 0;
|
||||
|
||||
if (!suck)
|
||||
{
|
||||
entityItem.motionZ = Math.max(-Settings.LEVITATOR_MAX_SPEED, entityItem.motionZ - Settings.LEVITATOR_ACCELERATION);
|
||||
}
|
||||
else
|
||||
{
|
||||
entityItem.motionZ = Math.min(Settings.LEVITATOR_MAX_SPEED, entityItem.motionZ + Settings.LEVITATOR_ACCELERATION);
|
||||
}
|
||||
|
||||
break;
|
||||
case SOUTH:
|
||||
|
||||
entityItem.setPosition(lockVector.x + 0.5, lockVector.y + 0.5, entityItem.posZ);
|
||||
|
||||
entityItem.motionX = 0;
|
||||
entityItem.motionY = 0;
|
||||
|
||||
if (!suck)
|
||||
{
|
||||
entityItem.motionZ = Math.min(Settings.LEVITATOR_MAX_SPEED, entityItem.motionZ + Settings.LEVITATOR_ACCELERATION);
|
||||
}
|
||||
else
|
||||
{
|
||||
entityItem.motionZ = Math.max(-Settings.LEVITATOR_MAX_SPEED, entityItem.motionZ - Settings.LEVITATOR_ACCELERATION);
|
||||
}
|
||||
|
||||
break;
|
||||
case WEST:
|
||||
|
||||
entityItem.setPosition(entityItem.posX, lockVector.y + 0.5, lockVector.z + 0.5);
|
||||
|
||||
entityItem.motionY = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
||||
if (!suck)
|
||||
{
|
||||
entityItem.motionX = Math.max(-Settings.LEVITATOR_MAX_SPEED, entityItem.motionX - Settings.LEVITATOR_ACCELERATION);
|
||||
}
|
||||
else
|
||||
{
|
||||
entityItem.motionX = Math.min(Settings.LEVITATOR_MAX_SPEED, entityItem.motionX + Settings.LEVITATOR_ACCELERATION);
|
||||
}
|
||||
|
||||
break;
|
||||
case EAST:
|
||||
entityItem.setPosition(entityItem.posX, lockVector.y + 0.5, lockVector.z + 0.5);
|
||||
|
||||
entityItem.motionY = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
||||
if (!suck)
|
||||
{
|
||||
entityItem.motionX = Math.min(Settings.LEVITATOR_MAX_SPEED, entityItem.motionX + Settings.LEVITATOR_ACCELERATION);
|
||||
}
|
||||
else
|
||||
{
|
||||
entityItem.motionX = Math.max(-Settings.LEVITATOR_MAX_SPEED, entityItem.motionX - Settings.LEVITATOR_ACCELERATION);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
entityItem.ticksExisted = 1;
|
||||
entityItem.isAirBorne = true;
|
||||
entityItem.delayBeforeCanPickup = 1;
|
||||
entityItem.age = Math.max(entityItem.age - 1, 0);
|
||||
}
|
||||
|
||||
private EntityItem getItemWithPosition(ItemStack toSend)
|
||||
{
|
||||
EntityItem item = null;
|
||||
|
||||
switch (placementSide.getOpposite())
|
||||
{
|
||||
case DOWN:
|
||||
item = new EntityItem(world(), x() + 0.5, y() - 0.2, z() + 0.5, toSend);
|
||||
break;
|
||||
case UP:
|
||||
item = new EntityItem(world(), x() + 0.5, y() + 1.2, z() + 0.5, toSend);
|
||||
break;
|
||||
case NORTH:
|
||||
item = new EntityItem(world(), x() + 0.5, y() + 0.5, z() - 0.2, toSend);
|
||||
break;
|
||||
case SOUTH:
|
||||
item = new EntityItem(world(), x() + 0.5, y() + 0.5, z() + 1.2, toSend);
|
||||
break;
|
||||
case WEST:
|
||||
item = new EntityItem(world(), x() - 0.2, y() + 0.5, z() + 0.5, toSend);
|
||||
break;
|
||||
case EAST:
|
||||
item = new EntityItem(world(), x() + 1.2, y() + 0.5, z() + 0.5, toSend);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
item.motionX = 0;
|
||||
item.motionY = 0;
|
||||
item.motionZ = 0;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public void updateBounds()
|
||||
{
|
||||
ForgeDirection dir = placementSide;
|
||||
MovingObjectPosition mop = world().clip(getPosition().translate(dir).toVec3(), getPosition().translate(dir, Settings.LEVITATOR_MAX_REACH).toVec3());
|
||||
|
||||
int reach = Settings.LEVITATOR_MAX_REACH;
|
||||
|
||||
if (mop != null)
|
||||
{
|
||||
reach = (int) Math.min(getPosition().distance(new Vector3(mop.hitVec)), reach);
|
||||
}
|
||||
|
||||
if (dir.offsetX + dir.offsetY + dir.offsetZ < 0)
|
||||
{
|
||||
operationBounds = AxisAlignedBB.getBoundingBox(x() + dir.offsetX * reach, y() + dir.offsetY * reach, z() + dir.offsetZ * reach, x() + 1, y() + 1, z() + 1);
|
||||
suckBounds = AxisAlignedBB.getBoundingBox(x() + dir.offsetX, y() + dir.offsetY, z() + dir.offsetZ, x() + 1, y() + 1, z() + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
operationBounds = AxisAlignedBB.getBoundingBox(x(), y(), z(), x() + 1 + dir.offsetX * reach, y() + 1 + dir.offsetY * reach, z() + 1 + dir.offsetZ * reach);
|
||||
suckBounds = AxisAlignedBB.getBoundingBox(x(), y(), z(), x() + 1 + dir.offsetX, y() + 1 + dir.offsetY, z() + 1 + dir.offsetZ);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isLatched()
|
||||
{
|
||||
return getLatched() != null;
|
||||
}
|
||||
|
||||
public TileEntity getLatched()
|
||||
{
|
||||
ForgeDirection side = placementSide;
|
||||
|
||||
TileEntity tile = world().getBlockTileEntity(x() + side.offsetX, y() + side.offsetY, z() + side.offsetZ);
|
||||
|
||||
if (tile instanceof IInventory)
|
||||
{
|
||||
return tile;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDesc(MCDataInput packet)
|
||||
{
|
||||
super.readDesc(packet);
|
||||
suck = packet.readBoolean();
|
||||
dyeID = packet.readByte();
|
||||
|
||||
if (packet.readBoolean())
|
||||
{
|
||||
tempLinkVector = new Vector3(packet.readInt(), packet.readInt(), packet.readInt());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDesc(MCDataOutput packet)
|
||||
{
|
||||
super.writeDesc(packet);
|
||||
packet.writeBoolean(suck);
|
||||
packet.writeByte(dyeID);
|
||||
|
||||
if (linked != null)
|
||||
{
|
||||
packet.writeBoolean(true);
|
||||
packet.writeInt(linked.x());
|
||||
packet.writeInt(linked.y());
|
||||
packet.writeInt(linked.z());
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeBoolean(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean canFunction()
|
||||
{
|
||||
return isLatched() && !world().isBlockIndirectlyGettingPowered(x(), y(), z());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(NBTTagCompound nbt)
|
||||
{
|
||||
super.load(nbt);
|
||||
|
||||
this.suck = nbt.getBoolean("suck");
|
||||
this.dyeID = nbt.getInteger("dyeID");
|
||||
|
||||
if (nbt.hasKey("link"))
|
||||
{
|
||||
tempLinkVector = new Vector3(nbt.getCompoundTag("link"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(NBTTagCompound nbt)
|
||||
{
|
||||
super.save(nbt);
|
||||
|
||||
nbt.setBoolean("suck", suck);
|
||||
nbt.setInteger("dyeID", dyeID);
|
||||
|
||||
if (linked != null)
|
||||
{
|
||||
nbt.setCompoundTag("link", new Vector3(linked.x(), linked.y(), linked.z()).writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Link between two TileEntities, do pathfinding operation.
|
||||
*/
|
||||
public void setLink(PartLevitator tileEntity, boolean setOpponent)
|
||||
{
|
||||
if (linked != null && setOpponent)
|
||||
{
|
||||
linked.setLink(null, false);
|
||||
}
|
||||
|
||||
linked = tileEntity;
|
||||
|
||||
if (setOpponent)
|
||||
{
|
||||
linked.setLink(this, false);
|
||||
}
|
||||
|
||||
updatePath();
|
||||
}
|
||||
|
||||
public void updatePath()
|
||||
{
|
||||
if (thread == null && linked != null && lastCalcTime <= 0)
|
||||
{
|
||||
pathfinder = null;
|
||||
|
||||
Vector3 start = getPosition().translate(placementSide.getOpposite());
|
||||
Vector3 target = new Vector3(linked.x(), linked.y(), linked.z()).translate(linked.placementSide.getOpposite());
|
||||
|
||||
if (start.distance(target) < Settings.MAX_CONTRACTOR_DISTANCE)
|
||||
{
|
||||
if (PartLevitator.canBePath(world(), start) && PartLevitator.canBePath(world(), target))
|
||||
{
|
||||
thread = new ThreadEMPathfinding(new PathfinderEMContractor(world(), target), start);
|
||||
thread.start();
|
||||
lastCalcTime = 40;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDye(int dye)
|
||||
{
|
||||
dyeID = dye;
|
||||
world().markBlockForUpdate(x(), y(), z());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLink(EntityPlayer player, VectorWorld vector)
|
||||
{
|
||||
tempLinkVector = vector;
|
||||
return false;
|
||||
}
|
||||
|
||||
public Vector3 getPosition()
|
||||
{
|
||||
return new Vector3(x(), y(), z());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderDynamic(codechicken.lib.vec.Vector3 pos, float frame, int pass)
|
||||
{
|
||||
if (pass == 0)
|
||||
{
|
||||
RenderLevitator.INSTANCE.render(this, pos.x, pos.y, pos.z);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package resonantinduction.electrical.levitator;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
@ -12,46 +13,47 @@ import net.minecraftforge.client.model.IModelCustom;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import calclavia.lib.render.RenderUtility;
|
||||
import calclavia.lib.render.block.ICustomBlockRenderer;
|
||||
import calclavia.lib.render.item.ISimpleItemRenderer;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
|
||||
public class RenderLevitator extends TileEntitySpecialRenderer implements ICustomBlockRenderer
|
||||
public class RenderLevitator implements ISimpleItemRenderer
|
||||
{
|
||||
public static final RenderLevitator INSTANCE = new RenderLevitator();
|
||||
|
||||
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "levitator.tcn");
|
||||
public static final ResourceLocation TEXTURE_ON = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "levitator_on.png");
|
||||
public static final ResourceLocation TEXTURE_OFF = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "levitator_off.png");
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)
|
||||
public void render(PartLevitator part, double x, double y, double z)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
RenderUtility.rotateFaceToSideNoTranslate(((TileLevitator) t).getDirection().getOpposite());
|
||||
TileLevitator tile = (TileLevitator) t;
|
||||
if (tile.canFunction())
|
||||
bindTexture(TEXTURE_ON);
|
||||
RenderUtility.rotateFaceToSideNoTranslate(part.placementSide);
|
||||
|
||||
if (part.canFunction())
|
||||
RenderUtility.bind(TEXTURE_ON);
|
||||
else
|
||||
bindTexture(TEXTURE_OFF);
|
||||
RenderUtility.bind(TEXTURE_OFF);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(tile.renderRotation, 1, 0, 0);
|
||||
GL11.glRotatef(part.renderRotation, 1, 0, 0);
|
||||
MODEL.renderOnly("ring1");
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(-tile.renderRotation, 1, 0, 0);
|
||||
GL11.glRotatef(-part.renderRotation, 1, 0, 0);
|
||||
MODEL.renderOnly("ring2");
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(tile.renderRotation, 0, 0, 1);
|
||||
GL11.glRotatef(part.renderRotation, 0, 0, 1);
|
||||
MODEL.renderOnly("ring3");
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(-tile.renderRotation, 0, 0, 1);
|
||||
GL11.glRotatef(-part.renderRotation, 0, 0, 1);
|
||||
MODEL.renderOnly("ring4");
|
||||
GL11.glPopMatrix();
|
||||
|
||||
|
@ -61,19 +63,7 @@ public class RenderLevitator extends TileEntitySpecialRenderer implements ICusto
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderStatic(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderDynamic(TileEntity tile, Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
public void renderInventoryItem(ItemStack itemStack)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.5f, 0.5f, 0.5f);
|
||||
|
|
|
@ -42,6 +42,7 @@ import com.google.common.io.ByteArrayDataInput;
|
|||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class TileLevitator extends TileAdvanced implements IPacketReceiver, IPacketSender, ILinkable
|
||||
{
|
||||
private int pushDelay;
|
||||
|
|
|
@ -24,7 +24,13 @@ import codechicken.multipart.TFacePart;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartTransformer extends PartFace implements JNormalOcclusion, TFacePart, IVoltageOutput, IEnergyInterface
|
||||
/**
|
||||
* TODO: We can't use face parts, need to use thicker ones. Also, transformer is currently NO-OP
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class PartTransformer extends PartFace implements IVoltageOutput, IEnergyInterface
|
||||
{
|
||||
|
||||
/** Step the voltage up */
|
||||
|
|
|
@ -7,7 +7,10 @@ import net.minecraft.world.IBlockAccess;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import universalelectricity.api.vector.VectorWorld;
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
|
||||
/**
|
||||
|
@ -24,6 +27,28 @@ public class MultipartUtility
|
|||
return te instanceof TileMultipart ? (TileMultipart) te : null;
|
||||
}
|
||||
|
||||
public static TMultiPart getMultipart(World world, Vector3 vector, int partMap)
|
||||
{
|
||||
return getMultipart(new VectorWorld(world, vector), partMap);
|
||||
}
|
||||
|
||||
public static TMultiPart getMultipart(VectorWorld vector, int partMap)
|
||||
{
|
||||
return getMultipart(vector.world, vector.intX(), vector.intY(), vector.intZ(), partMap);
|
||||
}
|
||||
|
||||
public static TMultiPart getMultipart(World world, int x, int y, int z, int partMap)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileMultipart)
|
||||
{
|
||||
return ((TileMultipart) tile).partMap(partMap);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean canPlaceWireOnSide(World w, int x, int y, int z, ForgeDirection side, boolean _default)
|
||||
{
|
||||
if (!w.blockExists(x, y, z))
|
||||
|
|
|
@ -106,7 +106,7 @@ tile.resonantinduction\:filter.name=Filter
|
|||
### Electrical Module
|
||||
## Blocks
|
||||
tile.resonantinduction\:tesla.name=Tesla Coil
|
||||
tile.resonantinduction\:levitator.name=Electromagnetic Levitator
|
||||
item.resonantinduction\:levitator.name=Electromagnetic Levitator
|
||||
tile.resonantinduction\:battery.name=Battery
|
||||
tile.resonantinduction\:armbot.name=Armbot
|
||||
tile.resonantinduction\:encoder.name=Encoder
|
||||
|
|
2395
src/main/resources/assets/resonantinduction/models/waterTurbines.obj
Normal file
2395
src/main/resources/assets/resonantinduction/models/waterTurbines.obj
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue