Skip to content

Commit

Permalink
Prevent placement of fully grown plants (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
OneEyeMaker authored Nov 13, 2024
1 parent 862bd34 commit 5119bce
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Add your dependencies here

dependencies {
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.50.58:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.50.67:dev') {transitive=false}

compile('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compile('com.github.GTNewHorizons:CodeChickenLib:1.3.0:dev')
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ enableGenericInjection = false
# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
generateGradleTokenClass =
generateGradleTokenClass = tb.core.Tags

# Name of the token containing the project's current version to generate/replace.
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenVersion = VERSION

# [DEPRECATED] Mod ID replacement token.
gradleTokenModId =
Expand All @@ -70,7 +70,7 @@ gradleTokenGroupName =
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...]).
# Leave these properties empty to skip individual token replacements.
replaceGradleTokenInFile = TBCore.java
replaceGradleTokenInFile =

# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/tb/common/block/BlockTBPlant.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.block.IGrowable;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
Expand Down Expand Up @@ -52,7 +53,7 @@ public Item getItem(World w, int x, int y, int z) {
}

protected boolean canPlaceBlockOn(Block b) {
return requiresFarmland ? b == Blocks.farmland : true;
return !requiresFarmland || b == Blocks.farmland;
}

public void updateTick(World w, int x, int y, int z, Random rnd) {
Expand Down Expand Up @@ -143,6 +144,12 @@ public void func_149853_b(World w, Random r, int x, int y, int z) {
3);
}

@Override
public void onBlockPlacedBy(World worldIn, int x, int y, int z, EntityLivingBase placer, ItemStack itemIn) {
// Prevent placement of fully grown plants
worldIn.setBlockMetadataWithNotify(x, y, z, 0, 2);
}

@Override
public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int aSide, float pX,
float pY, float pZ) {
Expand Down Expand Up @@ -177,7 +184,7 @@ public int getRenderType() {

@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
ArrayList<ItemStack> ret = new ArrayList<>();

if (this.dropItem != null && metadata >= growthStages - 1) {
// You can approximate the fortune bonus by diving https://oeis.org/A000169 with https://oeis.org/A000435
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/tb/core/TBCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
public class TBCore {

public static final String modid = "thaumicbases";
public static final String version = "GRADLETOKEN_VERSION";
public static final String version = Tags.VERSION;
public static final String name = "Thaumic Bases";
public static final String serverProxy = "tb.network.proxy.TBServer";
public static final String clientProxy = "tb.network.proxy.TBClient";
Expand Down Expand Up @@ -104,7 +104,7 @@ public void setupModInfo(ModMetadata meta) {
meta.name = name;
meta.version = version;
meta.description = "A Thaumcraft addon, that adds more earlygame and midgame content";
ArrayList<String> authors = new ArrayList<String>();
ArrayList<String> authors = new ArrayList<>();
authors.add("Modbder");
authors.add("KryptonCaptain");
authors.add("bartimaeusnek");
Expand Down

0 comments on commit 5119bce

Please sign in to comment.