use of net.minecraft.util.text.TextComponentTranslation in project SpongeForge by SpongePowered.
the class SpongeForgeEventFactory method createServerChatEvent.
// Server events
private static ServerChatEvent createServerChatEvent(Event event) {
MessageChannelEvent.Chat spongeEvent = (MessageChannelEvent.Chat) event;
Optional<Player> player = spongeEvent.getCause().first(Player.class);
if (!player.isPresent()) {
return null;
}
Text spongeText = spongeEvent.getOriginalMessage();
ITextComponent component = SpongeTexts.toComponent(spongeText);
if (!(component instanceof TextComponentTranslation)) {
component = new TextComponentTranslation("%s", component);
}
// Using toPlain here is fine, since the raw message from the client
// can't have formatting.
ServerChatEvent forgeEvent = new ServerChatEvent((EntityPlayerMP) player.get(), spongeEvent.getOriginalMessage().toPlain(), (TextComponentTranslation) component);
((IMixinInitCause) forgeEvent).initCause(spongeEvent.getCause());
return forgeEvent;
}
use of net.minecraft.util.text.TextComponentTranslation in project YABBA by LatvianModder.
the class TileBarrelBase method createConfig.
public void createConfig(YabbaConfigEvent event) {
DataStorage data = getUpgradeData(YabbaItems.UPGRADE_REDSTONE_OUT);
if (data instanceof ItemUpgradeRedstone.Data) {
String group = Yabba.MOD_ID + ".redstone";
event.getConfig().setGroupName(group, new TextComponentTranslation(YabbaItems.UPGRADE_REDSTONE_OUT.getUnlocalizedName() + ".name"));
ItemUpgradeRedstone.Data data1 = (ItemUpgradeRedstone.Data) data;
event.getConfig().add(group, "mode", data1.mode);
event.getConfig().add(group, "count", data1.count);
}
data = getUpgradeData(YabbaItems.UPGRADE_HOPPER);
if (data instanceof ItemUpgradeHopper.Data) {
String group = Yabba.MOD_ID + ".hopper";
event.getConfig().setGroupName(group, new TextComponentTranslation(YabbaItems.UPGRADE_HOPPER.getUnlocalizedName() + ".name"));
ItemUpgradeHopper.Data data1 = (ItemUpgradeHopper.Data) data;
event.getConfig().add(group, "up", data1.up);
event.getConfig().add(group, "down", data1.down);
event.getConfig().add(group, "collect", data1.collect);
}
}
use of net.minecraft.util.text.TextComponentTranslation in project MineCamera by PorPit.
the class EventLoader method ActiveTripod.
private void ActiveTripod(String playername, int delay) {
if (!TripodActiveThread.isshooting) {
TripodActiveThread thread = new TripodActiveThread(playername, delay);
thread.start();
} else {
Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new TextComponentTranslation("chat.minecamera.isshooting"));
}
}
use of net.minecraft.util.text.TextComponentTranslation in project MineCamera by PorPit.
the class ItemCamera method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
// System.out.println("1:"+playerIn.getActiveHand());
playerIn.setActiveHand(hand);
// System.out.println("2:"+playerIn.getActiveHand());
if (playerIn.isSneaking()) {
if (!worldIn.isRemote) {
BlockPos pos = playerIn.getPosition();
int id = GuiElementLoader.GUI_CAMERA;
playerIn.openGui(MineCamera.instance, id, worldIn, pos.getX(), pos.getY(), pos.getZ());
}
} else {
// ��Ʒ����
if (!itemStackIn.hasTagCompound()) {
itemStackIn.setTagCompound(new NBTTagCompound());
}
if (itemStackIn.getTagCompound().hasKey("filmOutCatch")) {
if (!worldIn.isRemote)
playerIn.addChatComponentMessage(new TextComponentTranslation("chat.minecamera.isouting"));
return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
if (!itemStackIn.getTagCompound().hasKey("filmSlot")) {
if (!worldIn.isRemote)
playerIn.addChatComponentMessage(new TextComponentTranslation("chat.minecamera.nofilm"));
return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
if (!itemStackIn.getTagCompound().hasKey("betterySlot")) {
if (!worldIn.isRemote)
playerIn.addChatComponentMessage(new TextComponentTranslation("chat.minecamera.nobettery"));
return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
if (itemStackIn.getTagCompound().hasKey("filmOutSlot")) {
if (!worldIn.isRemote)
playerIn.addChatComponentMessage(new TextComponentTranslation("chat.minecamera.hasfilmout"));
return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
ItemStack betteryStack = ItemStack.loadItemStackFromNBT(itemStackIn.getTagCompound().getCompoundTag("betterySlot"));
if (betteryStack.getItemDamage() == betteryStack.getMaxDamage()) {
itemStackIn.getTagCompound().removeTag("betterySlot");
if (!worldIn.isRemote)
playerIn.addChatComponentMessage(new TextComponentTranslation("chat.minecamera.betteryrunout"));
} else {
betteryStack.damageItem(1, playerIn);
NBTTagCompound itemTag = new NBTTagCompound();
betteryStack.writeToNBT(itemTag);
itemStackIn.getTagCompound().setTag("betterySlot", itemTag);
}
ItemStack filmStack = ItemStack.loadItemStackFromNBT(itemStackIn.getTagCompound().getCompoundTag("filmSlot"));
String createdpid = playerIn.getName() + "%_%" + System.currentTimeMillis();
if (filmStack.hasTagCompound() && filmStack.getTagCompound().hasKey("pid")) {
if (!worldIn.isRemote)
playerIn.addChatComponentMessage((new TextComponentTranslation("chat.minecamera.filmcantwrite")));
return new ActionResult(EnumActionResult.PASS, itemStackIn);
} else {
itemStackIn.getTagCompound().removeTag("filmSlot");
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("pid", createdpid);
filmStack.setTagCompound(nbt);
NBTTagCompound itemTag = new NBTTagCompound();
filmStack.writeToNBT(itemTag);
itemStackIn.getTagCompound().setTag("filmOutCatch", itemTag);
if (!worldIn.isRemote) {
MessageImageSyncSave message = new MessageImageSyncSave();
message.imageName = createdpid;
NetworkLoader.instance.sendTo(message, (EntityPlayerMP) playerIn);
}
}
itemStackIn.getTagCompound().setInteger("burnTime", 0);
// ��Ⱦ
if (!worldIn.isRemote) {
double particlePosX = playerIn.posX, particlePosY = playerIn.posY + 1.35, particlePosZ = playerIn.posZ;
particlePosX = particlePosX + (-Math.sin(Math.toRadians(playerIn.rotationYaw + 15)) * 0.7) * Math.cos(Math.toRadians(playerIn.rotationPitch));
particlePosY = particlePosY + (-Math.sin(Math.toRadians(playerIn.rotationPitch)) * 0.7);
particlePosZ = particlePosZ + (Math.cos(Math.toRadians(playerIn.rotationYaw + 15)) * 0.7) * Math.cos(Math.toRadians(playerIn.rotationPitch));
List<EntityPlayer> listentity = worldIn.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(playerIn.posX - 16, playerIn.posY - 16, playerIn.posZ - 16, playerIn.posX + 16, playerIn.posY + 16, playerIn.posZ + 16));
if (listentity != null) {
for (EntityPlayer i : listentity) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) i;
entityplayermp.connection.sendPacket(new SPacketCustomSound("minecamera:minecamera.kacha", SoundCategory.PLAYERS, playerIn.posX, playerIn.posY, playerIn.posZ, 1.0F, 1.0F));
MessageSpawnParticle message = new MessageSpawnParticle();
message.delay = 200;
message.typeid = EnumParticleTypes.FIREWORKS_SPARK.getParticleID();
message.PosX = particlePosX;
message.PosY = particlePosY;
message.PosZ = particlePosZ;
message.SpeedX = 0;
message.SpeedY = 0;
message.SpeedZ = 0;
NetworkLoader.instance.sendTo(message, entityplayermp);
/*
* entityplayermp.connection.sendPacket(new
* SPacketParticles(EnumParticleTypes.FIREWORKS_SPARK,
* EnumParticleTypes.FIREWORKS_SPARK.
* getShouldIgnoreRange(), (float) particlePosX, (float)
* particlePosY, (float) particlePosZ, 0F, 0F, 0F,
* 0.03F, 1));
*/
}
}
}
if (!worldIn.isRemote)
playerIn.addChatComponentMessage((new TextComponentTranslation("chat.minecamera.success")));
}
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
use of net.minecraft.util.text.TextComponentTranslation in project MineCamera by PorPit.
the class ItemTripod method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!worldIn.isRemote) {
if (!facing.equals(EnumFacing.UP)) {
playerIn.addChatComponentMessage(new TextComponentTranslation("chat.tripod.mustup"));
return EnumActionResult.PASS;
}
Entity entity = new EntityTripod(worldIn);
entity.setPositionAndUpdate(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
entity.rotationYaw = playerIn.rotationYaw;
entity.rotationPitch = playerIn.rotationPitch;
worldIn.spawnEntityInWorld(entity);
// worldIn.updateEntities();
stack.stackSize--;
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}
Aggregations