Added force field projectors and relays (wip)
Upgrades are mostly defined with energy & damages handling Recipes are implemented with 2 new components Projector placement is broken, shapes won't form
This commit is contained in:
parent
7f2dda6835
commit
863455c80a
24 changed files with 1389 additions and 839 deletions
|
@ -126,9 +126,6 @@ import cr0s.warpdrive.world.SpaceWorldGenerator;
|
|||
|
||||
@Mod(modid = WarpDrive.MODID, name = "WarpDrive", version = WarpDrive.VERSION, dependencies = "after:IC2API;" + " after:CoFHCore;" + " after:ComputerCraft;"
|
||||
+ " after:OpenComputer;" + " after:CCTurtle;" + " after:gregtech;" + " after:AppliedEnergistics;" + " after:EnderIO;")
|
||||
/**
|
||||
* @author Cr0s
|
||||
*/
|
||||
public class WarpDrive implements LoadingCallback {
|
||||
public static final String MODID = "WarpDrive";
|
||||
public static final String VERSION = "@version@";
|
||||
|
@ -163,8 +160,9 @@ public class WarpDrive implements LoadingCallback {
|
|||
public static Block blockHighlyAdvancedMachine;
|
||||
public static Block blockTransportBeacon;
|
||||
public static Block blockChunkLoader;
|
||||
public static Block blockForceField;
|
||||
public static Block blockProjector;
|
||||
public static Block[] blockForceFields;
|
||||
public static Block[] blockForceFieldProjectors;
|
||||
public static Block[] blockForceFieldRelays;
|
||||
public static BlockDecorative blockDecorative;
|
||||
public static Block[] blockHulls_plain;
|
||||
public static Block[] blockHulls_glass;
|
||||
|
@ -176,7 +174,7 @@ public class WarpDrive implements LoadingCallback {
|
|||
public static ItemUpgrade itemUpgrade;
|
||||
public static ItemTuningFork itemTuningRod;
|
||||
public static ItemForceFieldShape itemForceFieldShape;
|
||||
public static BlockForceFieldUpgrade blockForceFieldUpgrade;
|
||||
public static ItemForceFieldUpgrade itemForceFieldUpgrade;
|
||||
|
||||
public static final ArmorMaterial armorMaterial = EnumHelper.addArmorMaterial("WARP", 18, new int[] { 2, 6, 5, 2 }, 9);
|
||||
public static ItemHelmet itemHelmet;
|
||||
|
@ -400,22 +398,26 @@ public class WarpDrive implements LoadingCallback {
|
|||
GameRegistry.registerBlock(blockChunkLoader, "blockChunkLoader");
|
||||
GameRegistry.registerTileEntity(TileEntityChunkLoader.class, MODID + ":blockChunkLoader");
|
||||
|
||||
// FORCE FIELD BLOCKS
|
||||
blockForceFields = new Block[3];
|
||||
blockForceFieldProjectors = new Block[3];
|
||||
blockForceFieldRelays = new Block[3];
|
||||
for(byte tier = 1; tier <= 3; tier++) {
|
||||
int index = tier - 1;
|
||||
// FORCE FIELD
|
||||
blockForceField = new BlockForceField(tier);
|
||||
GameRegistry.registerBlock(blockForceField, "blockForceField" + tier);
|
||||
blockForceFields[index] = new BlockForceField(tier);
|
||||
GameRegistry.registerBlock(blockForceFields[index], "blockForceField" + tier);
|
||||
GameRegistry.registerTileEntity(TileEntityForceField.class, MODID + ":blockForceField" + tier);
|
||||
|
||||
// FORCE FIELD PROJECTOR
|
||||
blockProjector = new BlockProjector(tier);
|
||||
GameRegistry.registerBlock(blockProjector, "blockProjector" + tier);
|
||||
GameRegistry.registerTileEntity(TileEntityProjector.class, MODID + ":blockProjector" + tier);
|
||||
/* TODO
|
||||
// FORCE FIELD CORE
|
||||
blockForceFieldCore = new BlockForceFieldCore(tier);
|
||||
GameRegistry.registerBlock(blockProjector, "blockForceFieldCore" + tier);
|
||||
GameRegistry.registerTileEntity(TileEntityForceFieldCore.class, MODID + ":blockForceFieldCore" + tier);
|
||||
*/
|
||||
blockForceFieldProjectors[index] = new BlockForceFieldProjector(tier);
|
||||
GameRegistry.registerBlock(blockForceFieldProjectors[index], "blockProjector" + tier);
|
||||
GameRegistry.registerTileEntity(TileEntityForceFieldProjector.class, MODID + ":blockProjector" + tier);
|
||||
|
||||
// FORCE FIELD RELAY
|
||||
blockForceFieldRelays[index] = new BlockForceFieldRelay(tier);
|
||||
GameRegistry.registerBlock(blockForceFieldRelays[index], "blockForceFieldRelay" + tier);
|
||||
GameRegistry.registerTileEntity(TileEntityForceFieldRelay.class, MODID + ":blockForceFieldRelay" + tier);
|
||||
}
|
||||
/* TODO
|
||||
// SECURITY STATION
|
||||
|
@ -466,14 +468,13 @@ public class WarpDrive implements LoadingCallback {
|
|||
itemTuningRod = new ItemTuningFork();
|
||||
GameRegistry.registerItem(itemTuningRod, "itemTuningRod");
|
||||
|
||||
// FORCEFIELD UPGRADES
|
||||
// FORCE FIELD UPGRADES
|
||||
itemForceFieldShape = new ItemForceFieldShape();
|
||||
GameRegistry.registerItem(itemForceFieldShape, "itemForceFieldShape");
|
||||
|
||||
blockForceFieldUpgrade = new BlockForceFieldUpgrade();
|
||||
GameRegistry.registerBlock(blockForceFieldUpgrade, ItemBlockForceFieldUpgrade.class, "blockForceFieldUpgrade");
|
||||
GameRegistry.registerTileEntity(TileEntityForceFieldUpgrade.class, MODID + ":blockForceFieldUpgrade");
|
||||
|
||||
|
||||
itemForceFieldUpgrade = new ItemForceFieldUpgrade();
|
||||
GameRegistry.registerItem(itemForceFieldUpgrade, "itemForceFieldUpgrade");
|
||||
|
||||
// DAMAGE SOURCES
|
||||
damageAsphyxia = new DamageAsphyxia();
|
||||
damageCold = new DamageCold();
|
||||
|
@ -556,7 +557,7 @@ public class WarpDrive implements LoadingCallback {
|
|||
event.registerServerCommand(new CommandEntity());
|
||||
}
|
||||
|
||||
public Ticket registerChunkLoadTE(TileEntityAbstractChunkLoading tileEntity, boolean refreshLoading) {
|
||||
private Ticket registerChunkLoadTE(TileEntityAbstractChunkLoading tileEntity, boolean refreshLoading) {
|
||||
World worldObj = tileEntity.getWorldObj();
|
||||
if (ForgeChunkManager.ticketCountAvailableFor(this, worldObj) > 0) {
|
||||
Ticket ticket = ForgeChunkManager.requestTicket(this, worldObj, Type.NORMAL);
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
package cr0s.warpdrive.api;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Created by LemADEC on 16/05/2016.
|
||||
*/
|
||||
public interface IEffector {
|
||||
void onEntityCollided(World world, final int x, final int y, final int z, Entity entity);
|
||||
}
|
|
@ -6,7 +6,7 @@ import cr0s.warpdrive.data.VectorI;
|
|||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IShapeProvider {
|
||||
public interface IForceFieldShape {
|
||||
|
||||
/**
|
||||
* Return a collection of coordinates to all blocks in a shape.
|
|
@ -1,26 +1,9 @@
|
|||
package cr0s.warpdrive.api;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Created by LemADEC on 16/05/2016.
|
||||
*/
|
||||
public interface IForceFieldUpgrade {
|
||||
// Unique name for this upgrade category
|
||||
String getUpgradeKey();
|
||||
// Get the effect calculation object for this upgrade category
|
||||
IForceFieldUpgradeEffector getUpgradeEffector();
|
||||
|
||||
// Bonus give to this upgrade category (can be positive or negative)
|
||||
// Bonus provided to this upgrade category (can be positive or negative)
|
||||
int getUpgradeValue();
|
||||
|
||||
// Maximum speed of this upgrade in blocks per projector update
|
||||
// 0.3 to 30 blocks per upgrade ?
|
||||
float getMaxScanSpeed(final String upgradeKey, final int upgradeCount);
|
||||
float getMaxPlaceSpeed(final String upgradeKey, final int upgradeCount);
|
||||
|
||||
// Energy impacts of this upgrade
|
||||
float getStartupEnergyCost(final String upgradeKey, final int upgradeCount);
|
||||
float getScanEnergyCost(final String upgradeKey, final int upgradeCount);
|
||||
float getPlaceEnergyCost(final String upgradeKey, final int upgradeCount);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package cr0s.warpdrive.api;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IForceFieldUpgradeEffector {
|
||||
// Apply scaling to the sum of all upgrades for this upgrade category
|
||||
// Use this to cap the upgrade or apply non-linear scaling.
|
||||
float getScaledValue(final float ratio, final int upgradeValue);
|
||||
|
||||
// Maximum speed of this upgrade in blocks per projector update
|
||||
// Typical values: 0.3 to 30 blocks per upgrade
|
||||
// Return 0 if the upgrade has no effect
|
||||
float getMaxScanSpeed(final float scaledValue);
|
||||
float getMaxPlaceSpeed(final float scaledValue);
|
||||
|
||||
// Energy impacts of this upgrade
|
||||
float getStartupEnergyCost(final float scaledValue);
|
||||
float getScanEnergyCost(final float scaledValue);
|
||||
float getPlaceEnergyCost(final float scaledValue);
|
||||
float getEntityEffectEnergyCost(final float scaledValue);
|
||||
|
||||
// Entity impact of this upgrade
|
||||
// Return
|
||||
int onEntityEffect(final float scaledValue, World world, final int x, final int y, final int z, Entity entity);
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package cr0s.warpdrive.block.forcefield;
|
||||
|
||||
import cr0s.warpdrive.block.BlockAbstractContainer;
|
||||
import cr0s.warpdrive.config.WarpDriveConfig;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
public abstract class BlockAbstractForceField extends BlockAbstractContainer {
|
||||
protected byte tier;
|
||||
|
||||
BlockAbstractForceField(final byte tier, final Material material) {
|
||||
super(material);
|
||||
this.tier = tier;
|
||||
setHardness(WarpDriveConfig.HULL_HARDNESS[tier - 1]);
|
||||
setResistance(WarpDriveConfig.HULL_BLAST_RESISTANCE[tier - 1] * 5 / 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMobilityFlag() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canSilkHarvest() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -3,9 +3,7 @@ package cr0s.warpdrive.block.forcefield;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.api.IEffector;
|
||||
import cr0s.warpdrive.api.IDamageReceiver;
|
||||
import cr0s.warpdrive.block.BlockAbstractContainer;
|
||||
import cr0s.warpdrive.block.hull.BlockHullGlass;
|
||||
import cr0s.warpdrive.config.WarpDriveConfig;
|
||||
import cr0s.warpdrive.data.ForceFieldSetup;
|
||||
|
@ -36,19 +34,14 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockForceField extends BlockAbstractContainer implements IDamageReceiver {
|
||||
public class BlockForceField extends BlockAbstractForceField implements IDamageReceiver {
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
private int tier;
|
||||
private static final float BOUNDING_TOLERANCE = 0.05F;
|
||||
|
||||
public BlockForceField(final int tier) {
|
||||
super(Material.glass);
|
||||
this.tier = tier;
|
||||
setHardness(WarpDriveConfig.HULL_HARDNESS[tier - 1]);
|
||||
setResistance(WarpDriveConfig.HULL_BLAST_RESISTANCE[tier - 1] * 5 / 3);
|
||||
public BlockForceField(final byte tier) {
|
||||
super(tier, Material.glass);
|
||||
setStepSound(Block.soundTypeCloth);
|
||||
setCreativeTab(WarpDrive.creativeTabWarpDrive);
|
||||
setBlockName("warpdrive.forcefield.block" + tier);
|
||||
setBlockTextureName("warpdrive:forcefield/forcefield");
|
||||
}
|
||||
|
@ -62,12 +55,7 @@ public class BlockForceField extends BlockAbstractContainer implements IDamageRe
|
|||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer entityPlayer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMobilityFlag() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
|
@ -88,12 +76,7 @@ public class BlockForceField extends BlockAbstractContainer implements IDamageRe
|
|||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canSilkHarvest() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs creativeTab, List list) {
|
||||
|
@ -138,7 +121,7 @@ public class BlockForceField extends BlockAbstractContainer implements IDamageRe
|
|||
return !world.isSideSolid(x, y, z, direction, false);
|
||||
}
|
||||
|
||||
protected TileEntityProjector getProjector(World world, int x, int y, int z) {
|
||||
protected TileEntityForceFieldProjector getProjector(World world, int x, int y, int z) {
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (tileEntity instanceof TileEntityForceField) {
|
||||
return ((TileEntityForceField) tileEntity).getProjector();
|
||||
|
@ -157,9 +140,7 @@ public class BlockForceField extends BlockAbstractContainer implements IDamageRe
|
|||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer entityPlayer) {
|
||||
ForceFieldSetup forceFieldSetup = getForceFieldSetup(world, x, y, z);
|
||||
if (forceFieldSetup != null) {
|
||||
for (IEffector effector : forceFieldSetup.getEffectors()) {
|
||||
effector.onEntityCollided(world, x, y, z, entityPlayer);
|
||||
}
|
||||
forceFieldSetup.onEntityEffect(world, x, y, z, entityPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,9 +171,7 @@ public class BlockForceField extends BlockAbstractContainer implements IDamageRe
|
|||
|
||||
ForceFieldSetup forceFieldSetup = getForceFieldSetup(world, x, y, z);
|
||||
if (forceFieldSetup != null) {
|
||||
for (IEffector effector : forceFieldSetup.getEffectors()) {
|
||||
effector.onEntityCollided(world, x, y, z, entity);
|
||||
}
|
||||
forceFieldSetup.onEntityEffect(world, x, y, z, entity);
|
||||
|
||||
if (entity instanceof EntityLiving && new Vector3(x, y, z).translate(0.5F).distanceTo_square(entity) < 0.4D) {
|
||||
boolean hasPermission = false;
|
||||
|
|
|
@ -0,0 +1,205 @@
|
|||
package cr0s.warpdrive.block.forcefield;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.data.EnumForceFieldShape;
|
||||
import cr0s.warpdrive.item.ItemForceFieldShape;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
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.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityHopper;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockForceFieldProjector extends BlockAbstractForceField {
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
|
||||
public BlockForceFieldProjector(final byte tier) {
|
||||
super(tier, Material.iron);
|
||||
isRotating = true;
|
||||
setBlockName("warpdrive.forcefield.projector" + tier);
|
||||
setBlockTextureName("warpdrive:forcefield/projector");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
icons = new IIcon[11];
|
||||
icons[ 0] = iconRegister.registerIcon("warpdrive:forcefield/projectorSide_notConnected");
|
||||
icons[ 1] = iconRegister.registerIcon("warpdrive:forcefield/projectorSide_connectedNotPowered");
|
||||
icons[ 2] = iconRegister.registerIcon("warpdrive:forcefield/projectorSide_connectedPowered");
|
||||
icons[ 3] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_none");
|
||||
icons[ 4] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_sphere");
|
||||
icons[ 5] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_cylinder_h");
|
||||
icons[ 6] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_cylinder_v");
|
||||
icons[ 7] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_cube");
|
||||
icons[ 8] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_plane");
|
||||
icons[ 9] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_tube");
|
||||
icons[10] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_tunnel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (tileEntity == null || !(tileEntity instanceof TileEntityForceFieldProjector)) {
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
if (side == (metadata & 7) || (((TileEntityForceFieldProjector)tileEntity).isDoubleSided && ForgeDirection.OPPOSITES[side] == (metadata & 7))) {
|
||||
return icons[3 + ((TileEntityForceFieldProjector)tileEntity).getShape().ordinal()];
|
||||
} else if (((TileEntityForceFieldProjector)tileEntity).isConnected) {
|
||||
if (((TileEntityForceFieldProjector)tileEntity).isPowered) {
|
||||
return icons[2];
|
||||
} else {
|
||||
return icons[1];
|
||||
}
|
||||
}
|
||||
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return side == 3 ? icons[4] : icons[2];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) {
|
||||
super.onBlockPlacedBy(world, x, y, z, entityLiving, itemStack);
|
||||
TileEntityForceFieldProjector tileEntityForceFieldProjector = (TileEntityForceFieldProjector)world.getTileEntity(x, y, z);
|
||||
tileEntityForceFieldProjector.isDoubleSided = (itemStack.getItemDamage() == 1);
|
||||
if (itemStack.hasTagCompound()) {
|
||||
tileEntityForceFieldProjector.readFromNBT(itemStack.getTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
|
||||
return willHarvest || super.removedByPlayer(world, player, x, y, z, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dropBlockAsItem(World world, int x, int y, int z, ItemStack itemStack) {
|
||||
// TODO: TE is already removed, need another method
|
||||
TileEntityForceFieldProjector tileEntityForceFieldProjector = (TileEntityForceFieldProjector)world.getTileEntity(x, y, z);
|
||||
if (tileEntityForceFieldProjector == null) {
|
||||
WarpDrive.logger.error("Missing tile entity for " + this + " at " + world + " " + x + " " + y + " " + z);
|
||||
} else {
|
||||
NBTTagCompound nbtTagCompound = new NBTTagCompound();
|
||||
tileEntityForceFieldProjector.writeToNBT(nbtTagCompound);
|
||||
itemStack.setTagCompound(nbtTagCompound);
|
||||
}
|
||||
world.setBlockToAir(x, y, z);
|
||||
super.dropBlockAsItem(world, x, y, z, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int metadata) {
|
||||
TileEntityForceFieldProjector tileEntityForceFieldProjector = (TileEntityForceFieldProjector)world.getTileEntity(x, y, z);
|
||||
super.breakBlock(world, x, y, z, block, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
|
||||
return super.getItemDropped(p_149650_1_, p_149650_2_, p_149650_3_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (!(tileEntity instanceof TileEntityForceFieldProjector)) {
|
||||
return false;
|
||||
}
|
||||
TileEntityForceFieldProjector tileEntityForceFieldProjector = (TileEntityForceFieldProjector) tileEntity;
|
||||
ItemStack itemStackHeld = entityPlayer.getHeldItem();
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
if (entityPlayer.isSneaking()) {
|
||||
if (tileEntityForceFieldProjector.getShape() != EnumForceFieldShape.NONE) {
|
||||
if (side == (metadata & 7) || (tileEntityForceFieldProjector.isDoubleSided && ForgeDirection.OPPOSITES[side] == (metadata & 7))) {
|
||||
// dismount the shape item(s)
|
||||
ItemStack itemStackDrop = ItemForceFieldShape.getItemStackNoCache(tileEntityForceFieldProjector.getShape(), tileEntityForceFieldProjector.isDoubleSided ? 2 : 1);
|
||||
EntityItem entityItem = new EntityItem(world, entityPlayer.posX, entityPlayer.posY + 0.5D, entityPlayer.posZ, itemStackDrop);
|
||||
entityItem.delayBeforeCanPickup = 0;
|
||||
world.spawnEntityInWorld(entityItem);
|
||||
|
||||
tileEntityForceFieldProjector.setShape(EnumForceFieldShape.NONE);
|
||||
} else {
|
||||
// wrong side TODO
|
||||
WarpDrive.addChatMessage(entityPlayer, tileEntityForceFieldProjector.getStatus());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// no shape to dismount TODO
|
||||
WarpDrive.addChatMessage(entityPlayer, tileEntityForceFieldProjector.getStatus());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
WarpDrive.addChatMessage(entityPlayer, tileEntityForceFieldProjector.getStatus());
|
||||
return true;
|
||||
}
|
||||
} else if (itemStackHeld.getItem() instanceof ItemForceFieldShape) {
|
||||
if (side == (metadata & 7) || (((TileEntityForceFieldProjector) tileEntity).isDoubleSided && ForgeDirection.OPPOSITES[side] == (metadata & 7))) {
|
||||
// validate quantity
|
||||
if (itemStackHeld.stackSize < (tileEntityForceFieldProjector.isDoubleSided ? 2 : 1)) {
|
||||
// not enough shape items TODO
|
||||
WarpDrive.addChatMessage(entityPlayer, tileEntityForceFieldProjector.getStatus());
|
||||
return true;
|
||||
}
|
||||
|
||||
// update player inventory
|
||||
itemStackHeld.stackSize -= tileEntityForceFieldProjector.isDoubleSided ? 2 : 1;
|
||||
|
||||
// dismount the shape item(s)
|
||||
if (tileEntityForceFieldProjector.getShape() != EnumForceFieldShape.NONE) {
|
||||
ItemStack itemStackDrop = ItemForceFieldShape.getItemStackNoCache(tileEntityForceFieldProjector.getShape(), tileEntityForceFieldProjector.isDoubleSided ? 2 : 1);
|
||||
EntityItem entityItem = new EntityItem(world, entityPlayer.posX, entityPlayer.posY + 0.5D, entityPlayer.posZ, itemStackDrop);
|
||||
entityItem.delayBeforeCanPickup = 0;
|
||||
world.spawnEntityInWorld(entityItem);
|
||||
}
|
||||
|
||||
// mount the new shape item(s)
|
||||
tileEntityForceFieldProjector.setShape(EnumForceFieldShape.get(itemStackHeld.getItemDamage()));
|
||||
} else {
|
||||
// wrong side TODO
|
||||
WarpDrive.addChatMessage(entityPlayer, tileEntityForceFieldProjector.getStatus());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int metadata) {
|
||||
return new TileEntityForceFieldProjector();
|
||||
}
|
||||
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer entityPlayer) {
|
||||
ItemStack itemStack = super.getPickBlock(target, world, x, y, z, entityPlayer);
|
||||
TileEntityForceFieldProjector tileEntityForceFieldProjector = (TileEntityForceFieldProjector)world.getTileEntity(x, y, z);
|
||||
NBTTagCompound nbtTagCompound = new NBTTagCompound();
|
||||
tileEntityForceFieldProjector.writeToNBT(nbtTagCompound);
|
||||
itemStack.setTagCompound(nbtTagCompound);
|
||||
return itemStack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
package cr0s.warpdrive.block.forcefield;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.data.EnumForceFieldUpgrade;
|
||||
import cr0s.warpdrive.item.ItemForceFieldUpgrade;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockForceFieldRelay extends BlockAbstractForceField {
|
||||
@SideOnly(Side.CLIENT)
|
||||
private final IIcon[] icons;
|
||||
|
||||
public BlockForceFieldRelay(final byte tier) {
|
||||
super(tier, Material.iron);
|
||||
isRotating = false;
|
||||
setBlockName("warpdrive.forcefield.relay" + tier);
|
||||
setBlockTextureName("warpdrive:forcefield/relay");
|
||||
|
||||
icons = new IIcon[EnumForceFieldUpgrade.length + 1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
for (EnumForceFieldUpgrade enumForceFieldUpgrade : EnumForceFieldUpgrade.values()) {
|
||||
if (enumForceFieldUpgrade.allowOnRelay) {
|
||||
icons[enumForceFieldUpgrade.ordinal()] = iconRegister.registerIcon("warpdrive:forcefield/relay" + "_" + enumForceFieldUpgrade.unlocalizedName);
|
||||
} else {
|
||||
icons[enumForceFieldUpgrade.ordinal()] = iconRegister.registerIcon("warpdrive:forcefield/relay" + "_" + EnumForceFieldUpgrade.NONE.unlocalizedName);
|
||||
}
|
||||
}
|
||||
icons[EnumForceFieldUpgrade.length] = iconRegister.registerIcon("warpdrive:forcefield/relay_top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (tileEntity == null || !(tileEntity instanceof TileEntityForceFieldRelay)) {
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
if (side == 0 || side == 1) {
|
||||
return icons[EnumForceFieldUpgrade.length];
|
||||
}
|
||||
return icons[((TileEntityForceFieldRelay)tileEntity).getUpgrade().ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int damage) {
|
||||
if (side == 0 || side == 1) {
|
||||
return icons[EnumForceFieldUpgrade.length];
|
||||
}
|
||||
if (damage >= 0 && damage < EnumForceFieldUpgrade.length) {
|
||||
return icons[damage];
|
||||
}
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (!(tileEntity instanceof TileEntityForceFieldRelay)) {
|
||||
return false;
|
||||
}
|
||||
TileEntityForceFieldRelay tileEntityForceFieldRelay = (TileEntityForceFieldRelay) tileEntity;
|
||||
ItemStack itemStackHeld = entityPlayer.getHeldItem();
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
if (entityPlayer.isSneaking()) {
|
||||
if (tileEntityForceFieldRelay.getUpgrade() != EnumForceFieldUpgrade.NONE) {
|
||||
// dismount the upgrade item(s)
|
||||
ItemStack itemStackDrop = ItemForceFieldUpgrade.getItemStackNoCache(tileEntityForceFieldRelay.getUpgrade(), 1);
|
||||
EntityItem entityItem = new EntityItem(world, entityPlayer.posX, entityPlayer.posY + 0.5D, entityPlayer.posZ, itemStackDrop);
|
||||
entityItem.delayBeforeCanPickup = 0;
|
||||
world.spawnEntityInWorld(entityItem);
|
||||
tileEntityForceFieldRelay.setUpgrade(EnumForceFieldUpgrade.NONE);
|
||||
} else {
|
||||
// no upgrade to dismount TODO
|
||||
WarpDrive.addChatMessage(entityPlayer, tileEntityForceFieldRelay.getStatus());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
WarpDrive.addChatMessage(entityPlayer, tileEntityForceFieldRelay.getStatus());
|
||||
return true;
|
||||
}
|
||||
|
||||
} else if (itemStackHeld.getItem() instanceof ItemForceFieldUpgrade) {
|
||||
// validate quantity
|
||||
if (itemStackHeld.stackSize < 1) {
|
||||
// not enough upgrade items TODO
|
||||
WarpDrive.addChatMessage(entityPlayer, tileEntityForceFieldRelay.getStatus());
|
||||
return true;
|
||||
}
|
||||
|
||||
// update player inventory
|
||||
itemStackHeld.stackSize -= 1;
|
||||
|
||||
// dismount the shape item(s)
|
||||
if (tileEntityForceFieldRelay.getUpgrade() != EnumForceFieldUpgrade.NONE) {
|
||||
ItemStack itemStackDrop = ItemForceFieldUpgrade.getItemStackNoCache(tileEntityForceFieldRelay.getUpgrade(), 1);
|
||||
EntityItem entityItem = new EntityItem(world, entityPlayer.posX, entityPlayer.posY + 0.5D, entityPlayer.posZ, itemStackDrop);
|
||||
entityItem.delayBeforeCanPickup = 0;
|
||||
world.spawnEntityInWorld(entityItem);
|
||||
}
|
||||
|
||||
// mount the new upgrade item(s)
|
||||
tileEntityForceFieldRelay.setUpgrade(EnumForceFieldUpgrade.get(itemStackHeld.getItemDamage()));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int metadata) {
|
||||
return new TileEntityForceFieldRelay();
|
||||
}
|
||||
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer entityPlayer) {
|
||||
return null; // FIXME
|
||||
}
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
package cr0s.warpdrive.block.forcefield;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.block.BlockAbstractContainer;
|
||||
import cr0s.warpdrive.data.EnumForceFieldUpgrade;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
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.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockForceFieldUpgrade extends BlockAbstractContainer {
|
||||
@SideOnly(Side.CLIENT)
|
||||
private final IIcon[] icons;
|
||||
|
||||
public BlockForceFieldUpgrade() {
|
||||
super(Material.iron);
|
||||
isRotating = false;
|
||||
setBlockName("warpdrive.forcefield.upgrade");
|
||||
setBlockTextureName("warpdrive:forcefield/upgrade");
|
||||
|
||||
icons = new IIcon[EnumForceFieldUpgrade.length];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) {
|
||||
for (EnumForceFieldUpgrade enumForceFieldUpgrade : EnumForceFieldUpgrade.values()) {
|
||||
list.add(new ItemStack(item, 1, enumForceFieldUpgrade.ordinal()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
for (EnumForceFieldUpgrade enumForceFieldUpgrade : EnumForceFieldUpgrade.values()) {
|
||||
icons[enumForceFieldUpgrade.ordinal()] = iconRegister.registerIcon("warpdrive:forcefield/upgrade" + "_" + enumForceFieldUpgrade.unlocalizedName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int damage) {
|
||||
if (damage >= 0 && damage < EnumForceFieldUpgrade.length) {
|
||||
return icons[damage];
|
||||
}
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (!(tileEntity instanceof TileEntityForceFieldUpgrade)) {
|
||||
return false;
|
||||
}
|
||||
TileEntityForceFieldUpgrade tileEntityForceFieldUpgrade = (TileEntityForceFieldUpgrade) tileEntity;
|
||||
ItemStack itemStackHeld = entityPlayer.getHeldItem();
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
WarpDrive.addChatMessage(entityPlayer, tileEntityForceFieldUpgrade.getStatus());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int metadata) {
|
||||
return new TileEntityForceFieldUpgrade();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canSilkHarvest() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer entityPlayer) {
|
||||
return null; // FIXME
|
||||
}
|
||||
}
|
|
@ -1,163 +0,0 @@
|
|||
package cr0s.warpdrive.block.forcefield;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.block.BlockAbstractContainer;
|
||||
import cr0s.warpdrive.config.WarpDriveConfig;
|
||||
import cr0s.warpdrive.data.EnumForceFieldShape;
|
||||
import cr0s.warpdrive.item.ItemForceFieldShape;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockProjector extends BlockAbstractContainer {
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
protected byte tier;
|
||||
|
||||
public BlockProjector(final byte tier) {
|
||||
super(Material.iron);
|
||||
isRotating = true;
|
||||
this.tier = tier;
|
||||
setHardness(WarpDriveConfig.HULL_HARDNESS[tier - 1]);
|
||||
setResistance(WarpDriveConfig.HULL_BLAST_RESISTANCE[tier - 1] * 5 / 3);
|
||||
setBlockName("warpdrive.forcefield.projector" + tier);
|
||||
setBlockTextureName("warpdrive:forcefield/projector");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
icons = new IIcon[11];
|
||||
icons[ 0] = iconRegister.registerIcon("warpdrive:forcefield/projectorSide_notConnected");
|
||||
icons[ 1] = iconRegister.registerIcon("warpdrive:forcefield/projectorSide_connectedNotPowered");
|
||||
icons[ 2] = iconRegister.registerIcon("warpdrive:forcefield/projectorSide_connectedPowered");
|
||||
icons[ 3] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_none");
|
||||
icons[ 4] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_sphere");
|
||||
icons[ 5] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_cylinder_h");
|
||||
icons[ 6] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_cylinder_v");
|
||||
icons[ 7] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_cube");
|
||||
icons[ 8] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_plane");
|
||||
icons[ 9] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_tube");
|
||||
icons[10] = iconRegister.registerIcon("warpdrive:forcefield/projectorShape_tunnel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (tileEntity == null || !(tileEntity instanceof TileEntityProjector)) {
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
if (side == (metadata & 7) || (((TileEntityProjector)tileEntity).isDoubleSided && ForgeDirection.OPPOSITES[side] == (metadata & 7))) {
|
||||
return icons[3 + ((TileEntityProjector)tileEntity).getShape().ordinal()];
|
||||
} else if (((TileEntityProjector)tileEntity).isConnected) {
|
||||
if (((TileEntityProjector)tileEntity).isPowered) {
|
||||
return icons[2];
|
||||
} else {
|
||||
return icons[1];
|
||||
}
|
||||
}
|
||||
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return side == 3 ? icons[4] : icons[2];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (!(tileEntity instanceof TileEntityProjector)) {
|
||||
return false;
|
||||
}
|
||||
TileEntityProjector tileEntityProjector = (TileEntityProjector) tileEntity;
|
||||
ItemStack itemStackHeld = entityPlayer.getHeldItem();
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
if (entityPlayer.isSneaking()) {
|
||||
if (tileEntityProjector.getShape() != EnumForceFieldShape.NONE) {
|
||||
if (side == (metadata & 7) || (tileEntityProjector.isDoubleSided && ForgeDirection.OPPOSITES[side] == (metadata & 7))) {
|
||||
// dismount the shape item(s)
|
||||
ItemStack itemStackDrop = ItemForceFieldShape.getItemStackNoCache(tileEntityProjector.getShape(), tileEntityProjector.isDoubleSided ? 2 : 1);
|
||||
EntityItem entityItem = new EntityItem(world, entityPlayer.posX, entityPlayer.posY + 0.5D, entityPlayer.posZ, itemStackDrop);
|
||||
entityItem.delayBeforeCanPickup = 0;
|
||||
world.spawnEntityInWorld(entityItem);
|
||||
|
||||
tileEntityProjector.setShape(EnumForceFieldShape.NONE);
|
||||
} else {
|
||||
// wrong side TODO
|
||||
WarpDrive.addChatMessage(entityPlayer, tileEntityProjector.getStatus());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// no shape to dismount TODO
|
||||
WarpDrive.addChatMessage(entityPlayer, tileEntityProjector.getStatus());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
WarpDrive.addChatMessage(entityPlayer, tileEntityProjector.getStatus());
|
||||
return true;
|
||||
}
|
||||
} else if (itemStackHeld.getItem() instanceof ItemForceFieldShape) {
|
||||
if (side == (metadata & 7) || (((TileEntityProjector) tileEntity).isDoubleSided && ForgeDirection.OPPOSITES[side] == (metadata & 7))) {
|
||||
// validate quantity
|
||||
if (itemStackHeld.stackSize < (tileEntityProjector.isDoubleSided ? 2 : 1)) {
|
||||
// not enough shape items TODO
|
||||
WarpDrive.addChatMessage(entityPlayer, ((TileEntityProjector) tileEntity).getStatus());
|
||||
return true;
|
||||
}
|
||||
|
||||
// update player inventory
|
||||
itemStackHeld.stackSize -= tileEntityProjector.isDoubleSided ? 2 : 1;
|
||||
|
||||
// dismount the shape item(s)
|
||||
if (tileEntityProjector.getShape() != EnumForceFieldShape.NONE) {
|
||||
ItemStack itemStackDrop = ItemForceFieldShape.getItemStackNoCache(tileEntityProjector.getShape(), tileEntityProjector.isDoubleSided ? 2 : 1);
|
||||
EntityItem entityItem = new EntityItem(world, entityPlayer.posX, entityPlayer.posY + 0.5D, entityPlayer.posZ, itemStackDrop);
|
||||
entityItem.delayBeforeCanPickup = 0;
|
||||
world.spawnEntityInWorld(entityItem);
|
||||
}
|
||||
|
||||
// mount the new shape item(s)
|
||||
tileEntityProjector.setShape(EnumForceFieldShape.get(itemStackHeld.getItemDamage()));
|
||||
} else {
|
||||
// wrong side TODO
|
||||
WarpDrive.addChatMessage(entityPlayer, ((TileEntityProjector) tileEntity).getStatus());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int metadata) {
|
||||
return new TileEntityProjector();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canSilkHarvest() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer entityPlayer) {
|
||||
return null; // FIXME
|
||||
}
|
||||
}
|
|
@ -12,17 +12,16 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
|
|||
import li.cil.oc.api.machine.Arguments;
|
||||
import li.cil.oc.api.machine.Callback;
|
||||
import li.cil.oc.api.machine.Context;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
/**
|
||||
* Created by LemADEC on 16/05/2016.
|
||||
*/
|
||||
public class TileEntityAbstractForceField extends TileEntityAbstractEnergy implements IBeamFrequency {
|
||||
// persistent properties
|
||||
protected byte tier = -1;
|
||||
protected int beamFrequency = -1;
|
||||
public boolean isEnabled = true;
|
||||
|
||||
|
@ -32,7 +31,7 @@ public class TileEntityAbstractForceField extends TileEntityAbstractEnergy imple
|
|||
|
||||
public TileEntityAbstractForceField() {
|
||||
super();
|
||||
|
||||
|
||||
addMethods(new String[]{
|
||||
"enable",
|
||||
"beamFrequency"
|
||||
|
@ -41,6 +40,12 @@ public class TileEntityAbstractForceField extends TileEntityAbstractEnergy imple
|
|||
|
||||
@Override
|
||||
protected void onFirstUpdateTick() {
|
||||
Block block = getBlockType();
|
||||
if (block instanceof BlockAbstractForceField) {
|
||||
tier = ((BlockAbstractForceField) block).tier;
|
||||
} else {
|
||||
WarpDrive.logger.error("Missing block for " + this + " at " + worldObj + " " + xCoord + " " + yCoord + " " + zCoord);
|
||||
}
|
||||
if (beamFrequency >= 0 && beamFrequency <= IBeamFrequency.BEAM_FREQUENCY_MAX) {
|
||||
ForceFieldRegistry.updateInRegistry(this);
|
||||
}
|
||||
|
@ -63,7 +68,7 @@ public class TileEntityAbstractForceField extends TileEntityAbstractEnergy imple
|
|||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
// reload chunks as needed?
|
||||
// reload chunks as needed
|
||||
// ForceFieldRegistry.removeFromRegistry(this);
|
||||
}
|
||||
|
||||
|
@ -90,7 +95,7 @@ public class TileEntityAbstractForceField extends TileEntityAbstractEnergy imple
|
|||
}
|
||||
}
|
||||
|
||||
protected String getBeamFrequencyStatus() {
|
||||
String getBeamFrequencyStatus() {
|
||||
if (beamFrequency < 0) {
|
||||
return StatCollector.translateToLocalFormatted("warpdrive.beamFrequency.statusLine.invalid",
|
||||
beamFrequency);
|
||||
|
@ -101,14 +106,17 @@ public class TileEntityAbstractForceField extends TileEntityAbstractEnergy imple
|
|||
}
|
||||
|
||||
public String getStatus() {
|
||||
String strEnergyStatus = getEnergyStatus();
|
||||
return StatCollector.translateToLocalFormatted("warpdrive.guide.prefix",
|
||||
getBlockType().getLocalizedName())
|
||||
+ getBeamFrequencyStatus();
|
||||
+ getBeamFrequencyStatus()
|
||||
+ (strEnergyStatus.isEmpty() ? "" : "\n" + strEnergyStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
tier = tag.getByte("tier");
|
||||
setBeamFrequency(tag.getInteger("beamFrequency"));
|
||||
isEnabled = tag.getBoolean("isEnabled");
|
||||
}
|
||||
|
@ -116,6 +124,7 @@ public class TileEntityAbstractForceField extends TileEntityAbstractEnergy imple
|
|||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
tag.setByte("tier", tier);
|
||||
tag.setInteger("beamFrequency", beamFrequency);
|
||||
tag.setBoolean("isEnabled", isEnabled);
|
||||
}
|
||||
|
|
|
@ -3,21 +3,20 @@ package cr0s.warpdrive.block.forcefield;
|
|||
import cr0s.warpdrive.block.TileEntityAbstractBase;
|
||||
import cr0s.warpdrive.data.ForceFieldSetup;
|
||||
import cr0s.warpdrive.data.VectorI;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/**
|
||||
* Created by LemADEC on 16/05/2016.
|
||||
*/
|
||||
public class TileEntityForceField extends TileEntityAbstractBase {
|
||||
private VectorI vProjector;
|
||||
|
||||
// cache parameters used for rendering, force projector check for others
|
||||
private int cache_beamFrequency;
|
||||
private ItemStack cache_itemStackCamouflage;
|
||||
private Block cache_blockCamouflage;
|
||||
private int cache_metadataCamouflage;
|
||||
private int gracePeriod_calls = 1;
|
||||
|
||||
@Override
|
||||
|
@ -33,17 +32,20 @@ public class TileEntityForceField extends TileEntityAbstractBase {
|
|||
cache_beamFrequency = tag.getInteger("beamFrequency");
|
||||
if (tag.hasKey("projector")) {
|
||||
try {
|
||||
cache_itemStackCamouflage = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("camouflage"));
|
||||
cache_blockCamouflage = Block.getBlockFromName(tag.getString("camouflageBlock"));
|
||||
cache_metadataCamouflage = tag.getByte("camouflageMeta");
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
cache_itemStackCamouflage = null;
|
||||
cache_blockCamouflage = null;
|
||||
cache_metadataCamouflage = 0;
|
||||
}
|
||||
} else {
|
||||
vProjector = null;
|
||||
cache_beamFrequency = -1;
|
||||
cache_itemStackCamouflage = null;
|
||||
cache_blockCamouflage = null;
|
||||
cache_metadataCamouflage = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,8 +55,9 @@ public class TileEntityForceField extends TileEntityAbstractBase {
|
|||
if (vProjector != null) {
|
||||
tagCompound.setTag("projector", vProjector.writeToNBT(new NBTTagCompound()));
|
||||
tagCompound.setInteger("beamFrequency", cache_beamFrequency);
|
||||
if (cache_itemStackCamouflage != null) {
|
||||
tagCompound.setTag("camouflage", cache_itemStackCamouflage.writeToNBT(new NBTTagCompound()));
|
||||
if (cache_blockCamouflage != null) {
|
||||
tagCompound.setString("camouflageBlock", Block.blockRegistry.getNameForObject(cache_blockCamouflage));
|
||||
tagCompound.setByte("camouflageMeta", (byte)cache_metadataCamouflage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,18 +82,19 @@ public class TileEntityForceField extends TileEntityAbstractBase {
|
|||
ForceFieldSetup forceFieldSetup = getForceFieldSetup();
|
||||
if (forceFieldSetup != null) {
|
||||
cache_beamFrequency = forceFieldSetup.beamFrequency;
|
||||
cache_itemStackCamouflage = forceFieldSetup.itemStackCamouflage;
|
||||
cache_blockCamouflage = forceFieldSetup.getCamouflageBlock();
|
||||
cache_metadataCamouflage = forceFieldSetup.getCamouflageMetadata();
|
||||
}
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public TileEntityProjector getProjector() {
|
||||
public TileEntityForceFieldProjector getProjector() {
|
||||
if (vProjector != null) {
|
||||
TileEntity tileEntity = vProjector.getTileEntity(worldObj);
|
||||
if (tileEntity instanceof TileEntityProjector) {
|
||||
TileEntityProjector tileEntityProjector = (TileEntityProjector) tileEntity;
|
||||
if (worldObj.isRemote || tileEntityProjector.isPartOfForceField(new VectorI(this))) {
|
||||
return tileEntityProjector;
|
||||
if (tileEntity instanceof TileEntityForceFieldProjector) {
|
||||
TileEntityForceFieldProjector tileEntityForceFieldProjector = (TileEntityForceFieldProjector) tileEntity;
|
||||
if (worldObj.isRemote || tileEntityForceFieldProjector.isPartOfForceField(new VectorI(this))) {
|
||||
return tileEntityForceFieldProjector;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,10 +110,10 @@ public class TileEntityForceField extends TileEntityAbstractBase {
|
|||
}
|
||||
|
||||
public ForceFieldSetup getForceFieldSetup() {
|
||||
TileEntityProjector tileEntityProjector = getProjector();
|
||||
if (tileEntityProjector == null) {
|
||||
TileEntityForceFieldProjector tileEntityForceFieldProjector = getProjector();
|
||||
if (tileEntityForceFieldProjector == null) {
|
||||
return null;
|
||||
}
|
||||
return tileEntityProjector.getForceFieldSetup();
|
||||
return tileEntityForceFieldProjector.getForceFieldSetup();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package cr0s.warpdrive.block.forcefield;
|
||||
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.api.IShapeProvider;
|
||||
import cr0s.warpdrive.api.IForceFieldShape;
|
||||
import cr0s.warpdrive.config.*;
|
||||
import cr0s.warpdrive.config.Dictionary;
|
||||
import cr0s.warpdrive.data.*;
|
||||
|
@ -22,27 +22,30 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* Created by LemADEC on 16/05/2016.
|
||||
*/
|
||||
public class TileEntityProjector extends TileEntityAbstractForceField {
|
||||
public class TileEntityForceFieldProjector extends TileEntityAbstractForceField {
|
||||
private static final int PROJECTOR_MAX_ENERGY_STORED = 100000;
|
||||
private static final int PROJECTOR_COOLDOWN_TICKS = 200;
|
||||
private static final int PROJECTOR_PROJECTION_UPDATE_TICKS = 8;
|
||||
private static final int PROJECTOR_SOUND_UPDATE_TICKS = Integer.MAX_VALUE; // TODO
|
||||
private static final int PROJECTOR_SETUP_TICKS = 20;
|
||||
private static final int PROJECTOR_SOUND_UPDATE_TICKS = 200; // TODO
|
||||
private static final int PROJECTOR_SCAN_MAX_BLOCKS_PER_UPDATE = 200;
|
||||
private static final int PROJECTOR_PLACE_MAX_BLOCKS_PER_UPDATE = 100;
|
||||
|
||||
// persistent properties
|
||||
public boolean isDoubleSided = true;
|
||||
private byte tier = -1;
|
||||
private EnumForceFieldShape shape = EnumForceFieldShape.NONE;
|
||||
public boolean isDoubleSided;
|
||||
private EnumForceFieldShape shape;
|
||||
|
||||
// computed properties
|
||||
private int cooldownTicks;
|
||||
private int setupTicks;
|
||||
private int updateTicks;
|
||||
protected boolean isPowered = true;
|
||||
private final boolean enableSound = false;
|
||||
private boolean isMuted = false;
|
||||
private ForceFieldSetup forceFieldSetup_cache;
|
||||
|
||||
// carry over speed to next tick, useful for slow interactions
|
||||
private float carryScanSpeed;
|
||||
private float carryPlaceSpeed;
|
||||
|
||||
// allow only one computation at a time
|
||||
private static final AtomicBoolean isGlobalThreadRunning = new AtomicBoolean(false);
|
||||
|
@ -55,10 +58,10 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
private Set<VectorI> calculated_forceField = null;
|
||||
private Iterator<VectorI> iteratorForcefield = null;
|
||||
|
||||
// currently placed forcefields
|
||||
// currently placed forcefield blocks
|
||||
private final Set<VectorI> vForceFields = new HashSet<>();
|
||||
|
||||
public TileEntityProjector() {
|
||||
public TileEntityForceFieldProjector() {
|
||||
super();
|
||||
|
||||
peripheralName = "warpdriveForceFieldProjector";
|
||||
|
@ -70,8 +73,10 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
@Override
|
||||
protected void onFirstUpdateTick() {
|
||||
super.onFirstUpdateTick();
|
||||
tier = ((BlockProjector) getBlockType()).tier;
|
||||
cooldownTicks = worldObj.rand.nextInt(PROJECTOR_PROJECTION_UPDATE_TICKS);
|
||||
cooldownTicks = worldObj.rand.nextInt(PROJECTOR_COOLDOWN_TICKS);
|
||||
setupTicks = worldObj.rand.nextInt(PROJECTOR_SETUP_TICKS);
|
||||
updateTicks = worldObj.rand.nextInt(PROJECTOR_PROJECTION_UPDATE_TICKS);
|
||||
getForceFieldSetup();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,6 +88,13 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
return;
|
||||
}
|
||||
|
||||
// clear setup cache periodically
|
||||
setupTicks--;
|
||||
if (setupTicks <= 0) {
|
||||
setupTicks = PROJECTOR_SETUP_TICKS;
|
||||
forceFieldSetup_cache = null;
|
||||
}
|
||||
|
||||
// Powered ?
|
||||
int energyRequired;
|
||||
energyRequired = getEnergyRequired();
|
||||
|
@ -94,10 +106,10 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
consumeEnergy(energyRequired, false);
|
||||
cooldownTicks = 0;
|
||||
|
||||
updateTicks++;
|
||||
updateTicks--;
|
||||
if (!worldObj.isRemote) {
|
||||
if (updateTicks > PROJECTOR_PROJECTION_UPDATE_TICKS) {
|
||||
updateTicks = 0;
|
||||
if (updateTicks <= 0) {
|
||||
updateTicks = PROJECTOR_PROJECTION_UPDATE_TICKS;
|
||||
if (!isCalculated()) {
|
||||
calculateForceField();
|
||||
} else {
|
||||
|
@ -106,8 +118,9 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
}
|
||||
} else {
|
||||
// TODO add some animation
|
||||
if (updateTicks > PROJECTOR_SOUND_UPDATE_TICKS) {
|
||||
if (enableSound) {
|
||||
if (updateTicks <= 0) {
|
||||
updateTicks = PROJECTOR_SOUND_UPDATE_TICKS;
|
||||
if (isPowered && !isMuted) {
|
||||
worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "projecting", 1.0F, 0.85F + 0.15F * worldObj.rand.nextFloat());
|
||||
}
|
||||
}
|
||||
|
@ -119,12 +132,12 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
cooldownTicks--;
|
||||
} else if (isEnabledAndValid) {
|
||||
cooldownTicks = PROJECTOR_COOLDOWN_TICKS;
|
||||
// TODO: localization
|
||||
String msg = "We're running out of power captain, reduce our consumption or get that scottish engineer to boost our power!";
|
||||
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(xCoord - 10, yCoord - 10, zCoord - 10, xCoord + 10, yCoord + 10, zCoord + 10);
|
||||
List<Entity> list = worldObj.getEntitiesWithinAABBExcludingEntity(null, axisalignedbb);
|
||||
|
||||
System.out.println(this + " messageToPlayersNearby: " + msg);
|
||||
for (Entity entity : list) {
|
||||
if (entity == null || (!(entity instanceof EntityPlayer)) || entity instanceof FakePlayer) {
|
||||
continue;
|
||||
|
@ -181,7 +194,7 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
isGlobalThreadRunning.set(false);
|
||||
}
|
||||
|
||||
public boolean isPartOfForceField(VectorI vector) {
|
||||
boolean isPartOfForceField(VectorI vector) {
|
||||
if (!isEnabled || !isValid()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -205,36 +218,44 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
}
|
||||
|
||||
ForceFieldSetup forceFieldSetup = getForceFieldSetup();
|
||||
int scanCount = 0;
|
||||
int scanSpeed = Math.min(calculated_forceField.size(), PROJECTOR_SCAN_MAX_BLOCKS_PER_UPDATE);
|
||||
int constructionCount = 0;
|
||||
int constructionSpeed = Math.min(forceFieldSetup.getProjectionSpeed(), PROJECTOR_PLACE_MAX_BLOCKS_PER_UPDATE);
|
||||
|
||||
boolean hasDisintegration = forceFieldSetup.disintegrationLevel > 0;
|
||||
// compute maximum number of blocks to scan
|
||||
int countScanned = 0;
|
||||
float floatScanSpeed = Math.min(calculated_forceField.size(), PROJECTOR_SCAN_MAX_BLOCKS_PER_UPDATE);
|
||||
floatScanSpeed = Math.min(forceFieldSetup.maxScanSpeed * PROJECTOR_PROJECTION_UPDATE_TICKS / 20.0F + carryScanSpeed, floatScanSpeed);
|
||||
int countMaxScanned = (int)Math.floor(floatScanSpeed);
|
||||
carryScanSpeed = floatScanSpeed - countMaxScanned;
|
||||
|
||||
Set<TileEntityProjector> projectors = new HashSet<>();
|
||||
// compute maximum number of blocks to place
|
||||
int countPlaced = 0;
|
||||
float floatPlaceSpeed = Math.min(calculated_forceField.size(), PROJECTOR_PLACE_MAX_BLOCKS_PER_UPDATE);
|
||||
floatPlaceSpeed = Math.min(forceFieldSetup.maxPlaceSpeed * PROJECTOR_PROJECTION_UPDATE_TICKS / 20.0F + carryPlaceSpeed, floatPlaceSpeed);
|
||||
int countMaxPlaced = (int)Math.floor(floatPlaceSpeed);
|
||||
carryPlaceSpeed = floatPlaceSpeed - countMaxPlaced;
|
||||
|
||||
Set<TileEntityForceFieldProjector> projectors = new HashSet<>();
|
||||
if (forceFieldSetup.hasFusion) {
|
||||
for (TileEntity tileEntity : ForceFieldRegistry.getTileEntities(getBeamFrequency())) {
|
||||
if ( (tileEntity instanceof TileEntityProjector)
|
||||
if ( (tileEntity instanceof TileEntityForceFieldProjector)
|
||||
&& (tileEntity != this)
|
||||
&& (((TileEntityProjector) tileEntity).worldObj == worldObj)
|
||||
&& (((TileEntityProjector) tileEntity).isEnabled)
|
||||
&& (((TileEntityProjector) tileEntity).isValid())
|
||||
&& (((TileEntityProjector) tileEntity).isCalculated())) {
|
||||
projectors.add((TileEntityProjector) tileEntity);
|
||||
&& (((TileEntityForceFieldProjector) tileEntity).worldObj == worldObj)
|
||||
&& (((TileEntityForceFieldProjector) tileEntity).isEnabled)
|
||||
&& (((TileEntityForceFieldProjector) tileEntity).isValid())
|
||||
&& (((TileEntityForceFieldProjector) tileEntity).isCalculated())) {
|
||||
projectors.add((TileEntityForceFieldProjector) tileEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VectorI vector;
|
||||
Block block;
|
||||
boolean noFusion;
|
||||
boolean doProjectThisBlock;
|
||||
|
||||
while (scanCount < scanSpeed && constructionCount < constructionSpeed) {
|
||||
while (countScanned < countMaxScanned && countPlaced < countMaxPlaced) {
|
||||
if (iteratorForcefield == null || !iteratorForcefield.hasNext()) {
|
||||
iteratorForcefield = calculated_forceField.iterator();
|
||||
}
|
||||
scanCount++;
|
||||
countScanned++;
|
||||
|
||||
vector = iteratorForcefield.next();
|
||||
|
||||
|
@ -243,68 +264,99 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
}
|
||||
|
||||
block = vector.getBlock(worldObj);
|
||||
noFusion = true;
|
||||
doProjectThisBlock = true;
|
||||
|
||||
// skip if fusion upgrade is present and it's inside another projector area
|
||||
if (forceFieldSetup.hasFusion) {
|
||||
for (TileEntityProjector projector : projectors) {
|
||||
for (TileEntityForceFieldProjector projector : projectors) {
|
||||
if (projector.getInteriorPoints().contains(vector)) {
|
||||
noFusion = false;
|
||||
doProjectThisBlock = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (noFusion) {
|
||||
// TODO: check area protection
|
||||
// skip if block properties prevents it
|
||||
if (doProjectThisBlock) {
|
||||
// MFR laser is unbreakable and replaceable
|
||||
// Liquid, vine and snow are replaceable
|
||||
if ( (block == null) || (block == Blocks.tallgrass) || (block == Blocks.deadbush)
|
||||
|| Dictionary.BLOCKS_EXPANDABLE.contains(block)
|
||||
|| (hasDisintegration && (block.getBlockHardness(worldObj, vector.x, vector.y, vector.z) != -1.0F))
|
||||
|| (!hasDisintegration && block.isReplaceable(worldObj, vector.x, vector.y, vector.z))) {
|
||||
|
||||
if ((block != WarpDrive.blockForceField) && (!vector.equals(this))) {
|
||||
float energyConsumed = 0;
|
||||
// if (forceFieldSetup.disintegrationLevel > 0) {
|
||||
// TODO break the block
|
||||
// TODO store result in chest or drop it?
|
||||
// } else if (forceFieldSetup.hasStabilize) {
|
||||
// TODO collect from chest
|
||||
// TODO place block (ItemBlock.place?)
|
||||
// } else if (forceFieldSetup.hasPump) {
|
||||
|
||||
// } else if (forceFieldSetup.temperatureLevel != 0 && forceFieldSetup.hasWorldInteraction) {
|
||||
// TODO glass <> sandstone <> sand <> gravel <> cobblestone <> stone <> obsidian
|
||||
// TODO ice <> snow <> water <> air > fire
|
||||
// TODO obsidian < lava
|
||||
// } else {
|
||||
energyConsumed = 1; // TODO
|
||||
worldObj.setBlock(vector.x, vector.y, vector.z, WarpDrive.blockForceField, 0, 2);
|
||||
|
||||
TileEntity tileEntity = worldObj.getTileEntity(vector.x, vector.y, vector.z);
|
||||
if (tileEntity instanceof TileEntityForceField) {
|
||||
((TileEntityForceField) tileEntity).setProjector(new VectorI(this));
|
||||
}
|
||||
|
||||
vForceFields.add(vector);
|
||||
// }
|
||||
if (energyConsumed > 0) {
|
||||
constructionCount++;
|
||||
consumeEnergy(Math.round(energyConsumed), false);
|
||||
} else {
|
||||
consumeEnergy(Math.round(1), false); // TODO
|
||||
}
|
||||
if ((block == null) || (block == Blocks.tallgrass) || (block == Blocks.deadbush) || Dictionary.BLOCKS_EXPANDABLE.contains(block)) {
|
||||
// all good, continue
|
||||
} else if (forceFieldSetup.disintegrationLevel > 0) {
|
||||
float blockHardness = block.getBlockHardness(worldObj, vector.x, vector.y, vector.z);
|
||||
// stops on unbreakable or too hard
|
||||
if (blockHardness == -1.0F || blockHardness > forceFieldSetup.disintegrationLevel) {
|
||||
doProjectThisBlock = false;
|
||||
}
|
||||
} else if (block == WarpDrive.blockForceField && !vForceFields.contains(vector)) {
|
||||
TileEntity tileEntity = worldObj.getTileEntity(vector.x, vector.y, vector.z);
|
||||
if (tileEntity instanceof TileEntityForceField && (((TileEntityForceField) tileEntity).getProjector() == this)) {
|
||||
} else {// doesn't have disintegration
|
||||
doProjectThisBlock = block.isReplaceable(worldObj, vector.x, vector.y, vector.z);
|
||||
}
|
||||
}
|
||||
|
||||
// skip if area is protected
|
||||
if (doProjectThisBlock) {
|
||||
// TODO: check area protection
|
||||
}
|
||||
|
||||
if (doProjectThisBlock) {
|
||||
if ((block != WarpDrive.blockForceFields[tier - 1]) && (!vector.equals(this))) {
|
||||
boolean hasConsumedEnergy = false;
|
||||
if (forceFieldSetup.disintegrationLevel > 0) {
|
||||
// TODO break the block
|
||||
// if (forceFieldSetup.attractionLevel > 10.0F) {
|
||||
// TODO store result in chest
|
||||
// } else {
|
||||
// TODO drop
|
||||
// }
|
||||
} else if (forceFieldSetup.hasStabilize) {
|
||||
// TODO collect from chest
|
||||
// TODO place block (ItemBlock.place?)
|
||||
} else if (forceFieldSetup.hasPump) {
|
||||
// TODO fluid support
|
||||
} else if (forceFieldSetup.temperatureLevel != 0.0F && forceFieldSetup.isInverted) {
|
||||
// TODO glass <> sandstone <> sand <> gravel <> cobblestone <> stone <> obsidian
|
||||
// TODO ice <> snow <> water <> air > fire
|
||||
// TODO obsidian < lava
|
||||
} else {
|
||||
hasConsumedEnergy = true;
|
||||
worldObj.setBlock(vector.x, vector.y, vector.z, WarpDrive.blockForceFields[tier - 1], 0, 2);
|
||||
|
||||
TileEntity tileEntity = worldObj.getTileEntity(vector.x, vector.y, vector.z);
|
||||
if (tileEntity instanceof TileEntityForceField) {
|
||||
((TileEntityForceField) tileEntity).setProjector(new VectorI(this));
|
||||
}
|
||||
|
||||
vForceFields.add(vector);
|
||||
}
|
||||
if (hasConsumedEnergy) {
|
||||
countPlaced++;
|
||||
consumeEnergy(Math.round(forceFieldSetup.placeEnergyCost), false);
|
||||
} else {
|
||||
consumeEnergy(Math.round(forceFieldSetup.scanEnergyCost), false);
|
||||
}
|
||||
|
||||
} else {
|
||||
// scanning a valid position
|
||||
consumeEnergy(Math.round(forceFieldSetup.scanEnergyCost), false);
|
||||
|
||||
// recover forcefield blocks from recalculation or chunk loading
|
||||
if (block == WarpDrive.blockForceFields[tier - 1] && !vForceFields.contains(vector)) {
|
||||
TileEntity tileEntity = worldObj.getTileEntity(vector.x, vector.y, vector.z);
|
||||
if (tileEntity instanceof TileEntityForceField && (((TileEntityForceField) tileEntity).getProjector() == this)) {
|
||||
vForceFields.add(vector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (block == WarpDrive.blockForceField) {
|
||||
// scanning an invalid position
|
||||
consumeEnergy(Math.round(forceFieldSetup.scanEnergyCost), false);
|
||||
|
||||
// remove our own force field block
|
||||
if (block == WarpDrive.blockForceFields[tier - 1]) {
|
||||
if (((BlockForceField) block).getProjector(worldObj, vector.x, vector.y, vector.z) == this) {
|
||||
worldObj.setBlockToAir(vector.x, vector.y, vector.z);
|
||||
vForceFields.remove(vector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -325,7 +377,7 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
}
|
||||
Block block = vector.getBlock(worldObj);
|
||||
|
||||
if (block == WarpDrive.blockForceField) {
|
||||
if (block == WarpDrive.blockForceFields[tier - 1]) {
|
||||
worldObj.setBlockToAir(vector.x, vector.y, vector.z);
|
||||
}
|
||||
iterator.remove();
|
||||
|
@ -336,7 +388,7 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
for (VectorI vector : calculated_forceField) {
|
||||
Block block = vector.getBlock(worldObj);
|
||||
|
||||
if (block == WarpDrive.blockForceField) {
|
||||
if (block == WarpDrive.blockForceFields[tier - 1]) {
|
||||
TileEntity tileEntity = worldObj.getTileEntity(vector.x, vector.y, vector.z);
|
||||
if (tileEntity instanceof TileEntityForceField && (((TileEntityForceField) tileEntity).getProjector() == this)) {
|
||||
worldObj.setBlockToAir(vector.x, vector.y, vector.z);
|
||||
|
@ -346,8 +398,8 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
}
|
||||
}
|
||||
|
||||
public IShapeProvider getShapeProvider() {
|
||||
return WarpDrive.itemForceFieldShape;
|
||||
public IForceFieldShape getShapeProvider() {
|
||||
return getShape();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -364,18 +416,30 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
}
|
||||
}
|
||||
|
||||
private String getShapeStatus() {
|
||||
EnumForceFieldShape enumForceFieldShape = getShape();
|
||||
String strDisplayName = StatCollector.translateToLocalFormatted("warpdrive.forcefield.shape.statusLine." + enumForceFieldShape.unlocalizedName);
|
||||
if (enumForceFieldShape == EnumForceFieldShape.NONE) {
|
||||
return StatCollector.translateToLocalFormatted("warpdrive.forcefield.shape.statusLine.none",
|
||||
strDisplayName);
|
||||
} else if (isDoubleSided) {
|
||||
return StatCollector.translateToLocalFormatted("warpdrive.forcefield.shape.statusLine.double",
|
||||
strDisplayName);
|
||||
} else {
|
||||
return StatCollector.translateToLocalFormatted("warpdrive.forcefield.shape.statusLine.single",
|
||||
strDisplayName);
|
||||
}
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return StatCollector.translateToLocalFormatted("warpdrive.guide.prefix",
|
||||
getBlockType().getLocalizedName())
|
||||
+ getBeamFrequencyStatus();
|
||||
// TODO add energy info
|
||||
return super.getStatus()
|
||||
+ "\n" + getShapeStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
isDoubleSided = tag.getBoolean("isDoubleSided");
|
||||
tier = tag.getByte("tier");
|
||||
setShape(EnumForceFieldShape.get(tag.getByte("shape")));
|
||||
}
|
||||
|
||||
|
@ -383,7 +447,6 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
tag.setBoolean("isDoubleSided", isDoubleSided);
|
||||
tag.setByte("tier", tier);
|
||||
tag.setByte("shape", (byte) getShape().ordinal());
|
||||
}
|
||||
|
||||
|
@ -403,7 +466,11 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
}
|
||||
|
||||
public ForceFieldSetup getForceFieldSetup() {
|
||||
return new ForceFieldSetup(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, tier, beamFrequency);
|
||||
if (forceFieldSetup_cache == null) {
|
||||
forceFieldSetup_cache = new ForceFieldSetup(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, tier, beamFrequency);
|
||||
setupTicks = Math.max(setupTicks, 10);
|
||||
}
|
||||
return forceFieldSetup_cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -417,10 +484,13 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
}
|
||||
|
||||
public EnumForceFieldShape getShape() {
|
||||
if (shape == null) {
|
||||
return EnumForceFieldShape.NONE;
|
||||
}
|
||||
return shape;
|
||||
}
|
||||
|
||||
public void setShape(EnumForceFieldShape shape) {
|
||||
void setShape(EnumForceFieldShape shape) {
|
||||
this.shape = shape;
|
||||
isDirty.set(true);
|
||||
if (worldObj != null) {
|
||||
|
@ -430,9 +500,9 @@ public class TileEntityProjector extends TileEntityAbstractForceField {
|
|||
}
|
||||
|
||||
private class ThreadCalculation extends Thread {
|
||||
private final TileEntityProjector projector;
|
||||
private final TileEntityForceFieldProjector projector;
|
||||
|
||||
public ThreadCalculation(TileEntityProjector projector) {
|
||||
ThreadCalculation(TileEntityForceFieldProjector projector) {
|
||||
this.projector = projector;
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
package cr0s.warpdrive.block.forcefield;
|
||||
|
||||
import cr0s.warpdrive.api.IForceFieldUpgrade;
|
||||
import cr0s.warpdrive.api.IForceFieldUpgradeEffector;
|
||||
import cr0s.warpdrive.data.EnumForceFieldUpgrade;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class TileEntityForceFieldRelay extends TileEntityAbstractForceField implements IForceFieldUpgrade {
|
||||
|
||||
// persistent properties
|
||||
private EnumForceFieldUpgrade upgrade = EnumForceFieldUpgrade.NONE;
|
||||
|
||||
public TileEntityForceFieldRelay() {
|
||||
super();
|
||||
|
||||
peripheralName = "warpdriveForceFieldRelay";
|
||||
}
|
||||
|
||||
// onFirstUpdateTick
|
||||
// updateEntity
|
||||
|
||||
protected EnumForceFieldUpgrade getUpgrade() {
|
||||
if (upgrade == null) {
|
||||
return EnumForceFieldUpgrade.NONE;
|
||||
}
|
||||
return upgrade;
|
||||
}
|
||||
|
||||
protected void setUpgrade(EnumForceFieldUpgrade upgrade) {
|
||||
this.upgrade = upgrade;
|
||||
if (worldObj != null) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
private String getUpgradeStatus() {
|
||||
EnumForceFieldUpgrade enumForceFieldUpgrade = getUpgrade();
|
||||
String strDisplayName = StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.statusLine." + enumForceFieldUpgrade.unlocalizedName);
|
||||
if (enumForceFieldUpgrade == EnumForceFieldUpgrade.NONE) {
|
||||
return StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.statusLine.none",
|
||||
strDisplayName);
|
||||
} else {
|
||||
return StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.statusLine.valid",
|
||||
strDisplayName);
|
||||
}
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return super.getStatus()
|
||||
+ "\n" + getUpgradeStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
setUpgrade(EnumForceFieldUpgrade.get(tag.getByte("upgrade")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
tag.setByte("upgrade", (byte) getUpgrade().ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
writeToNBT(tagCompound);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) {
|
||||
NBTTagCompound tagCompound = packet.func_148857_g();
|
||||
readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IForceFieldUpgradeEffector getUpgradeEffector() {
|
||||
return isEnabled ? getUpgrade() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUpgradeValue() {
|
||||
return isEnabled ? getUpgrade().getUpgradeValue() * tier / 2 : 0;
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package cr0s.warpdrive.block.forcefield;
|
||||
|
||||
import cr0s.warpdrive.api.IForceFieldUpgrade;
|
||||
import cr0s.warpdrive.data.EnumForceFieldUpgrade;
|
||||
|
||||
/**
|
||||
* Created by LemADEC on 16/05/2016.
|
||||
*/
|
||||
public class TileEntityForceFieldUpgrade extends TileEntityAbstractForceField implements IForceFieldUpgrade {
|
||||
public TileEntityForceFieldUpgrade() {
|
||||
super();
|
||||
|
||||
peripheralName = "warpdriveForceFieldUpgrade";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUpgradeKey() {
|
||||
return isEnabled ? EnumForceFieldUpgrade.get(getBlockMetadata()).unlocalizedName : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUpgradeValue() {
|
||||
return 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxScanSpeed(final String upgradeKey, final int upgradeCount) {
|
||||
return 10.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxPlaceSpeed(final String upgradeKey, final int upgradeCount) {
|
||||
return 10.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStartupEnergyCost(final String upgradeKey, final int upgradeCount) {
|
||||
return 100.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getScanEnergyCost(final String upgradeKey, final int upgradeCount) {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPlaceEnergyCost(final String upgradeKey, final int upgradeCount) {
|
||||
return 10.0F;
|
||||
}
|
||||
}
|
|
@ -6,10 +6,10 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
|||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.block.hull.BlockHullPlain;
|
||||
import cr0s.warpdrive.block.passive.BlockDecorative;
|
||||
import cr0s.warpdrive.data.ComponentType;
|
||||
import cr0s.warpdrive.data.DecorativeType;
|
||||
import cr0s.warpdrive.data.UpgradeType;
|
||||
import cr0s.warpdrive.data.*;
|
||||
import cr0s.warpdrive.item.ItemComponent;
|
||||
import cr0s.warpdrive.item.ItemForceFieldShape;
|
||||
import cr0s.warpdrive.item.ItemForceFieldUpgrade;
|
||||
import cr0s.warpdrive.item.ItemUpgrade;
|
||||
import net.minecraft.block.BlockColored;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
@ -21,9 +21,6 @@ import net.minecraftforge.oredict.ShapelessOreRecipe;
|
|||
|
||||
/**
|
||||
* Hold the different recipe sets
|
||||
*
|
||||
* @author LemADEC
|
||||
*
|
||||
*/
|
||||
public class Recipes {
|
||||
private static final String[] oreDyes = {
|
||||
|
@ -565,62 +562,67 @@ public class Recipes {
|
|||
}
|
||||
|
||||
// Get the machine casing to use
|
||||
ItemStack itemMachineCasingLV;
|
||||
ItemStack itemMachineCasingMV;
|
||||
ItemStack itemMachineCasingHV;
|
||||
ItemStack itemMachineCasingEV;
|
||||
ItemStack itemMotorLV = ItemComponent.getItemStack(ComponentType.MOTOR);
|
||||
ItemStack itemMotorMV = ItemComponent.getItemStack(ComponentType.MOTOR);
|
||||
ItemStack itemMotorHV = ItemComponent.getItemStack(ComponentType.MOTOR);
|
||||
@SuppressWarnings("unused")
|
||||
ItemStack itemMotorEV = ItemComponent.getItemStack(ComponentType.MOTOR);
|
||||
ItemStack itemStackMachineCasingLV;
|
||||
ItemStack itemStackMachineCasingMV;
|
||||
ItemStack itemStackMachineCasingHV;
|
||||
ItemStack itemStackMachineCasingEV;
|
||||
ItemStack itemStackMotorLV = ItemComponent.getItemStack(ComponentType.MOTOR);
|
||||
ItemStack itemStackMotorMV = ItemComponent.getItemStack(ComponentType.MOTOR);
|
||||
ItemStack itemStackMotorHV = ItemComponent.getItemStack(ComponentType.MOTOR);
|
||||
ItemStack itemStackMotorEV = ItemComponent.getItemStack(ComponentType.MOTOR);
|
||||
|
||||
if (WarpDriveConfig.isGregTech5Loaded) {
|
||||
itemMachineCasingLV = WarpDriveConfig.getModItemStack("gregtech", "gt.blockcasings", 1);
|
||||
itemMachineCasingMV = WarpDriveConfig.getModItemStack("gregtech", "gt.blockcasings", 2);
|
||||
itemMachineCasingHV = WarpDriveConfig.getModItemStack("gregtech", "gt.blockcasings", 3);
|
||||
itemMachineCasingEV = WarpDriveConfig.getModItemStack("gregtech", "gt.blockcasings", 4);
|
||||
itemStackMachineCasingLV = WarpDriveConfig.getModItemStack("gregtech", "gt.blockcasings", 1);
|
||||
itemStackMachineCasingMV = WarpDriveConfig.getModItemStack("gregtech", "gt.blockcasings", 2);
|
||||
itemStackMachineCasingHV = WarpDriveConfig.getModItemStack("gregtech", "gt.blockcasings", 3);
|
||||
itemStackMachineCasingEV = WarpDriveConfig.getModItemStack("gregtech", "gt.blockcasings", 4);
|
||||
|
||||
itemMotorLV = WarpDriveConfig.getModItemStack("gregtech", "gt.metaitem.01", 32600); // LV Motor
|
||||
itemMotorMV = WarpDriveConfig.getModItemStack("gregtech", "gt.metaitem.01", 32601); // MV Motor
|
||||
itemMotorHV = WarpDriveConfig.getModItemStack("gregtech", "gt.metaitem.01", 32602); // HV Motor
|
||||
itemMotorEV = WarpDriveConfig.getModItemStack("gregtech", "gt.metaitem.01", 32603); // EV Motor
|
||||
itemStackMotorLV = WarpDriveConfig.getModItemStack("gregtech", "gt.metaitem.01", 32600); // LV Motor
|
||||
itemStackMotorMV = WarpDriveConfig.getModItemStack("gregtech", "gt.metaitem.01", 32601); // MV Motor
|
||||
itemStackMotorHV = WarpDriveConfig.getModItemStack("gregtech", "gt.metaitem.01", 32602); // HV Motor
|
||||
itemStackMotorEV = WarpDriveConfig.getModItemStack("gregtech", "gt.metaitem.01", 32603); // EV Motor
|
||||
|
||||
} else if (WarpDriveConfig.isIndustrialCraft2Loaded) {
|
||||
itemMachineCasingLV = WarpDriveConfig.getModItemStack("IC2", "blockMachine", 0); // Basic machine casing
|
||||
itemMachineCasingMV = WarpDriveConfig.getModItemStack("IC2", "blockMachine", 12); // Advanced machine casing
|
||||
itemMachineCasingHV = new ItemStack(WarpDrive.blockHighlyAdvancedMachine);
|
||||
itemMachineCasingEV = new ItemStack(WarpDrive.blockHighlyAdvancedMachine);
|
||||
itemStackMachineCasingLV = WarpDriveConfig.getModItemStack("IC2", "blockMachine", 0); // Basic machine casing
|
||||
itemStackMachineCasingMV = WarpDriveConfig.getModItemStack("IC2", "blockMachine", 12); // Advanced machine casing
|
||||
itemStackMachineCasingHV = new ItemStack(WarpDrive.blockHighlyAdvancedMachine);
|
||||
itemStackMachineCasingEV = new ItemStack(WarpDrive.blockHighlyAdvancedMachine);
|
||||
|
||||
itemMotorHV = WarpDriveConfig.getModItemStack("IC2", "itemRecipePart", 1); // Electric motor
|
||||
itemMotorEV = WarpDriveConfig.getModItemStack("IC2", "itemRecipePart", 1);
|
||||
itemStackMotorHV = WarpDriveConfig.getModItemStack("IC2", "itemRecipePart", 1); // Electric motor
|
||||
itemStackMotorEV = WarpDriveConfig.getModItemStack("IC2", "itemRecipePart", 1);
|
||||
|
||||
ItemStack iridiumAlloy = WarpDriveConfig.getModItemStack("IC2", "itemPartIridium", -1);
|
||||
GameRegistry.addRecipe(new ItemStack(WarpDrive.blockHighlyAdvancedMachine), "iii", "imi", "iii",
|
||||
'i', iridiumAlloy,
|
||||
'm', itemMachineCasingMV);
|
||||
'i', iridiumAlloy,
|
||||
'm', itemStackMachineCasingMV);
|
||||
|
||||
} else if (WarpDriveConfig.isThermalExpansionLoaded) {
|
||||
itemMachineCasingLV = WarpDriveConfig.getModItemStack("ThermalExpansion", "Frame", 0);
|
||||
itemMachineCasingMV = WarpDriveConfig.getModItemStack("ThermalExpansion", "Frame", 1);
|
||||
itemMachineCasingHV = WarpDriveConfig.getModItemStack("ThermalExpansion", "Frame", 2);
|
||||
itemMachineCasingEV = WarpDriveConfig.getModItemStack("ThermalExpansion", "Frame", 3);
|
||||
itemStackMachineCasingLV = WarpDriveConfig.getModItemStack("ThermalExpansion", "Frame", 0);
|
||||
itemStackMachineCasingMV = WarpDriveConfig.getModItemStack("ThermalExpansion", "Frame", 1);
|
||||
itemStackMachineCasingHV = WarpDriveConfig.getModItemStack("ThermalExpansion", "Frame", 2);
|
||||
itemStackMachineCasingEV = WarpDriveConfig.getModItemStack("ThermalExpansion", "Frame", 3);
|
||||
|
||||
} else if (WarpDriveConfig.isEnderIOloaded) {
|
||||
itemMachineCasingLV = WarpDriveConfig.getModItemStack("EnderIO", "itemMachinePart", 0); // Machine chassis
|
||||
itemMachineCasingMV = WarpDriveConfig.getModItemStack("EnderIO", "blockVacuumChest", 0); // Pulsating crystal => Vacuum chest
|
||||
itemMachineCasingHV = WarpDriveConfig.getModItemStack("EnderIO", "blockIngotStorage", 2); // Vibrant alloy block
|
||||
itemMachineCasingEV = WarpDriveConfig.getModItemStack("EnderIO", "itemMaterial", 8); // Ender crystal
|
||||
itemStackMachineCasingLV = WarpDriveConfig.getModItemStack("EnderIO", "itemMachinePart", 0); // Machine chassis
|
||||
itemStackMachineCasingMV = WarpDriveConfig.getModItemStack("EnderIO", "blockVacuumChest", 0); // Pulsating crystal => Vacuum chest
|
||||
itemStackMachineCasingHV = WarpDriveConfig.getModItemStack("EnderIO", "blockIngotStorage", 2); // Vibrant alloy block
|
||||
itemStackMachineCasingEV = WarpDriveConfig.getModItemStack("EnderIO", "itemMaterial", 8); // Ender crystal
|
||||
|
||||
} else {// vanilla
|
||||
itemMachineCasingLV = new ItemStack(Blocks.iron_block);
|
||||
itemMachineCasingMV = new ItemStack(Blocks.diamond_block);
|
||||
itemMachineCasingHV = new ItemStack(WarpDrive.blockHighlyAdvancedMachine);
|
||||
itemMachineCasingEV = new ItemStack(Blocks.beacon);
|
||||
itemStackMachineCasingLV = new ItemStack(Blocks.iron_block);
|
||||
itemStackMachineCasingMV = new ItemStack(Blocks.diamond_block);
|
||||
itemStackMachineCasingHV = new ItemStack(WarpDrive.blockHighlyAdvancedMachine);
|
||||
itemStackMachineCasingEV = new ItemStack(Blocks.beacon);
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(WarpDrive.blockHighlyAdvancedMachine, 4), "pep", "ede", "pep",
|
||||
'e', Items.emerald,
|
||||
'p', Items.ender_eye,
|
||||
'd', Blocks.diamond_block);
|
||||
'e', Items.emerald,
|
||||
'p', Items.ender_eye,
|
||||
'd', Blocks.diamond_block);
|
||||
}
|
||||
|
||||
ItemStack[] itemStackMachineCasings = { itemStackMachineCasingLV, itemStackMachineCasingMV, itemStackMachineCasingHV, itemStackMachineCasingEV };
|
||||
ItemStack[] itemStackMotors = { itemStackMotorLV, itemStackMotorMV, itemStackMotorHV, itemStackMotorEV };
|
||||
|
||||
// Base tuning crystals
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemComponent.getItemStack(ComponentType.EMERALD_CRYSTAL), false, " e ", "BBB", "qrq",
|
||||
'e', Items.emerald,
|
||||
|
@ -649,7 +651,7 @@ public class Recipes {
|
|||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemComponent.getItemStack(ComponentType.REACTOR_CORE), false, "shs", "hmh", "shs",
|
||||
's', Items.nether_star,
|
||||
'h', "blockHull3_plain",
|
||||
'm', itemMachineCasingHV));
|
||||
'm', itemStackMachineCasings[2]));
|
||||
|
||||
|
||||
// Computer interface is 2 gold ingot, 2 wired modems (or redstone), 1 lead/tin ingot
|
||||
|
@ -774,7 +776,7 @@ public class Recipes {
|
|||
'r', Items.redstone,
|
||||
'i', Items.iron_ingot,
|
||||
'l', ItemComponent.getItemStack(ComponentType.LENS),
|
||||
't', itemMotorLV,
|
||||
't', itemStackMotors[0],
|
||||
'd', "dye"));
|
||||
|
||||
// Glass tank is 4 slime balls, 4 glass
|
||||
|
@ -845,23 +847,136 @@ public class Recipes {
|
|||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemComponent.getItemStack(ComponentType.LASER_MEDIUM_EMPTY), false, " ", "ggg", "pmc",
|
||||
'g', ItemComponent.getItemStack(ComponentType.GLASS_TANK),
|
||||
'p', ItemComponent.getItemStack(ComponentType.POWER_INTERFACE),
|
||||
'm', itemMachineCasingMV,
|
||||
'm', itemStackMachineCasings[1],
|
||||
'c', ItemComponent.getItemStack(ComponentType.COMPUTER_INTERFACE)));
|
||||
|
||||
// Coil crystal is 6 iron bars, 2 gold ingots, 1 diamond crystal
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL), false, "bbg", "bdb", "gbb",
|
||||
'b', ironBars,
|
||||
'g', "ingotGold",
|
||||
'd', ItemComponent.getItemStack(ComponentType.DIAMOND_CRYSTAL)));
|
||||
|
||||
// EMC Projector is 5 coil crystals, 1 power interface, 1 computer interface, 2 motors
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemComponent.getItemStack(ComponentType.EMC_PROJECTOR), false, "CCm", "Cpc", "CCm",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'p', ItemComponent.getItemStack(ComponentType.POWER_INTERFACE),
|
||||
'm', ItemComponent.getItemStack(ComponentType.MOTOR),
|
||||
'c', ItemComponent.getItemStack(ComponentType.COMPUTER_INTERFACE)));
|
||||
|
||||
// *** Force field shapes
|
||||
// Force field shapes are 1 Memory crystal, 3 to 5 Coil crystal
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldShape.getItemStack(EnumForceFieldShape.SPHERE), false, " ", "CmC", "CCC",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'm', ItemComponent.getItemStack(ComponentType.MEMORY_CRYSTAL)));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldShape.getItemStack(EnumForceFieldShape.CYLINDER_H), false, "C C", " m ", "C C",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'm', ItemComponent.getItemStack(ComponentType.MEMORY_CRYSTAL)));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldShape.getItemStack(EnumForceFieldShape.CYLINDER_V), false, " C ", "CmC", " C ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'm', ItemComponent.getItemStack(ComponentType.MEMORY_CRYSTAL)));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldShape.getItemStack(EnumForceFieldShape.CUBE), false, "CCC", "CmC", " ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'm', ItemComponent.getItemStack(ComponentType.MEMORY_CRYSTAL)));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldShape.getItemStack(EnumForceFieldShape.PLANE), false, "CCC", " m ", " ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'm', ItemComponent.getItemStack(ComponentType.MEMORY_CRYSTAL)));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldShape.getItemStack(EnumForceFieldShape.TUBE), false, " ", "CmC", "C C",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'm', ItemComponent.getItemStack(ComponentType.MEMORY_CRYSTAL)));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldShape.getItemStack(EnumForceFieldShape.TUNNEL), false, "C C", "CmC", " ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'm', ItemComponent.getItemStack(ComponentType.MEMORY_CRYSTAL)));
|
||||
|
||||
// *** Force field upgrades
|
||||
// Force field break upgrade is 3 Coil crystal, 1 Diamond axe, 1 diamond shovel, 1 diamond pick
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldUpgrade.getItemStack(EnumForceFieldUpgrade.BREAK), false, "CCC", "sap", " ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
's', Items.diamond_axe,
|
||||
'a', Items.diamond_shovel,
|
||||
'p', Items.diamond_pickaxe));
|
||||
// Force field camouflage upgrade is 3 Coil crystal, 2 Diffraction grating, 1 Zoom, 1 Emerald crystal
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldUpgrade.getItemStack(EnumForceFieldUpgrade.CAMOUFLAGE), false, "CCC", "zre", " ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'z', ItemComponent.getItemStack(ComponentType.ZOOM),
|
||||
'r', Blocks.daylight_detector,
|
||||
'e', ItemComponent.getItemStack(ComponentType.EMERALD_CRYSTAL)));
|
||||
// Force field cool upgrade is 3 Coil crystal, 2 Ice, 1 MV Motor
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldUpgrade.getItemStack(EnumForceFieldUpgrade.COOL), false, "CCC", "imi", " ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'i', Blocks.ice,
|
||||
'm', itemStackMotors[1]));
|
||||
// Force field fusion upgrade is 3 Coil crystal, 2 Computer interface, 1 Emerald crystal
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldUpgrade.getItemStack(EnumForceFieldUpgrade.FUSION), false, "CCC", "cec", " ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'c', ItemComponent.getItemStack(ComponentType.COMPUTER_INTERFACE),
|
||||
'e', ItemComponent.getItemStack(ComponentType.EMERALD_CRYSTAL)));
|
||||
// Force field invert upgrade is 3 Coil crystal, 1 Gold nugget, 2 Redstone
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldUpgrade.getItemStack(EnumForceFieldUpgrade.INVERT), false, "rgr", "CCC", "CCC",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'r', Items.redstone,
|
||||
'g', Items.gold_nugget));
|
||||
// Force field mute upgrade is 3 Coil crystal, 3 Wool
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldUpgrade.getItemStack(EnumForceFieldUpgrade.MUTE), false, "CCC", "www", " ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'w', Blocks.wool));
|
||||
// Force field pump upgrade is 3 Coil crystal, 1 MV Motor, 2 glass tanks
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldUpgrade.getItemStack(EnumForceFieldUpgrade.PUMP), false, "CCC", "tmt", " ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'm', itemStackMotors[1],
|
||||
't', ItemComponent.getItemStack(ComponentType.GLASS_TANK)));
|
||||
// Force field range upgrade is 3 Coil crystal, 2 Memory crystal, 1 Redstone block
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldUpgrade.getItemStack(EnumForceFieldUpgrade.RANGE), false, "CCC", "RMR", " ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'M', ItemComponent.getItemStack(ComponentType.MEMORY_CRYSTAL),
|
||||
'R', Blocks.redstone_block));
|
||||
// Force field rotation upgrade is 3 Coil crystal, 2 MV Motors, 1 Computer interface
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldUpgrade.getItemStackNoCache(EnumForceFieldUpgrade.ROTATION, 2), false, "CCC", " m ", " mc",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'm', itemStackMotors[1],
|
||||
'c', ItemComponent.getItemStack(ComponentType.COMPUTER_INTERFACE)));
|
||||
// Force field shock upgrade is 3 Coil crystal, 1 Power interface
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldUpgrade.getItemStack(EnumForceFieldUpgrade.SHOCK), false, "CCC", " p ", " ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'p', ItemComponent.getItemStack(ComponentType.POWER_INTERFACE)));
|
||||
// Force field speed upgrade is 3 Coil crystal, 2 Ghast tear, 1 Emerald crystal
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldUpgrade.getItemStack(EnumForceFieldUpgrade.SPEED), false, "CCC", "geg", " ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'g', Items.ghast_tear,
|
||||
'e', ItemComponent.getItemStack(ComponentType.EMERALD_CRYSTAL)));
|
||||
// Force field stabilize upgrade is 3 Coil crystal, 1 Memory crystal, 2 Lapis block
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldUpgrade.getItemStack(EnumForceFieldUpgrade.STABILIZE), "CCC", "lMl", " ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'M', ItemComponent.getItemStack(ComponentType.MEMORY_CRYSTAL),
|
||||
'l', Blocks.lapis_block));
|
||||
// Force field thickness upgrade is 8 Coil crystal, 1 Diamond crystal
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldUpgrade.getItemStack(EnumForceFieldUpgrade.THICKNESS), false, "CCC", "CpC", " ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'p', ItemComponent.getItemStack(ComponentType.EMC_PROJECTOR)));
|
||||
// Force field translation upgrade is 3 Coil crystal, 2 MV Motor, 1 Computer interface
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldUpgrade.getItemStackNoCache(EnumForceFieldUpgrade.TRANSLATION, 2), false, "CCC", "m m", " c ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'm', itemStackMotors[1],
|
||||
'c', ItemComponent.getItemStack(ComponentType.COMPUTER_INTERFACE)));
|
||||
// Force field warm upgrade is 3 Coil crystal, 2 Blaze rod, 1 MV Motor
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemForceFieldUpgrade.getItemStack(EnumForceFieldUpgrade.WARM), false, "CCC", "bmb", " ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'b', Items.blaze_rod,
|
||||
'm', itemStackMotors[1]));
|
||||
|
||||
// *** Blocks
|
||||
// Ship core is 1x Ghast tear, 4x Capacitive crystal, 2x Tuning ender, 1x Power interface, 1x MV Machine casing
|
||||
// Ship core is 1 Ghast tear, 4 Capacitive crystal, 2 Tuning ender, 1 Power interface, 1 MV Machine casing
|
||||
GameRegistry.addRecipe(new ItemStack(WarpDrive.blockShipCore),"csc", "eme", "cpc",
|
||||
's', Items.ghast_tear,
|
||||
'c', ItemComponent.getItemStack(ComponentType.CAPACITIVE_CRYSTAL),
|
||||
'e', ItemComponent.getItemStack(ComponentType.ENDER_CRYSTAL),
|
||||
'p', ItemComponent.getItemStack(ComponentType.POWER_INTERFACE),
|
||||
'm', itemMachineCasingMV);
|
||||
'm', itemStackMachineCasings[1]);
|
||||
|
||||
// Ship controller is 1x Computer interface, 1x Tuning emerald, 1x LV Machine casing, 2x Memory bank
|
||||
// Ship controller is 1 Computer interface, 1 Tuning emerald, 1 LV Machine casing, 2 Memory bank
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockShipController), false, " e ", "bmb", " c ",
|
||||
'c', ItemComponent.getItemStack(ComponentType.COMPUTER_INTERFACE),
|
||||
'e', ItemComponent.getItemStack(ComponentType.EMERALD_CRYSTAL),
|
||||
'm', itemMachineCasingLV,
|
||||
'm', itemStackMachineCasings[0],
|
||||
'b', ItemComponent.getItemStack(ComponentType.MEMORY_CRYSTAL)));
|
||||
|
||||
// Radar is 1 motor, 4 Titanium plate (diamond), 1 quarztite rod (nether quartz), 1 computer interface, 1 HV Machine casing, 1 power interface
|
||||
|
@ -884,17 +999,17 @@ public class Recipes {
|
|||
oreAntenna = "nuggetPulsatingIron";
|
||||
}
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockRadar), false, "PAP", "PtP", "pmc",
|
||||
't', itemMotorHV,
|
||||
't', itemStackMotors[2],
|
||||
'P', oreCloakingPlate,
|
||||
'A', oreAntenna,
|
||||
'c', ItemComponent.getItemStack(ComponentType.COMPUTER_INTERFACE),
|
||||
'm', itemMachineCasingHV,
|
||||
'm', itemStackMachineCasings[2],
|
||||
'p', ItemComponent.getItemStack(ComponentType.POWER_INTERFACE)));
|
||||
|
||||
// Warp isolation is 1 EV Machine casing (Ti), 4 Titanium plate/Enderium ingot/Vibrant alloy/Iridium plate/quartz
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockWarpIsolation), false, "i i", " m ", "i i",
|
||||
'i', oreCloakingPlate,
|
||||
'm', itemMachineCasingEV));
|
||||
'm', itemStackMachineCasings[3]));
|
||||
|
||||
// Air generator is 1 power interface, 4 activated carbon, 1 motor, 1 MV Machine casing, 2 tanks
|
||||
ItemStack itemStackCompressorOrTank = ItemComponent.getItemStack(ComponentType.GLASS_TANK);
|
||||
|
@ -910,18 +1025,18 @@ public class Recipes {
|
|||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockAirGenerator), false, "aca", "ata", "gmp",
|
||||
'p', ItemComponent.getItemStack(ComponentType.POWER_INTERFACE),
|
||||
'a', ItemComponent.getItemStack(ComponentType.ACTIVATED_CARBON),
|
||||
't', itemMotorMV,
|
||||
't', itemStackMotors[1],
|
||||
'g', ItemComponent.getItemStack(ComponentType.GLASS_TANK),
|
||||
'm', itemMachineCasingMV,
|
||||
'm', itemStackMachineCasings[1],
|
||||
'c', itemStackCompressorOrTank));
|
||||
|
||||
// Laser cannon is 2 motors, 1 diffraction grating, 1 lens, 1 computer interface, 1 HV Machine casing, 1 redstone dust, 2 glass pane
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockLaser), false, "gtr", "ldm", "gtc",
|
||||
't', itemMotorHV,
|
||||
't', itemStackMotors[2],
|
||||
'd', ItemComponent.getItemStack(ComponentType.DIFFRACTION_GRATING),
|
||||
'l', ItemComponent.getItemStack(ComponentType.LENS),
|
||||
'c', ItemComponent.getItemStack(ComponentType.COMPUTER_INTERFACE),
|
||||
'm', itemMachineCasingHV,
|
||||
'm', itemStackMachineCasings[2],
|
||||
'r', Items.redstone,
|
||||
'g', "paneGlassColorless"));
|
||||
|
||||
|
@ -933,11 +1048,11 @@ public class Recipes {
|
|||
itemStackDiamondPick = WarpDriveConfig.getModItemStack("IC2", "blockMachine2", 11); // Advanced Miner
|
||||
}
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockMiningLaser), false, "cmr", "tdt", "glg",
|
||||
't', itemMotorMV,
|
||||
't', itemStackMotors[1],
|
||||
'd', ItemComponent.getItemStack(ComponentType.DIFFRACTION_GRATING),
|
||||
'l', ItemComponent.getItemStack(ComponentType.LENS),
|
||||
'c', ItemComponent.getItemStack(ComponentType.COMPUTER_INTERFACE),
|
||||
'm', itemMachineCasingMV,
|
||||
'm', itemStackMachineCasings[1],
|
||||
'r', itemStackDiamondPick,
|
||||
'g', "paneGlassColorless"));
|
||||
|
||||
|
@ -949,7 +1064,7 @@ public class Recipes {
|
|||
'l', Blocks.lapis_block));
|
||||
|
||||
// Laser lift is ...
|
||||
Object oreMagnetizer = itemMachineCasingLV;
|
||||
Object oreMagnetizer = itemStackMachineCasings[0];
|
||||
if (WarpDriveConfig.isGregTech5Loaded) {
|
||||
oreMagnetizer = WarpDriveConfig.getModItemStack("gregtech", "gt.blockmachines", 551); // Basic polarizer
|
||||
} else if (WarpDriveConfig.isIndustrialCraft2Loaded) {
|
||||
|
@ -1030,11 +1145,11 @@ public class Recipes {
|
|||
|
||||
// Camera is 1 daylight sensor, 2 motors, 1 computer interface, 2 glass panel, 1 Tuning diamond, 1 LV Machine casing
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockCamera), false, "gtd", "zlm", "gtc",
|
||||
't', itemMotorLV,
|
||||
't', itemStackMotors[0],
|
||||
'z', ItemComponent.getItemStack(ComponentType.ZOOM),
|
||||
'd', ItemComponent.getItemStack(ComponentType.DIAMOND_CRYSTAL),
|
||||
'c', ItemComponent.getItemStack(ComponentType.COMPUTER_INTERFACE),
|
||||
'm', itemMachineCasingLV,
|
||||
'm', itemStackMachineCasings[0],
|
||||
'l', Blocks.daylight_detector,
|
||||
'g', "paneGlassColorless"));
|
||||
|
||||
|
@ -1043,7 +1158,7 @@ public class Recipes {
|
|||
'f', ItemComponent.getItemStack(ComponentType.FLAT_SCREEN),
|
||||
'd', ItemComponent.getItemStack(ComponentType.DIAMOND_CRYSTAL),
|
||||
'c', ItemComponent.getItemStack(ComponentType.COMPUTER_INTERFACE),
|
||||
'm', itemMachineCasingLV));
|
||||
'm', itemStackMachineCasings[0]));
|
||||
|
||||
// Ship scanner is non-functional => no recipe
|
||||
/*
|
||||
|
@ -1056,10 +1171,10 @@ public class Recipes {
|
|||
|
||||
// Laser tree farm is 2 motors, 2 lenses, 1 computer interface, 1 LV Machine casing, 1 diamond axe, 2 glass pane
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockLaserTreeFarm), false, "glg", "tlt", "amc",
|
||||
't', itemMotorLV,
|
||||
't', itemStackMotors[0],
|
||||
'l', ItemComponent.getItemStack(ComponentType.LENS),
|
||||
'c', ItemComponent.getItemStack(ComponentType.COMPUTER_INTERFACE),
|
||||
'm', itemMachineCasingLV,
|
||||
'm', itemStackMachineCasings[0],
|
||||
'a', Items.diamond_axe,
|
||||
'g', "paneGlassColorless"));
|
||||
|
||||
|
@ -1095,7 +1210,7 @@ public class Recipes {
|
|||
'c', ItemComponent.getItemStack(ComponentType.COMPUTER_INTERFACE),
|
||||
'p', ItemComponent.getItemStack(ComponentType.POWER_INTERFACE),
|
||||
'g', "paneGlassColorless",
|
||||
'm', itemMachineCasingMV));
|
||||
'm', itemStackMachineCasings[1]));
|
||||
}
|
||||
|
||||
// Cloaking core is 3 Cloaking coils, 4 iridium blocks, 1 ship controller, 1 power interface
|
||||
|
@ -1105,7 +1220,7 @@ public class Recipes {
|
|||
's', WarpDrive.blockShipController,
|
||||
'p', ItemComponent.getItemStack(ComponentType.POWER_INTERFACE)));
|
||||
|
||||
// Cloaking coil is 1 Titanium plate, 4 reinforced iridium plate, 1x EV Machine casing (Ti) or 1 Beacon, 4 emerald, 4 diamond
|
||||
// Cloaking coil is 1 Titanium plate, 4 reinforced iridium plate, 1 EV Machine casing (Ti) or 1 Beacon, 4 emerald, 4 diamond
|
||||
ItemStack itemStackGoldIngotOrCoil = new ItemStack(Items.gold_ingot);
|
||||
if (WarpDriveConfig.isGregTech5Loaded) {
|
||||
itemStackGoldIngotOrCoil = WarpDriveConfig.getModItemStack("gregtech", "gt.blockcasings", 14); // Nichrome Coil block
|
||||
|
@ -1146,7 +1261,7 @@ public class Recipes {
|
|||
't', oreEmeraldOrTitaniumPlate,
|
||||
'i', oreEmeraldOrReinforcedIridiumPlate,
|
||||
'c', itemStackGoldIngotOrCoil,
|
||||
'm', itemMachineCasingEV ));
|
||||
'm', itemStackMachineCasings[3] ));
|
||||
|
||||
// Enantiomorphic reactor core is 1 EV Machine casing (Ti), 4 Capacitive crystal, 1 Computer interface, 1 Power interface, 2 Lenses
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockEnanReactorCore), false, "CpC", "lml", "CcC",
|
||||
|
@ -1161,11 +1276,41 @@ public class Recipes {
|
|||
'd', ItemComponent.getItemStack(ComponentType.DIFFRACTION_GRATING),
|
||||
'l', ItemComponent.getItemStack(ComponentType.LENS),
|
||||
'c', ItemComponent.getItemStack(ComponentType.COMPUTER_INTERFACE),
|
||||
'm', itemMachineCasingHV,
|
||||
'm', itemStackMachineCasings[2],
|
||||
'r', Items.redstone,
|
||||
'g', "paneGlassColorless",
|
||||
'h', "blockHull3_plain"));
|
||||
|
||||
// Force field projector is 1 or 2 EMC Projector + 1 LV/MV/HV Machine casing + 1 Ender crystal + 1 Redstone
|
||||
for (int tier = 1; tier <= 3; tier++) {
|
||||
int index = tier - 1;
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockForceFieldProjectors[index], 0), false, " e ", "pm ", " r ",
|
||||
'p', ItemComponent.getItemStack(ComponentType.EMC_PROJECTOR),
|
||||
'm', itemStackMachineCasings[index],
|
||||
'e', ItemComponent.getItemStack(ComponentType.ENDER_CRYSTAL),
|
||||
'r', Items.redstone));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockForceFieldProjectors[index], 0), false, " e ", " mp", " r ",
|
||||
'p', ItemComponent.getItemStack(ComponentType.EMC_PROJECTOR),
|
||||
'm', itemStackMachineCasings[index],
|
||||
'e', ItemComponent.getItemStack(ComponentType.ENDER_CRYSTAL),
|
||||
'r', Items.redstone));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockForceFieldProjectors[index], 1), false, " e ", "pmp", " r ",
|
||||
'p', ItemComponent.getItemStack(ComponentType.EMC_PROJECTOR),
|
||||
'm', itemStackMachineCasings[index],
|
||||
'e', ItemComponent.getItemStack(ComponentType.ENDER_CRYSTAL),
|
||||
'r', Items.redstone));
|
||||
}
|
||||
|
||||
// Force field relay is 2 Coil crystals + 1 LV/MV/HV Machine casing + 1 Ender crystal + 1 Redstone
|
||||
for (int tier = 1; tier <= 3; tier++) {
|
||||
int index = tier - 1;
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(WarpDrive.blockForceFieldRelays[index]), false, " e ", "CmC", " r ",
|
||||
'C', ItemComponent.getItemStack(ComponentType.COIL_CRYSTAL),
|
||||
'm', itemStackMachineCasings[index],
|
||||
'e', ItemComponent.getItemStack(ComponentType.ENDER_CRYSTAL),
|
||||
'r', Items.redstone));
|
||||
}
|
||||
|
||||
// Decorative blocks
|
||||
OreDictionary.registerOre("warpDecorative", BlockDecorative.getItemStack(DecorativeType.PLAIN));
|
||||
OreDictionary.registerOre("warpDecorative", BlockDecorative.getItemStack(DecorativeType.ENERGIZED));
|
||||
|
|
|
@ -20,7 +20,9 @@ public enum ComponentType {
|
|||
MOTOR ("Motor"),
|
||||
BONE_CHARCOAL ("BoneCharcoal"),
|
||||
ACTIVATED_CARBON ("ActivatedCarbon"),
|
||||
LASER_MEDIUM_EMPTY ("LaserMediumEmpty");
|
||||
LASER_MEDIUM_EMPTY ("LaserMediumEmpty"),
|
||||
COIL_CRYSTAL ("CoilCrystal"),
|
||||
EMC_PROJECTOR ("EMCProjector");
|
||||
|
||||
public final String unlocalizedName;
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package cr0s.warpdrive.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import cr0s.warpdrive.api.IForceFieldShape;
|
||||
|
||||
public enum EnumForceFieldShape {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum EnumForceFieldShape implements IForceFieldShape {
|
||||
NONE ("none"),
|
||||
SPHERE ("sphere"),
|
||||
CYLINDER_H ("cylinder_h"),
|
||||
|
@ -32,4 +35,144 @@ public enum EnumForceFieldShape {
|
|||
public static EnumForceFieldShape get(final int damage) {
|
||||
return ID_MAP.get(damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<VectorI, Boolean> getVertexes(ForceFieldSetup forceFieldSetup) {
|
||||
VectorI vScale = forceFieldSetup.vMax.clone().translateBack(forceFieldSetup.vMin);
|
||||
Map<VectorI, Boolean> mapVertexes = new HashMap<>(vScale.x * vScale.y * vScale.z);
|
||||
int radius;
|
||||
int thickness;
|
||||
int radiusInterior2;
|
||||
int radiusPerimeter2;
|
||||
VectorI vCenter;
|
||||
switch(this) {
|
||||
case SPHERE:
|
||||
radius = forceFieldSetup.vMax.y;
|
||||
radiusInterior2 = Math.round((radius - forceFieldSetup.thickness) * (radius - forceFieldSetup.thickness));
|
||||
radiusPerimeter2 = Math.round((radius + forceFieldSetup.thickness) * (radius + forceFieldSetup.thickness));
|
||||
vCenter = new VectorI(0, 0, 0);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
int y2 = (y - vCenter.y) * (y - vCenter.y);
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
int x2 = (x - vCenter.x) * (x - vCenter.x);
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
int z2 = (z - vCenter.z) * (z - vCenter.z);
|
||||
if (x2 + y2 + z2 <= radiusPerimeter2) {
|
||||
mapVertexes.put(new VectorI(x, y, z), x2 + y2 + z2 >= radiusInterior2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CYLINDER_H:
|
||||
radius = Math.round((forceFieldSetup.vMax.y + forceFieldSetup.vMax.z) / 2);
|
||||
radiusInterior2 = Math.round((radius - forceFieldSetup.thickness) * (radius - forceFieldSetup.thickness));
|
||||
radiusPerimeter2 = Math.round((radius + forceFieldSetup.thickness) * (radius + forceFieldSetup.thickness));
|
||||
vCenter = new VectorI(0, 0, 0);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
int y2 = (y - vCenter.y) * (y - vCenter.y);
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
int z2 = (z - vCenter.z) * (z - vCenter.z);
|
||||
if (y2 + z2 <= radiusPerimeter2) {
|
||||
boolean isPerimeter = y2 + z2 >= radiusInterior2;
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
mapVertexes.put(new VectorI(x, y, z), isPerimeter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CYLINDER_V:
|
||||
radius = Math.round((forceFieldSetup.vMax.x + forceFieldSetup.vMax.y) / 2);
|
||||
radiusInterior2 = Math.round((radius - forceFieldSetup.thickness) * (radius - forceFieldSetup.thickness));
|
||||
radiusPerimeter2 = Math.round((radius + forceFieldSetup.thickness) * (radius + forceFieldSetup.thickness));
|
||||
vCenter = new VectorI(0, 0, 0);
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
int x2 = (x - vCenter.x) * (x - vCenter.x);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
int y2 = (y - vCenter.y) * (y - vCenter.y);
|
||||
if (x2 + y2 <= radiusPerimeter2) {
|
||||
boolean isPerimeter = x2 + y2 >= radiusInterior2;
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
mapVertexes.put(new VectorI(x, y, z), isPerimeter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TUBE:
|
||||
radius = Math.round((forceFieldSetup.vMax.x + forceFieldSetup.vMax.z) / 2);
|
||||
radiusInterior2 = Math.round((radius - forceFieldSetup.thickness) * (radius - forceFieldSetup.thickness));
|
||||
radiusPerimeter2 = Math.round((radius + forceFieldSetup.thickness) * (radius + forceFieldSetup.thickness));
|
||||
vCenter = new VectorI(0, 0, 0);
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
int x2 = (x - vCenter.x) * (x - vCenter.x);
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
int z2 = (z - vCenter.z) * (z - vCenter.z);
|
||||
if (x2 + z2 <= radiusPerimeter2) {
|
||||
boolean isPerimeter = x2 + z2 >= radiusInterior2;
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
mapVertexes.put(new VectorI(x, y, z), isPerimeter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CUBE:
|
||||
thickness = Math.round(forceFieldSetup.thickness);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
boolean yFace = Math.abs(y - forceFieldSetup.vMin.y) <= thickness
|
||||
|| Math.abs(y - forceFieldSetup.vMax.y) <= thickness;
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
boolean xFace = Math.abs(x - forceFieldSetup.vMin.x) <= thickness
|
||||
|| Math.abs(x - forceFieldSetup.vMax.x) <= thickness;
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
boolean zFace = Math.abs(z - forceFieldSetup.vMin.z) <= thickness
|
||||
|| Math.abs(z - forceFieldSetup.vMax.z) <= thickness;
|
||||
mapVertexes.put(new VectorI(x, y, z), xFace || yFace || zFace);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PLANE:
|
||||
thickness = Math.round(forceFieldSetup.thickness);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
boolean yFace = Math.abs(y - forceFieldSetup.vMin.y) <= thickness
|
||||
|| Math.abs(y - forceFieldSetup.vMax.y) <= thickness;
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
mapVertexes.put(new VectorI(x, y, z), yFace);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TUNNEL:
|
||||
thickness = Math.round(forceFieldSetup.thickness);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
boolean xFace = Math.abs(x - forceFieldSetup.vMin.x) <= thickness
|
||||
|| Math.abs(x - forceFieldSetup.vMax.x) <= thickness;
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
boolean isPerimeter = xFace
|
||||
|| Math.abs(z - forceFieldSetup.vMin.z) <= thickness
|
||||
|| Math.abs(z - forceFieldSetup.vMax.z) <= thickness;
|
||||
mapVertexes.put(new VectorI(x, y, z), isPerimeter);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return mapVertexes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,30 +1,46 @@
|
|||
package cr0s.warpdrive.data;
|
||||
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.api.IForceFieldUpgrade;
|
||||
import cr0s.warpdrive.api.IForceFieldUpgradeEffector;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
|
||||
public enum EnumForceFieldUpgrade {
|
||||
NONE ("none" , false, false),
|
||||
BREAK ("break" , false, true ),
|
||||
CAMOUFLAGE ("camouflage" , false, true ),
|
||||
COOL ("cool" , true , true ),
|
||||
FUSION ("fusion" , true , true ),
|
||||
MUTE ("mute" , true , false),
|
||||
RANGE ("range" , true , true ),
|
||||
ROTATION ("rotation" , true , false),
|
||||
SHOCK ("shock" , true , true ),
|
||||
SPEED ("speed" , true , true ),
|
||||
STABILIZE ("stabilize" , false, true ),
|
||||
THICKNESS ("thickness" , true , true ),
|
||||
TRANSLATION ("translation" , true , false),
|
||||
WARM ("warm" , true , true ),
|
||||
// reserved 13
|
||||
// reserved 14
|
||||
// reserved 15
|
||||
public enum EnumForceFieldUpgrade implements IForceFieldUpgrade, IForceFieldUpgradeEffector {
|
||||
// name projector relay value cap scan place startup scan place entity comment
|
||||
NONE ("none" , false, false, 0, 0, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, ""),
|
||||
BREAK ("break" , false, true , 1000, 25000, 10.0F, 10.0F, 100.0F, 1.0F, 10.0F, 100.0F, "value is hardness level"),
|
||||
CAMOUFLAGE ("camouflage" , false, true , 1000, 1000, 10.0F, 10.0F, 100.0F, 1.0F, 10.0F, 100.0F, "value is boolean"),
|
||||
COOL ("cool" , true , true , 1000, 1000, 10.0F, 10.0F, 100.0F, 1.0F, 10.0F, 100.0F, "value is heat units"),
|
||||
FUSION ("fusion" , true , true , 1000, 1000, 10.0F, 10.0F, 100.0F, 1.0F, 10.0F, 100.0F, "value is boolean"),
|
||||
INVERT ("invert" , false, true , 1000, 1000, 10.0F, 10.0F, 100.0F, 1.0F, 10.0F, 100.0F, "value is boolean"),
|
||||
MUTE ("mute" , true , false, 1000, 1000, 10.0F, 10.0F, 100.0F, 1.0F, 10.0F, 100.0F, "value is boolean"),
|
||||
PUMP ("pump" , false, true , 1000, 1000, 10.0F, 10.0F, 100.0F, 1.0F, 10.0F, 100.0F, "value is TO BE DEFINED"),
|
||||
RANGE ("range" , true , true , 1000, 1000, 10.0F, 10.0F, 100.0F, 1.0F, 10.0F, 100.0F, "value is bonus blocks"),
|
||||
ROTATION ("rotation" , true , false, 1000, 1000, 10.0F, 10.0F, 100.0F, 1.0F, 10.0F, 100.0F, "value is boolean"),
|
||||
SHOCK ("shock" , true , true , 1000, 1000, 10.0F, 10.0F, 100.0F, 1.0F, 10.0F, 100.0F, "value is damage points"),
|
||||
SPEED ("speed" , true , true , 1000, 1000, 10.0F, 10.0F, 100.0F, 1.0F, 10.0F, 100.0F, "value is bonus ratio"),
|
||||
STABILIZE ("stabilize" , false, true , 1000, 1000, 10.0F, 10.0F, 100.0F, 1.0F, 10.0F, 100.0F, "value is boolean"),
|
||||
THICKNESS ("thickness" , true , true , 1000, 1000, 10.0F, 10.0F, 100.0F, 1.0F, 10.0F, 100.0F, "value is bonus ratio"),
|
||||
TRANSLATION ("translation" , true , false, 1000, 1000, 10.0F, 10.0F, 100.0F, 1.0F, 10.0F, 100.0F, "value is boolean"),
|
||||
WARM ("warm" , true , true , 1000, 1000, 10.0F, 10.0F, 100.0F, 1.0F, 10.0F, 100.0F, "value is heat units"),
|
||||
;
|
||||
|
||||
public final String unlocalizedName;
|
||||
public final boolean allowAsItem;
|
||||
public final boolean allowAsBlock;
|
||||
public final boolean allowOnProjector;
|
||||
public final boolean allowOnRelay;
|
||||
private final int upgradeValue;
|
||||
private final int upgradeValueMax;
|
||||
private final float maxScanSpeed;
|
||||
private final float maxPlaceSpeed;
|
||||
private final float startupEnergyCost;
|
||||
private final float scanEnergyCost;
|
||||
private final float placeEnergyCost;
|
||||
private final float entityEffectEnergyCost;
|
||||
|
||||
// cached values
|
||||
public static final int length;
|
||||
|
@ -37,13 +53,106 @@ public enum EnumForceFieldUpgrade {
|
|||
}
|
||||
}
|
||||
|
||||
EnumForceFieldUpgrade(final String unlocalizedName, final boolean allowAsItem, final boolean allowAsBlock) {
|
||||
EnumForceFieldUpgrade(final String unlocalizedName, final boolean allowOnProjector, final boolean allowOnRelay,
|
||||
final int upgradeValue, final int upgradeValueMax,
|
||||
final float maxScanSpeed, final float maxPlaceSpeed,
|
||||
final float startupEnergyCost, final float scanEnergyCost, final float placeEnergyCost, final float entityEffectEnergyCost,
|
||||
final String comment) {
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
this.allowAsItem = allowAsItem;
|
||||
this.allowAsBlock = allowAsBlock;
|
||||
this.allowOnProjector = allowOnProjector;
|
||||
this.allowOnRelay = allowOnRelay;
|
||||
this.upgradeValue = upgradeValue;
|
||||
this.upgradeValueMax = upgradeValueMax;
|
||||
this.maxScanSpeed = maxScanSpeed;
|
||||
this.maxPlaceSpeed = maxPlaceSpeed;
|
||||
this.startupEnergyCost = startupEnergyCost;
|
||||
this.scanEnergyCost = scanEnergyCost;
|
||||
this.placeEnergyCost = placeEnergyCost;
|
||||
this.entityEffectEnergyCost = entityEffectEnergyCost;
|
||||
assert(!comment.isEmpty());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static EnumForceFieldUpgrade get(final int damage) {
|
||||
return ID_MAP.get(damage);
|
||||
EnumForceFieldUpgrade enumForceFieldUpgrade = ID_MAP.get(damage);
|
||||
return enumForceFieldUpgrade == null ? EnumForceFieldUpgrade.NONE : enumForceFieldUpgrade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IForceFieldUpgradeEffector getUpgradeEffector() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUpgradeValue() {
|
||||
return upgradeValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getScaledValue(final float ratio, final int upgradeValue) {
|
||||
return ratio * Math.min(upgradeValueMax, upgradeValue) / 1000.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxScanSpeed(final float scaledValue) {
|
||||
return maxScanSpeed * scaledValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxPlaceSpeed(final float scaledValue) {
|
||||
return maxPlaceSpeed * scaledValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStartupEnergyCost(final float scaledValue) {
|
||||
return startupEnergyCost * scaledValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getScanEnergyCost(final float scaledValue) {
|
||||
return scanEnergyCost * scaledValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPlaceEnergyCost(final float scaledValue) {
|
||||
return placeEnergyCost * scaledValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEntityEffectEnergyCost(final float scaledValue) { return entityEffectEnergyCost * scaledValue; }
|
||||
|
||||
|
||||
@Override
|
||||
public int onEntityEffect(final float scaledValue, World world, final int x, final int y, final int z, Entity entity) {
|
||||
if (scaledValue == 0.0F) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO add some particle effects
|
||||
switch(this) {
|
||||
case COOL:
|
||||
if (scaledValue >= 0 || !(entity instanceof EntityLivingBase)) {
|
||||
return 0;
|
||||
}
|
||||
entity.attackEntityFrom(WarpDrive.damageCold, Math.abs(scaledValue));
|
||||
return 10;
|
||||
|
||||
case SHOCK:
|
||||
if (scaledValue <= 0 || !(entity instanceof EntityLivingBase)) {
|
||||
return 0;
|
||||
}
|
||||
entity.attackEntityFrom(WarpDrive.damageShock, Math.abs(scaledValue));
|
||||
return 10;
|
||||
|
||||
case WARM:
|
||||
if (scaledValue <= 0 || !(entity instanceof EntityLivingBase)) {
|
||||
return 0;
|
||||
}
|
||||
entity.attackEntityFrom(WarpDrive.damageWarm, Math.abs(scaledValue));
|
||||
return 10;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package cr0s.warpdrive.data;
|
||||
|
||||
import cr0s.warpdrive.api.IEffector;
|
||||
import cr0s.warpdrive.api.IForceFieldUpgrade;
|
||||
import cr0s.warpdrive.api.IShapeProvider;
|
||||
import cr0s.warpdrive.block.forcefield.TileEntityProjector;
|
||||
import cr0s.warpdrive.api.IForceFieldShape;
|
||||
import cr0s.warpdrive.api.IForceFieldUpgradeEffector;
|
||||
import cr0s.warpdrive.block.forcefield.TileEntityForceFieldProjector;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -15,21 +15,33 @@ import net.minecraft.world.World;
|
|||
import java.util.*;
|
||||
|
||||
public class ForceFieldSetup extends GlobalPosition {
|
||||
public int beamFrequency;
|
||||
public byte tier;
|
||||
public ItemStack itemStackCamouflage;
|
||||
private Block blockCamouflage_cache;
|
||||
private static final float FORCEFIELD_BASE_SCAN_SPEED = 1000;
|
||||
private static final float FORCEFIELD_BASE_PLACE_SPEED = 300;
|
||||
private static final float FORCEFIELD_MAX_SCAN_SPEED = 1000;
|
||||
private static final float FORCEFIELD_MAX_PLACE_SPEED = 300;
|
||||
|
||||
public final int beamFrequency;
|
||||
public final byte tier;
|
||||
private Block blockCamouflage;
|
||||
private int metadataCamouflage;
|
||||
private static final List<Integer> ALLOWED_RENDER_TYPES = Arrays.asList(0, 1, 4, 5, 6, 8, 7, 12, 13, 14, 16, 17, 20, 23, 29, 30, 31, 39);
|
||||
private final HashMap<String, Integer> upgrades = new HashMap<>(EnumForceFieldUpgrade.length);
|
||||
private final HashMap<IForceFieldUpgradeEffector, Float> upgrades = new HashMap<>(EnumForceFieldUpgrade.length);
|
||||
public float maxScanSpeed;
|
||||
public float maxPlaceSpeed;
|
||||
private float startupEnergyCost;
|
||||
public float scanEnergyCost;
|
||||
public float placeEnergyCost;
|
||||
private float entityEnergyCost;
|
||||
public float disintegrationLevel;
|
||||
public float temperatureLevel;
|
||||
public boolean hasStabilize;
|
||||
public boolean hasFusion;
|
||||
public boolean isInverted;
|
||||
public float thickness;
|
||||
|
||||
// TODO
|
||||
public Set<TileEntityProjector> projectors = new HashSet<>();
|
||||
public Set<IEffector> effectors = new HashSet<>();
|
||||
public int disintegrationLevel;
|
||||
public int temperatureLevel;
|
||||
public boolean hasStabilize;
|
||||
public boolean isInverted = false;
|
||||
public boolean hasFusion;
|
||||
private final Set<TileEntityForceFieldProjector> projectors = new HashSet<>();
|
||||
public boolean hasPump;
|
||||
|
||||
// Projector provided properties
|
||||
public float rotationYaw;
|
||||
|
@ -37,10 +49,8 @@ public class ForceFieldSetup extends GlobalPosition {
|
|||
public VectorI vTranslation = new VectorI(0, 0, 0);
|
||||
public VectorI vMin = new VectorI(-8, -8, -8);
|
||||
public VectorI vMax = new VectorI(8, 8, 8);
|
||||
public IShapeProvider shapeProvider;
|
||||
public EnumForceFieldShape enumForceFieldShape;
|
||||
public IForceFieldShape shapeProvider;
|
||||
public boolean isDoubleSided = true;
|
||||
public float thickness = 1.0F;
|
||||
|
||||
public ForceFieldSetup(final int dimensionId, final int x, final int y, final int z, final byte tier, final int beamFrequency) {
|
||||
super(dimensionId, x, y, z);
|
||||
|
@ -49,35 +59,36 @@ public class ForceFieldSetup extends GlobalPosition {
|
|||
refresh();
|
||||
}
|
||||
|
||||
public Collection<IEffector> getEffectors() {
|
||||
return effectors;
|
||||
}
|
||||
|
||||
public boolean isAccessGranted(EntityPlayer entityPlayer, PermissionNode permissionNode) {
|
||||
return false; // TODO
|
||||
}
|
||||
|
||||
public static boolean isValidCamouflage(ItemStack itemStack) {
|
||||
if (itemStack != null && itemStack.stackSize > 0 && itemStack.getItem() instanceof ItemBlock) {
|
||||
Block block = Block.getBlockFromItem(itemStack.getItem());
|
||||
return ALLOWED_RENDER_TYPES.contains(block.getRenderType());
|
||||
}
|
||||
return false;
|
||||
private static boolean isValidCamouflage(final Block block) {
|
||||
return block != null && block != Blocks.air && ALLOWED_RENDER_TYPES.contains(block.getRenderType());
|
||||
}
|
||||
|
||||
public Block getCamouflageBlock() {
|
||||
if (blockCamouflage_cache != null) {
|
||||
return blockCamouflage_cache;
|
||||
}
|
||||
if (isValidCamouflage(itemStackCamouflage)) {
|
||||
blockCamouflage_cache = Block.getBlockFromItem(itemStackCamouflage.getItem());
|
||||
return blockCamouflage_cache;
|
||||
if (isValidCamouflage(blockCamouflage)) {
|
||||
return blockCamouflage;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getCamouflageMetadata() {
|
||||
if (isValidCamouflage(blockCamouflage)) {
|
||||
return metadataCamouflage;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private float getScaledUpgrade(final IForceFieldUpgradeEffector effector) {
|
||||
Float scaledValue = upgrades.get(effector);
|
||||
return scaledValue == null ? 0.0F : scaledValue;
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
Set<TileEntity> tileEntities = ForceFieldRegistry.getTileEntities(beamFrequency);
|
||||
HashMap<IForceFieldUpgradeEffector, Integer> upgradeValues = new HashMap<>(EnumForceFieldUpgrade.length);
|
||||
|
||||
for (TileEntity tileEntity : tileEntities) {
|
||||
// only consider same dimension
|
||||
|
@ -85,37 +96,86 @@ public class ForceFieldSetup extends GlobalPosition {
|
|||
continue;
|
||||
}
|
||||
// projectors
|
||||
if (tileEntity instanceof TileEntityProjector) {
|
||||
TileEntityProjector projector = (TileEntityProjector) tileEntity;
|
||||
if (tileEntity instanceof TileEntityForceFieldProjector) {
|
||||
TileEntityForceFieldProjector projector = (TileEntityForceFieldProjector) tileEntity;
|
||||
if (tileEntity.xCoord == x && tileEntity.yCoord == y && tileEntity.zCoord == z) {
|
||||
shapeProvider = projector.getShapeProvider();
|
||||
enumForceFieldShape = projector.getShape();
|
||||
isDoubleSided = projector.isDoubleSided;
|
||||
vTranslation = new VectorI(projector);
|
||||
// TODO vMin = projector.vMin;
|
||||
// TODO vMax = projector.vMax;
|
||||
// TODO upgrades ?
|
||||
} else {
|
||||
if ((((TileEntityProjector) tileEntity).isEnabled)
|
||||
&& (((TileEntityProjector) tileEntity).isCalculated())
|
||||
&& (((TileEntityProjector) tileEntity).isValid())) {
|
||||
projectors.add((TileEntityProjector) tileEntity);
|
||||
if ((((TileEntityForceFieldProjector) tileEntity).isEnabled)
|
||||
&& (((TileEntityForceFieldProjector) tileEntity).isCalculated())
|
||||
&& (((TileEntityForceFieldProjector) tileEntity).isValid())) {
|
||||
projectors.add((TileEntityForceFieldProjector) tileEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
// block upgrades
|
||||
// upgrade blocks (namely, relays)
|
||||
if (tileEntity instanceof IForceFieldUpgrade) {
|
||||
String upgradeKey = ((IForceFieldUpgrade)tileEntity).getUpgradeKey();
|
||||
if (!upgradeKey.isEmpty()) {
|
||||
Integer count = upgrades.get(upgradeKey);
|
||||
if (count == null) {
|
||||
count = 0;
|
||||
IForceFieldUpgradeEffector upgradeEffector = ((IForceFieldUpgrade)tileEntity).getUpgradeEffector();
|
||||
if (upgradeEffector != null) {
|
||||
Integer currentValue = upgradeValues.get(upgradeEffector);
|
||||
if (currentValue == null) {
|
||||
currentValue = 0;
|
||||
}
|
||||
upgradeValues.put(upgradeEffector, currentValue + ((IForceFieldUpgrade)tileEntity).getUpgradeValue());
|
||||
|
||||
// camouflage identification
|
||||
Block blockCandidate = tileEntity.getWorldObj().getBlock(tileEntity.xCoord, tileEntity.yCoord + 1, tileEntity.zCoord);
|
||||
if (isValidCamouflage(blockCandidate)) {
|
||||
blockCamouflage = blockCandidate;
|
||||
metadataCamouflage = tileEntity.getWorldObj().getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord + 1, tileEntity.zCoord);
|
||||
}
|
||||
upgrades.put(upgradeKey, count + ((IForceFieldUpgrade)tileEntity).getUpgradeValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hasFusion = upgrades.containsKey(EnumForceFieldUpgrade.FUSION.unlocalizedName);
|
||||
// set default coefficients, depending on projector
|
||||
maxScanSpeed = upgradeValues.get(EnumForceFieldUpgrade.SPEED) != null ? FORCEFIELD_MAX_SCAN_SPEED : FORCEFIELD_BASE_SCAN_SPEED;
|
||||
maxPlaceSpeed = upgradeValues.get(EnumForceFieldUpgrade.SPEED) != null ? FORCEFIELD_MAX_PLACE_SPEED : FORCEFIELD_BASE_PLACE_SPEED;
|
||||
startupEnergyCost = 60.0F + 20.0F * tier;
|
||||
scanEnergyCost = 1.0F + 1.0F * tier;
|
||||
placeEnergyCost = 3.0F + 3.0F * tier;
|
||||
entityEnergyCost = 2.0F;
|
||||
|
||||
// apply scaling
|
||||
float maxSpeed;
|
||||
for (Map.Entry<IForceFieldUpgradeEffector, Integer> entry : upgradeValues.entrySet()) {
|
||||
float scaledValue = entry.getKey().getScaledValue(1.0F, entry.getValue());
|
||||
if (scaledValue != 0.0F) {
|
||||
upgrades.put(entry.getKey(), scaledValue);
|
||||
|
||||
maxSpeed = entry.getKey().getMaxScanSpeed(scaledValue);
|
||||
if (maxSpeed > 0.0F) {
|
||||
maxScanSpeed = Math.min(maxScanSpeed, maxSpeed);
|
||||
}
|
||||
maxSpeed = entry.getKey().getMaxPlaceSpeed(scaledValue);
|
||||
if (maxSpeed > 0.0F) {
|
||||
maxPlaceSpeed = Math.min(maxPlaceSpeed, maxSpeed);
|
||||
}
|
||||
|
||||
startupEnergyCost += entry.getKey().getStartupEnergyCost(scaledValue);
|
||||
scanEnergyCost += entry.getKey().getScanEnergyCost(scaledValue);
|
||||
placeEnergyCost += entry.getKey().getPlaceEnergyCost(scaledValue);
|
||||
entityEnergyCost += entry.getKey().getEntityEffectEnergyCost(scaledValue);
|
||||
}
|
||||
}
|
||||
|
||||
// fusion and stabilize just needs to be defined
|
||||
hasFusion = getScaledUpgrade(EnumForceFieldUpgrade.FUSION) > 0.0F;
|
||||
isInverted = getScaledUpgrade(EnumForceFieldUpgrade.INVERT) > 0.0F;
|
||||
hasPump = getScaledUpgrade(EnumForceFieldUpgrade.PUMP) > 0.0F;
|
||||
hasStabilize = getScaledUpgrade(EnumForceFieldUpgrade.STABILIZE) > 0.0F;
|
||||
|
||||
// temperature is a compound of cooling and warming
|
||||
temperatureLevel = getScaledUpgrade(EnumForceFieldUpgrade.WARM) - getScaledUpgrade(EnumForceFieldUpgrade.COOL);
|
||||
|
||||
// disintegration and thickness is the actual value
|
||||
disintegrationLevel = getScaledUpgrade(EnumForceFieldUpgrade.BREAK);
|
||||
thickness = 1.0F + getScaledUpgrade(EnumForceFieldUpgrade.THICKNESS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -127,12 +187,16 @@ public class ForceFieldSetup extends GlobalPosition {
|
|||
vMax.x, vMax.y, vMax.z);
|
||||
}
|
||||
|
||||
public int onEntityEffect(World world, final int x, final int y, final int z, Entity entity) {
|
||||
int countdown = 0;
|
||||
for (Map.Entry<IForceFieldUpgradeEffector, Float> entry : upgrades.entrySet()) {
|
||||
countdown += entry.getKey().onEntityEffect(entry.getValue(), world, x, y, z, entity);
|
||||
}
|
||||
return countdown;
|
||||
}
|
||||
|
||||
public int applyDamages(World world, int x, int y, int z, DamageSource damageSource, int damageParameter, Vector3 damageDirection, int damageLevel) {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getProjectionSpeed() {
|
||||
return 100; // TODO
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package cr0s.warpdrive.item;
|
||||
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.api.IShapeProvider;
|
||||
import cr0s.warpdrive.data.ForceFieldSetup;
|
||||
import cr0s.warpdrive.data.EnumForceFieldShape;
|
||||
import cr0s.warpdrive.data.VectorI;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -15,7 +12,7 @@ import net.minecraft.util.StatCollector;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
public class ItemForceFieldShape extends Item implements IShapeProvider {
|
||||
public class ItemForceFieldShape extends Item {
|
||||
private final IIcon[] icons;
|
||||
private static ItemStack[] itemStackCache;
|
||||
|
||||
|
@ -33,7 +30,7 @@ public class ItemForceFieldShape extends Item implements IShapeProvider {
|
|||
if (enumForceFieldShape != null) {
|
||||
int damage = enumForceFieldShape.ordinal();
|
||||
if (itemStackCache[damage] == null) {
|
||||
itemStackCache[damage] = new ItemStack(WarpDrive.itemComponent, 1, damage);
|
||||
itemStackCache[damage] = new ItemStack(WarpDrive.itemForceFieldShape, 1, damage);
|
||||
}
|
||||
return itemStackCache[damage];
|
||||
}
|
||||
|
@ -71,7 +68,9 @@ public class ItemForceFieldShape extends Item implements IShapeProvider {
|
|||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs creativeTab, List list) {
|
||||
for(EnumForceFieldShape enumForceFieldShape : EnumForceFieldShape.values()) {
|
||||
list.add(new ItemStack(item, 1, enumForceFieldShape.ordinal()));
|
||||
if (enumForceFieldShape != EnumForceFieldShape.NONE) {
|
||||
list.add(new ItemStack(item, 1, enumForceFieldShape.ordinal()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,144 +88,4 @@ public class ItemForceFieldShape extends Item implements IShapeProvider {
|
|||
WarpDrive.addTooltip(list, StatCollector.translateToLocalFormatted(tooltipName2));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<VectorI, Boolean> getVertexes(ForceFieldSetup forceFieldSetup) {
|
||||
VectorI vScale = forceFieldSetup.vMax.clone().translateBack(forceFieldSetup.vMin);
|
||||
Map<VectorI, Boolean> mapVertexes = new HashMap<>(vScale.x * vScale.y * vScale.z);
|
||||
int radius;
|
||||
int thickness;
|
||||
int radiusInterior2;
|
||||
int radiusPerimeter2;
|
||||
VectorI vCenter;
|
||||
switch(forceFieldSetup.enumForceFieldShape) {
|
||||
case SPHERE:
|
||||
radius = forceFieldSetup.vMax.y;
|
||||
radiusInterior2 = Math.round((radius - forceFieldSetup.thickness) * (radius - forceFieldSetup.thickness));
|
||||
radiusPerimeter2 = Math.round((radius + forceFieldSetup.thickness) * (radius + forceFieldSetup.thickness));
|
||||
vCenter = new VectorI(0, 0, 0);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
int y2 = (y - vCenter.y) * (y - vCenter.y);
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
int x2 = (x - vCenter.x) * (x - vCenter.x);
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
int z2 = (z - vCenter.z) * (z - vCenter.z);
|
||||
if (x2 + y2 + z2 <= radiusPerimeter2) {
|
||||
mapVertexes.put(new VectorI(x, y, z), x2 + y2 + z2 >= radiusInterior2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CYLINDER_H:
|
||||
radius = Math.round((forceFieldSetup.vMax.y + forceFieldSetup.vMax.z) / 2);
|
||||
radiusInterior2 = Math.round((radius - forceFieldSetup.thickness) * (radius - forceFieldSetup.thickness));
|
||||
radiusPerimeter2 = Math.round((radius + forceFieldSetup.thickness) * (radius + forceFieldSetup.thickness));
|
||||
vCenter = new VectorI(0, 0, 0);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
int y2 = (y - vCenter.y) * (y - vCenter.y);
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
int z2 = (z - vCenter.z) * (z - vCenter.z);
|
||||
if (y2 + z2 <= radiusPerimeter2) {
|
||||
boolean isPerimeter = y2 + z2 >= radiusInterior2;
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
mapVertexes.put(new VectorI(x, y, z), isPerimeter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CYLINDER_V:
|
||||
radius = Math.round((forceFieldSetup.vMax.x + forceFieldSetup.vMax.y) / 2);
|
||||
radiusInterior2 = Math.round((radius - forceFieldSetup.thickness) * (radius - forceFieldSetup.thickness));
|
||||
radiusPerimeter2 = Math.round((radius + forceFieldSetup.thickness) * (radius + forceFieldSetup.thickness));
|
||||
vCenter = new VectorI(0, 0, 0);
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
int x2 = (x - vCenter.x) * (x - vCenter.x);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
int y2 = (y - vCenter.y) * (y - vCenter.y);
|
||||
if (x2 + y2 <= radiusPerimeter2) {
|
||||
boolean isPerimeter = x2 + y2 >= radiusInterior2;
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
mapVertexes.put(new VectorI(x, y, z), isPerimeter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TUBE:
|
||||
radius = Math.round((forceFieldSetup.vMax.x + forceFieldSetup.vMax.z) / 2);
|
||||
radiusInterior2 = Math.round((radius - forceFieldSetup.thickness) * (radius - forceFieldSetup.thickness));
|
||||
radiusPerimeter2 = Math.round((radius + forceFieldSetup.thickness) * (radius + forceFieldSetup.thickness));
|
||||
vCenter = new VectorI(0, 0, 0);
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
int x2 = (x - vCenter.x) * (x - vCenter.x);
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
int z2 = (z - vCenter.z) * (z - vCenter.z);
|
||||
if (x2 + z2 <= radiusPerimeter2) {
|
||||
boolean isPerimeter = x2 + z2 >= radiusInterior2;
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
mapVertexes.put(new VectorI(x, y, z), isPerimeter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CUBE:
|
||||
thickness = Math.round(forceFieldSetup.thickness);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
boolean yFace = Math.abs(y - forceFieldSetup.vMin.y) <= thickness
|
||||
|| Math.abs(y - forceFieldSetup.vMax.y) <= thickness;
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
boolean xFace = Math.abs(x - forceFieldSetup.vMin.x) <= thickness
|
||||
|| Math.abs(x - forceFieldSetup.vMax.x) <= thickness;
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
boolean zFace = Math.abs(z - forceFieldSetup.vMin.z) <= thickness
|
||||
|| Math.abs(z - forceFieldSetup.vMax.z) <= thickness;
|
||||
mapVertexes.put(new VectorI(x, y, z), xFace || yFace || zFace);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PLANE:
|
||||
thickness = Math.round(forceFieldSetup.thickness);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
boolean yFace = Math.abs(y - forceFieldSetup.vMin.y) <= thickness
|
||||
|| Math.abs(y - forceFieldSetup.vMax.y) <= thickness;
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
mapVertexes.put(new VectorI(x, y, z), yFace);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TUNNEL:
|
||||
thickness = Math.round(forceFieldSetup.thickness);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
boolean xFace = Math.abs(x - forceFieldSetup.vMin.x) <= thickness
|
||||
|| Math.abs(x - forceFieldSetup.vMax.x) <= thickness;
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
boolean isPerimeter = xFace
|
||||
|| Math.abs(z - forceFieldSetup.vMin.z) <= thickness
|
||||
|| Math.abs(z - forceFieldSetup.vMax.z) <= thickness;
|
||||
mapVertexes.put(new VectorI(x, y, z), isPerimeter);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return mapVertexes;
|
||||
}
|
||||
}
|
|
@ -1,39 +1,50 @@
|
|||
package cr0s.warpdrive.block.forcefield;
|
||||
package cr0s.warpdrive.item;
|
||||
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.data.DecorativeType;
|
||||
import cr0s.warpdrive.data.EnumForceFieldUpgrade;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBlockForceFieldUpgrade extends ItemBlock {
|
||||
public class ItemForceFieldUpgrade extends Item {
|
||||
private final IIcon[] icons;
|
||||
private static ItemStack[] itemStackCache;
|
||||
|
||||
public ItemBlockForceFieldUpgrade(Block block) {
|
||||
super(block);
|
||||
public ItemForceFieldUpgrade() {
|
||||
super();
|
||||
setHasSubtypes(true);
|
||||
setUnlocalizedName("warpdrive.forcefield.upgrade");
|
||||
setCreativeTab(WarpDrive.creativeTabWarpDrive);
|
||||
|
||||
icons = new IIcon[EnumForceFieldUpgrade.length];
|
||||
itemStackCache = new ItemStack[EnumForceFieldUpgrade.length];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
public static ItemStack getItemStack(EnumForceFieldUpgrade enumForceFieldUpgrade) {
|
||||
if (enumForceFieldUpgrade != null) {
|
||||
int damage = enumForceFieldUpgrade.ordinal();
|
||||
if (itemStackCache[damage] == null) {
|
||||
itemStackCache[damage] = new ItemStack(WarpDrive.itemForceFieldUpgrade, 1, damage);
|
||||
}
|
||||
return itemStackCache[damage];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack getItemStackNoCache(EnumForceFieldUpgrade enumForceFieldUpgrade, int amount) {
|
||||
return new ItemStack(WarpDrive.itemForceFieldUpgrade, amount, enumForceFieldUpgrade.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs creativeTab, List list) {
|
||||
public void registerIcons(IIconRegister par1IconRegister) {
|
||||
for(EnumForceFieldUpgrade enumForceFieldUpgrade : EnumForceFieldUpgrade.values()) {
|
||||
list.add(new ItemStack(item, 1, enumForceFieldUpgrade.ordinal()));
|
||||
icons[enumForceFieldUpgrade.ordinal()] = par1IconRegister.registerIcon("warpdrive:forcefield/upgrade_" + enumForceFieldUpgrade.unlocalizedName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,19 +57,21 @@ public class ItemBlockForceFieldUpgrade extends ItemBlock {
|
|||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
public static ItemStack getItemStack(EnumForceFieldUpgrade enumForceFieldUpgrade) {
|
||||
if (enumForceFieldUpgrade != null) {
|
||||
int damage = enumForceFieldUpgrade.ordinal();
|
||||
if (itemStackCache[damage] == null) {
|
||||
itemStackCache[damage] = new ItemStack(WarpDrive.itemComponent, 1, damage);
|
||||
}
|
||||
return itemStackCache[damage];
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int damage) {
|
||||
if (damage >= 0 && damage < EnumForceFieldUpgrade.length) {
|
||||
return icons[damage];
|
||||
}
|
||||
return null;
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
public static ItemStack getItemStackNoCache(EnumForceFieldUpgrade enumForceFieldUpgrade, int amount) {
|
||||
return new ItemStack(WarpDrive.blockForceFieldUpgrade, amount, enumForceFieldUpgrade.ordinal());
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs creativeTab, List list) {
|
||||
for(EnumForceFieldUpgrade enumForceFieldUpgrade : EnumForceFieldUpgrade.values()) {
|
||||
if (enumForceFieldUpgrade != EnumForceFieldUpgrade.NONE) {
|
||||
list.add(new ItemStack(item, 1, enumForceFieldUpgrade.ordinal()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
|
@ -31,6 +31,7 @@ public class RenderBlockForceField implements ISimpleBlockRenderingHandler {
|
|||
|
||||
int renderType = -1;
|
||||
Block blockCamouflage = forceFieldSetup.getCamouflageBlock();
|
||||
int metaCamouflage = forceFieldSetup.getCamouflageMetadata();
|
||||
if (blockCamouflage != null) {
|
||||
renderType = blockCamouflage.getRenderType();
|
||||
}
|
||||
|
@ -94,7 +95,7 @@ public class RenderBlockForceField implements ISimpleBlockRenderingHandler {
|
|||
return false;
|
||||
}
|
||||
} catch(Exception exception) {
|
||||
renderer.renderBlockAsItem(blockCamouflage, forceFieldSetup.itemStackCamouflage.getItemDamage(), 1);
|
||||
renderer.renderBlockAsItem(blockCamouflage, metaCamouflage, 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue