Skip to content

Commit

Permalink
Fix StemBlock/AttachedStemBlock/PitcherCropBlock not being placeable …
Browse files Browse the repository at this point in the history
…on BWG Farmland (Fabric Only). Closes #176

Signed-off-by: Joseph T. McQuigg <[email protected]>
  • Loading branch information
JT122406 committed Dec 2, 2024
1 parent b9b75f1 commit b44fd1c
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 1.4.5
- Add Spanish (Chile) Translations (es_cl) (Credits: Ganbare-Lucifer) (#172)
- Generalize Particle Registration
- Fix StemBlock/AttachedStemBlock/PitcherCropBlock not being placeable on BWG Farmland (Fabric Only)

# 1.4.4
- Add Russian Translations (ru_ru) (Credits: j-tap)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package net.potionstudios.biomeswevegone.fabric.mixin;

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.AttachedStemBlock;
import net.minecraft.world.level.block.BushBlock;
import net.minecraft.world.level.block.FarmBlock;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(AttachedStemBlock.class)
public abstract class AttachedStemBlockMixin extends BushBlock {
protected AttachedStemBlockMixin(Properties properties) {
super(properties);
}

/**
* @reason Allows crops to be placed on Blocks that extend FarmBlock
* @author Joseph T. McQuigg
*/
@Inject(method = "mayPlaceOn", at = @At("RETURN"), cancellable = true)
protected void mayPlaceOn(BlockState state, BlockGetter level, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(state.getBlock() instanceof FarmBlock);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.potionstudios.biomeswevegone.fabric.mixin;

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.world.level.block.DoublePlantBlock;
import net.minecraft.world.level.block.FarmBlock;
import net.minecraft.world.level.block.PitcherCropBlock;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(PitcherCropBlock.class)
public abstract class PitcherCropBlockMixin extends DoublePlantBlock implements BonemealableBlock {
public PitcherCropBlockMixin(Properties properties) {
super(properties);
}

/**
* @reason Allows crops to be placed on Blocks that extend FarmBlock
* @author Joseph T. McQuigg
*/
@Inject(method = "mayPlaceOn", at = @At("RETURN"), cancellable = true)
protected void mayPlaceOn(BlockState state, BlockGetter level, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(state.getBlock() instanceof FarmBlock);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.potionstudios.biomeswevegone.fabric.mixin;

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.world.level.block.BushBlock;
import net.minecraft.world.level.block.FarmBlock;
import net.minecraft.world.level.block.StemBlock;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(StemBlock.class)
public abstract class StemBlockMixin extends BushBlock implements BonemealableBlock {
protected StemBlockMixin(Properties properties) {
super(properties);
}

/**
* @reason Allows crops to be placed on Blocks that extend FarmBlock
* @author Joseph T. McQuigg
*/
@Inject(method = "mayPlaceOn", at = @At("RETURN"), cancellable = true)
protected void mayPlaceOn(BlockState state, BlockGetter level, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(state.getBlock() instanceof FarmBlock);
}
}
5 changes: 4 additions & 1 deletion Fabric/src/main/resources/biomeswevegone.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
"client": [
],
"mixins": [
"AttachedStemBlockMixin",
"CropBlockMixin",
"PrairieGrassMixin"
"PitcherCropBlockMixin",
"PrairieGrassMixin",
"StemBlockMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit b44fd1c

Please sign in to comment.