Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement right-click functionality for crops #40

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Add your dependencies here

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

compile('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compile('com.github.GTNewHorizons:CodeChickenLib:1.2.1:dev')
compile('com.github.GTNewHorizons:CodeChickenLib:1.3.0:dev')
compile('com.github.GTNewHorizons:DummyCore:1.19.0:dev')
runtimeOnly("com.github.GTNewHorizons:NotEnoughItems:2.6.11-GTNH:dev")
runtimeOnly("com.github.GTNewHorizons:NotEnoughItems:2.6.22-GTNH:dev")

runtimeOnly('com.github.GTNewHorizons:Baubles:1.0.4:dev')
runtimeOnly('com.github.GTNewHorizons:CodeChickenCore:1.2.1:dev') // Required to allow dummycore to run in dev
runtimeOnly('com.github.GTNewHorizons:CodeChickenCore:1.3.6:dev') // Required to allow dummycore to run in dev
}
22 changes: 21 additions & 1 deletion src/main/java/tb/common/block/BlockTBPlant.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import net.minecraft.block.BlockBush;
import net.minecraft.block.IGrowable;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
Expand All @@ -27,6 +29,7 @@ public class BlockTBPlant extends BlockBush implements IGrowable {
public IIcon[] growthIcons;
public ItemStack dropItem;
public ItemStack dropSeed;
private boolean pRightClick = false;

public BlockTBPlant(int stages, int delay, boolean isCrop) {
super();
Expand Down Expand Up @@ -140,6 +143,23 @@ public void func_149853_b(World w, Random r, int x, int y, int z) {
3);
}

@Override
public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int aSide, float pX,
float pY, float pZ) {
int aMeta = aWorld.getBlockMetadata(aX, aY, aZ);
// check for Growth Stage
if (aMeta >= growthStages - 1) {
// eval fortune on rightclick
int fortune = EnchantmentHelper.getFortuneModifier(aPlayer);
this.pRightClick = true;
this.dropBlockAsItem(aWorld, aX, aY, aZ, aMeta, fortune);
this.pRightClick = false;

aWorld.setBlock(aX, aY, aZ, this, 0, 2);
}
return false;
}

@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
growthIcons = new IIcon[growthStages];
Expand Down Expand Up @@ -192,7 +212,7 @@ public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metad
ret.add(drop);
}
}
if (dropSeed != null) ret.add(dropSeed.copy());
if (dropSeed != null && !pRightClick) ret.add(dropSeed.copy());

return ret;
}
Expand Down