mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 20:22:12 +00:00
Added the ability to set the output direction of Ender Rails
This commit is contained in:
1 parent
7d36e04771
commit
72b4a2fc50
5 files changed
+30
-14
No files matched your search
@@ -23,6 +23,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.machine.transceiver.Channel;
|
||||
@@ -44,7 +45,7 @@ public class BlockEnderRail extends BlockRail implements IResourceTooltipProvide
|
||||
if(isEastWest(meta)) {
|
||||
result = ForgeDirection.EAST;
|
||||
} else {
|
||||
result = ForgeDirection.NORTH;
|
||||
result = ForgeDirection.SOUTH;
|
||||
}
|
||||
if(isReverse(meta)) {
|
||||
result = result.getOpposite();
|
||||
@@ -106,15 +107,14 @@ public class BlockEnderRail extends BlockRail implements IResourceTooltipProvide
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
|
||||
// //TODO: Don't let people decide which way the carts come out. Can't figure out how to reliably reverse directions
|
||||
// if(ConduitUtil.isToolEquipped(player)) {
|
||||
// if(!world.isRemote) {
|
||||
// int meta = world.getBlockMetadata(x, y, z);
|
||||
// meta = MetadataUtil.setBit(3, !MetadataUtil.isBitSet(3, meta), meta);
|
||||
// world.setBlockMetadataWithNotify(x, y, z, meta, 2);
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
if(ConduitUtil.isToolEquipped(player)) {
|
||||
if(!world.isRemote) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
meta = MetadataUtil.setBit(3, !MetadataUtil.isBitSet(3, meta), meta);
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta, 2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,9 +110,13 @@ public class EnderRailController {
|
||||
if(failedSpawn) {
|
||||
doRandomSpawn(ent);
|
||||
} else {
|
||||
TeleportUtil.spawn(transciever.getWorldObj(), ent);
|
||||
EntityMinecart cart = null;
|
||||
if(ent instanceof EntityMinecart) {
|
||||
EntityMinecart cart = (EntityMinecart) ent;
|
||||
cart = (EntityMinecart) ent;
|
||||
setCartDirection(cart);
|
||||
}
|
||||
TeleportUtil.spawn(transciever.getWorldObj(), ent);
|
||||
if(cart != null) {
|
||||
newlySpawnedCarts.add(cart.getPersistentID());
|
||||
CartLinkUtil.recreateLinks(cart);
|
||||
}
|
||||
@@ -123,6 +127,15 @@ public class EnderRailController {
|
||||
|
||||
}
|
||||
|
||||
private void setCartDirection(EntityMinecart cart) {
|
||||
int meta = transciever.getWorldObj().getBlockMetadata(transciever.xCoord, transciever.yCoord + 1, transciever.zCoord);
|
||||
ForgeDirection dir = BlockEnderRail.getDirection(meta);
|
||||
double velocity = Math.max(Math.abs(cart.motionX), Math.abs(cart.motionZ));
|
||||
cart.motionX = dir.offsetX * velocity;
|
||||
cart.motionZ = dir.offsetZ * velocity;
|
||||
|
||||
}
|
||||
|
||||
public void onTrainRecieved(List<List<Entity>> toTeleport) {
|
||||
cartsToSpawn.addAll(toTeleport);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user