use of net.minecraft.util.text.TextComponentString in project EnderIO by SleepyTrousers.
the class ItemRemoteInvAccess method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
if (!world.isRemote) {
ItemStack equipped = player.getHeldItem(hand);
if (!REMOTE_X.hasTag(equipped) || !REMOTE_Y.hasTag(equipped) || !REMOTE_Z.hasTag(equipped) || !REMOTE_D.hasTag(equipped)) {
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.notarget")), true);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, equipped);
}
int x = REMOTE_X.getInt(equipped);
int y = REMOTE_Y.getInt(equipped);
int z = REMOTE_Z.getInt(equipped);
int d = REMOTE_D.getInt(equipped);
ItemRemoteInvAccessType type = ItemRemoteInvAccessType.fromStack(equipped);
if (!type.inRange(d, x, y, z, world.provider.getDimension(), (int) player.posX, (int) player.posY, (int) player.posZ)) {
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.outofrange")), true);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, equipped);
}
World targetWorld = world;
if (world.provider.getDimension() != d) {
targetWorld = DimensionManager.getWorld(d);
if (targetWorld == null) {
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.invalidtargetworld")), true);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, equipped);
}
}
final BlockPos pos = new BlockPos(x, y, z);
if (!targetWorld.isBlockLoaded(pos)) {
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.notloaded")), true);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, equipped);
}
if (targetWorld.getBlockState(pos).getBlock() != InvpanelObject.blockInventoryPanel.getBlock()) {
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.invalidtarget")), true);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, equipped);
}
if (!(world instanceof WorldServer) || !(player instanceof EntityPlayerMP)) {
Log.warn("Unexpected world or player: " + world + " " + player);
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.error")), true);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, equipped);
}
if (getEnergyStored(equipped) < type.getRfPerTick() * 10) {
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.outofpower")), true);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, equipped);
}
if (!drain(equipped, type.getMbPerOpen())) {
Fluid fluid = type.getFluidType();
String fluidname = fluid.getLocalizedName(new FluidStack(fluid, 1));
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.outoffluid").replace("{FLUIDNAME}", fluidname)), true);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, equipped);
}
ServerRemoteGuiManager.openGui((EntityPlayerMP) player, targetWorld, pos);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, equipped);
}
return super.onItemRightClick(world, player, hand);
}
use of net.minecraft.util.text.TextComponentString in project EnderIO by SleepyTrousers.
the class PacketRemoteInvPanel method onMessage.
@Override
public IMessage onMessage(PacketRemoteInvPanel message, MessageContext ctx) {
EntityPlayerMP player = ctx.getServerHandler().player;
ItemStack heldItem = player.getHeldItem(message.hand);
if (heldItem == null || !(heldItem.getItem() instanceof ItemRemoteInvAccess)) {
return null;
}
if (!REMOTE_X.hasTag(heldItem)) {
return null;
}
int x = REMOTE_X.getInt(heldItem);
int y = REMOTE_Y.getInt(heldItem);
int z = REMOTE_Z.getInt(heldItem);
int d = REMOTE_D.getInt(heldItem);
ItemRemoteInvAccessType type = ItemRemoteInvAccessType.fromStack(heldItem);
if (!type.inRange(d, x, y, z, player.getEntityWorld().provider.getDimension(), (int) player.posX, (int) player.posY, (int) player.posZ)) {
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.outofrange")), true);
return null;
}
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if (server == null) {
return null;
}
WorldServer world = server.getWorld(d);
if (world == null) {
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.invalidtarget")), true);
return null;
}
final BlockPos pos = new BlockPos(x, y, z);
if (!world.isBlockLoaded(pos)) {
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.notloaded")), true);
return null;
}
TileEntity tileEntity = player.getEntityWorld().getTileEntity(pos);
if (!(tileEntity instanceof TileInventoryPanel)) {
player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.invalidtarget")), true);
return null;
}
Container c = player.openContainer;
player.interactionManager.processRightClickBlock(player, player.world, null, EnumHand.MAIN_HAND, pos, EnumFacing.UP, 0f, 0f, 0f);
return null;
}
use of net.minecraft.util.text.TextComponentString in project EnderIO by SleepyTrousers.
the class Config method onPlayerLoggon.
@SubscribeEvent
public void onPlayerLoggon(PlayerLoggedInEvent evt) {
PacketHandler.INSTANCE.sendTo(new PacketConfigSync(), (EntityPlayerMP) evt.player);
if (EnderIO.VERSION.contains("-") || EnderIO.VERSION.contains("@")) {
// e.g. 1.2.3-nightly
evt.player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + "This is an " + TextFormatting.BLACK + "Ender IO " + TextFormatting.DARK_RED + "development build!"));
evt.player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + "It may trash your world at any time!"));
evt.player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + "Do not use it for anything but testing!"));
evt.player.sendMessage(new TextComponentString("You have been warned..."));
}
}
use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.
the class StandardPlayerRequestResolver method resolve.
@Nullable
@Override
public void resolve(@NotNull final IRequestManager manager, @NotNull final IRequest request) throws RuntimeException {
final IColony colony = manager.getColony();
if (colony instanceof Colony) {
if (Configurations.requestSystem.creativeResolve && request.getRequest() instanceof IDeliverable && request.getRequester() instanceof BuildingBasedRequester && ((BuildingBasedRequester) request.getRequester()).getBuilding(manager, request.getToken()).isPresent() && ((BuildingBasedRequester) request.getRequester()).getBuilding(manager, request.getToken()).get() instanceof AbstractBuilding) {
final AbstractBuilding building = (AbstractBuilding) ((BuildingBasedRequester) request.getRequester()).getBuilding(manager, request.getToken()).get();
final Optional<CitizenData> citizenDataOptional = building.getCitizenForRequest(request.getToken());
final List<ItemStack> resolvablestacks = request.getDisplayStacks();
if (!resolvablestacks.isEmpty() && citizenDataOptional.isPresent()) {
final ItemStack resolveStack = resolvablestacks.get(0);
resolveStack.setCount(Math.min(((IDeliverable) request.getRequest()).getCount(), resolveStack.getMaxStackSize()));
final ItemStack remainingItemStack = InventoryUtils.addItemStackToItemHandlerWithResult(new InvWrapper(citizenDataOptional.get().getInventory()), resolveStack);
if (ItemStackUtils.isEmpty(remainingItemStack)) {
manager.updateRequestState(request.getToken(), RequestState.COMPLETED);
return;
}
}
}
final List<EntityPlayer> players = new ArrayList<>(((Colony) colony).getMessageEntityPlayers());
final EntityPlayer owner = ServerUtils.getPlayerFromUUID(colony.getWorld(), ((Colony) colony).getPermissions().getOwner());
final TextComponentString colonyDescription = new TextComponentString(colony.getName() + ":");
if (manager.getColony().getWorld().isDaytime()) {
if (owner != null) {
players.remove(owner);
LanguageHandler.sendPlayerMessage(owner, "com.minecolonies.requestsystem.playerresolver", request.getRequester().getDisplayName(manager, request.getToken()).getFormattedText(), getRequestMessage(request).getFormattedText(), request.getRequester().getRequesterLocation().toString());
}
LanguageHandler.sendPlayersMessage(players, "com.minecolonies.requestsystem.playerresolver", colonyDescription.getFormattedText() + " " + request.getRequester().getDisplayName(manager, request.getToken()).getFormattedText(), getRequestMessage(request).getFormattedText(), request.getRequester().getRequesterLocation().toString());
}
}
assignedRequests.add(request.getToken());
}
use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.
the class ClaimChunksCommand method execute.
@Override
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final ActionMenu actionMenu) throws CommandException {
// See if the player is opped.
if (sender instanceof EntityPlayerMP && isPlayerOpped(sender)) {
final Colony colony = actionMenu.getColonyForArgument("colony");
if (colony == null) {
sender.sendMessage(new TextComponentString(NO_COLONY_MESSAGE));
return;
}
final int range = actionMenu.getIntegerForArgument("range");
final Boolean add = actionMenu.getBooleanForArgument("add");
final Chunk chunk = ((EntityPlayerMP) sender).getServerWorld().getChunkFromBlockCoords(sender.getPosition());
ColonyManager.claimChunksInRange(colony.getID(), colony.getDimension(), add == null ? true : add, chunk.x, chunk.z, range, 0);
return;
} else {
sender.sendMessage(new TextComponentString(NO_PERMISSION_TO_CLAIM_MESSAGE));
}
}
Aggregations