use of com.ferreusveritas.dynamictrees.trees.Species.LogsAndSticks in project DynamicTrees by DynamicTreesTeam.
the class WailaBranchHandler method getWailaBody.
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> tooltip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (WailaOther.invalid) {
lastPos = BlockPos.ORIGIN;
lastSpecies = Species.NULLSPECIES;
lastVolume = 0;
WailaOther.invalid = false;
}
NBTTagCompound nbtData = accessor.getNBTData();
BlockPos pos = accessor.getPosition();
Species species = Species.NULLSPECIES;
// Attempt to get species from server via NBT data
if (nbtData.hasKey("species")) {
species = TreeRegistry.findSpecies(new ResourceLocation(nbtData.getString("species")));
}
// Attempt to get species by checking if we're still looking at the same block
if (species == Species.NULLSPECIES && lastPos.equals(pos)) {
species = lastSpecies;
}
// Attempt to get species from the world as a last resort as the operation can be rather expensive
if (species == Species.NULLSPECIES) {
species = getWailaSpecies(accessor.getWorld(), pos);
}
if (!species.useDefaultWailaBody()) {
return tooltip;
}
if (!lastPos.equals(pos)) {
lastVolume = getTreeVolume(accessor.getWorld(), pos);
}
// Update the cached species and position
lastSpecies = species;
lastPos = pos;
if (species != Species.NULLSPECIES) {
if (species.showSpeciesOnWaila()) {
tooltip.add("Species: " + species.getLocalizedName());
}
if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips) {
tooltip.add(TextFormatting.DARK_GRAY + species.getRegistryName().toString());
}
String renderString = "";
ItemStack seedStack = species.getSeedStack(1);
String seedName = seedStack.getItem().getRegistryName().toString();
renderString += SpecialChars.getRenderString("waila.stack", "1", seedName, String.valueOf(1), String.valueOf(seedStack.getItemDamage()));
if (lastVolume > 0) {
LogsAndSticks las = species.getLogsAndSticks(lastVolume);
if (las.logs > 0) {
ItemStack logStack = species.getFamily().getPrimitiveLogItemStack(1);
String logName = logStack.getItem().getRegistryName().toString();
renderString += SpecialChars.getRenderString("waila.stack", "1", logName, String.valueOf(las.logs), String.valueOf(logStack.getItemDamage()));
}
if (las.sticks > 0) {
ItemStack stickStack = species.getFamily().getStick(1);
String stickName = stickStack.getItem().getRegistryName().toString();
renderString += SpecialChars.getRenderString("waila.stack", "1", stickName, String.valueOf(las.sticks), String.valueOf(stickStack.getItemDamage()));
}
}
tooltip.add(renderString);
}
return tooltip;
}
use of com.ferreusveritas.dynamictrees.trees.Species.LogsAndSticks in project DynamicTrees by DynamicTreesTeam.
the class DropCreatorLogs method getLogsDrop.
@Override
public List<ItemStack> getLogsDrop(World world, Species species, BlockPos breakPos, Random random, List<ItemStack> dropList, float volume) {
LogsAndSticks las = species.getLogsAndSticks(volume);
int numLogs = las.logs;
while (numLogs > 0) {
dropList.add(species.getFamily().getPrimitiveLogItemStack(numLogs >= 64 ? 64 : numLogs));
numLogs -= 64;
}
int numSticks = las.sticks;
if (numSticks > 0) {
dropList.add(species.getFamily().getStick(numSticks));
}
return dropList;
}
Aggregations