Skip to content

Commit 584a691

Browse files
committed
pebbles break glass
1 parent da95e01 commit 584a691

4 files changed

Lines changed: 60 additions & 0 deletions

File tree

CHANGELOG-LATEST.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
- Config option to modify Savage & Ravage creeper spore cloud durations.
88
- Disabled some curative items.
99
- Items in the `raspberry:fireproof` tag no longer burn.
10+
- Spawn eggs are no longer tinted.
11+
- Pebbles now break glass (Twigs).
1012

1113
### Fixed
1214
- Swap Arrows can no longer force Withers into boats.

src/main/java/cc/cassian/raspberry/config/ModConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public class ModConfig {
7070
public boolean disableCurativeItems = true;
7171
public double creeperSporesDurationModifier = 1.0;
7272
public boolean disableSpawnEggTinting = true;
73+
public boolean strongerPebbles = true;
7374

7475
public static void load() {
7576
if (!Files.exists(configPath())) {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package cc.cassian.raspberry.mixin.twigs;
2+
3+
import cc.cassian.raspberry.config.ModConfig;
4+
import com.ninni.twigs.entity.Pebble;
5+
import net.mehvahdjukaar.supplementaries.reg.ModTags;
6+
import net.minecraft.core.BlockPos;
7+
import net.minecraft.world.entity.EntityType;
8+
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
9+
import net.minecraft.world.level.Level;
10+
import net.minecraft.world.level.block.state.BlockState;
11+
import net.minecraft.world.phys.BlockHitResult;
12+
import net.minecraft.world.phys.HitResult;
13+
import org.spongepowered.asm.mixin.Mixin;
14+
import org.spongepowered.asm.mixin.Unique;
15+
import org.spongepowered.asm.mixin.injection.At;
16+
import org.spongepowered.asm.mixin.injection.Inject;
17+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
18+
19+
@Mixin(Pebble.class)
20+
public abstract class PebbleMixin extends ThrowableItemProjectile {
21+
22+
public PebbleMixin(EntityType<? extends ThrowableItemProjectile> entityType, Level level) {
23+
super(entityType, level);
24+
}
25+
26+
@Inject(
27+
method = "onHit",
28+
at = @At(value = "INVOKE", target = "Lcom/ninni/twigs/entity/Pebble;getItem()Lnet/minecraft/world/item/ItemStack;"),
29+
cancellable = true)
30+
private void rewriteRarity(HitResult hitResult, CallbackInfo ci) {
31+
if (ModConfig.get().strongerPebbles && hitResult instanceof BlockHitResult blockHitResult) {
32+
if (raspberryCore$breakGlass(blockHitResult.getBlockPos(), 6))
33+
ci.cancel();
34+
}
35+
}
36+
37+
@Unique
38+
private boolean raspberryCore$breakGlass(BlockPos pos, int chance) {
39+
boolean flag = false;
40+
int c = chance - 1 - this.random.nextInt(4);
41+
BlockState state = this.level.getBlockState(pos);
42+
if (!(state.getBlock().getExplosionResistance() > 3.0F)) {
43+
if (c >= 0 && state.is(ModTags.BRICK_BREAKABLE_GLASS)) {
44+
this.level.destroyBlock(pos, true);
45+
this.raspberryCore$breakGlass(pos.above(), c);
46+
this.raspberryCore$breakGlass(pos.below(), c);
47+
this.raspberryCore$breakGlass(pos.east(), c);
48+
this.raspberryCore$breakGlass(pos.west(), c);
49+
this.raspberryCore$breakGlass(pos.north(), c);
50+
this.raspberryCore$breakGlass(pos.south(), c);
51+
flag = true;
52+
}
53+
}
54+
return flag;
55+
}
56+
}

src/main/resources/raspberry.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
"survivality.SurvivalityUtilsMixin",
155155
"toms_storage.AbstractStorageTerminalScreenMixin",
156156
"toms_storage.StorageTerminalMenuMixin",
157+
"twigs.PebbleMixin",
157158
"upgrade_aquatic.PikeMixin",
158159
"upgrade_aquatic.ThrasherMixin",
159160
"upgrade_aquatic.ThrasherThrashGoalMixin",

0 commit comments

Comments
 (0)