use of net.minecraft.util.ChatComponentText in project ICBM-Classic by BuiltBrokenModding.
the class ItemGrenade method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) {
if (itemStack != null) {
Explosive zhaPin = Explosives.get(itemStack.getItemDamage()).handler;
ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(world, entityPlayer, ExplosiveType.ITEM, zhaPin);
MinecraftForge.EVENT_BUS.post(evt);
if (!evt.isCanceled()) {
entityPlayer.setItemInUse(itemStack, this.getMaxItemUseDuration(itemStack));
} else {
entityPlayer.addChatMessage(new ChatComponentText("Grenades are banned in this region."));
}
}
return itemStack;
}
use of net.minecraft.util.ChatComponentText in project ICBM-Classic by BuiltBrokenModding.
the class ItemRadarGun method read.
@Override
public void read(ByteBuf buf, EntityPlayer player, PacketType packet) {
ItemStack stack = player.inventory.getCurrentItem();
if (stack != null && stack.getItem() == this) {
setLocation(stack, new Location(player.worldObj, buf.readInt(), buf.readInt(), buf.readInt()));
player.addChatComponentMessage(new ChatComponentText("GPS data set"));
}
}
use of net.minecraft.util.ChatComponentText in project ICBM-Classic by BuiltBrokenModding.
the class ItemRocketLauncher method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
if (!world.isRemote) {
long clickMs = System.currentTimeMillis();
if (clickTimePlayer.containsKey(player.getCommandSenderName())) {
if (clickMs - clickTimePlayer.get(player.getCommandSenderName()) < firingDelay) {
//TODO play weapon empty click audio to note the gun is reloading
return itemStack;
}
}
if (this.getEnergy(itemStack) >= ENERGY || player.capabilities.isCreativeMode) {
// Check the player's inventory and look for missiles.
for (int slot = 0; slot < player.inventory.getSizeInventory(); slot++) {
ItemStack inventoryStack = player.inventory.getStackInSlot(slot);
if (inventoryStack != null) {
if (inventoryStack.getItem() instanceof ItemMissile) {
int meta = inventoryStack.getItemDamage();
Explosives ex = Explosives.get(meta);
ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(world, player.posX, player.posY, player.posZ, ExplosiveType.AIR, Explosives.get(meta).handler);
MinecraftForge.EVENT_BUS.post(evt);
if (((Explosion) ex.handler) != null && !evt.isCanceled()) {
// Limit the missile to tier two.
if ((((Explosion) ex.handler).getTier() <= Settings.MAX_ROCKET_LAUCNHER_TIER || Engine.runningAsDev) && ((Explosion) ex.handler).isCruise()) {
EntityMissile entityMissile = new EntityMissile(player);
entityMissile.missileType = EntityMissile.MissileType.LAUNCHER;
entityMissile.explosiveID = ex;
entityMissile.acceleration = 1;
entityMissile.launch(null);
world.spawnEntityInWorld(entityMissile);
if (player.isSneaking()) {
player.mountEntity(entityMissile);
player.setSneaking(false);
}
if (!player.capabilities.isCreativeMode) {
player.inventory.setInventorySlotContents(slot, null);
player.inventoryContainer.detectAndSendChanges();
this.discharge(itemStack, ENERGY, true);
}
//Store last time player launched a rocket
clickTimePlayer.put(player.getCommandSenderName(), clickMs);
return itemStack;
}
} else {
player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("message.launcher.protected")));
}
}
}
}
}
}
return itemStack;
}
use of net.minecraft.util.ChatComponentText in project ICBM-Classic by BuiltBrokenModding.
the class MissileHoming method onInteract.
@Override
public boolean onInteract(EntityMissile missileObj, EntityPlayer entityPlayer) {
if (!missileObj.worldObj.isRemote && missileObj.getTicksInAir() <= 0) {
if (entityPlayer.getCurrentEquippedItem() != null) {
if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemTracker) {
Entity trackingEntity = ((ItemTracker) entityPlayer.getCurrentEquippedItem().getItem()).getTrackingEntity(missileObj.worldObj, entityPlayer.getCurrentEquippedItem());
if (trackingEntity != null) {
if (missileObj.trackingVar != trackingEntity.getEntityId()) {
missileObj.trackingVar = trackingEntity.getEntityId();
entityPlayer.addChatMessage(new ChatComponentText("Missile target locked to: " + trackingEntity.getCommandSenderName()));
if (missileObj.getLauncher() != null && missileObj.getLauncher().getController() != null) {
Pos newTarget = new Pos(trackingEntity.posX, 0, trackingEntity.posZ);
missileObj.getLauncher().getController().setTarget(newTarget);
}
return true;
}
}
}
}
}
return false;
}
use of net.minecraft.util.ChatComponentText in project ICBM-Classic by BuiltBrokenModding.
the class TileCruiseLauncher method onPlayerActivated.
@Override
public boolean onPlayerActivated(EntityPlayer player, int side, Pos hit) {
if (isServer()) {
boolean notNull = player.getHeldItem() != null;
if (notNull && player.getHeldItem().getItem() == Items.redstone) {
if (canLaunch()) {
launch();
} else {
player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.failedToFire")));
String translation = LanguageUtility.getLocal("chat.launcher.status");
translation = translation.replace("%1", getStatus());
player.addChatComponentMessage(new ChatComponentText(translation));
}
} else if (notNull && player.getHeldItem().getItem() instanceof IWorldPosItem) {
IWorldPosition location = ((IWorldPosItem) player.getHeldItem().getItem()).getLocation(player.getHeldItem());
if (location != null) {
if (location.world() == world()) {
setTarget(new Pos(location.x(), location.y(), location.z()));
player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.toolTargetSet")));
} else {
player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.toolWorldNotMatch")));
}
} else {
player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.noTargetInTool")));
}
} else {
player.openGui(ICBMClassic.INSTANCE, 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
}
return true;
}
Aggregations