Skip to content

Commit d6f3934

Browse files
committed
add rule: disabledEnderManPickupGoal
1 parent 50cb256 commit d6f3934

File tree

5 files changed

+63
-4
lines changed

5 files changed

+63
-4
lines changed

build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '0.7-SNAPSHOT'
2+
id 'fabric-loom' version '0.11-SNAPSHOT'
33
id 'maven-publish'
44
}
55

@@ -55,6 +55,10 @@ tasks.withType(JavaCompile).configureEach {
5555
}
5656
}
5757

58+
loom {
59+
accessWidenerPath.set(file("src/main/resources/opt-carpet-addition.accesswidener"))
60+
}
61+
5862
java {
5963
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
6064
// if it is present.

src/main/java/io/github/optijava/opt_carpet_addition/OptCarpetSettings.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,15 @@ public class OptCarpetSettings {
8787
public static boolean enableTpHerePrefixWhitelist = false;
8888

8989
@Rule(
90-
desc = "Disable Chicken Lays Eggs",
90+
desc = "Disable chicken laying eggs",
9191
category = RuleCategory.FEATURE
9292
)
9393
public static boolean disabledLayEggs = false;
9494

95+
@Rule(
96+
desc = "Disable Enderman pickup goal",
97+
category = RuleCategory.FEATURE
98+
)
99+
public static boolean disabledEnderManPickupGoal = false;
95100

96101
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package io.github.optijava.opt_carpet_addition.mixins.disabledEnderManPickupGoal;
2+
3+
import io.github.optijava.opt_carpet_addition.OptCarpetSettings;
4+
import net.minecraft.block.Block;
5+
import net.minecraft.block.BlockState;
6+
import net.minecraft.entity.mob.EndermanEntity;
7+
import net.minecraft.tag.BlockTags;
8+
import net.minecraft.util.hit.BlockHitResult;
9+
import net.minecraft.util.math.BlockPos;
10+
import net.minecraft.util.math.MathHelper;
11+
import net.minecraft.util.math.Vec3d;
12+
import net.minecraft.world.RaycastContext;
13+
import net.minecraft.world.World;
14+
import org.spongepowered.asm.mixin.Mixin;
15+
import org.spongepowered.asm.mixin.Overwrite;
16+
import org.spongepowered.asm.mixin.Shadow;
17+
18+
import java.util.Random;
19+
20+
@Mixin(EndermanEntity.PickUpBlockGoal.class)
21+
public class EnderManEntity_Mixin {
22+
@Shadow
23+
EndermanEntity enderman;
24+
25+
@Overwrite
26+
public void tick() {
27+
if (!OptCarpetSettings.disabledEnderManPickupGoal) {
28+
Random random = this.enderman.getRandom();
29+
World world = this.enderman.world;
30+
int i = MathHelper.floor(this.enderman.getX() - 2.0 + random.nextDouble() * 4.0);
31+
int j = MathHelper.floor(this.enderman.getY() + random.nextDouble() * 3.0);
32+
int k = MathHelper.floor(this.enderman.getZ() - 2.0 + random.nextDouble() * 4.0);
33+
BlockPos blockPos = new BlockPos(i, j, k);
34+
BlockState blockState = world.getBlockState(blockPos);
35+
Block block = blockState.getBlock();
36+
Vec3d vec3d = new Vec3d((double) MathHelper.floor(this.enderman.getX()) + 0.5, (double) j + 0.5, (double) MathHelper.floor(this.enderman.getZ()) + 0.5);
37+
Vec3d vec3d2 = new Vec3d((double) i + 0.5, (double) j + 0.5, (double) k + 0.5);
38+
BlockHitResult blockHitResult = world.raycast(new RaycastContext(vec3d, vec3d2, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, this.enderman));
39+
boolean bl = blockHitResult.getBlockPos().equals(blockPos);
40+
if (block.isIn(BlockTags.ENDERMAN_HOLDABLE) && bl) {
41+
world.removeBlock(blockPos, false);
42+
this.enderman.setCarriedBlock(blockState.getBlock().getDefaultState());
43+
}
44+
}
45+
}
46+
}

src/main/resources/fabric.mod.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
"mixins": [
2323
"opt-carpet-addition.mixins.json"
2424
],
25+
"accessWidener": "opt-carpet-addition.accesswidener",
2526
"depends": {
2627
"minecraft": "1.16.x",
27-
"fabric": "*",
28-
"carpet": "*"
28+
"fabricloader": ">=0.7.4",
29+
"fabric": ">=0.34.2",
30+
"carpet": ">=1.4.40+v210608"
2931
},
3032
"suggests": {
3133
"another-mod": "Carpet-TIS-Addition"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
accessWidener v1 named
2+
accessible class net/minecraft/entity/mob/EndermanEntity$PickUpBlockGoal

0 commit comments

Comments
 (0)