Merging air canister & fixing laser lift
This commit is contained in:
parent
3e12e537e3
commit
1e05dc711a
10 changed files with 456 additions and 141 deletions
|
@ -6,6 +6,11 @@ item.warpdrive.crafting.LaserCore.name=Laser Core
|
|||
item.warpdrive.crafting.ReactorCore.name=Reactor Core
|
||||
item.warpdrive.crafting.InterfaceComputer.name=Computer Interface
|
||||
item.warpdrive.crafting.InterfacePower.name=Power Interface
|
||||
item.warpdrive.crafting.PowerCore.name=Energy Core
|
||||
item.warpdrive.crafting.AirCanEmpty.name=Empty Air Canister
|
||||
|
||||
item.warpdrive.useful.AirCanFull.name=Air Canister
|
||||
item.warpdrive.armor.Helmet.name=Warp Helmet
|
||||
|
||||
tile.warpdrive.blocks.Air.name=Air Block
|
||||
tile.warpdrive.blocks.Gas.name=Gas Block
|
||||
|
@ -14,6 +19,7 @@ tile.warpdrive.blocks.IridiumBlock.name=Iridium Block
|
|||
item.warpdrive.items.ReactorLaserFocus.name=Reactor Laser Focus
|
||||
tile.warpdrive.power.Reactor.name=Enantiomorphic Reactor
|
||||
tile.warpdrive.power.Laser.name=Aurbis Reactor Stabilisation Laser
|
||||
tile.warpdrive.power.Store.name=Anuic Energy Store
|
||||
tile.warpdrive.machines.WarpCore.name=Warp Drive Core
|
||||
tile.warpdrive.machines.WarpProtocol.name=Warp Drive Controller
|
||||
tile.warpdrive.machines.WarpRadar.name=Warp Radar
|
||||
|
|
|
@ -5,7 +5,8 @@ import ic2.api.item.Items;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import cr0s.WarpDrive.CloakedArea;
|
||||
import cr0s.WarpDrive.data.CloakedArea;
|
||||
import cr0s.WarpDrive.world.SpaceTeleporter;
|
||||
import cr0s.WarpDrive.api.IBreathingHelmet;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
|
@ -114,13 +115,14 @@ public class SpaceEventHandler {
|
|||
Item helmet = helmetStack.getItem();
|
||||
if (helmet instanceof IBreathingHelmet) {
|
||||
IBreathingHelmet breathHelmet = (IBreathingHelmet)helmet;
|
||||
int airTicks = breathHelmet.ticksPerCanDamage();
|
||||
if (breathHelmet.canBreath(player)) {
|
||||
hasHelmet = true;
|
||||
if (air == null) {// new player in space => grace period
|
||||
player_airTank.put(player.username, AIR_TANK_TICKS);
|
||||
player_airTank.put(player.username, airTicks);
|
||||
} else if (air <= 1) {
|
||||
if (breathHelmet.removeAir(player)) {
|
||||
player_airTank.put(player.username, AIR_TANK_TICKS);
|
||||
player_airTank.put(player.username, airTicks);
|
||||
} else {
|
||||
player_airTank.put(player.username, AIR_DROWN_TICKS);
|
||||
player.attackEntityFrom(DamageSource.drown, 2.0F);
|
||||
|
|
10
src/cr0s/WarpDrive/api/IAirCanister.java
Normal file
10
src/cr0s/WarpDrive/api/IAirCanister.java
Normal file
|
@ -0,0 +1,10 @@
|
|||
package cr0s.WarpDrive.api;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IAirCanister {
|
||||
public ItemStack emptyDrop(ItemStack can);
|
||||
public ItemStack fullDrop(ItemStack can);
|
||||
public boolean canContainAir(ItemStack can);
|
||||
public boolean containsAir(ItemStack can);
|
||||
}
|
|
@ -5,4 +5,5 @@ import net.minecraft.entity.Entity;
|
|||
public interface IBreathingHelmet {
|
||||
public boolean canBreath(Entity player);
|
||||
public boolean removeAir(Entity player);
|
||||
public int ticksPerCanDamage();
|
||||
}
|
56
src/cr0s/WarpDrive/item/ItemWarpAircan.java
Normal file
56
src/cr0s/WarpDrive/item/ItemWarpAircan.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package cr0s.WarpDrive.item;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.WarpDrive.WarpDrive;
|
||||
import cr0s.WarpDrive.api.IAirCanister;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
public class ItemWarpAircan extends Item implements IAirCanister {
|
||||
Icon icon;
|
||||
public ItemWarpAircan(int id) {
|
||||
super(id);
|
||||
setMaxDamage(20);
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
setMaxStackSize(1);
|
||||
setUnlocalizedName("warpdrive.useful.AirCanFull");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister ir) {
|
||||
icon = ir.registerIcon("warpdrive:aircanFull");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIconFromDamage(int damage) {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack emptyDrop(ItemStack is) {
|
||||
return WarpDrive.componentItem.getISNoCache(1, 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack fullDrop(ItemStack can) {
|
||||
return new ItemStack(WarpDrive.airCanItem,1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canContainAir(ItemStack can) {
|
||||
if (can != null && can.getItem() instanceof ItemWarpAircan) {
|
||||
return can.getItemDamage() > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAir(ItemStack can) {
|
||||
return true;
|
||||
}
|
||||
}
|
102
src/cr0s/WarpDrive/item/ItemWarpArmor.java
Normal file
102
src/cr0s/WarpDrive/item/ItemWarpArmor.java
Normal file
|
@ -0,0 +1,102 @@
|
|||
package cr0s.WarpDrive.item;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.WarpDrive.WarpDrive;
|
||||
import cr0s.WarpDrive.WarpDriveConfig;
|
||||
import cr0s.WarpDrive.api.IAirCanister;
|
||||
import cr0s.WarpDrive.api.IBreathingHelmet;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.EnumArmorMaterial;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
public class ItemWarpArmor extends ItemArmor implements IBreathingHelmet {
|
||||
// private static Random ran = new Random();
|
||||
private int slot;
|
||||
|
||||
Icon ic;
|
||||
|
||||
public ItemWarpArmor(int id,int slot) {
|
||||
super(id, WarpDrive.armorMaterial, 0, slot);
|
||||
this.slot = slot;
|
||||
setUnlocalizedName("warpdrive.armor.Helmet");
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getArmorTexture(ItemStack is, Entity en, int parSlot, String type) {
|
||||
return "warpdrive:textures/armor/warpArmor_1.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister ir) {
|
||||
if (slot == 0) {
|
||||
ic = ir.registerIcon("warpdrive:warpArmorHelmet");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIconFromDamage(int damage) {
|
||||
return ic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBreath(Entity player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAir(Entity player) {
|
||||
WarpDrive.debugPrint("Checking breathing!");
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP pl = (EntityPlayerMP) player;
|
||||
ItemStack[] plInv = pl.inventory.mainInventory;
|
||||
for(int i = 0; i < plInv.length; i++) {
|
||||
ItemStack is = plInv[i];
|
||||
if (is != null && is.getItem() instanceof IAirCanister) {
|
||||
IAirCanister airCanister = (IAirCanister)is.getItem();
|
||||
if (airCanister.containsAir(is)) {
|
||||
if (is.stackSize > 1) {// unstack
|
||||
is.stackSize--;
|
||||
ItemStack toAdd = is.copy();
|
||||
toAdd.stackSize = 1;
|
||||
toAdd.setItemDamage(is.getItemDamage() + 1); // bypass unbreaking enchantment
|
||||
if (is.getItemDamage() >= is.getMaxDamage()) {
|
||||
toAdd = airCanister.emptyDrop(is);
|
||||
}
|
||||
if (!pl.inventory.addItemStackToInventory(toAdd)) {
|
||||
EntityItem ie = new EntityItem(pl.worldObj, pl.posX, pl.posY, pl.posZ, toAdd);
|
||||
pl.worldObj.spawnEntityInWorld(ie);
|
||||
}
|
||||
} else {
|
||||
is.setItemDamage(is.getItemDamage() + 1); // bypass unbreaking enchantment
|
||||
if (is.getItemDamage() >= is.getMaxDamage()) {
|
||||
plInv[i] = airCanister.emptyDrop(is);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int ticksPerCanDamage()
|
||||
{
|
||||
return 40;
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.WarpDrive.WarpDrive;
|
||||
import cr0s.WarpDrive.api.IAirCanister;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
@ -14,16 +15,13 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
public class ItemWarpComponent extends Item {
|
||||
public class ItemWarpComponent extends Item implements IAirCanister {
|
||||
private Icon[] potentialIcons;
|
||||
private String[] potentialUnlocalized = new String[7];
|
||||
private String[] potentialUnlocalized = new String[9];
|
||||
private ItemStack[] cachedIS;
|
||||
|
||||
private int id;
|
||||
|
||||
public ItemWarpComponent(int par1) {
|
||||
super(par1);
|
||||
id = par1;
|
||||
setHasSubtypes(true);
|
||||
//this.setMaxDamage(potentialUnlocalized.length);
|
||||
setUnlocalizedName("warpdrive.crafting.Malformed");
|
||||
|
@ -36,6 +34,8 @@ public class ItemWarpComponent extends Item {
|
|||
potentialUnlocalized[4] = "ReactorCore";
|
||||
potentialUnlocalized[5] = "InterfaceComputer";
|
||||
potentialUnlocalized[6] = "InterfacePower";
|
||||
potentialUnlocalized[7] = "PowerCore";
|
||||
potentialUnlocalized[8] = "AirCanEmpty";
|
||||
|
||||
potentialIcons = new Icon[potentialUnlocalized.length];
|
||||
cachedIS = new ItemStack[potentialUnlocalized.length];
|
||||
|
@ -51,6 +51,10 @@ public class ItemWarpComponent extends Item {
|
|||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getISNoCache(int amount,int damage) {
|
||||
return new ItemStack(WarpDrive.componentItem, amount, damage);
|
||||
}
|
||||
|
||||
public void registerRecipes() {
|
||||
WarpDrive.debugPrint("Registering empty recipe");
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(0),false,"nrn","r r","nrn",
|
||||
|
@ -88,8 +92,29 @@ public class ItemWarpComponent extends Item {
|
|||
'g', Item.goldNugget,
|
||||
'r', Item.redstone,
|
||||
'i', Item.ingotIron));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(7),false,"glg","ldl","glg",
|
||||
'g', Item.goldNugget,
|
||||
'l', "dyeBlue",
|
||||
'd', Item.diamond));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(8),false,"gcg","g g","gcg",
|
||||
'g', Block.glass,
|
||||
'c', getIS(0)));
|
||||
}
|
||||
|
||||
public boolean doesMatch(ItemStack is, String unlocalised) {
|
||||
if (is == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(is.getItem() instanceof ItemWarpComponent)) {
|
||||
return false;
|
||||
}
|
||||
String data = potentialUnlocalized[is.getItemDamage()];
|
||||
WarpDrive.debugPrint(data);
|
||||
return data.equals(unlocalised);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister) {
|
||||
for(int i = 0; i < potentialUnlocalized.length; i++) {
|
||||
|
@ -118,7 +143,35 @@ public class ItemWarpComponent extends Item {
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
for(int i = 0; i < potentialUnlocalized.length; i++)
|
||||
for(int i = 0; i < potentialUnlocalized.length; i++) {
|
||||
par3List.add(new ItemStack(par1, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
//For empty air cans
|
||||
@Override
|
||||
public ItemStack fullDrop(ItemStack is) {
|
||||
if (doesMatch(is,"AirCanEmpty")) {
|
||||
return WarpDrive.airCanItem.fullDrop(is);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack emptyDrop(ItemStack is) {
|
||||
if (doesMatch(is,"AirCanEmpty")) {
|
||||
return WarpDrive.airCanItem.emptyDrop(is);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canContainAir(ItemStack is) {
|
||||
return doesMatch(is,"AirCanEmpty");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAir(ItemStack is) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,8 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.WarpDrive.WarpDrive;
|
||||
import cr0s.WarpDrive.WarpDriveConfig;
|
||||
import cr0s.WarpDrive.api.IAirCanister;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -11,7 +13,10 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -84,17 +89,36 @@ public class BlockAirGenerator extends BlockContainer
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer player, int par6, float par7, float par8, float par9) {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
WarpEnergyTE te = (WarpEnergyTE)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
if (te != null && (par5EntityPlayer.getHeldItem() == null)) {
|
||||
par5EntityPlayer.addChatMessage(te.getStatus());
|
||||
return true;
|
||||
if (te != null) {
|
||||
ItemStack heldItemStack = player.getHeldItem();
|
||||
if (heldItemStack == null) {
|
||||
player.addChatMessage(te.getStatus());
|
||||
return true;
|
||||
} else {
|
||||
Item heldItem = heldItemStack.getItem();
|
||||
if (heldItem != null && (heldItem instanceof IAirCanister)) {
|
||||
IAirCanister airCanister = (IAirCanister)heldItem;
|
||||
if (airCanister.canContainAir(heldItemStack) && te.consumeEnergy(WarpDriveConfig.AG_RF_PER_CANISTER, true)) {
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
ItemStack toAdd = airCanister.fullDrop(heldItemStack);
|
||||
if (toAdd != null) {
|
||||
if (!player.inventory.addItemStackToInventory(toAdd)) {
|
||||
EntityItem ie = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, toAdd);
|
||||
player.worldObj.spawnEntityInWorld(ie);
|
||||
}
|
||||
te.consumeEnergy(WarpDriveConfig.AG_RF_PER_CANISTER, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,17 +9,32 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import cr0s.WarpDrive.*;
|
||||
import cr0s.WarpDrive.data.Vector3;
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
||||
public class TileEntityLift extends WarpEnergyTE {
|
||||
private final int MAX_ENERGY_VALUE = 2048; // eU
|
||||
|
||||
private int mode = 0; // 0 - inactive, 1 - up, 2 - down
|
||||
public class TileEntityLift extends WarpEnergyTE implements IPeripheral {
|
||||
private static final int MODE_REDSTONE = -1;
|
||||
private static final int MODE_INACTIVE = 0;
|
||||
private static final int MODE_UP = 1;
|
||||
private static final int MODE_DOWN = 2;
|
||||
|
||||
private int firstUncoveredY;
|
||||
|
||||
private int mode = MODE_INACTIVE;
|
||||
private boolean isEnabled = false;
|
||||
|
||||
int ticks = 0;
|
||||
|
||||
private boolean computerEnabled = true;
|
||||
private int computerMode = MODE_REDSTONE;
|
||||
|
||||
private String[] methodsArray = {
|
||||
"energy",
|
||||
"mode",
|
||||
"active",
|
||||
"help"
|
||||
};
|
||||
|
||||
int tickCount = 0;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
|
@ -27,34 +42,34 @@ public class TileEntityLift extends WarpEnergyTE {
|
|||
}
|
||||
super.updateEntity();
|
||||
|
||||
if (++ticks > 40)
|
||||
{
|
||||
ticks = 0;
|
||||
|
||||
tickCount++;
|
||||
if (tickCount >= WarpDriveConfig.LL_TICK_RATE) {
|
||||
tickCount = 0;
|
||||
|
||||
// Switching mode
|
||||
if (worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord))
|
||||
{
|
||||
if (computerMode == MODE_DOWN || (computerMode == MODE_REDSTONE && worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord))) {
|
||||
mode = 2; // down
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
mode = 1; // up
|
||||
}
|
||||
|
||||
isEnabled = (worldObj.isAirBlock(xCoord, yCoord + 1, zCoord) && worldObj.isAirBlock(xCoord, yCoord + 2, zCoord));
|
||||
|
||||
if (getEnergyStored() != MAX_ENERGY_VALUE || !isEnabled) {
|
||||
mode = 0;
|
||||
|
||||
isEnabled = computerEnabled
|
||||
&& worldObj.isAirBlock(xCoord, yCoord + 1, zCoord)
|
||||
&& worldObj.isAirBlock(xCoord, yCoord + 2, zCoord)
|
||||
&& worldObj.isAirBlock(xCoord, yCoord - 1, zCoord);
|
||||
|
||||
if (getEnergyStored() < WarpDriveConfig.LL_LIFT_ENERGY || !isEnabled) {
|
||||
mode = MODE_INACTIVE;
|
||||
if (getBlockMetadata() != 0) {
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2); // disabled
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (getBlockMetadata() != mode) {
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, mode, 2); // current mode
|
||||
}
|
||||
|
||||
|
||||
// Launch a beam: search non-air blocks under lift
|
||||
for (int ny = yCoord - 1; ny > 0; ny--) {
|
||||
int blockId = worldObj.getBlockId(xCoord, ny, zCoord);
|
||||
|
@ -64,7 +79,7 @@ public class TileEntityLift extends WarpEnergyTE {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (yCoord - firstUncoveredY > 0) {
|
||||
if (mode == 1) {
|
||||
WarpDrive.instance.sendLaserPacket(worldObj, new Vector3(this).translate(0.5D), new Vector3(xCoord, firstUncoveredY, zCoord).translate(0.5D), 0f, 1f, 0f, 40, 0, 100);
|
||||
|
@ -72,81 +87,45 @@ public class TileEntityLift extends WarpEnergyTE {
|
|||
WarpDrive.instance.sendLaserPacket(worldObj, new Vector3(this).translate(0.5D), new Vector3(xCoord, firstUncoveredY, zCoord).translate(0.5D), 0f, 0f, 1f, 40, 0, 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
liftEntity();
|
||||
}
|
||||
}
|
||||
|
||||
public void liftEntity()
|
||||
{
|
||||
int xmax, zmax, x1, x2, z1, z2;
|
||||
int xmin, zmin;
|
||||
final int CUBE_SIDE = 2;
|
||||
x1 = xCoord + CUBE_SIDE / 2;
|
||||
x2 = xCoord - CUBE_SIDE / 2;
|
||||
|
||||
if (x1 < x2)
|
||||
{
|
||||
xmin = x1;
|
||||
xmax = x2;
|
||||
}
|
||||
else
|
||||
{
|
||||
xmin = x2;
|
||||
xmax = x1;
|
||||
}
|
||||
|
||||
z1 = zCoord + CUBE_SIDE / 2;
|
||||
z2 = zCoord - CUBE_SIDE / 2;
|
||||
|
||||
if (z1 < z2)
|
||||
{
|
||||
zmin = z1;
|
||||
zmax = z2;
|
||||
}
|
||||
else
|
||||
{
|
||||
zmin = z2;
|
||||
zmax = z1;
|
||||
}
|
||||
|
||||
public void liftEntity() {
|
||||
final double CUBE_RADIUS = 0.4;
|
||||
double xmax, zmax;
|
||||
double xmin, zmin;
|
||||
|
||||
xmin = xCoord + 0.5 - CUBE_RADIUS;
|
||||
xmax = xCoord + 0.5 + CUBE_RADIUS;
|
||||
zmin = zCoord + 0.5 - CUBE_RADIUS;
|
||||
zmax = zCoord + 0.5 + CUBE_RADIUS;
|
||||
|
||||
// Lift up
|
||||
if (mode == 1)
|
||||
{
|
||||
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xmin + 0.3, firstUncoveredY, zmin + 0.3, xmax - 0.3, yCoord, zmax - 0.3);
|
||||
if (mode == MODE_UP) {
|
||||
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xmin, firstUncoveredY, zmin, xmax, yCoord, zmax);
|
||||
List list = worldObj.getEntitiesWithinAABBExcludingEntity(null, aabb);
|
||||
|
||||
if (list != null) // up
|
||||
{
|
||||
for (Object o : list)
|
||||
{
|
||||
if (o != null && o instanceof EntityLivingBase)
|
||||
{
|
||||
if (list != null) {
|
||||
for (Object o : list) {
|
||||
if (o != null && o instanceof EntityLivingBase && consumeEnergy(WarpDriveConfig.LL_LIFT_ENERGY, true)) {
|
||||
((EntityLivingBase)o).setPositionAndUpdate(xCoord + 0.5f, yCoord + 1, zCoord + 0.5f);
|
||||
WarpDrive.sendLaserPacket(worldObj, new Vector3(this).translate(0.5), new Vector3(xCoord, firstUncoveredY, zCoord).translate(0.5), 1F, 1F, 0F, 40, 0, 100);
|
||||
worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:hilaser", 4F, 1F);
|
||||
consumeAllEnergy();
|
||||
return;
|
||||
consumeEnergy(WarpDriveConfig.LL_LIFT_ENERGY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mode == 2) // down
|
||||
{
|
||||
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xmin + 0.3, yCoord, zmin + 0.3, xmax - 0.3, yCoord + 2, zmax - 0.3);
|
||||
} else if (mode == MODE_DOWN) {
|
||||
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xmin, firstUncoveredY + 2, zmin, xmax, yCoord + 2, zmax);
|
||||
List list = worldObj.getEntitiesWithinAABBExcludingEntity(null, aabb);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
for (Object o : list)
|
||||
{
|
||||
if (o != null && o instanceof EntityLivingBase)
|
||||
{
|
||||
((EntityLivingBase)o).setPositionAndUpdate(xCoord + 0.5f, firstUncoveredY + 1, zCoord + 0.5f);
|
||||
WarpDrive.sendLaserPacket(worldObj, new Vector3(this).translate(0.5), new Vector3(xCoord, firstUncoveredY + 1, zCoord).translate(0.5), 1F, 1F, 0F, 40, 0, 100);
|
||||
worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:hilaser", 4F, 1F);
|
||||
consumeAllEnergy();
|
||||
return;
|
||||
if (list != null) {
|
||||
for (Object o : list) {
|
||||
if (o != null && o instanceof EntityLivingBase && consumeEnergy(WarpDriveConfig.LL_LIFT_ENERGY, true)) {
|
||||
((EntityLivingBase)o).setPositionAndUpdate(xCoord + 0.5f, firstUncoveredY + 1, zCoord + 0.5f);
|
||||
WarpDrive.sendLaserPacket(worldObj, new Vector3(this).translate(0.5), new Vector3(xCoord, firstUncoveredY + 1, zCoord).translate(0.5), 1F, 1F, 0F, 40, 0, 100);
|
||||
worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:hilaser", 4F, 1F);
|
||||
consumeEnergy(WarpDriveConfig.LL_LIFT_ENERGY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +146,7 @@ public class TileEntityLift extends WarpEnergyTE {
|
|||
|
||||
@Override
|
||||
public int getMaxEnergyStored() {
|
||||
return MAX_ENERGY_VALUE;
|
||||
return WarpDriveConfig.LL_MAX_ENERGY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -180,4 +159,86 @@ public class TileEntityLift extends WarpEnergyTE {
|
|||
public int getMaxSafeInput() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "warpdriveLaserLift";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
return methodsArray;
|
||||
}
|
||||
|
||||
public String helpStr(Object[] args)
|
||||
{
|
||||
if(args.length == 1)
|
||||
{
|
||||
String fun = args[0].toString().toLowerCase();
|
||||
if(fun.equals("energy"))
|
||||
return WarpDrive.defEnergyStr;
|
||||
else if(fun.equals("mode"))
|
||||
return "mode(\"up\" or \"down\" or \"redstone\"): sets the mode\nmode(): returns the current mode";
|
||||
else if(fun.equals("active"))
|
||||
return "active(boolean): sets whether the laser is active\nactive(): returns whether the laser is active";
|
||||
}
|
||||
return WarpDrive.defHelpStr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] args) throws Exception {
|
||||
String methodName = methodsArray[method];
|
||||
if (methodName.equals("energy")) {
|
||||
return getEnergyObject();
|
||||
} else if (methodName.equals("mode")) {
|
||||
if (args.length == 1) {
|
||||
if (args[0].toString().equals("up")) {
|
||||
computerMode = MODE_UP;
|
||||
} else if(args[0].toString().equals("down")) {
|
||||
computerMode = MODE_DOWN;
|
||||
} else {
|
||||
computerMode = MODE_REDSTONE;
|
||||
}
|
||||
}
|
||||
switch (computerMode) {
|
||||
case -1:
|
||||
return new Object[] { "redstone" };
|
||||
case 1:
|
||||
return new Object[] { "up" };
|
||||
case 2:
|
||||
return new Object[] { "down" };
|
||||
}
|
||||
} else if (methodName.equals("active")) {
|
||||
if (args.length == 1) {
|
||||
computerEnabled = toBool(args[0]);
|
||||
}
|
||||
return new Object[] { computerEnabled ? false : isEnabled };
|
||||
}
|
||||
else if (methodName.equals("help")) {
|
||||
return new Object[] { helpStr(args) };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach(IComputerAccess computer) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach(IComputerAccess computer) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (((((super.hashCode() + worldObj.provider.dimensionId << 4) + xCoord) << 4) + yCoord) << 4) + zCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(IPeripheral other) {
|
||||
return other.hashCode() == hashCode();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,55 +17,60 @@ public abstract class WarpChunkTE extends WarpEnergyTE
|
|||
protected ChunkCoordIntPair minChunk = null;
|
||||
protected ChunkCoordIntPair maxChunk = null;
|
||||
|
||||
boolean areChunksLoaded = false;
|
||||
boolean isRefreshing = false;
|
||||
|
||||
public void refreshLoading(boolean force)
|
||||
{
|
||||
if(isRefreshing)
|
||||
return;
|
||||
protected boolean areChunksLoaded = false;
|
||||
private boolean isRefreshing = false;
|
||||
|
||||
// OVERRIDES
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (shouldChunkLoad() != areChunksLoaded) {
|
||||
refreshLoading();
|
||||
}
|
||||
|
||||
isRefreshing = true;
|
||||
boolean load = shouldChunkLoad();
|
||||
if(ticketList.size() != 0)
|
||||
{
|
||||
if(load && (!areChunksLoaded || force))
|
||||
{
|
||||
if (shouldChunkLoad()) {
|
||||
handleLoadedTick();
|
||||
}
|
||||
}
|
||||
|
||||
public void handleLoadedTick() {
|
||||
|
||||
}
|
||||
|
||||
public synchronized void refreshLoading(boolean force) {
|
||||
boolean loadRequested = shouldChunkLoad();
|
||||
if (ticketList.size() != 0) {
|
||||
if (loadRequested && (!areChunksLoaded || force)) {
|
||||
int ticketSize = ticketList.get(0).getMaxChunkListDepth();
|
||||
ArrayList<ChunkCoordIntPair> chunkList = getChunksToLoad();
|
||||
int numTicketsRequired = (int) Math.ceil((double) chunkList.size() / ticketSize);
|
||||
if(ticketList.size() != numTicketsRequired)
|
||||
{
|
||||
for(int i=ticketList.size();i<numTicketsRequired;i++)
|
||||
int numTicketsRequired = (int) Math.ceil((double) chunkList.size() / ticketSize); // FIXME there should be only one ticket per requesting TileEntity
|
||||
if (ticketList.size() != numTicketsRequired) {
|
||||
for(int i = ticketList.size(); i < numTicketsRequired; i++) {
|
||||
WarpDrive.instance.getTicket(this);
|
||||
}
|
||||
}
|
||||
|
||||
int tickNum = 0;
|
||||
int chunkInTick = 0;
|
||||
int chunkInTicket = 0;
|
||||
|
||||
Ticket t = ticketList.get(0);
|
||||
for(ChunkCoordIntPair chunk:chunkList)
|
||||
{
|
||||
if(chunkInTick >= ticketSize)
|
||||
{
|
||||
chunkInTick = 0;
|
||||
for(ChunkCoordIntPair chunk:chunkList) {
|
||||
if (chunkInTicket >= ticketSize) {
|
||||
chunkInTicket = 0;
|
||||
tickNum++;
|
||||
t = ticketList.get(tickNum);
|
||||
}
|
||||
|
||||
WarpDrive.debugPrint("Attempting to force chunk" + chunk);
|
||||
ForgeChunkManager.forceChunk(t, chunk);
|
||||
chunkInTick++;
|
||||
chunkInTicket++;
|
||||
}
|
||||
areChunksLoaded = true;
|
||||
}
|
||||
else if(!load)
|
||||
{
|
||||
for(Ticket ticket:ticketList)
|
||||
{
|
||||
} else if(!loadRequested) {
|
||||
for(Ticket ticket:ticketList) {
|
||||
ImmutableSet<ChunkCoordIntPair> chunks = ticket.getChunkList();
|
||||
for(ChunkCoordIntPair chunk:chunks)
|
||||
for(ChunkCoordIntPair chunk:chunks) {
|
||||
ForgeChunkManager.unforceChunk(ticket, chunk);
|
||||
}
|
||||
|
||||
ForgeChunkManager.releaseTicket(ticket);
|
||||
WarpDrive.instance.removeTicket(ticket);
|
||||
|
@ -73,21 +78,16 @@ public abstract class WarpChunkTE extends WarpEnergyTE
|
|||
ticketList.clear();
|
||||
areChunksLoaded = false;
|
||||
}
|
||||
}
|
||||
else if(load)
|
||||
{
|
||||
} else if(loadRequested) {
|
||||
WarpDrive.instance.registerChunkLoadTE(this);
|
||||
}
|
||||
isRefreshing = false;
|
||||
}
|
||||
|
||||
public void refreshLoading()
|
||||
{
|
||||
public void refreshLoading() {
|
||||
refreshLoading(false);
|
||||
}
|
||||
|
||||
public void giveTicket(Ticket t)
|
||||
{
|
||||
public void giveTicket(Ticket t) {
|
||||
ticketList.add(t);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue