Added transporter (redesign with fresh reimplementation) wip
This commit is contained in:
parent
0180bdd40b
commit
d835480ac5
6 changed files with 919 additions and 493 deletions
|
@ -48,12 +48,9 @@ public class BlockTransporter extends BlockAbstractContainer {
|
|||
return iconBuffer[2];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) {
|
||||
public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer entityPlayer,
|
||||
final int side, final float hitX, final float hitY, final float hitZ) {
|
||||
if (world.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
@ -66,6 +63,6 @@ public class BlockTransporter extends BlockAbstractContainer {
|
|||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return super.onBlockActivated(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -48,6 +48,7 @@ public class Dictionary {
|
|||
public static HashSet<Block> BLOCKS_STOPMINING = null;
|
||||
public static HashMap<Block, Integer> BLOCKS_PLACE = null;
|
||||
public static HashSet<Block> BLOCKS_NOCAMOUFLAGE = null;
|
||||
public static HashSet<Block> BLOCKS_NOBLINK = null;
|
||||
|
||||
// Entities dictionary
|
||||
public static HashSet<String> ENTITIES_ANCHOR = null;
|
||||
|
@ -80,13 +81,14 @@ public class Dictionary {
|
|||
+ "- Expandable: this block will be squished/ignored in case of collision.\n"
|
||||
+ "- Mining: this block is mineable (default: all 'ore' blocks from the ore dictionary).\n"
|
||||
+ "- SkipMining: this block is ignored from mining (default: bedrock).\n"
|
||||
+ "- StopMining: this block will prevent mining through it (default: forcefields).\n"
|
||||
+ "- StopMining: this block will prevent mining through it (default: command/creative, bedrock, force fields).\n"
|
||||
+ "- PlaceEarliest: this block will be removed last and placed first (default: ship hull and projectors).\n"
|
||||
+ "- PlaceEarlier: this block will be placed fairly soon (default: forcefield blocks).\n"
|
||||
+ "- PlaceNormal: this block will be removed and placed with non-tile entities.\n"
|
||||
+ "- PlaceLater: this block will be placed fairly late (default: IC2 Reactor core).\n"
|
||||
+ "- PlaceLatest: this block will be removed first and placed last (default: IC2 Reactor chamber).\n"
|
||||
+ "- NoCamouflage: this block isn't valid for camouflage.");
|
||||
+ "- NoCamouflage: this block isn't valid for camouflage.\n"
|
||||
+ "- NoBlink: this block will prevent teleportation through it (default: bedrock, force fields)");
|
||||
|
||||
ConfigCategory categoryBlockTags = config.getCategory("block_tags");
|
||||
String[] taggedBlocksName = categoryBlockTags.getValues().keySet().toArray(new String[0]);
|
||||
|
@ -103,17 +105,17 @@ public class Dictionary {
|
|||
config.get("block_tags", "TConstruct:slime.leaves" , "Leaf").getString();
|
||||
|
||||
// anchors
|
||||
config.get("block_tags", "minecraft:bedrock" , "Anchor SkipMining").getString();
|
||||
config.get("block_tags", "minecraft:bedrock" , "Anchor SkipMining NoBlink").getString();
|
||||
config.get("block_tags", "minecraft:command_block" , "Anchor StopMining").getString();
|
||||
config.get("block_tags", "minecraft:end_portal_frame" , "Anchor StopMining").getString();
|
||||
config.get("block_tags", "minecraft:end_portal" , "Anchor StopMining").getString();
|
||||
config.get("block_tags", "Artifacts:invisible_bedrock" , "Anchor StopMining").getString();
|
||||
config.get("block_tags", "Artifacts:invisible_bedrock" , "Anchor StopMining NoBlink").getString();
|
||||
config.get("block_tags", "Artifacts:anti_anti_builder_stone" , "Anchor StopMining").getString();
|
||||
config.get("block_tags", "Artifacts:anti_builder" , "Anchor StopMining").getString();
|
||||
config.get("block_tags", "ComputerCraft:command_computer" , "Anchor SkipMining").getString();
|
||||
config.get("block_tags", "IC2:blockPersonal" , "Anchor SkipMining").getString();
|
||||
config.get("block_tags", "malisisdoors:rustyHatch" , "Anchor").getString();
|
||||
config.get("block_tags", "WarpDrive:blockBedrockGlass" , "Anchor SkipMining").getString();
|
||||
config.get("block_tags", "WarpDrive:blockBedrockGlass" , "Anchor SkipMining NoBlink").getString();
|
||||
|
||||
// placement priorities
|
||||
config.get("block_tags", "minecraft:lever" , "PlaceLatest").getString();
|
||||
|
@ -130,8 +132,8 @@ public class Dictionary {
|
|||
config.get("block_tags", "IC2:blockAlloy" , "PlaceEarliest StopMining").getString();
|
||||
config.get("block_tags", "IC2:blockAlloyGlass" , "PlaceEarliest StopMining").getString();
|
||||
config.get("block_tags", "minecraft:obsidian" , "PlaceEarliest Mining").getString();
|
||||
config.get("block_tags", "AdvancedRepulsionSystems:field" , "PlaceEarlier StopMining").getString();
|
||||
// config.get("block_tags", "MFFS:field" , "PlaceEarlier StopMining" ).getString();
|
||||
config.get("block_tags", "AdvancedRepulsionSystems:field" , "PlaceEarlier StopMining NoBlink").getString();
|
||||
// config.get("block_tags", "MFFS:field" , "PlaceEarlier StopMining NoBlink").getString();
|
||||
config.get("block_tags", "IC2:blockGenerator" , "PlaceLater").getString();
|
||||
config.get("block_tags", "IC2:blockReactorChamber" , "PlaceLatest").getString();
|
||||
config.get("block_tags", "ImmersiveEngineering:metalDevice" , "PlaceLatest").getString(); // FIXME: need to fine tune at metadata level
|
||||
|
@ -153,9 +155,9 @@ public class Dictionary {
|
|||
config.get("block_tags", "OpenComputers:caseCreative" , "PlaceLatest").getString();
|
||||
config.get("block_tags", "OpenComputers:keyboard" , "PlaceLatest").getString();
|
||||
config.get("block_tags", "PneumaticCraft:pressureChamberValve" , "PlaceEarlier").getString();
|
||||
config.get("block_tags", "StargateTech2:block.shieldEmitter" , "PlaceLater StopMining").getString();
|
||||
config.get("block_tags", "StargateTech2:block.shieldController" , "PlaceNormal StopMining").getString();
|
||||
config.get("block_tags", "StargateTech2:block.shield" , "PlaceNormal StopMining").getString();
|
||||
config.get("block_tags", "StargateTech2:block.shieldEmitter" , "PlaceLater StopMining NoBlink").getString();
|
||||
config.get("block_tags", "StargateTech2:block.shieldController" , "PlaceNormal StopMining NoBlink").getString();
|
||||
config.get("block_tags", "StargateTech2:block.shield" , "PlaceNormal StopMining NoBlink").getString();
|
||||
config.get("block_tags", "StargateTech2:block.busAdapter" , "PlaceLatest StopMining").getString();
|
||||
config.get("block_tags", "StargateTech2:block.busCable" , "PlaceNormal StopMining").getString();
|
||||
|
||||
|
@ -183,7 +185,7 @@ public class Dictionary {
|
|||
config.get("block_tags", "deepresonance:resonatingCrystalBlock" , "NoCamouflage").getString();
|
||||
config.get("block_tags", "evilcraft:bloodInfuser" , "NoCamouflage").getString();
|
||||
config.get("block_tags", "evilcraft:darkOre" , "NoCamouflage").getString();
|
||||
config.get("block_tags", "evilcraft:sanguinaryEnvironmentalAccumulator", "NoCamouflage").getString();
|
||||
config.get("block_tags", "evilcraft:sanguinaryEnvironmentalAccumulator" , "NoCamouflage").getString();
|
||||
config.get("block_tags", "evilcraft:spiritReanimator" , "NoCamouflage").getString();
|
||||
config.get("block_tags", "openmodularturrets:baseTierWood" , "NoCamouflage").getString();
|
||||
config.get("block_tags", "openmodularturrets:baseTierOneBlock" , "NoCamouflage").getString();
|
||||
|
@ -361,6 +363,7 @@ public class Dictionary {
|
|||
BLOCKS_STOPMINING = new HashSet<>(taggedBlocks.size());
|
||||
BLOCKS_PLACE = new HashMap<>(taggedBlocks.size());
|
||||
BLOCKS_NOCAMOUFLAGE = new HashSet<>(taggedBlocks.size());
|
||||
BLOCKS_NOBLINK = new HashSet<>(taggedBlocks.size());
|
||||
for (final Entry<String, String> taggedBlock : taggedBlocks.entrySet()) {
|
||||
final Block block = Block.getBlockFromName(taggedBlock.getKey());
|
||||
if (block == null) {
|
||||
|
@ -385,6 +388,7 @@ public class Dictionary {
|
|||
case "PlaceLater" : BLOCKS_PLACE.put(block, 3); break;
|
||||
case "PlaceLatest" : BLOCKS_PLACE.put(block, 4); break;
|
||||
case "NoCamouflage" : BLOCKS_NOCAMOUFLAGE.add(block); break;
|
||||
case "NoBlink" : BLOCKS_NOBLINK.add(block); break;
|
||||
default:
|
||||
WarpDrive.logger.error("Unsupported tag '" + tag + "' for block " + block);
|
||||
break;
|
||||
|
|
|
@ -356,10 +356,39 @@ public class WarpDriveConfig {
|
|||
public static int IC2_REACTOR_COOLING_INTERVAL_TICKS = 10;
|
||||
|
||||
// Transporter
|
||||
public static int TRANSPORTER_MAX_ENERGY_STORED = 1000000;
|
||||
public static boolean TRANSPORTER_USE_RELATIVE_COORDS = true;
|
||||
public static double TRANSPORTER_ENERGY_PER_BLOCK = 100.0;
|
||||
public static double TRANSPORTER_MAX_BOOST_MUL = 4.0;
|
||||
public static int TRANSPORTER_MAX_ENERGY_STORED = 2000000;
|
||||
public static int TRANSPORTER_ENERGY_STORED_UPGRADE_BONUS = TRANSPORTER_MAX_ENERGY_STORED / 2;
|
||||
public static int TRANSPORTER_ENERGY_STORED_UPGRADE_MAX_QUANTITY = 8;
|
||||
public static int TRANSPORTER_RANGE_BASE_BLOCKS = 128;
|
||||
public static int TRANSPORTER_RANGE_UPGRADE_BLOCKS = 16;
|
||||
public static int TRANSPORTER_RANGE_UPGRADE_MAX_QUANTITY = 8;
|
||||
public static double TRANSPORTER_ACQUIRING_ENERGY_FACTOR = 0.02D;
|
||||
public static int TRANSPORTER_JAMMED_COOLDOWN_TICKS = 2 * 20;
|
||||
public static int TRANSPORTER_TRANSFER_ENERGY_AT_MIN_RANGE = 100000;
|
||||
public static int TRANSPORTER_TRANSFER_ENERGY_AT_MAX_RANGE = 1000000;
|
||||
public static double TRANSPORTER_TRANSFER_ENERGY_FACTOR_MAX = 10.0D;
|
||||
public static int TRANSPORTER_TRANSFER_FAILURE_MAX_DAMAGE = 5;
|
||||
public static double TRANSPORTER_TRANSFER_SUCCESS_LOCK_BONUS = 0.20D;
|
||||
public static int TRANSPORTER_TRANSFER_SUCCESS_MAX_DAMAGE = 100;
|
||||
public static double TRANSPORTER_TRANSFER_LOCKING_LOST = 0.5D;
|
||||
public static int TRANSPORTER_TRANSFER_WARMUP_TICKS = 3 * 20;
|
||||
public static int TRANSPORTER_TRANSFER_RELEASE_TICKS = 2 * 20;
|
||||
public static int TRANSPORTER_TRANSFER_COOLDOWN_TICKS = 10 * 20;
|
||||
public static double TRANSPORTER_ENTITY_MOVEMENT_TOLERANCE_BLOCKS = 1.0D;
|
||||
public static int TRANSPORTER_ENTITY_GRAB_RADIUS_BLOCKS = 2;
|
||||
public static int TRANSPORTER_FOCUS_SEARCH_RADIUS_BLOCKS = 2;
|
||||
public static double TRANSPORTER_LOCKING_STRENGTH_FACTOR_PER_TICK = 0.999D; // natural decay
|
||||
public static double TRANSPORTER_LOCKING_STRENGTH_IN_WILDERNESS = 0.25D;
|
||||
public static double TRANSPORTER_LOCKING_STRENGTH_AT_FOCUS = 0.5D;
|
||||
public static double TRANSPORTER_LOCKING_STRENGTH_AT_TRANSPORTER = 1.0D;
|
||||
public static double TRANSPORTER_LOCKING_STRENGTH_BONUS_AT_MAX_ENERGY_FACTOR = 0.5D;
|
||||
public static double TRANSPORTER_LOCKING_STRENGTH_UPGRADE = 0.15D;
|
||||
public static double TRANSPORTER_LOCKING_SPEED_IN_WILDERNESS = 0.25D;
|
||||
public static double TRANSPORTER_LOCKING_SPEED_AT_FOCUS = 0.75D;
|
||||
public static double TRANSPORTER_LOCKING_SPEED_AT_TRANSPORTER = 1.0D;
|
||||
public static double TRANSPORTER_LOCKING_SPEED_UPGRADE = 0.25D;
|
||||
public static int TRANSPORTER_LOCKING_SPEED_OPTIMAL_TICKS = 5 * 20;
|
||||
public static int TRANSPORTER_LOCKING_UPGRADE_MAX_QUANTITY = 2;
|
||||
|
||||
// Enantiomorphic power reactor
|
||||
public static int ENAN_REACTOR_MAX_ENERGY_STORED = 100000000;
|
||||
|
@ -942,11 +971,10 @@ public class WarpDriveConfig {
|
|||
// Transporter
|
||||
TRANSPORTER_MAX_ENERGY_STORED = Commons.clamp(1, Integer.MAX_VALUE,
|
||||
config.get("transporter", "max_energy_stored", TRANSPORTER_MAX_ENERGY_STORED, "Maximum energy stored").getInt());
|
||||
TRANSPORTER_USE_RELATIVE_COORDS = config.get("transporter", "use_relative_coords", TRANSPORTER_USE_RELATIVE_COORDS, "Should transporter use relative coordinates?").getBoolean(true);
|
||||
TRANSPORTER_ENERGY_PER_BLOCK = Commons.clamp(1.0D, TRANSPORTER_MAX_ENERGY_STORED / 10.0D,
|
||||
config.get("transporter", "energy_per_block", TRANSPORTER_ENERGY_PER_BLOCK, "Energy cost per block distance").getDouble(100.0D));
|
||||
TRANSPORTER_MAX_BOOST_MUL = Commons.clamp(1.0D, 1000.0D,
|
||||
config.get("transporter", "max_boost", TRANSPORTER_MAX_BOOST_MUL, "Maximum energy boost allowed").getDouble(4.0));
|
||||
// TRANSPORTER_ENERGY_PER_BLOCK = Commons.clamp(1.0D, TRANSPORTER_MAX_ENERGY_STORED / 10.0D,
|
||||
// config.get("transporter", "energy_per_block", TRANSPORTER_ENERGY_PER_BLOCK, "Energy cost per block distance").getDouble(100.0D));
|
||||
// TRANSPORTER_MAX_BOOST_MUL = Commons.clamp(1.0D, 1000.0D,
|
||||
// config.get("transporter", "max_boost", TRANSPORTER_MAX_BOOST_MUL, "Maximum energy boost allowed").getDouble(4.0));
|
||||
|
||||
// Enantiomorphic reactor
|
||||
ENAN_REACTOR_MAX_ENERGY_STORED = Commons.clamp(1, Integer.MAX_VALUE,
|
||||
|
|
45
src/main/java/cr0s/warpdrive/data/EnumTransporterState.java
Normal file
45
src/main/java/cr0s/warpdrive/data/EnumTransporterState.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package cr0s.warpdrive.data;
|
||||
|
||||
import cr0s.warpdrive.api.IStringSerializable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
|
||||
public enum EnumTransporterState implements IStringSerializable {
|
||||
|
||||
DISABLED (0, "disabled"), // disabled
|
||||
IDLE (1, "idle"), // enabling, waiting for lock
|
||||
ACQUIRING (2, "acquiring"), // acquiring lock
|
||||
ENERGIZING (3, "energizing"); // transferring entities
|
||||
|
||||
private final int metadata;
|
||||
private final String unlocalizedName;
|
||||
|
||||
// cached values
|
||||
public static final int length;
|
||||
private static final HashMap<Integer, EnumTransporterState> ID_MAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
length = EnumTransporterState.values().length;
|
||||
for (final EnumTransporterState transporterState : values()) {
|
||||
ID_MAP.put(transporterState.ordinal(), transporterState);
|
||||
}
|
||||
}
|
||||
|
||||
EnumTransporterState(final int metadata, final String unlocalizedName) {
|
||||
this.metadata = metadata;
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
}
|
||||
|
||||
public int getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public static EnumTransporterState get(final int id) {
|
||||
return ID_MAP.get(id);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() { return unlocalizedName; }
|
||||
}
|
|
@ -8,13 +8,11 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.ChunkProviderServer;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
|
@ -209,6 +207,13 @@ public class VectorI implements Cloneable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public VectorI translate(final EnumFacing side) {
|
||||
x += side.getFrontOffsetX();
|
||||
y += side.getFrontOffsetY();
|
||||
z += side.getFrontOffsetZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
// return a new vector adding both parts
|
||||
public static VectorI add(final VectorI vector1, final VectorI vector2) {
|
||||
return new VectorI(vector1.x + vector2.x, vector1.y + vector2.y, vector1.z + vector2.z);
|
||||
|
@ -279,13 +284,13 @@ public class VectorI implements Cloneable {
|
|||
return vector;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
public void readFromNBT(final NBTTagCompound nbtTagCompound) {
|
||||
x = nbtTagCompound.getInteger("x");
|
||||
y = nbtTagCompound.getInteger("y");
|
||||
z = nbtTagCompound.getInteger("z");
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound) {
|
||||
public NBTTagCompound writeToNBT(final NBTTagCompound nbtTagCompound) {
|
||||
nbtTagCompound.setInteger("x", x);
|
||||
nbtTagCompound.setInteger("y", y);
|
||||
nbtTagCompound.setInteger("z", z);
|
||||
|
@ -308,11 +313,11 @@ public class VectorI implements Cloneable {
|
|||
return (newX * newX + newY * newY + newZ * newZ);
|
||||
}
|
||||
|
||||
public int distance2To(final Entity entity) {
|
||||
int newX = (int) (Math.round(entity.posX)) - x;
|
||||
int newY = (int) (Math.round(entity.posY)) - y;
|
||||
int newZ = (int) (Math.round(entity.posZ)) - z;
|
||||
return (newX * newX + newY * newY + newZ * newZ);
|
||||
public double distance2To(final Entity entity) {
|
||||
final double newX = entity.posX - x;
|
||||
final double newY = entity.posY - y;
|
||||
final double newZ = entity.posZ - z;
|
||||
return newX * newX + newY * newY + newZ * newZ;
|
||||
}
|
||||
|
||||
public int distance2To(final TileEntity tileEntity) {
|
||||
|
|
Loading…
Reference in a new issue