Skip to content

Commit

Permalink
Fix #28, Update for recent versions of DT.
Browse files Browse the repository at this point in the history
Fix #27 and #20, register TFC soils as acceptable for all registered DT species. Cactus?
Fix #24, no tree punching!
  • Loading branch information
Gaelmare committed Sep 19, 2020
1 parent b3cb7bc commit 5ccc97d
Show file tree
Hide file tree
Showing 53 changed files with 347 additions and 41 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ repositories {
}

dependencies {
deobfCompile 'com.ferreusveritas.dynamictrees:dynamictrees:0.9.7'
deobfCompile 'com.ferreusveritas.dynamictrees:dynamictrees:0.9.14'
}

processResources {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modGroup=org.labellum.mc
modVersion=0.9.12
modVersion=0.9.13
modBaseName=dynamictreestfc
forgeVersion=1.12.2-14.23.5.2847
mcpVersion=stable_39
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import com.ferreusveritas.dynamictrees.event.BiomeSuitabilityEvent;
import net.dries007.tfc.TerraFirmaCraft;
import org.labellum.mc.dynamictreestfc.proxy.CommonProxy;
import org.labellum.mc.dynamictreestfc.proxy.ClientProxy;

import static com.ferreusveritas.dynamictrees.ModConstants.*;

Expand All @@ -32,10 +30,10 @@ public class DynamicTreesTFC

public static final String MOD_ID = "dynamictreestfc";
public static final String MOD_NAME = "DynamicTreesTFC";
public static final String VERSION = "0.9.12";
public static final String VERSION = "0.9.13";
public static final String DEPENDENCIES
= REQAFTER + TerraFirmaCraft.MOD_ID +
AT + "1.5.3.153" + ORGREATER +
AT + "1.7.3.161" + ORGREATER +
NEXT +
REQAFTER + DYNAMICTREES_LATEST
;
Expand Down Expand Up @@ -79,7 +77,7 @@ public void init(FMLInitializationEvent event)
@Mod.EventHandler
public void postinit(FMLPostInitializationEvent event)
{

ModTrees.postInit();
}


Expand Down
11 changes: 5 additions & 6 deletions src/main/java/org/labellum/mc/dynamictreestfc/ModTrees.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.ResourceLocation;

import net.minecraftforge.registries.IForgeRegistry;
Expand All @@ -16,12 +15,10 @@
import com.ferreusveritas.dynamictrees.growthlogic.IGrowthLogicKit;
import com.ferreusveritas.dynamictrees.systems.featuregen.FeatureGenConiferTopper;
import com.ferreusveritas.dynamictrees.trees.Species;
import com.ferreusveritas.dynamictrees.trees.TreeFamily;

import net.dries007.tfc.api.registries.TFCRegistries;
import net.dries007.tfc.api.types.Tree;
import net.dries007.tfc.objects.blocks.BlocksTFC;
import net.dries007.tfc.objects.blocks.wood.BlockLogTFC;
import net.dries007.tfc.objects.blocks.wood.BlockSaplingTFC;

import org.labellum.mc.dynamictreestfc.trees.TreeFamilyTFC;
Expand Down Expand Up @@ -94,9 +91,6 @@ public static void registerBlocks(IForgeRegistry<Block> registry) {
}
});

Block[] soilBlocks = ModBlocks.allGrowableVariants.toArray(new Block[]{});
Species.REGISTRY.forEach(species -> species.addAcceptableSoil(soilBlocks)); //allow all DT trees on TFC soils. No guarantees on rooty soil behavior!

tfcTrees.forEach(tree -> tree.getRegisterableBlocks(treeBlocks));

treeBlocks.addAll(LeavesPaging.getLeavesMapForModId(MOD_ID).values());
Expand All @@ -112,6 +106,11 @@ public static void registerItems(IForgeRegistry<Item> registry) //has to wait un
});
}

public static void postInit()
{
Block[] soilBlocks = ModBlocks.allGrowableVariants.toArray(new Block[]{});
Species.REGISTRY.forEach(species -> species.addAcceptableSoil(soilBlocks)); //allow all DT trees on TFC soils. No guarantees on rooty soil behavior!
}

private static void fillMaps(Map<String, float[]> paramMap, Map<String, IGrowthLogicKit> logicMap)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.labellum.mc.dynamictreestfc.blocks;

import com.ferreusveritas.dynamictrees.blocks.BlockBranchBasic;
import net.dries007.tfc.ConfigTFC;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import java.util.Set;

