use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.
the class TileEntityRailReception method cart.
public static void cart(boolean isAnti, EntityMinecart cart, TileEntityRailReception rail, EntityPlayer player, boolean playerDetectable) {
if (rail == null)
return;
if (cart == null)
return;
World world = rail.worldObj;
int x = rail.xCoord, y = rail.yCoord, z = rail.zCoord;
double maxV;
if (!playerDetectable) {
maxV = 0.1;
if (isRailPowered(world, x, y, z)) {
if (isAnti) {
if (getRailDirection(world, x, y, z) == RailDirection.NS) {
if (cart.motionZ < -maxV) {
// cart.motionZ < -maxV
if (cart.motionZ > -maxV * 1.5)
cart.motionZ = -maxV * 1.5;
} else {
if (cart.motionZ <= 0)
cart.motionZ = 0.005;
if (cart.motionZ < maxV)
cart.motionZ = Dynamics.LocoMotions.calcVelocityUp(Math.abs(cart.motionZ), 0.1, 1.0, 0.1, 0.02);
}
} else {
if (cart.motionX > maxV) {
// cart.motionX > maxV
if (cart.motionX < maxV * 1.5)
cart.motionX = maxV * 1.5;
} else {
if (cart.motionX >= 0)
cart.motionX = -0.005;
if (cart.motionX > -maxV)
cart.motionX = -Dynamics.LocoMotions.calcVelocityUp(Math.abs(cart.motionX), 0.1, 1.0, 0.1, 0.02);
}
}
} else {
if (getRailDirection(world, x, y, z) == RailDirection.NS) {
if (cart.motionZ > maxV) {
// cart.motionZ > maxV
if (cart.motionZ < maxV * 1.5)
cart.motionZ = maxV * 1.5;
} else {
if (cart.motionZ >= 0)
cart.motionZ = -0.005;
if (cart.motionZ > -maxV)
cart.motionZ = -Dynamics.LocoMotions.calcVelocityUp(Math.abs(cart.motionZ), 0.1, 1.0, 0.1, 0.02);
}
} else {
if (cart.motionX < -maxV) {
// cart.motionX < -maxV
if (cart.motionX > -maxV * 1.5)
cart.motionX = -maxV * 1.5;
} else {
if (cart.motionX <= 0)
cart.motionX = 0.005;
if (cart.motionX < maxV)
cart.motionX = Dynamics.LocoMotions.calcVelocityUp(Math.abs(cart.motionX), 0.1, 1.0, 0.1, 0.02);
}
}
}
} else {
if (Math.abs(cart.motionX) > maxV || Math.abs(cart.motionZ) > maxV) {
cart.motionX = Math.signum(cart.motionX) * Dynamics.LocoMotions.calcVelocityDown(Math.abs(cart.motionX), 0.1, 1.0, 1.0, 1.0, 0.05, 0.02);
cart.motionZ = Math.signum(cart.motionZ) * Dynamics.LocoMotions.calcVelocityDown(Math.abs(cart.motionZ), 0.1, 1.0, 1.0, 1.0, 0.05, 0.02);
} else {
if (getRailDirection(world, x, y, z) == RailDirection.NS) {
cart.motionZ = 0.0D;
} else {
cart.motionX = 0.0D;
}
}
}
} else {
maxV = 0.2;
if (rail.cartType.equals("loco")) {
return;
}
if (rail.cartType.isEmpty() && (cart.motionX * cart.motionX + cart.motionZ * cart.motionZ == 0))
registerCart(rail, cart);
if (!world.isBlockIndirectlyGettingPowered(x, y, z)) {
if (player != null) {
if ((cart.motionX * cart.motionX + cart.motionZ * cart.motionZ > 0) && !rail.enable) {
if ((Math.abs(cart.motionX) > maxV / 2) || (Math.abs(cart.motionZ) > maxV / 2)) {
cart.motionX = (Math.signum(cart.motionX) * Dynamics.LocoMotions.calcVelocityDown(Math.abs(cart.motionX), 0.1D, 1.0D, 1.0D, 1.0D, 0.05D, 0.02D));
cart.motionZ = (Math.signum(cart.motionZ) * Dynamics.LocoMotions.calcVelocityDown(Math.abs(cart.motionZ), 0.1D, 1.0D, 1.0D, 1.0D, 0.05D, 0.02D));
} else {
rail.enable = true;
rail.doorCtrl = true;
if (getRailDirection(world, x, y, z) == RailDirection.NS) {
cart.motionZ = 0.0D;
} else {
cart.motionX = 0.0D;
}
cart.setPosition(x + 0.5, y + 0.5, z + 0.5);
if (player instanceof EntityPlayerMP && rail.setDelay == 10) {
player.addChatComponentMessage(new ChatComponentTranslation("info.reception.pause", rail.setDelay));
world.playSoundAtEntity(cart, "nyasamarailway:info.reception.pause", 0.5F, 1.0F);
}
}
} else {
if (rail.delay < rail.setDelay * 20 && rail.enable) {
boolean isEnabled = false;
if (rail.getSender() != null)
isEnabled = rail.senderIsPowered();
if (!isEnabled)
rail.delay += 1;
else {
rail.count += 1;
if (rail.delay + rail.count == rail.setDelay * 15) {
rail.delay = rail.setDelay * 15 - 1;
rail.count += 1;
if (player instanceof EntityPlayerMP) {
player.addChatComponentMessage(new ChatComponentTranslation("info.reception.delay"));
world.playSoundAtEntity(cart, "nyasamarailway:info.reception.delay", 0.5F, 1.0F);
}
}
}
if (rail.delay == rail.setDelay * 15) {
rail.count = 0;
rail.doorCtrl = false;
if (player instanceof EntityPlayerMP) {
player.addChatComponentMessage(new ChatComponentTranslation("info.reception.ready"));
world.playSoundAtEntity(cart, "nyasamarailway:info.reception.ready", 0.5F, 1.0F);
}
}
cart.motionX = 0.0D;
cart.motionZ = 0.0D;
cart.setPosition(x + 0.5, y + 0.5, z + 0.5);
} else {
if (isAnti) {
if (getRailDirection(world, x, y, z) == RailDirection.NS) {
if (cart.motionZ < -maxV) {
if (cart.motionZ > -maxV * 1.5D)
cart.motionZ = (-maxV * 1.5D);
} else {
if (cart.motionZ <= 0.0D)
cart.motionZ = 0.005D;
if (cart.motionZ < maxV) {
cart.motionZ = Dynamics.LocoMotions.calcVelocityUp(Math.abs(cart.motionZ), 0.1D, 1.0D, 0.1D, 0.02D);
}
}
} else {
if (cart.motionX > maxV) {
if (cart.motionX < maxV * 1.5D)
cart.motionX = (maxV * 1.5D);
} else {
if (cart.motionX >= 0.0D)
cart.motionX = -0.005D;
if (cart.motionX > -maxV) {
cart.motionX = -Dynamics.LocoMotions.calcVelocityUp(Math.abs(cart.motionX), 0.1D, 1.0D, 0.1D, 0.02D);
}
}
}
} else {
if (getRailDirection(world, x, y, z) == RailDirection.NS) {
if (cart.motionZ > maxV) {
if (cart.motionZ < maxV * 1.5D)
cart.motionZ = (maxV * 1.5D);
} else {
if (cart.motionZ >= 0.0D)
cart.motionZ = -0.005D;
if (cart.motionZ > -maxV) {
cart.motionZ = -Dynamics.LocoMotions.calcVelocityUp(Math.abs(cart.motionZ), 0.1D, 1.0D, 0.1D, 0.02D);
}
}
} else {
if (cart.motionX < -maxV) {
if (cart.motionX > -maxV * 1.5D)
cart.motionX = (-maxV * 1.5D);
} else {
if (cart.motionX <= 0.0D)
cart.motionX = 0.005D;
if (cart.motionX < maxV) {
cart.motionX = Dynamics.LocoMotions.calcVelocityUp(Math.abs(cart.motionX), 0.1D, 1.0D, 0.1D, 0.02D);
}
}
}
}
}
}
} else {
cart.motionX = 0.0D;
cart.motionZ = 0.0D;
cart.setPosition(x + 0.5, y + 0.5, z + 0.5);
rail.reset();
}
} else {
if (isAnti) {
if (cart.motionX * cart.motionX + cart.motionZ * cart.motionZ > 0) {
if (getRailDirection(world, x, y, z) == RailDirection.NS) {
if (cart.posZ - 0.5 < z) {
cart.killMinecart(new DamageSource("nsr"));
}
} else {
if (cart.posX - 0.5 > x) {
cart.killMinecart(new DamageSource("nsr"));
}
}
}
} else {
if (cart.motionX * cart.motionX + cart.motionZ * cart.motionZ > 0) {
if (getRailDirection(world, x, y, z) == RailDirection.NS) {
if (cart.posZ - 0.5 > z) {
cart.killMinecart(new DamageSource("nsr"));
}
} else {
if (cart.posX - 0.5 < x) {
cart.killMinecart(new DamageSource("nsr"));
}
}
}
}
}
}
}
use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.
the class BlockRailSniffer method onBlockActivated.
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (world.getTileEntity(x, y, z) == null)
return false;
if (world.getTileEntity(x, y, z) instanceof RailSniffer) {
RailSniffer sniffer = (RailSniffer) world.getTileEntity(x, y, z);
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null) {
NBTTagList list = Util.getTagListFromNGT(stack);
if (list == null)
return false;
if (!world.isRemote) {
String code = NSASM.getCodeString(list);
sniffer.nsasmState = RailSniffer.NSASM_IDLE;
sniffer.nsasmCode = code;
player.addChatComponentMessage(new ChatComponentTranslation("info.sniffer.set"));
}
return true;
}
}
return false;
}
use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.
the class Item74HC04 method onConnectorUseLast.
@Override
public boolean onConnectorUseLast(EntityPlayer player, UUID uuid, TileEntity tileEntity) {
if (Railcraft.getInstance() != null) {
if (Railcraft.getInstance().verifySwitch(tileEntity)) {
if (receiverRails.containsKey(uuid)) {
if (receiverRails.get(uuid) instanceof TileEntityActuator) {
TileEntityActuator actuator = (TileEntityActuator) receiverRails.get(uuid);
if (actuator.getTarget() != tileEntity) {
actuator.setTarget(tileEntity);
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.signal.connected"));
updateTileEntity(actuator);
updateTileEntity(tileEntity);
} else {
actuator.setTarget(null);
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.signal.disconnected"));
updateTileEntity(actuator);
updateTileEntity(tileEntity);
}
}
receiverRails.remove(uuid);
} else {
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.signal.error"));
}
return true;
}
}
return false;
}
use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.
the class ItemNTP32Bit method clearCart.
public void clearCart(ItemStack itemStack, EntityPlayer player) {
int[] array = new int[] { -1 };
power.set(itemStack, 0);
brake.set(itemStack, 5);
dir.set(itemStack, 0);
carts.set(itemStack, array);
if (player instanceof EntityPlayerMP) {
TrainPacket packet = new TrainPacket();
packet.fromStack(itemStack);
NetworkWrapper.instance.sendTo(packet, (EntityPlayerMP) player);
}
player.addChatComponentMessage(new ChatComponentTranslation("info.ntp.cleared"));
}
use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.
the class ItemPierBuilder method onItemUseFirst.
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
Block block = world.getBlock(x, y, z);
if (block == null)
return false;
if (player.isSneaking()) {
endBlock = block;
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.PierBuilder.endBlock", endBlock.getLocalizedName()));
} else {
if (block instanceof BlockPierTag) {
if (endBlock == null)
return false;
world.setBlock(x, y, z, Blocks.air);
block = world.getBlock(x, y + 1, z);
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.PierBuilder.begin"));
// dy = -1 to use pier tag
for (int dy = -1; !reachesEndBlock(world, x, y - dy - 1, z); dy++) {
traversalCounter = 0;
TraversalBlocks(world, block, x, y - dy, z);
if (traversalCounter > TRAVERSAL_MAX) {
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.PierBuilder.abort"));
break;
}
}
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.PierBuilder.finish"));
} else {
if (isFenceBuilding(world, x, y, z)) {
Block fence = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.PierBuilder.fence"));
traversalCounter = 0;
TraversalFence(world, fence, meta, x, y, z);
if (traversalCounter > TRAVERSAL_MAX) {
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.PierBuilder.abort"));
} else {
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.PierBuilder.finish"));
}
} else if (isRailBuilding(world, x, y, z)) {
Block rail = world.getBlock(x, y, z);
Block base = world.getBlock(x, y - 1, z);
if (getEdge(world, x, y, z) == null)
return false;
Block edge = getEdge(world, x, y, z);
int edgeMeta = getEdgeMeta(world, x, y, z);
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.PierBuilder.rails"));
traversalCounter = 0;
TraversalRails(world, rail, base, edge, edgeMeta, x, y - 1, z);
if (traversalCounter > TRAVERSAL_MAX) {
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.PierBuilder.abort"));
} else {
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.PierBuilder.finish"));
}
} else
return false;
}
}
return !world.isRemote;
}
Aggregations