use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees by DynamicTreesTeam.
the class CommandSetTree method execute.
@Override
public void execute(World world, ICommandSender sender, String[] args) throws CommandException {
BlockPos pos = BlockPos.ORIGIN;
Species species = null;
String joCode = "";
int turns = 0;
if (args.length < 5) {
throw new WrongUsageException("commands.dynamictrees.setree.usage");
}
for (int arg = 0; arg < args.length; arg++) {
switch(arg) {
case 3:
pos = CommandBase.parseBlockPos(sender, args, 1, false);
break;
case 4:
species = TreeRegistry.findSpeciesSloppy(args[4]);
if (species == Species.NULLSPECIES) {
throw new WrongUsageException("commands.dynamictrees.setree.specieserror", args[4]);
}
break;
case 5:
joCode = args[5];
break;
case 6:
try {
turns = Integer.parseInt(args[6]);
} catch (NumberFormatException e) {
throw new WrongUsageException("commands.dynamictrees.rotatejocode.turnserror", args[6]);
}
break;
}
}
if (joCode.isEmpty()) {
joCode = DEFAULTJOCODE;
}
turns = (3 - (turns % 4)) + 3;
species.getJoCode(joCode).rotate(EnumFacing.getHorizontal(turns)).setCareful(true).generate(world, species, pos, world.getBiome(pos), EnumFacing.SOUTH, 8, SafeChunkBounds.ANY);
}
use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees by DynamicTreesTeam.
the class DendroPotion method addInformation.
@Override
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag tooltipFlag) {
super.addInformation(stack, world, tooltip, tooltipFlag);
DendroPotionType potionType = getPotionType(stack);
if (potionType == DendroPotionType.TRANSFORM) {
Species species = getTargetSpecies(stack);
if (species == null) {
tooltip.add(getPotionType(stack).getLore());
} else {
tooltip.add(getTranslationText("potion.transform.description", species.getLocalizedName()));
}
} else {
tooltip.add(getPotionType(stack).getLore());
}
}
use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees by DynamicTreesTeam.
the class Seed method doPlanting.
public boolean doPlanting(World world, BlockPos pos, EntityPlayer planter, ItemStack seedStack) {
Species species = getSpecies(seedStack);
final Species speciesForLocation = species.getFamily().getSpeciesForLocation(world, pos);
// If the species is the common species and the location override is not the common species, do location override.
if (species.equals(species.getFamily().getCommonSpecies()) && !speciesForLocation.equals(species.getFamily().getCommonSpecies())) {
species = speciesForLocation;
}
if (species.plantSapling(world, pos)) {
// Do the planting
String joCode = getCode(seedStack);
if (!joCode.isEmpty()) {
// Remove the newly created dynamic sapling
world.setBlockToAir(pos);
species.getJoCode(joCode).setCareful(true).generate(world, species, pos.down(), world.getBiome(pos), planter != null ? planter.getHorizontalFacing() : EnumFacing.NORTH, 8, SafeChunkBounds.ANY);
}
return true;
}
return false;
}
use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees by DynamicTreesTeam.
the class Staff method getSpecies.
public Species getSpecies(ItemStack itemStack) {
NBTTagCompound nbt = getNBT(itemStack);
if (nbt.hasKey(TREE)) {
return TreeRegistry.findSpecies(new ResourceLocation(nbt.getString(TREE)));
} else {
Species species = TreeRegistry.findSpeciesSloppy("oak");
setSpecies(itemStack, species);
return species;
}
}
use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees by DynamicTreesTeam.
the class ModelEntityFallingTree method generateTreeQuads.
public List<TreeQuadData> generateTreeQuads(EntityFallingTree entity, World world) {
final BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
final BranchDestructionData destructionData = entity.getDestroyData();
final Species species = destructionData.species;
final BlockPos cutPos = destructionData.cutPos;
final EnumFacing cutDir = destructionData.cutDir;
final ArrayList<TreeQuadData> treeQuads = new ArrayList<>();
if (destructionData.getNumBranches() <= 0) {
return treeQuads;
}
// Draw the ring texture cap on the cut block
IExtendedBlockState exState = destructionData.getBranchBlockState(0);
if (exState == null) {
return treeQuads;
}
for (EnumFacing face : EnumFacing.VALUES) {
exState = exState.withProperty(BlockBranch.CONNECTIONS[face.getIndex()], face == cutDir.getOpposite() ? 8 : 0);
}
int radius = ((BlockBranch) exState.getBlock()).getRadius(exState);
float offset = (8 - Math.min(radius, BlockBranch.RADMAX_NORMAL)) / 16f;
// Since we source the blockState from the destruction data it will always be the same
IBakedModel branchModel = dispatcher.getModelForState(exState.getClean());
treeQuads.addAll(toTreeQuadData(QuadManipulator.getQuads(branchModel, exState, new Vec3d(BlockPos.ORIGIN.offset(cutDir)).scale(offset), new EnumFacing[] { cutDir }), 0xFFFFFFFF, exState.getClean()));
// Draw the rest of the tree/branch
for (int index = 0; index < destructionData.getNumBranches(); index++) {
Block previousBranch = exState.getBlock();
exState = destructionData.getBranchBlockState(index);
if (// Update the branch model only if the block is different
!previousBranch.equals(exState.getBlock())) {
branchModel = dispatcher.getModelForState(exState.getClean());
}
BlockPos relPos = destructionData.getBranchRelPos(index);
treeQuads.addAll(toTreeQuadData(QuadManipulator.getQuads(branchModel, exState, new Vec3d(relPos)), 0xFFFFFFFF, exState.getClean()));
}
// Draw the leaves
HashMap<BlockPos, IBlockState> leavesClusters = species.getFamily().getFellingLeavesClusters(destructionData);
if (leavesClusters != null) {
for (Entry<BlockPos, IBlockState> leafLoc : leavesClusters.entrySet()) {
IBlockState leafState = leafLoc.getValue();
if (leafState instanceof IExtendedBlockState) {
leafState = ((IExtendedBlockState) leafState).getClean();
}
treeQuads.addAll(toTreeQuadData(QuadManipulator.getQuads(dispatcher.getModelForState(leafState), leafLoc.getValue(), new Vec3d(leafLoc.getKey())), species.getLeavesProperties().foliageColorMultiplier(leafState, world, cutPos), leafState));
}
} else {
for (int index = 0; index < destructionData.getNumLeaves(); index++) {
BlockPos relPos = destructionData.getLeavesRelPos(index);
IBlockState state = destructionData.getLeavesBlockState(index);
IBakedModel leavesModel = dispatcher.getModelForState(state);
treeQuads.addAll(toTreeQuadData(QuadManipulator.getQuads(leavesModel, state, new Vec3d(relPos)), destructionData.getLeavesProperties(index).foliageColorMultiplier(state, world, cutPos.add(relPos)), state));
}
}
return treeQuads;
}
Aggregations