public class BlockBranchBasicTFC extends BlockBranchBasic {
public BlockBranchBasicTFC(String name) {
super(name);
}

@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos cutPos, EntityPlayer player, boolean canHarvest) {
ItemStack tool = player.getHeldItemMainhand();
// after BlockLogTFC#harvestBlock
final Set<String> toolClasses = tool.getItem().getToolClasses(tool);
if (toolClasses.contains("axe") || toolClasses.contains("saw")) {
// success!
} else if (toolClasses.contains("hammer") && ConfigTFC.General.TREE.enableHammerSticks) {
// can't force only stick drop from here
// so hammers only drop a few sticks from dynamic trees
return false; //No wood for you!
} else if (ConfigTFC.General.TREE.requiresAxe) {
// Here, there was no valid tool used. Deny spawning any drops since logs require axes
return false; //Also no wood for you!
} else {
// or no tool, but handle normally
}

return super.removedByPlayer(state, world, cutPos, player, canHarvest);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.labellum.mc.dynamictreestfc.blocks;

import com.ferreusveritas.dynamictrees.blocks.BlockBranchThick;
import net.dries007.tfc.ConfigTFC;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import java.util.Set;

public class BlockBranchThickTFC extends BlockBranchThick {
public BlockBranchThickTFC(String name) {
super(name);
}

@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos cutPos, EntityPlayer player, boolean canHarvest) {
ItemStack tool = player.getHeldItemMainhand();
// after BlockLogTFC#harvestBlock
final Set<String> toolClasses = tool.getItem().getToolClasses(tool);
if (toolClasses.contains("axe") || toolClasses.contains("saw")) {
// success!
} else if (toolClasses.contains("hammer") && ConfigTFC.General.TREE.enableHammerSticks) {
// can't force only stick drop from here
// so hammers only drop a few sticks from dynamic trees
return false; //No wood for you!
} else if (ConfigTFC.General.TREE.requiresAxe) {
// Here, there was no valid tool used. Deny spawning any drops since logs require axes
return false; //Also no wood for you!
} else {
// or no tool, but handle normally
}

return super.removedByPlayer(state, world, cutPos, player, canHarvest);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@

import net.minecraft.block.BlockLog;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;

import net.dries007.tfc.api.types.Tree;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import static org.labellum.mc.dynamictreestfc.DynamicTreesTFC.MOD_ID;
// The only purpose of this block is to avoid calling getBlockHardness on a BlockLogTFC with a
Expand All @@ -32,7 +29,7 @@ public BlockLogDTTFC(Tree wood) {
} else {
this.wood = wood;
setSoundType(SoundType.WOOD);
setHardness(5.0F).setResistance(5.0F);
setHardness(2.0F).setResistance(5.0F);
setHarvestLevel("axe", 0);
setCreativeTab(null);
Blocks.FIRE.setFireInfo(this, 5, 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import com.ferreusveritas.dynamictrees.ModConstants;
import com.ferreusveritas.dynamictrees.api.client.ModelHelper;
import com.ferreusveritas.dynamictrees.blocks.BlockBranch;
import com.ferreusveritas.dynamictrees.blocks.BlockBranchThick;
import com.ferreusveritas.dynamictrees.blocks.BlockSurfaceRoot;
import com.ferreusveritas.dynamictrees.models.ModelResourceLocationWrapped;
import com.ferreusveritas.dynamictrees.trees.TreeFamily;

/**
Expand All @@ -32,7 +30,8 @@ public class ModelHelperTFC extends ModelHelper
public static void regModel(TreeFamily tree) {

BlockBranch blockBranch = tree.getDynamicBranch();
ModelResourceLocation modelLocation = getCreateBranchModel(blockBranch, tree.autoCreateBranch());

ModelResourceLocation modelLocation = getBranchModelResourceLocation(blockBranch);

setGenericStateMapper(blockBranch, modelLocation);
if(blockBranch instanceof BlockBranchThick) {
Expand All @@ -45,16 +44,7 @@ public static void regModel(TreeFamily tree) {
}
}

private static ModelResourceLocation getCreateBranchModel(BlockBranch blockBranch, boolean automatic) {
return automatic ? getCreateBranchModelAuto(blockBranch) : getCreateBranchModelManual(blockBranch);
}

private static ModelResourceLocation getCreateBranchModelAuto(BlockBranch blockBranch) {
ResourceLocation family = blockBranch.getFamily().getName();
return new ModelResourceLocationWrapped(new ResourceLocation(ModConstants.MODID, "branch"), blockBranch.getDefaultState());
}

private static ModelResourceLocation getCreateBranchModelManual(BlockBranch blockBranch) {
private static ModelResourceLocation getBranchModelResourceLocation(BlockBranch blockBranch) {
ResourceLocation family = blockBranch.getFamily().getName();
ResourceLocation resloc = new ResourceLocation(family.getNamespace(), "branch/" + family.getPath() );
return new ModelResourceLocation(resloc , null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.labellum.mc.dynamictreestfc.trees;

import java.util.List;

import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
Expand All @@ -18,11 +16,11 @@
import net.dries007.tfc.objects.blocks.wood.BlockLogTFC;
import org.labellum.mc.dynamictreestfc.FeatureGenMoundTFC;
import org.labellum.mc.dynamictreestfc.ModBlocks;
import org.labellum.mc.dynamictreestfc.blocks.BlockBranchBasicTFC;
import org.labellum.mc.dynamictreestfc.blocks.BlockBranchThickTFC;
import org.labellum.mc.dynamictreestfc.blocks.BlockLogDTTFC;
import org.labellum.mc.dynamictreestfc.dropcreators.DropCreatorTFCLog;

import static org.labellum.mc.dynamictreestfc.DynamicTreesTFC.MOD_ID;

public class TreeFamilyTFC extends TreeFamily
{
public boolean hasConiferVariants = false;
Expand Down Expand Up @@ -125,12 +123,6 @@ public List<Item> getRegisterableItems(List<Item> itemList) {
@Override
public BlockBranch createBranch() {
String branchName = "branch/" + getName().getPath();
return isThick() ? new BlockBranchThick(branchName) : new BlockBranchBasic(branchName);
}

@Override
public boolean autoCreateBranch() {
return true;
return isThick() ? new BlockBranchThickTFC(branchName) : new BlockBranchBasicTFC(branchName);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/acacia#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/ash#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/aspen#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/white_cedar#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/birch#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/blackwood#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/chestnut#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/douglas_fir#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/hevea#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/hickory#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/kapok#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/maple#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/oak#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/palm#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/pine#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/rosewood#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/sequoia#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/spruce#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/sycamore#dynamictree" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
for i in ../../trees/*.txt; do tree=`echo $i|sed -e s/.txt// -e s,^.*/trees/,,`; echo $tree; sed -e s/white_cedar/$tree/ base.json >$tree.json ; done
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "dynamictreestfc:branch/white_cedar#dynamictree" }
}
}

0 comments on commit 5ccc97d

Please sign in to comment.