use of net.minecraft.util.text.TextComponentTranslation in project DefiledLands by Lykrast.
the class ItemBookWyrmAnalyzer method itemInteractionForEntity.
/**
* Returns true if the item can be used on the given entity, e.g. shears on sheep.
*/
@Override
public boolean itemInteractionForEntity(ItemStack itemstack, net.minecraft.entity.player.EntityPlayer player, EntityLivingBase entity, net.minecraft.util.EnumHand hand) {
if (entity.world.isRemote) {
return false;
}
if (entity instanceof EntityBookWyrm) {
EntityBookWyrm target = (EntityBookWyrm) entity;
String base = "ui.defiledlands.book_wyrm_analyze.";
player.sendMessage(new TextComponentTranslation(base + "health", (int) target.getHealth(), (int) target.getMaxHealth()));
player.sendMessage(new TextComponentTranslation(base + "digest_time", target.getDigestTime()));
player.sendMessage(new TextComponentTranslation(base + "max_level", target.getMaxLevel()));
player.sendMessage(new TextComponentTranslation(base + "digested", target.digested));
if (target.digesting > 0)
player.sendMessage(new TextComponentTranslation(base + "digesting", target.digesting));
if (target.isChild()) {
int minutes = (int) Math.ceil((-target.getGrowingAge()) / 1200.0D);
player.sendMessage(new TextComponentTranslation(base + "maturing", minutes));
} else if (target.getGrowingAge() > 0) {
int minutes = (int) Math.ceil(target.getGrowingAge() / 1200.0D);
player.sendMessage(new TextComponentTranslation(base + "reproduce", minutes));
} else
player.sendMessage(new TextComponentTranslation(base + "ready"));
if (target.isGolden())
player.sendMessage(new TextComponentTranslation(base + "golden"));
return true;
}
return false;
}
use of net.minecraft.util.text.TextComponentTranslation in project Wizardry by TeamWizardry.
the class ItemFairyBell method itemInteractionForEntity.
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target, EnumHand hand) {
if (playerIn.world.isRemote || playerIn.isSneaking())
return super.itemInteractionForEntity(stack, playerIn, target, hand);
if (target instanceof EntityFairy) {
EntityFairy targetFairy = (EntityFairy) target;
FairyData targetData = targetFairy.getDataFairy();
if (targetData == null)
return super.itemInteractionForEntity(stack, playerIn, target, hand);
if (targetData.isDepressed) {
IMiscCapability cap = MiscCapabilityProvider.getCap(playerIn);
if (cap != null) {
UUID selected = cap.getSelectedFairyUUID();
if (selected != null && selected.equals(targetFairy.getUniqueID())) {
cap.setSelectedFairy(null);
playerIn.world.playSound(null, playerIn.getPosition(), ModSounds.TINY_BELL, SoundCategory.NEUTRAL, 1, 0.25f);
playerIn.sendStatusMessage(new TextComponentTranslation("item.wizardry:fairy_bell.status.deselected"), true);
} else if (selected != null && !selected.equals(targetFairy.getUniqueID())) {
List<Entity> list = playerIn.world.loadedEntityList;
for (Entity entity : list) {
if (entity instanceof EntityFairy && entity.getUniqueID().equals(selected)) {
if (entity.isDead)
continue;
((EntityFairy) entity).setChainedFairy(targetFairy.getUniqueID());
targetFairy.setChainedFairy(selected);
playerIn.sendStatusMessage(new TextComponentTranslation("item.wizardry:fairy_bell.status.linked_to_fairy"), true);
break;
}
}
} else {
cap.setSelectedFairy(targetFairy.getUniqueID());
boolean movingMode = NBTHelper.getBoolean(stack, "moving_mode", true);
if (!movingMode) {
playerIn.world.playSound(null, playerIn.getPosition(), ModSounds.TINY_BELL, SoundCategory.NEUTRAL, 1, 0.75f);
} else {
playerIn.world.playSound(null, playerIn.getPosition(), ModSounds.TINY_BELL, SoundCategory.NEUTRAL, 1, 1.25f);
}
playerIn.sendStatusMessage(new TextComponentTranslation(movingMode ? "item.wizardry:fairy_bell.status.fairy_moving" : "item.wizardry:fairy_bell.status.fairy_aiming"), true);
}
cap.dataChanged(playerIn);
}
}
}
return super.itemInteractionForEntity(stack, playerIn, target, hand);
}
use of net.minecraft.util.text.TextComponentTranslation in project minecolonies by Minecolonies.
the class AbstractEntityAIStructure method structureStep.
private Boolean structureStep(final Structure.StructureBlock structureBlock) {
if (!BlockUtils.shouldNeverBeMessedWith(structureBlock.worldBlock)) {
worker.setLatestStatus(new TextComponentTranslation("com.minecolonies.coremod.status.building"));
// also ensure we are at that position.
if (!walkToConstructionSite()) {
return false;
}
if (structureBlock.block == null || (!structureBlock.metadata.getMaterial().isSolid() && structureBlock.block != Blocks.AIR)) {
// findNextBlock count was reached and we can ignore this block
return true;
}
if (structureBlock.doesStructureBlockEqualWorldBlock()) {
connectBlockToBuildingIfNecessary(structureBlock.metadata, structureBlock.blockPosition);
// findNextBlock count was reached and we can ignore this block
return true;
}
@Nullable Block block = structureBlock.block;
@Nullable IBlockState blockState = structureBlock.metadata;
if (block == ModBlocks.blockSolidSubstitution && shallReplaceSolidSubstitutionBlock(structureBlock.worldBlock, structureBlock.worldMetadata)) {
blockState = getSolidSubstitution(structureBlock.blockPosition);
block = blockState.getBlock();
}
worker.faceBlock(structureBlock.blockPosition);
// should never happen
if (block == null) {
@NotNull final BlockPos local = structureBlock.blockPosition;
Log.getLogger().error(String.format("StructureProxy has null block at %s - local(%s)", currentStructure.getCurrentBlockPosition(), local));
return true;
}
return placeBlockAt(blockState, structureBlock.blockPosition);
}
return true;
}
use of net.minecraft.util.text.TextComponentTranslation in project minecolonies by Minecolonies.
the class AbstractEntityAIStructure method spawnEntity.
/**
* Iterates through all entities and spawns them
* Suppressing Sonar Rule Squid:S3047
* The rule thinks we can merge the two forge loops iterating over resources
* But in this case the rule does not apply because that would destroy the logic.
*/
@SuppressWarnings(MULTIPLE_LOOPS_OVER_THE_SAME_SET_SHOULD_BE_COMBINED)
private Boolean spawnEntity(@NotNull final Structure.StructureBlock currentBlock) {
final Template.EntityInfo entityInfo = currentBlock.entity;
if (entityInfo == null) {
return true;
}
worker.setLatestStatus(new TextComponentTranslation("com.minecolonies.coremod.status.spawning"));
final Entity entity = ItemStackUtils.getEntityFromEntityInfoOrNull(entityInfo, world);
if (entity != null && !isEntityAtPosition(entity, world)) {
final List<ItemStack> request = new ArrayList<>();
if (entity instanceof EntityItemFrame) {
final ItemStack stack = ((EntityItemFrame) entity).getDisplayedItem();
if (!ItemStackUtils.isEmpty(stack)) {
ItemStackUtils.changeSize(stack, 1);
request.add(stack);
}
request.add(new ItemStack(Items.ITEM_FRAME, 1));
} else if (entity instanceof EntityArmorStand) {
request.add(entity.getPickedResult(new RayTraceResult(worker)));
entity.getArmorInventoryList().forEach(request::add);
entity.getHeldEquipment().forEach(request::add);
} else {
request.add(entity.getPickedResult(new RayTraceResult(worker)));
}
if (!Configurations.gameplay.builderInfiniteResources) {
if (PlacementHandlers.checkForListInInvAndRequest(this, new ArrayList<>(request))) {
return false;
}
// Surpress
for (final ItemStack stack : request) {
if (ItemStackUtils.isEmpty(stack)) {
continue;
}
final int slot = worker.findFirstSlotInInventoryWith(stack.getItem(), stack.getItemDamage());
if (slot != -1) {
new InvWrapper(getInventory()).extractItem(slot, 1, false);
reduceNeededResources(stack);
}
}
}
entity.setUniqueId(UUID.randomUUID());
entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
if (!world.spawnEntity(entity)) {
Log.getLogger().info("Failed to spawn entity");
}
}
return true;
}
use of net.minecraft.util.text.TextComponentTranslation in project minecolonies by Minecolonies.
the class AbstractEntityAIUsesFurnace method checkForAdditionalJobs.
/**
* Check for additional jobs to execute after the traditional furnace user jobs have been handled.
* @return the next AIState to go to.
*/
protected AIState checkForAdditionalJobs() {
worker.setLatestStatus(new TextComponentTranslation(COM_MINECOLONIES_COREMOD_STATUS_IDLING));
setDelay(WAIT_AFTER_REQUEST);
walkToBuilding();
return START_WORKING;
}
Aggregations