use of net.minecraft.text.TranslatableText in project ArmorStandEditor by Patbox.
the class Events method modifyArmorStand.
public static void modifyArmorStand(ServerPlayerEntity player, ArmorStandEntity armorStand, int val, Entity realEntity) {
SPEInterface spei = (SPEInterface) player;
ArmorStandEntityAccessor asea = (ArmorStandEntityAccessor) armorStand;
double power = spei.getArmorStandEditorPower();
int dX = spei.getArmorStandEditorXYZ() == 0 ? 1 : 0;
int dY = spei.getArmorStandEditorXYZ() == 1 ? 1 : 0;
int dZ = spei.getArmorStandEditorXYZ() == 2 ? 1 : 0;
double posX = armorStand.getX();
double posY = armorStand.getY();
double posZ = armorStand.getZ();
float angleChange = (float) (val * power * 30);
EulerAngle angle;
switch(spei.getArmorStandEditorAction()) {
case MOVE:
armorStand.teleport(posX + dX * power * val, posY + dY * power * val, posZ + dZ * power * val);
break;
case ROTATE:
armorStand.setYaw(armorStand.getYaw(1.0F) + angleChange);
armorStand.updatePositionAndAngles(posX, posY, posZ, armorStand.getYaw(1.0F), 0);
break;
case TOGGLE_GRAVITY:
armorStand.setNoGravity(!armorStand.hasNoGravity());
break;
case TOGGLE_BASE:
asea.callSetHideBasePlate(!armorStand.shouldHideBasePlate());
break;
case TOGGLE_SIZE:
asea.callSetSmall(!armorStand.isSmall());
break;
case TOGGLE_ARMS:
asea.callSetShowArms(!armorStand.shouldShowArms());
break;
case TOGGLE_VISIBILITY:
armorStand.setInvisible(!armorStand.isInvisible());
break;
case MODIFY_HEAD:
angle = armorStand.getHeadRotation();
armorStand.setHeadRotation(new EulerAngle(angle.getPitch() + dX * angleChange, angle.getYaw() + dY * angleChange, angle.getRoll() + dZ * angleChange));
break;
case MODIFY_BODY:
angle = armorStand.getBodyRotation();
armorStand.setBodyRotation(new EulerAngle(angle.getPitch() + dX * angleChange, angle.getYaw() + dY * angleChange, angle.getRoll() + dZ * angleChange));
break;
case MODIFY_LEFT_ARM:
angle = asea.getLeftArmRotation();
armorStand.setLeftArmRotation(new EulerAngle(angle.getPitch() + dX * angleChange, angle.getYaw() + dY * angleChange, angle.getRoll() + dZ * angleChange));
break;
case MODIFY_RIGHT_ARM:
angle = asea.getRightArmRotation();
armorStand.setRightArmRotation(new EulerAngle(angle.getPitch() + dX * angleChange, angle.getYaw() + dY * angleChange, angle.getRoll() + dZ * angleChange));
break;
case MODIFY_LEFT_LEG:
angle = asea.getLeftLegRotation();
armorStand.setLeftLegRotation(new EulerAngle(angle.getPitch() + dX * angleChange, angle.getYaw() + dY * angleChange, angle.getRoll() + dZ * angleChange));
break;
case MODIFY_RIGHT_LEG:
angle = asea.getRightLegRotation();
armorStand.setRightLegRotation(new EulerAngle(angle.getPitch() + dX * angleChange, angle.getYaw() + dY * angleChange, angle.getRoll() + dZ * angleChange));
break;
case RESET_POSE:
armorStand.setHeadRotation(new EulerAngle(0, 0, 0));
armorStand.setBodyRotation(new EulerAngle(0, 0, 0));
armorStand.setLeftArmRotation(new EulerAngle(0, 0, 0));
armorStand.setRightArmRotation(new EulerAngle(0, 0, 0));
armorStand.setLeftLegRotation(new EulerAngle(0, 0, 0));
armorStand.setRightLegRotation(new EulerAngle(0, 0, 0));
break;
case FLIP_POSE:
ArmorStandData data = new ArmorStandData(armorStand);
armorStand.setHeadRotation(new EulerAngle(data.headRotation.getPitch(), 360 - data.headRotation.getYaw(), 360 - data.headRotation.getRoll()));
armorStand.setBodyRotation(new EulerAngle(data.bodyRotation.getPitch(), 360 - data.bodyRotation.getYaw(), 360 - data.bodyRotation.getRoll()));
armorStand.setRightArmRotation(new EulerAngle(data.leftArmRotation.getPitch(), 360 - data.leftArmRotation.getYaw(), 360 - data.leftArmRotation.getRoll()));
armorStand.setLeftArmRotation(new EulerAngle(data.rightArmRotation.getPitch(), 360 - data.rightArmRotation.getYaw(), 360 - data.rightArmRotation.getRoll()));
armorStand.setRightLegRotation(new EulerAngle(data.leftLegRotation.getPitch(), 360 - data.leftLegRotation.getYaw(), 360 - data.leftLegRotation.getRoll()));
armorStand.setLeftLegRotation(new EulerAngle(data.rightLegRotation.getPitch(), 360 - data.rightLegRotation.getYaw(), 360 - data.rightLegRotation.getRoll()));
break;
case COPY:
spei.setArmorStandEditorData(new ArmorStandData(armorStand));
spei.setArmorStandEditorAction(EditorActions.PASTE);
player.sendMessage(new TranslatableText("armorstandeditor.message.copied"), true);
break;
case PASTE:
if (spei.getArmorStandEditorData() != null) {
ArmorStandData base = spei.getArmorStandEditorData();
base.apply(armorStand, player.isCreative());
if (realEntity != null) {
realEntity.setCustomNameVisible(base.customNameVisible);
if (base.customName != null) {
realEntity.setCustomName(base.customName);
}
if (player.isCreative() && realEntity instanceof LivingEntity) {
realEntity.equipStack(EquipmentSlot.HEAD, base.headItem);
realEntity.equipStack(EquipmentSlot.CHEST, base.chestItem);
realEntity.equipStack(EquipmentSlot.LEGS, base.legsItem);
realEntity.equipStack(EquipmentSlot.FEET, base.feetItem);
realEntity.equipStack(EquipmentSlot.MAINHAND, base.mainHandItem);
realEntity.equipStack(EquipmentSlot.OFFHAND, base.offhandItem);
}
}
player.sendMessage(new TranslatableText("armorstandeditor.message.pasted"), true);
}
break;
case INVENTORY:
if (realEntity instanceof LivingEntity) {
EditorGuis.openInventoryEditor(player, (LivingEntity) realEntity);
} else {
EditorGuis.openInventoryEditor(player, armorStand);
}
break;
case RENAME:
Entity nameTarget = realEntity != null ? realEntity : armorStand;
EditorGuis.openRenaming(player, nameTarget);
break;
}
if (realEntity != null) {
((EntityDisguise) realEntity).disguiseAs(armorStand);
}
}
use of net.minecraft.text.TranslatableText in project ArmorStandEditor by Patbox.
the class GeneralCommands method giveTool.
private static int giveTool(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ItemStack itemStack = ConfigManager.getConfig().armorStandTool.getDefaultStack();
itemStack.getOrCreateTag().putBoolean("isArmorStandEditor", true);
EntitySelector entitySelector = context.getArgument("targets", EntitySelector.class);
for (ServerPlayerEntity player : entitySelector.getPlayers(context.getSource())) {
player.inventory.offerOrDrop(player.world, itemStack);
context.getSource().sendFeedback(new TranslatableText("armorstandeditor.command.give", player.getDisplayName()), true);
}
return 1;
}
use of net.minecraft.text.TranslatableText in project CITResewn by SHsuperCM.
the class CITResewnConfigScreenFactory method create.
public static Screen create(Screen parent) {
CITResewnConfig currentConfig = CITResewnConfig.INSTANCE(), defaultConfig = new CITResewnConfig();
ConfigBuilder builder = ConfigBuilder.create().setParentScreen(parent).setTitle(new TranslatableText("config.citresewn.title")).setSavingRunnable(currentConfig::write);
ConfigCategory category = builder.getOrCreateCategory(new LiteralText(""));
ConfigEntryBuilder entryBuilder = builder.entryBuilder();
category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.enabled.title"), currentConfig.enabled).setTooltip(new TranslatableText("config.citresewn.enabled.tooltip")).setSaveConsumer(newConfig -> {
if (currentConfig.enabled != newConfig) {
currentConfig.enabled = newConfig;
MinecraftClient.getInstance().reloadResources();
}
}).setDefaultValue(defaultConfig.enabled).build());
category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.mute_errors.title"), currentConfig.mute_errors).setTooltip(new TranslatableText("config.citresewn.mute_errors.tooltip")).setSaveConsumer(newConfig -> currentConfig.mute_errors = newConfig).setDefaultValue(defaultConfig.mute_errors).build());
category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.mute_warns.title"), currentConfig.mute_warns).setTooltip(new TranslatableText("config.citresewn.mute_warns.tooltip")).setSaveConsumer(newConfig -> currentConfig.mute_warns = newConfig).setDefaultValue(defaultConfig.mute_warns).build());
category.addEntry(entryBuilder.startFloatField(new TranslatableText("config.citresewn.citenchantment_scroll_multiplier.title"), currentConfig.citenchantment_scroll_multiplier).setTooltip(new TranslatableText("config.citresewn.citenchantment_scroll_multiplier.tooltip")).setSaveConsumer(newConfig -> currentConfig.citenchantment_scroll_multiplier = newConfig).setDefaultValue(defaultConfig.citenchantment_scroll_multiplier).setMin(0f).build());
category.addEntry(entryBuilder.startIntSlider(new TranslatableText("config.citresewn.cache_ms.title"), currentConfig.cache_ms / 50, 0, 5 * 20).setTooltip(new TranslatableText("config.citresewn.cache_ms.tooltip")).setSaveConsumer(newConfig -> currentConfig.cache_ms = newConfig * 50).setDefaultValue(currentConfig.cache_ms / 50).setTextGetter(ticks -> {
if (ticks <= 1)
return new TranslatableText("config.citresewn.cache_ms.ticks." + ticks).formatted(Formatting.AQUA);
Formatting color = Formatting.DARK_RED;
if (ticks <= 40)
color = Formatting.RED;
if (ticks <= 20)
color = Formatting.GOLD;
if (ticks <= 10)
color = Formatting.DARK_GREEN;
if (ticks <= 5)
color = Formatting.GREEN;
return new TranslatableText("config.citresewn.cache_ms.ticks.any", ticks).formatted(color);
}).build());
category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.broken_paths.title"), currentConfig.broken_paths).setTooltip(new TranslatableText("config.citresewn.broken_paths.tooltip")).setSaveConsumer(newConfig -> currentConfig.broken_paths = newConfig).setDefaultValue(defaultConfig.broken_paths).requireRestart().build());
return builder.build();
}
use of net.minecraft.text.TranslatableText in project BedrockIfy by juancarloscp52.
the class Overlay method renderPositionText.
private void renderPositionText(MatrixStack matrixStack) {
BedrockifySettings settings = Bedrockify.getInstance().settings;
int screenBorder = settings.getScreenSafeArea();
int posY = settings.getPositionHUDHeight();
if (!settings.isShowPositionHUDEnabled())
return;
BlockPos blockPos = Objects.requireNonNull(this.client.getCameraEntity(), "Camera Entity cannot be null.").getBlockPos();
MutableText position = new TranslatableText("bedrockify.hud.position").append(new LiteralText(" " + blockPos.getX() + ", " + blockPos.getY() + ", " + blockPos.getZ()));
if (settings.getFPSHUDoption() == 1)
position.append(" ").append(fps);
int positionWidth = client.textRenderer.getWidth(position);
fill(matrixStack, textPosX + screenBorder, posY + screenBorder, textPosX + positionWidth + 6 + screenBorder, posY + 10 + screenBorder, MathHelper.ceil((255.0D * client.options.textBackgroundOpacity)) << 24);
client.textRenderer.drawWithShadow(matrixStack, position, textPosX + 3 + screenBorder, posY + 1 + screenBorder, 16777215);
}
use of net.minecraft.text.TranslatableText in project BedrockIfy by juancarloscp52.
the class HeldItemTooltips method getMaxTooltipLength.
private int getMaxTooltipLength(List<Tooltip> tooltips, TextRenderer textRenderer, ItemStack itemStack) {
int count = 0;
int maxLength = textRenderer.getWidth(itemStack.getName());
for (Tooltip elem : tooltips) {
int tipLength = textRenderer.getWidth(elem.getTooltipText());
if (count > 3)
tipLength = textRenderer.getWidth(new TranslatableText("container.shulkerBox.more", tooltips.size() - 4));
if (maxLength < tipLength)
maxLength = tipLength;
if (count > 3)
break;
count++;
}
return maxLength;
}
Aggregations