Work on things, may be unstable
This commit is contained in:
parent
5e50e920a6
commit
c2737ff064
16 changed files with 311 additions and 60 deletions
26
common/mekanism/client/ClientPlayerTracker.java
Normal file
26
common/mekanism/client/ClientPlayerTracker.java
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package mekanism.client;
|
||||||
|
|
||||||
|
import mekanism.common.Mekanism;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import cpw.mods.fml.common.IPlayerTracker;
|
||||||
|
|
||||||
|
public class ClientPlayerTracker implements IPlayerTracker
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onPlayerLogin(EntityPlayer player) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerLogout(EntityPlayer player)
|
||||||
|
{
|
||||||
|
Mekanism.jetpackOn.remove(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerChangedDimension(EntityPlayer player)
|
||||||
|
{
|
||||||
|
Mekanism.jetpackOn.remove(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerRespawn(EntityPlayer player) {}
|
||||||
|
}
|
|
@ -54,6 +54,7 @@ import mekanism.client.render.tileentity.RenderMetallurgicInfuser;
|
||||||
import mekanism.client.render.tileentity.RenderObsidianTNT;
|
import mekanism.client.render.tileentity.RenderObsidianTNT;
|
||||||
import mekanism.client.render.tileentity.RenderPressurizedTube;
|
import mekanism.client.render.tileentity.RenderPressurizedTube;
|
||||||
import mekanism.client.render.tileentity.RenderRotaryCondensentrator;
|
import mekanism.client.render.tileentity.RenderRotaryCondensentrator;
|
||||||
|
import mekanism.client.render.tileentity.RenderTeleporter;
|
||||||
import mekanism.client.render.tileentity.RenderUniversalCable;
|
import mekanism.client.render.tileentity.RenderUniversalCable;
|
||||||
import mekanism.client.sound.Sound;
|
import mekanism.client.sound.Sound;
|
||||||
import mekanism.client.sound.SoundHandler;
|
import mekanism.client.sound.SoundHandler;
|
||||||
|
@ -109,6 +110,7 @@ import cpw.mods.fml.client.registry.ClientRegistry;
|
||||||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
import cpw.mods.fml.common.registry.TickRegistry;
|
import cpw.mods.fml.common.registry.TickRegistry;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
@ -255,6 +257,7 @@ public class ClientProxy extends CommonProxy
|
||||||
ClientRegistry.registerTileEntity(TileEntityBin.class, "Bin", new RenderBin());
|
ClientRegistry.registerTileEntity(TileEntityBin.class, "Bin", new RenderBin());
|
||||||
ClientRegistry.registerTileEntity(TileEntityDigitalMiner.class, "DigitalMiner", new RenderDigitalMiner());
|
ClientRegistry.registerTileEntity(TileEntityDigitalMiner.class, "DigitalMiner", new RenderDigitalMiner());
|
||||||
ClientRegistry.registerTileEntity(TileEntityRotaryCondensentrator.class, "RotaryCondensentrator", new RenderRotaryCondensentrator());
|
ClientRegistry.registerTileEntity(TileEntityRotaryCondensentrator.class, "RotaryCondensentrator", new RenderRotaryCondensentrator());
|
||||||
|
ClientRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter", new RenderTeleporter());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -381,6 +384,8 @@ public class ClientProxy extends CommonProxy
|
||||||
NetworkRegistry.instance().registerConnectionHandler(new ClientConnectionHandler());
|
NetworkRegistry.instance().registerConnectionHandler(new ClientConnectionHandler());
|
||||||
|
|
||||||
KeyBindingRegistry.registerKeyBinding(new MekanismKeyHandler());
|
KeyBindingRegistry.registerKeyBinding(new MekanismKeyHandler());
|
||||||
|
|
||||||
|
GameRegistry.registerPlayerTracker(new ClientPlayerTracker());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer
|
||||||
toReturn.baseBlock = Block.stone;
|
toReturn.baseBlock = Block.stone;
|
||||||
toReturn.setTexture(MekanismRenderer.getColorIcon(color));
|
toReturn.setTexture(MekanismRenderer.getColorIcon(color));
|
||||||
|
|
||||||
DisplayInteger display = new DisplayInteger();
|
DisplayInteger display = DisplayInteger.createAndStart();
|
||||||
|
|
||||||
if(cachedOverlays.containsKey(side))
|
if(cachedOverlays.containsKey(side))
|
||||||
{
|
{
|
||||||
|
@ -118,9 +118,6 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer
|
||||||
cachedOverlays.put(side, map);
|
cachedOverlays.put(side, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
display.display = GLAllocation.generateDisplayLists(1);
|
|
||||||
GL11.glNewList(display.display, 4864);
|
|
||||||
|
|
||||||
switch(side)
|
switch(side)
|
||||||
{
|
{
|
||||||
case DOWN:
|
case DOWN:
|
||||||
|
@ -196,7 +193,7 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
MekanismRenderer.renderObject(toReturn);
|
MekanismRenderer.renderObject(toReturn);
|
||||||
GL11.glEndList();
|
display.endList();
|
||||||
|
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import mekanism.common.util.MekanismUtils.ResourceType;
|
||||||
import mekanism.common.util.TransporterUtils;
|
import mekanism.common.util.TransporterUtils;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.GLAllocation;
|
|
||||||
import net.minecraft.client.renderer.entity.RenderItem;
|
import net.minecraft.client.renderer.entity.RenderItem;
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
|
@ -215,7 +214,7 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
|
||||||
toReturn.baseBlock = Block.stone;
|
toReturn.baseBlock = Block.stone;
|
||||||
toReturn.setTexture(icon);
|
toReturn.setTexture(icon);
|
||||||
|
|
||||||
DisplayInteger display = new DisplayInteger();
|
DisplayInteger display = DisplayInteger.createAndStart();
|
||||||
|
|
||||||
if(cachedOverlays.containsKey(side))
|
if(cachedOverlays.containsKey(side))
|
||||||
{
|
{
|
||||||
|
@ -227,9 +226,6 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
|
||||||
cachedOverlays.put(side, map);
|
cachedOverlays.put(side, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
display.display = GLAllocation.generateDisplayLists(1);
|
|
||||||
GL11.glNewList(display.display, 4864);
|
|
||||||
|
|
||||||
switch(side)
|
switch(side)
|
||||||
{
|
{
|
||||||
case DOWN:
|
case DOWN:
|
||||||
|
@ -305,7 +301,7 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
MekanismRenderer.renderObject(toReturn);
|
MekanismRenderer.renderObject(toReturn);
|
||||||
GL11.glEndList();
|
display.endList();
|
||||||
|
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,7 +249,7 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
MekanismRenderer.renderObject(toReturn);
|
MekanismRenderer.renderObject(toReturn);
|
||||||
DisplayInteger.endList();
|
displays[i].endList();
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
|
@ -300,7 +300,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
MekanismRenderer.renderObject(toReturn);
|
MekanismRenderer.renderObject(toReturn);
|
||||||
DisplayInteger.endList();
|
display.endList();
|
||||||
|
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
127
common/mekanism/client/render/tileentity/RenderTeleporter.java
Normal file
127
common/mekanism/client/render/tileentity/RenderTeleporter.java
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
package mekanism.client.render.tileentity;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import mekanism.api.EnumColor;
|
||||||
|
import mekanism.api.Object3D;
|
||||||
|
import mekanism.api.gas.GasRegistry;
|
||||||
|
import mekanism.client.render.MekanismRenderer;
|
||||||
|
import mekanism.client.render.MekanismRenderer.DisplayInteger;
|
||||||
|
import mekanism.client.render.MekanismRenderer.Model3D;
|
||||||
|
import mekanism.common.Mekanism;
|
||||||
|
import mekanism.common.tileentity.TileEntityTeleporter;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.renderer.GLAllocation;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
public class RenderTeleporter extends TileEntitySpecialRenderer
|
||||||
|
{
|
||||||
|
private HashMap<Integer, DisplayInteger> cachedOverlays = new HashMap<Integer, DisplayInteger>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
|
||||||
|
{
|
||||||
|
renderAModelAt((TileEntityTeleporter)tileEntity, x, y, z, partialTick);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderAModelAt(TileEntityTeleporter tileEntity, double x, double y, double z, float partialTick)
|
||||||
|
{
|
||||||
|
if(tileEntity.shouldRender)
|
||||||
|
{
|
||||||
|
push();
|
||||||
|
|
||||||
|
GL11.glColor4f(EnumColor.PURPLE.getColor(0), EnumColor.PURPLE.getColor(1), EnumColor.PURPLE.getColor(2), 0.75F);
|
||||||
|
|
||||||
|
bindTexture(MekanismRenderer.getBlocksTexture());
|
||||||
|
GL11.glTranslatef((float)x, (float)y, (float)z);
|
||||||
|
|
||||||
|
Object3D obj = Object3D.get(tileEntity).getFromSide(ForgeDirection.WEST);
|
||||||
|
int type = 0;
|
||||||
|
|
||||||
|
if(obj.getBlockId(tileEntity.worldObj) == Mekanism.basicBlockID && obj.getMetadata(tileEntity.worldObj) == 7)
|
||||||
|
{
|
||||||
|
type = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int display = getOverlayDisplay(type).display;
|
||||||
|
GL11.glCallList(display);
|
||||||
|
|
||||||
|
pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pop()
|
||||||
|
{
|
||||||
|
GL11.glPopAttrib();
|
||||||
|
MekanismRenderer.glowOff();
|
||||||
|
MekanismRenderer.blendOff();
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void push()
|
||||||
|
{
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||||
|
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
MekanismRenderer.glowOn();
|
||||||
|
MekanismRenderer.blendOn();
|
||||||
|
}
|
||||||
|
|
||||||
|
private DisplayInteger getOverlayDisplay(Integer type)
|
||||||
|
{
|
||||||
|
if(cachedOverlays.containsKey(type))
|
||||||
|
{
|
||||||
|
return cachedOverlays.get(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
Model3D toReturn = new Model3D();
|
||||||
|
toReturn.baseBlock = Block.stone;
|
||||||
|
toReturn.setTexture(GasRegistry.getGas("oxygen").getIcon());
|
||||||
|
|
||||||
|
DisplayInteger display = DisplayInteger.createAndStart();
|
||||||
|
|
||||||
|
if(cachedOverlays.containsKey(type))
|
||||||
|
{
|
||||||
|
cachedOverlays.get(type);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cachedOverlays.put(type, display);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
toReturn.minY = 1;
|
||||||
|
toReturn.maxY = 3;
|
||||||
|
|
||||||
|
toReturn.minX = 0.46;
|
||||||
|
toReturn.minZ = 0;
|
||||||
|
toReturn.maxX = 0.54;
|
||||||
|
toReturn.maxZ = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
toReturn.minY = 1;
|
||||||
|
toReturn.maxY = 3;
|
||||||
|
|
||||||
|
toReturn.minX = 0;
|
||||||
|
toReturn.minZ = 0.46;
|
||||||
|
toReturn.maxX = 1;
|
||||||
|
toReturn.maxZ = 0.54;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MekanismRenderer.renderObject(toReturn);
|
||||||
|
display.endList();
|
||||||
|
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,10 @@ public class GasMaskSound extends PlayerSound
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else if(player.worldObj != world)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
else if(!world.loadedEntityList.contains(player))
|
else if(!world.loadedEntityList.contains(player))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -20,6 +20,10 @@ public class JetpackSound extends PlayerSound
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else if(player.worldObj != world)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
else if(!world.loadedEntityList.contains(player))
|
else if(!world.loadedEntityList.contains(player))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package mekanism.client.sound;
|
package mekanism.client.sound;
|
||||||
|
|
||||||
import mekanism.client.ClientPlayerTickHandler;
|
|
||||||
import mekanism.common.item.ItemJetpack;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.world.World;
|
|
||||||
import universalelectricity.core.vector.Vector3;
|
import universalelectricity.core.vector.Vector3;
|
||||||
|
|
||||||
public abstract class PlayerSound extends Sound
|
public abstract class PlayerSound extends Sound
|
||||||
|
@ -39,7 +36,4 @@ public abstract class PlayerSound extends Sound
|
||||||
|
|
||||||
ticksSincePlay = 0;
|
ticksSincePlay = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract boolean update(World world);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,10 @@ public class CommonPlayerTracker implements IPlayerTracker
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerChangedDimension(EntityPlayer player) {}
|
public void onPlayerChangedDimension(EntityPlayer player)
|
||||||
|
{
|
||||||
|
Mekanism.jetpackOn.remove(player);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerRespawn(EntityPlayer player) {}
|
public void onPlayerRespawn(EntityPlayer player) {}
|
||||||
|
|
|
@ -100,6 +100,7 @@ public class CommonProxy
|
||||||
GameRegistry.registerTileEntity(TileEntityDigitalMiner.class, "DigitalMiner");
|
GameRegistry.registerTileEntity(TileEntityDigitalMiner.class, "DigitalMiner");
|
||||||
GameRegistry.registerTileEntity(TileEntityObsidianTNT.class, "ObsidianTNT");
|
GameRegistry.registerTileEntity(TileEntityObsidianTNT.class, "ObsidianTNT");
|
||||||
GameRegistry.registerTileEntity(TileEntityRotaryCondensentrator.class, "RotaryCondensentrator");
|
GameRegistry.registerTileEntity(TileEntityRotaryCondensentrator.class, "RotaryCondensentrator");
|
||||||
|
GameRegistry.registerTileEntity(TileEntityTeleporter.class, "Teleporter");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1084,7 +1084,6 @@ public class Mekanism
|
||||||
//Tile entities
|
//Tile entities
|
||||||
GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock");
|
GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock");
|
||||||
GameRegistry.registerTileEntity(TileEntityAdvancedBoundingBlock.class, "AdvancedBoundingBlock");
|
GameRegistry.registerTileEntity(TileEntityAdvancedBoundingBlock.class, "AdvancedBoundingBlock");
|
||||||
GameRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter");
|
|
||||||
|
|
||||||
//Load tile entities that have special renderers.
|
//Load tile entities that have special renderers.
|
||||||
proxy.registerSpecialTileEntities();
|
proxy.registerSpecialTileEntities();
|
||||||
|
|
|
@ -627,23 +627,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
|
||||||
|
|
||||||
if(tileEntity != null)
|
if(tileEntity != null)
|
||||||
{
|
{
|
||||||
if(metadata == MachineType.TELEPORTER.meta)
|
if(metadata == MachineType.ELECTRIC_CHEST.meta)
|
||||||
{
|
|
||||||
if(entityplayer.isSneaking())
|
|
||||||
{
|
|
||||||
entityplayer.openGui(Mekanism.instance, 13, world, x, y, z);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
TileEntityTeleporter teleporter = (TileEntityTeleporter)tileEntity;
|
|
||||||
|
|
||||||
if(teleporter.canTeleport() == 1)
|
|
||||||
{
|
|
||||||
teleporter.teleport();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(metadata == MachineType.ELECTRIC_CHEST.meta)
|
|
||||||
{
|
{
|
||||||
TileEntityElectricChest electricChest = (TileEntityElectricChest)tileEntity;
|
TileEntityElectricChest electricChest = (TileEntityElectricChest)tileEntity;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import mekanism.common.PacketHandler;
|
||||||
import mekanism.common.Teleporter;
|
import mekanism.common.Teleporter;
|
||||||
import mekanism.common.PacketHandler.Transmission;
|
import mekanism.common.PacketHandler.Transmission;
|
||||||
import mekanism.common.item.ItemPortableTeleporter;
|
import mekanism.common.item.ItemPortableTeleporter;
|
||||||
|
import mekanism.common.tileentity.TileEntityTeleporter;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
@ -15,6 +16,8 @@ import net.minecraft.world.World;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
|
||||||
public class PacketPortableTeleport implements IMekanismPacket
|
public class PacketPortableTeleport implements IMekanismPacket
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,6 +52,11 @@ public class PacketPortableTeleport implements IMekanismPacket
|
||||||
((EntityPlayerMP)player).travelToDimension(coords.dimensionId);
|
((EntityPlayerMP)player).travelToDimension(coords.dimensionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
World teleWorld = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(coords.dimensionId);
|
||||||
|
TileEntityTeleporter teleporter = (TileEntityTeleporter)coords.getTileEntity(teleWorld);
|
||||||
|
|
||||||
|
teleporter.didTeleport.add(player);
|
||||||
|
teleporter.teleDelay = 5;
|
||||||
((EntityPlayerMP)player).playerNetServerHandler.setPlayerLocation(coords.xCoord+0.5, coords.yCoord+1, coords.zCoord+0.5, player.rotationYaw, player.rotationPitch);
|
((EntityPlayerMP)player).playerNetServerHandler.setPlayerLocation(coords.xCoord+0.5, coords.yCoord+1, coords.zCoord+0.5, player.rotationYaw, player.rotationPitch);
|
||||||
|
|
||||||
world.playSoundAtEntity(player, "mob.endermen.portal", 1.0F, 1.0F);
|
world.playSoundAtEntity(player, "mob.endermen.portal", 1.0F, 1.0F);
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package mekanism.common.tileentity;
|
package mekanism.common.tileentity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import mekanism.api.EnumColor;
|
import mekanism.api.EnumColor;
|
||||||
import mekanism.api.Object3D;
|
import mekanism.api.Object3D;
|
||||||
|
@ -11,18 +13,22 @@ import mekanism.common.PacketHandler.Transmission;
|
||||||
import mekanism.common.Teleporter;
|
import mekanism.common.Teleporter;
|
||||||
import mekanism.common.block.BlockMachine.MachineType;
|
import mekanism.common.block.BlockMachine.MachineType;
|
||||||
import mekanism.common.network.PacketPortalFX;
|
import mekanism.common.network.PacketPortalFX;
|
||||||
|
import mekanism.common.network.PacketTileEntity;
|
||||||
import mekanism.common.util.ChargeUtils;
|
import mekanism.common.util.ChargeUtils;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.network.packet.Packet34EntityTeleport;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import dan200.computer.api.IComputerAccess;
|
import dan200.computer.api.IComputerAccess;
|
||||||
import dan200.computer.api.ILuaContext;
|
import dan200.computer.api.ILuaContext;
|
||||||
import dan200.computer.api.IPeripheral;
|
import dan200.computer.api.IPeripheral;
|
||||||
|
@ -32,6 +38,16 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
/** This teleporter's frequency. */
|
/** This teleporter's frequency. */
|
||||||
public Teleporter.Code code;
|
public Teleporter.Code code;
|
||||||
|
|
||||||
|
public AxisAlignedBB teleportBounds = null;
|
||||||
|
|
||||||
|
public Set<Entity> didTeleport = new HashSet<Entity>();
|
||||||
|
|
||||||
|
public int teleDelay = 0;
|
||||||
|
|
||||||
|
public boolean shouldRender;
|
||||||
|
|
||||||
|
public boolean prevShouldRender;
|
||||||
|
|
||||||
/** This teleporter's current status. */
|
/** This teleporter's current status. */
|
||||||
public String status = (EnumColor.DARK_RED + "Not ready.");
|
public String status = (EnumColor.DARK_RED + "Not ready.");
|
||||||
|
|
||||||
|
@ -47,8 +63,13 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
{
|
{
|
||||||
super.onUpdate();
|
super.onUpdate();
|
||||||
|
|
||||||
if(!worldObj.isRemote)
|
if(teleportBounds == null)
|
||||||
{
|
{
|
||||||
|
resetBounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!worldObj.isRemote)
|
||||||
|
{
|
||||||
if(Mekanism.teleporters.containsKey(code))
|
if(Mekanism.teleporters.containsKey(code))
|
||||||
{
|
{
|
||||||
if(!Mekanism.teleporters.get(code).contains(Object3D.get(this)) && hasFrame())
|
if(!Mekanism.teleporters.get(code).contains(Object3D.get(this)) && hasFrame())
|
||||||
|
@ -88,11 +109,47 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
status = EnumColor.DARK_GREEN + "Idle.";
|
status = EnumColor.DARK_GREEN + "Idle.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(canTeleport() == 1 && teleDelay == 0)
|
||||||
|
{
|
||||||
|
teleport();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(teleDelay == 0 && didTeleport.size() > 0)
|
||||||
|
{
|
||||||
|
cleanTeleportCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte b = canTeleport();
|
||||||
|
shouldRender = b == 1 || b > 4;
|
||||||
|
|
||||||
|
if(shouldRender != prevShouldRender)
|
||||||
|
{
|
||||||
|
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())), Object3D.get(this), 40D);
|
||||||
|
}
|
||||||
|
|
||||||
|
prevShouldRender = shouldRender;
|
||||||
|
|
||||||
|
teleDelay = Math.max(0, teleDelay-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChargeUtils.discharge(0, this);
|
ChargeUtils.discharge(0, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cleanTeleportCache()
|
||||||
|
{
|
||||||
|
List<Entity> list = worldObj.getEntitiesWithinAABB(Entity.class, teleportBounds);
|
||||||
|
Set<Entity> teleportCopy = (Set<Entity>)((HashSet<Entity>)didTeleport).clone();
|
||||||
|
|
||||||
|
for(Entity entity : teleportCopy)
|
||||||
|
{
|
||||||
|
if(!list.contains(entity))
|
||||||
|
{
|
||||||
|
didTeleport.remove(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getAccessibleSlotsFromSide(int side)
|
public int[] getAccessibleSlotsFromSide(int side)
|
||||||
{
|
{
|
||||||
|
@ -110,6 +167,11 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetBounds()
|
||||||
|
{
|
||||||
|
teleportBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+1, yCoord+3, zCoord+1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1: yes
|
* 1: yes
|
||||||
* 2: no frame
|
* 2: no frame
|
||||||
|
@ -138,7 +200,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
|
|
||||||
if(Mekanism.teleporters.get(code).size() == 2)
|
if(Mekanism.teleporters.get(code).size() == 2)
|
||||||
{
|
{
|
||||||
List<EntityPlayer> entitiesInPortal = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord-1, yCoord, zCoord-1, xCoord+1, yCoord+3, zCoord+1));
|
List<Entity> entitiesInPortal = getToTeleport();
|
||||||
|
|
||||||
Object3D closestCoords = null;
|
Object3D closestCoords = null;
|
||||||
|
|
||||||
|
@ -153,7 +215,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
|
|
||||||
int electricityNeeded = 0;
|
int electricityNeeded = 0;
|
||||||
|
|
||||||
for(EntityPlayer entity : entitiesInPortal)
|
for(Entity entity : entitiesInPortal)
|
||||||
{
|
{
|
||||||
electricityNeeded += calculateEnergyCost(entity, closestCoords);
|
electricityNeeded += calculateEnergyCost(entity, closestCoords);
|
||||||
}
|
}
|
||||||
|
@ -178,7 +240,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
{
|
{
|
||||||
if(worldObj.isRemote) return;
|
if(worldObj.isRemote) return;
|
||||||
|
|
||||||
List<EntityPlayer> entitiesInPortal = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord-1, yCoord, zCoord-1, xCoord+1, yCoord+3, zCoord+1));
|
List<Entity> entitiesInPortal = getToTeleport();
|
||||||
|
|
||||||
Object3D closestCoords = null;
|
Object3D closestCoords = null;
|
||||||
|
|
||||||
|
@ -191,26 +253,58 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(EntityPlayer entity : entitiesInPortal)
|
for(Entity entity : entitiesInPortal)
|
||||||
{
|
{
|
||||||
setEnergy(getEnergy() - calculateEnergyCost(entity, closestCoords));
|
World teleWorld = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(closestCoords.dimensionId);
|
||||||
|
TileEntityTeleporter teleporter = (TileEntityTeleporter)closestCoords.getTileEntity(teleWorld);
|
||||||
|
|
||||||
worldObj.playSoundAtEntity((EntityPlayerMP)entity, "mob.endermen.portal", 1.0F, 1.0F);
|
if(teleporter != null)
|
||||||
|
|
||||||
if(entity.worldObj.provider.dimensionId != closestCoords.dimensionId)
|
|
||||||
{
|
{
|
||||||
entity.travelToDimension(closestCoords.dimensionId);
|
teleporter.didTeleport.add(entity);
|
||||||
}
|
teleporter.teleDelay = 5;
|
||||||
|
|
||||||
((EntityPlayerMP)entity).playerNetServerHandler.setPlayerLocation(closestCoords.xCoord+0.5, closestCoords.yCoord+1, closestCoords.zCoord+0.5, entity.rotationYaw, entity.rotationPitch);
|
if(entity.worldObj.provider.dimensionId != closestCoords.dimensionId)
|
||||||
|
{
|
||||||
for(Object3D coords : Mekanism.teleporters.get(code))
|
entity.travelToDimension(closestCoords.dimensionId);
|
||||||
{
|
}
|
||||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketPortalFX().setParams(coords), coords, 40D);
|
|
||||||
|
if(entity instanceof EntityPlayerMP)
|
||||||
|
{
|
||||||
|
((EntityPlayerMP)entity).playerNetServerHandler.setPlayerLocation(closestCoords.xCoord+0.5, closestCoords.yCoord+1, closestCoords.zCoord+0.5, entity.rotationYaw, entity.rotationPitch);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entity.setLocationAndAngles(closestCoords.xCoord+0.5, closestCoords.yCoord+1, closestCoords.zCoord+0.5, entity.rotationYaw, entity.rotationPitch);
|
||||||
|
PacketDispatcher.sendPacketToAllPlayers(new Packet34EntityTeleport(entity));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Object3D coords : Mekanism.teleporters.get(code))
|
||||||
|
{
|
||||||
|
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketPortalFX().setParams(coords), coords, 40D);
|
||||||
|
}
|
||||||
|
|
||||||
|
setEnergy(getEnergy() - calculateEnergyCost(entity, closestCoords));
|
||||||
|
|
||||||
|
worldObj.playSoundAtEntity(entity, "mob.endermen.portal", 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Entity> getToTeleport()
|
||||||
|
{
|
||||||
|
List<Entity> entities = worldObj.getEntitiesWithinAABB(Entity.class, teleportBounds);
|
||||||
|
List<Entity> ret = new ArrayList<Entity>();
|
||||||
|
|
||||||
|
for(Entity entity : entities)
|
||||||
|
{
|
||||||
|
if(!didTeleport.contains(entity))
|
||||||
|
{
|
||||||
|
ret.add(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidate()
|
public void invalidate()
|
||||||
{
|
{
|
||||||
|
@ -333,6 +427,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
code.digitTwo = dataStream.readInt();
|
code.digitTwo = dataStream.readInt();
|
||||||
code.digitThree = dataStream.readInt();
|
code.digitThree = dataStream.readInt();
|
||||||
code.digitFour = dataStream.readInt();
|
code.digitFour = dataStream.readInt();
|
||||||
|
shouldRender = dataStream.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -345,6 +440,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
data.add(code.digitTwo);
|
data.add(code.digitTwo);
|
||||||
data.add(code.digitThree);
|
data.add(code.digitThree);
|
||||||
data.add(code.digitFour);
|
data.add(code.digitFour);
|
||||||
|
data.add(shouldRender);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -420,10 +516,17 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void attach(IComputerAccess computer) {}
|
public void attach(IComputerAccess computer) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void detach(IComputerAccess computer) {}
|
public void detach(IComputerAccess computer) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public AxisAlignedBB getRenderBoundingBox()
|
||||||
|
{
|
||||||
|
return INFINITE_EXTENT_AABB;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue