use of net.minecraft.util.text.ITextComponent in project BloodMagic by WayofTime.
the class RitualLivingArmourDowngrade method performRitual.
@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
World world = masterRitualStone.getWorldObj();
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
if (currentEssence < getRefreshCost()) {
masterRitualStone.getOwnerNetwork().causeNausea();
return;
}
BlockPos masterPos = masterRitualStone.getBlockPos();
AreaDescriptor downgradeRange = getBlockRange(DOWNGRADE_RANGE);
boolean isActivatorPresent = false;
for (EntityPlayer player : world.getEntitiesWithinAABB(EntityPlayer.class, downgradeRange.getAABB(masterRitualStone.getBlockPos()))) {
if (player.getGameProfile().getId().equals(masterRitualStone.getOwner())) {
ItemStack keyStack = getStackFromItemFrame(world, masterPos, masterRitualStone.getDirection());
if (keyStack.isEmpty()) {
return;
}
List<ITextComponent> textList = LivingArmourDowngradeRecipeRegistry.getDialogForProcessTick(keyStack, internalTimer);
if (textList != null) {
ChatUtil.sendChat(player, textList.toArray(new ITextComponent[textList.size()]));
}
internalTimer++;
if (player.isSneaking()) {
double distance2 = masterPos.offset(EnumFacing.UP).distanceSqToCenter(player.posX, player.posY, player.posZ);
if (distance2 > 1) {
return;
}
BlockPos chestPos = masterPos.offset(masterRitualStone.getDirection(), 2).offset(EnumFacing.UP);
TileEntity tile = world.getTileEntity(chestPos);
if (tile == null) {
return;
}
IItemHandler inv = Utils.getInventory(tile, null);
if (inv != null) {
List<ItemStack> recipeList = new ArrayList<>();
for (int i = 0; i < inv.getSlots(); i++) {
ItemStack invStack = inv.getStackInSlot(i);
if (!invStack.isEmpty()) {
recipeList.add(invStack);
}
}
LivingArmourDowngradeRecipe recipe = LivingArmourDowngradeRecipeRegistry.getMatchingRecipe(keyStack, recipeList, world, masterPos);
if (recipe != null) {
LivingArmourUpgrade upgrade = recipe.getRecipeOutput();
if (LivingArmour.hasFullSet(player)) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null) {
if (armour.canApplyUpgrade(player, upgrade)) {
if (armour.upgradeArmour(player, upgrade)) {
ItemLivingArmour.setLivingArmour(chestStack, armour);
recipe.consumeInventory(inv);
EntityLightningBolt lightning = new EntityLightningBolt(world, chestPos.getX(), chestPos.getY(), chestPos.getZ(), true);
world.spawnEntity(lightning);
masterRitualStone.setActive(false);
}
} else {
// TODO: You are not able to receive my blessing...
// TODO: Need to add a timer that will stop it from working.
}
}
}
}
}
}
return;
}
}
if (!isActivatorPresent) {
internalTimer = 0;
}
}
use of net.minecraft.util.text.ITextComponent in project GregTech by GregTechCE.
the class MetaTileEntityLargeBoiler method addDisplayText.
@Override
protected void addDisplayText(List<ITextComponent> textList) {
super.addDisplayText(textList);
if (isStructureFormed()) {
textList.add(new TextComponentTranslation("gregtech.multiblock.large_boiler.temperature", currentTemperature, boilerType.maxTemperature));
textList.add(new TextComponentTranslation("gregtech.multiblock.large_boiler.steam_output", lastTickSteamOutput, boilerType.baseSteamOutput));
ITextComponent heatEffText = new TextComponentTranslation("gregtech.multiblock.large_boiler.heat_efficiency", (int) (getHeatEfficiencyMultiplier() * 100));
withHoverTextTranslate(heatEffText, "gregtech.multiblock.large_boiler.heat_efficiency.tooltip");
textList.add(heatEffText);
ITextComponent throttleText = new TextComponentTranslation("gregtech.multiblock.large_boiler.throttle", throttlePercentage, (int) (getThrottleEfficiency() * 100));
withHoverTextTranslate(throttleText, "gregtech.multiblock.large_boiler.throttle.tooltip");
textList.add(throttleText);
ITextComponent buttonText = new TextComponentTranslation("gregtech.multiblock.large_boiler.throttle_modify");
buttonText.appendText(" ");
buttonText.appendSibling(withButton(new TextComponentString("[-]"), "sub"));
buttonText.appendText(" ");
buttonText.appendSibling(withButton(new TextComponentString("[+]"), "add"));
textList.add(buttonText);
}
}
use of net.minecraft.util.text.ITextComponent in project GregTech by GregTechCE.
the class MultiblockWithDisplayBase method addDisplayText.
/**
* Called serverside to obtain text displayed in GUI
* each element of list is displayed on new line
* to use translation, use TextComponentTranslation
*/
protected void addDisplayText(List<ITextComponent> textList) {
if (!isStructureFormed()) {
ITextComponent tooltip = new TextComponentTranslation("gregtech.multiblock.invalid_structure.tooltip");
tooltip.setStyle(new Style().setColor(TextFormatting.GRAY));
textList.add(new TextComponentTranslation("gregtech.multiblock.invalid_structure").setStyle(new Style().setColor(TextFormatting.RED).setHoverEvent(new HoverEvent(Action.SHOW_TEXT, tooltip))));
}
}
use of net.minecraft.util.text.ITextComponent in project GregTech by GregTechCE.
the class BlockSurfaceRockNew method getMagnifyResults.
@Override
public List<ITextComponent> getMagnifyResults(IBlockAccess world, BlockPos pos, IBlockState blockState, EntityPlayer player) {
TileEntitySurfaceRock tileEntity = getTileEntity(world, pos);
if (tileEntity == null) {
return Collections.emptyList();
}
List<Material> materials = tileEntity.getUndergroundMaterials();
ITextComponent materialComponent = new TextComponentTranslation(tileEntity.getMaterial().getUnlocalizedName());
materialComponent.getStyle().setColor(TextFormatting.GREEN);
ITextComponent baseComponent = new TextComponentString("");
ITextComponent separator = new TextComponentString(", ");
separator.getStyle().setColor(TextFormatting.GRAY);
for (int i = 0; i < materials.size(); i++) {
ITextComponent extraComponent = new TextComponentTranslation(materials.get(i).getUnlocalizedName());
extraComponent.getStyle().setColor(TextFormatting.YELLOW);
baseComponent.appendSibling(extraComponent);
if (i + 1 != materials.size())
baseComponent.appendSibling(separator);
}
ArrayList<ITextComponent> result = new ArrayList<>();
result.add(new TextComponentTranslation("gregtech.block.surface_rock.material", materialComponent));
result.add(new TextComponentTranslation("gregtech.block.surface_rock.underground_materials", baseComponent));
return result;
}
use of net.minecraft.util.text.ITextComponent in project GregTech by GregTechCE.
the class CoverFluidRegulator method getHoverString.
protected void getHoverString(List<ITextComponent> textList) {
switch(this.transferMode) {
case KEEP_EXACT:
ITextComponent keepComponent = new TextComponentString(getTransferSizeString());
TextComponentTranslation hoverKeep = new TextComponentTranslation("cover.fluid_regulator.keep_exact", this.keepAmount);
keepComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverKeep));
textList.add(keepComponent);
break;
case TRANSFER_EXACT:
ITextComponent supplyComponent = new TextComponentString(getTransferSizeString());
TextComponentTranslation hoverSupply = new TextComponentTranslation("cover.fluid_regulator.supply_exact", this.supplyAmount);
supplyComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverSupply));
textList.add(supplyComponent);
break;
}
}
Aggregations