interdimensional teleporters yeah

This commit is contained in:
Boblet 2022-12-20 10:41:37 +01:00
parent d2f36ed784
commit 08076885cf
5 changed files with 115 additions and 10 deletions

View File

@ -62,7 +62,7 @@ public class MachineTeleporter extends BlockContainer implements ILookOverlay {
text.add(EnumChatFormatting.RED + "No destination set!");
} else {
text.add((tele.power >= tele.consumption ? EnumChatFormatting.GREEN : EnumChatFormatting.RED) + String.format("%,d", tele.power) + " / " + String.format("%,d", tele.maxPower));
text.add("Destination: " + tele.targetX + " / " + tele.targetY + " / " + tele.targetZ);
text.add("Destination: " + tele.targetX + " / " + tele.targetY + " / " + tele.targetZ + " (D: " + tele.targetDim + ")");
}
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);

View File

@ -174,8 +174,7 @@ public class AssemblerRecipes {
makeRecipe(new ComparableStack(ModItems.rtg_unit, 1), new AStack[] {new ComparableStack(ModItems.thermo_element, 2), new ComparableStack(ModItems.board_copper, 1), new OreDictStack(PB.ingot(), 2), new OreDictStack(STEEL.plate(), 2), new ComparableStack(ModItems.circuit_copper, 1), },100);
makeRecipe(new ComparableStack(ModItems.levitation_unit, 1), new AStack[] {new ComparableStack(ModItems.coil_copper, 4), new ComparableStack(ModItems.coil_tungsten, 2), new OreDictStack(TI.plate(), 6), new ComparableStack(ModItems.nugget_schrabidium, 2), },100);
makeRecipe(new ComparableStack(ModItems.drill_titanium, 1), new AStack[] {new OreDictStack(STEEL.ingot(), 2), new OreDictStack(DURA.ingot(), 2), new ComparableStack(ModItems.bolt_dura_steel, 2), new OreDictStack(TI.plate(), 6), },100);
makeRecipe(new ComparableStack(ModItems.telepad, 1), new AStack[] {new OreDictStack(ANY_PLASTIC.ingot(), 12), new OreDictStack(SA326.plate(), 2), new OreDictStack(CMB.plate(), 4), new OreDictStack(STEEL.plate(), 2), new ComparableStack(ModItems.wire_gold, 6), new ComparableStack(ModItems.circuit_schrabidium, 1), },300);
makeRecipe(new ComparableStack(ModItems.entanglement_kit, 1), new AStack[] {new ComparableStack(ModItems.coil_magnetized_tungsten, 6), new OreDictStack(PB.plate(), 16), new OreDictStack(OreDictManager.getReflector(), 4), new ComparableStack(ModItems.singularity_counter_resonant, 1), new ComparableStack(ModItems.singularity_super_heated, 1), new ComparableStack(ModItems.powder_power, 4), },200);
makeRecipe(new ComparableStack(ModItems.entanglement_kit, 1), new AStack[] {new OreDictStack(STEEL.plate(), 8), new OreDictStack(DURA.ingot(), 4), new OreDictStack(CU.plate(), 24), new ComparableStack(ModBlocks.hadron_coil_gold, 4), new OreDictStack(Fluids.XENON.getDict(1_000))},200);
makeRecipe(new ComparableStack(ModItems.dysfunctional_reactor, 1), new AStack[] {new OreDictStack(STEEL.plate(), 15), new OreDictStack(PB.ingot(), 5), new ComparableStack(ModItems.rod_quad_empty, 10), new OreDictStack("dyeBrown", 3), },200);
makeRecipe(new ComparableStack(ModItems.missile_assembly, 1), new AStack[] {new ComparableStack(ModItems.hull_small_steel, 1), new ComparableStack(ModItems.hull_small_aluminium, 4), new OreDictStack(STEEL.ingot(), 2), new OreDictStack(TI.plate(), 6), new ComparableStack(ModItems.wire_aluminium, 6), new ComparableStack(ModItems.canister_full, 3, Fluids.KEROSENE.getID()), new ComparableStack(ModItems.circuit_targeting_tier1, 1), },200);
makeRecipe(new ComparableStack(ModItems.missile_carrier, 1), new AStack[] {new ComparableStack(ModItems.fluid_barrel_full, 16, Fluids.KEROSENE.getID()), new ComparableStack(ModItems.thruster_medium, 4), new ComparableStack(ModItems.thruster_large, 1), new ComparableStack(ModItems.hull_big_titanium, 6), new ComparableStack(ModItems.hull_big_steel, 2), new ComparableStack(ModItems.hull_small_aluminium, 12), new OreDictStack(TI.plate(), 24), new ComparableStack(ModItems.plate_polymer, 128), new ComparableStack(ModBlocks.det_cord, 8), new ComparableStack(ModItems.circuit_targeting_tier3, 12), new ComparableStack(ModItems.circuit_targeting_tier4, 3), },4800);
@ -295,7 +294,7 @@ public class AssemblerRecipes {
makeRecipe(new ComparableStack(ModBlocks.machine_drill, 1), new AStack[] {new ComparableStack(ModBlocks.steel_scaffold, 6), new OreDictStack(STEEL.ingot(), 4), new ComparableStack(ModItems.wire_red_copper, 4), new ComparableStack(ModItems.circuit_copper, 1), new ComparableStack(ModItems.motor, 1), new OreDictStack(DURA.ingot(), 2), new ComparableStack(ModItems.bolt_dura_steel, 2), new ComparableStack(ModItems.drill_titanium, 1), },200);
makeRecipe(new ComparableStack(ModBlocks.machine_mining_laser, 1), new AStack[] {new ComparableStack(ModItems.tank_steel, 3), new OreDictStack(STEEL.plate(), 16), new ComparableStack(ModItems.crystal_redstone, 3), new ComparableStack(Items.diamond, 3), new OreDictStack(ANY_PLASTIC.ingot(), 4), new ComparableStack(ModItems.motor, 3), new OreDictStack(DURA.ingot(), 4), new ComparableStack(ModItems.bolt_dura_steel, 6), new ComparableStack(ModBlocks.machine_battery, 3), },400);
makeRecipe(new ComparableStack(ModBlocks.machine_turbofan, 1), new AStack[] {new ComparableStack(ModItems.hull_big_steel, 1), new ComparableStack(ModItems.hull_big_titanium, 3), new ComparableStack(ModItems.hull_small_steel, 2), new ComparableStack(ModItems.turbine_tungsten, 1), new ComparableStack(ModItems.turbine_titanium, 7), new ComparableStack(ModItems.bolt_compound, 8), new OreDictStack(MINGRADE.ingot(), 12), new ComparableStack(ModItems.wire_red_copper, 24), },500);
makeRecipe(new ComparableStack(ModBlocks.machine_teleporter, 1), new AStack[] {new OreDictStack(TI.ingot(), 6), new OreDictStack(ALLOY.plate(), 12), new OreDictStack(CMB.plate(), 4), new ComparableStack(ModItems.telepad, 1), new ComparableStack(ModItems.entanglement_kit, 1), new ComparableStack(ModBlocks.machine_battery, 2), new ComparableStack(ModItems.coil_magnetized_tungsten, 4), },300);
makeRecipe(new ComparableStack(ModBlocks.machine_teleporter, 1), new AStack[] {new OreDictStack(TI.ingot(), 8), new OreDictStack(ALLOY.plate(), 12), new ComparableStack(ModItems.wire_gold, 32), new ComparableStack(ModItems.entanglement_kit, 1), new ComparableStack(ModBlocks.machine_battery, 1) },300);
makeRecipe(new ComparableStack(ModBlocks.machine_schrabidium_transmutator, 1), new AStack[] {new OreDictStack(MAGTUNG.ingot(), 1), new OreDictStack(TI.ingot(), 24), new OreDictStack(ALLOY.plate(), 18), new OreDictStack(STEEL.plate(), 12), new ComparableStack(ModItems.plate_desh, 6), new OreDictStack(RUBBER.ingot(), 8), new ComparableStack(ModBlocks.machine_battery, 5), new ComparableStack(ModItems.circuit_gold, 5), },500);
makeRecipe(new ComparableStack(ModBlocks.machine_combine_factory, 1), new AStack[] {new OreDictStack(STEEL.ingot(), 8), new OreDictStack(ANY_PLASTIC.ingot(), 6), new OreDictStack(TI.plate(), 4), new OreDictStack(CU.plate(), 6), new ComparableStack(ModItems.circuit_gold, 6), new ComparableStack(ModItems.coil_advanced_alloy, 8), new ComparableStack(ModItems.coil_tungsten, 4), new OreDictStack(MAGTUNG.ingot(), 12), },150);
makeRecipe(new ComparableStack(ModBlocks.fusion_conductor, 1), new AStack[] {new OreDictStack(STEEL.ingot(), 2), new ComparableStack(ModItems.coil_advanced_alloy, 5), },150);

View File

@ -696,7 +696,7 @@ public class ModItems {
public static Item shimmer_axe_head;
public static Item shimmer_handle;
public static Item telepad;
//public static Item telepad;
public static Item entanglement_kit;
public static Item stamp_stone_flat;
@ -3165,7 +3165,7 @@ public class ModItems {
shimmer_axe_head = new Item().setUnlocalizedName("shimmer_axe_head").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":shimmer_axe_head");
shimmer_handle = new Item().setUnlocalizedName("shimmer_handle").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":shimmer_handle");
telepad = new Item().setUnlocalizedName("telepad").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":telepad");
//telepad = new Item().setUnlocalizedName("telepad").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":telepad");
entanglement_kit = new ItemCustomLore().setUnlocalizedName("entanglement_kit").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":entanglement_kit");
circuit_raw = new Item().setUnlocalizedName("circuit_raw").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_raw");
@ -6273,7 +6273,7 @@ public class ModItems {
GameRegistry.registerItem(plant_item, plant_item.getUnlocalizedName());
//Teleporter Parts
GameRegistry.registerItem(telepad, telepad.getUnlocalizedName());
//GameRegistry.registerItem(telepad, telepad.getUnlocalizedName());
GameRegistry.registerItem(entanglement_kit, entanglement_kit.getUnlocalizedName());
//AMS Parts

View File

@ -31,6 +31,7 @@ public class ItemTeleLink extends Item {
stack.stackTagCompound.setInteger("x", x);
stack.stackTagCompound.setInteger("y", y);
stack.stackTagCompound.setInteger("z", z);
stack.stackTagCompound.setInteger("dim", player.dimension);
world.playSoundAtEntity(player, "hbm:item.techBleep", 1.0F, 1.0F);
player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "[TeleLink] Set teleporter exit to " + x + ", " + y + ", " + z + "."));
player.swingItem();
@ -48,12 +49,14 @@ public class ItemTeleLink extends Item {
int x1 = stack.stackTagCompound.getInteger("x");
int y1 = stack.stackTagCompound.getInteger("y");
int z1 = stack.stackTagCompound.getInteger("z");
int dim = stack.stackTagCompound.getInteger("dim");
TileEntityMachineTeleporter tele = (TileEntityMachineTeleporter) te;
tele.targetX = x1;
tele.targetY = y1;
tele.targetZ = z1;
tele.targetDim = dim;
tele.markDirty();
world.playSoundAtEntity(player, "hbm:item.techBleep", 1.0F, 1.0F);
@ -72,6 +75,7 @@ public class ItemTeleLink extends Item {
list.add("X: " + itemstack.stackTagCompound.getInteger("x"));
list.add("Y: " + itemstack.stackTagCompound.getInteger("y"));
list.add("Z: " + itemstack.stackTagCompound.getInteger("z"));
list.add("D: " + itemstack.stackTagCompound.getInteger("dim"));
} else {
list.add(EnumChatFormatting.RED + "Select exit location first!");
}

View File

@ -1,15 +1,25 @@
package com.hbm.tileentity.machine;
import java.util.Iterator;
import java.util.List;
import com.hbm.tileentity.INBTPacketReceiver;
import com.hbm.tileentity.TileEntityLoadedBase;
import api.hbm.energy.IEnergyUser;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.play.server.S07PacketRespawn;
import net.minecraft.network.play.server.S1DPacketEntityEffect;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.management.ServerConfigurationManager;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.WorldServer;
public class TileEntityMachineTeleporter extends TileEntityLoadedBase implements IEnergyUser, INBTPacketReceiver {
@ -17,6 +27,7 @@ public class TileEntityMachineTeleporter extends TileEntityLoadedBase implements
public int targetX = -1;
public int targetY = -1;
public int targetZ = -1;
public int targetDim = 0;
public static final int maxPower = 1_500_000;
public static final int consumption = 1_000_000;
@ -28,6 +39,7 @@ public class TileEntityMachineTeleporter extends TileEntityLoadedBase implements
targetX = nbt.getInteger("x1");
targetY = nbt.getInteger("y1");
targetZ = nbt.getInteger("z1");
targetDim = nbt.getInteger("dim");
}
@Override
@ -38,6 +50,7 @@ public class TileEntityMachineTeleporter extends TileEntityLoadedBase implements
nbt.setInteger("x1", targetX);
nbt.setInteger("y1", targetY);
nbt.setInteger("z1", targetZ);
nbt.setInteger("dim", targetDim);
}
@Override
@ -58,7 +71,7 @@ public class TileEntityMachineTeleporter extends TileEntityLoadedBase implements
NBTTagCompound data = new NBTTagCompound();
data.setLong("power", power);
data.setIntArray("target", new int[] {targetX, targetY, targetZ});
data.setIntArray("target", new int[] {targetX, targetY, targetZ, targetDim});
INBTPacketReceiver.networkPack(this, data, 15);
} else {
@ -79,6 +92,7 @@ public class TileEntityMachineTeleporter extends TileEntityLoadedBase implements
this.targetX = target[0];
this.targetX = target[1];
this.targetX = target[2];
this.targetDim = target[3];
}
public void teleport(Entity entity) {
@ -88,9 +102,21 @@ public class TileEntityMachineTeleporter extends TileEntityLoadedBase implements
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, "mob.endermen.portal", 1.0F, 1.0F);
if((entity instanceof EntityPlayerMP)) {
((EntityPlayerMP) entity).setPositionAndUpdate(this.targetX + 0.5D, this.targetY + 1D + entity.getYOffset(), this.targetZ + 0.5D);
EntityPlayerMP player = (EntityPlayerMP) entity;
if(entity.dimension == this.targetDim) {
player.setPositionAndUpdate(this.targetX + 0.5D, this.targetY + 1D + entity.getYOffset(), this.targetZ + 0.5D);
} else {
teleportPlayerInterdimensionally(player, this.targetX + 0.5D, this.targetY + 1D + entity.getYOffset(), this.targetZ + 0.5D, this.targetDim);
}
} else {
entity.setPositionAndRotation(this.targetX + 0.5D, this.targetY + 1D + entity.getYOffset(), this.targetZ + 0.5D, entity.rotationYaw, entity.rotationPitch);
if(entity.dimension == this.targetDim) {
entity.setPositionAndRotation(this.targetX + 0.5D, this.targetY + 1D + entity.getYOffset(), this.targetZ + 0.5D, entity.rotationYaw, entity.rotationPitch);
} else {
teleportEntityInterdimensionally(entity, this.targetX + 0.5D, this.targetY + 1D + entity.getYOffset(), this.targetZ + 0.5D, this.targetDim);
}
}
worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
@ -98,6 +124,82 @@ public class TileEntityMachineTeleporter extends TileEntityLoadedBase implements
this.power -= consumption;
this.markDirty();
}
/** Teleports a player to a different dimension, gracefully copied from ServerConfigurationManager */
public static boolean teleportPlayerInterdimensionally(EntityPlayerMP player, double x, double y, double z, int dim) {
int prevDim = player.dimension;
WorldServer prevWorld = player.mcServer.worldServerForDimension(prevDim);
WorldServer newWorld = player.mcServer.worldServerForDimension(dim);
if(newWorld == null) return false;
ServerConfigurationManager man = player.mcServer.getConfigurationManager();
NetHandlerPlayServer net = player.playerNetServerHandler;
net.sendPacket(new S07PacketRespawn(player.dimension, player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), player.theItemInWorldManager.getGameType()));
prevWorld.removePlayerEntityDangerously(player);
player.isDead = false;
if(player.isEntityAlive()) {
player.setLocationAndAngles(x, y, z, player.rotationYaw, player.rotationPitch);
newWorld.spawnEntityInWorld(player);
newWorld.updateEntityWithOptionalForce(player, false);
}
player.setWorld(newWorld);
man.func_72375_a(player, prevWorld);
net.setPlayerLocation(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
player.theItemInWorldManager.setWorld(newWorld);
man.updateTimeAndWeatherForPlayer(player, newWorld);
man.syncPlayerInventory(player);
Iterator iterator = player.getActivePotionEffects().iterator();
while(iterator.hasNext()) {
PotionEffect potioneffect = (PotionEffect) iterator.next();
player.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(player.getEntityId(), potioneffect));
}
FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, prevDim, dim);
return true;
}
/** Teleports non-player entities to different dimensions, gracefully copied from Entity */
public static boolean teleportEntityInterdimensionally(Entity oldEntity, double x, double y, double z, int dim) {
MinecraftServer minecraftserver = MinecraftServer.getServer();
int prevDim = oldEntity.dimension;
WorldServer prevWorld = minecraftserver.worldServerForDimension(prevDim);
WorldServer newWorld = minecraftserver.worldServerForDimension(dim);
if(newWorld == null) return false;
if(dim == 1 && prevDim == 1) {
newWorld = minecraftserver.worldServerForDimension(0);
oldEntity.dimension = 0;
}
oldEntity.worldObj.removeEntity(oldEntity);
oldEntity.isDead = false;
minecraftserver.getConfigurationManager().transferEntityToWorld(oldEntity, prevDim, prevWorld, newWorld);
Entity entity = EntityList.createEntityByName(EntityList.getEntityString(oldEntity), newWorld);
if(entity != null) {
entity.copyDataFrom(oldEntity, true);
if(dim == 1 && prevDim == 1) {
entity.setLocationAndAngles(x, y, z, entity.rotationYaw, entity.rotationPitch);
}
newWorld.spawnEntityInWorld(entity);
}
entity.isDead = true;
prevWorld.resetUpdateEntityTick();
newWorld.resetUpdateEntityTick();
return true;
}
@Override
public void setPower(long i) {