generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create gamerule to control whether Endermen holding blocks are persis…
…tent
- Loading branch information
Samadi van Koten
committed
Feb 3, 2021
1 parent
95ab87b
commit f8bb8ad
Showing
9 changed files
with
63 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/main/java/net/fabricmc/example/mixin/ExampleMixin.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
src/main/java/vktec/unpersistendermen/UnpersistEndermenMod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package vktec.unpersistendermen; | ||
|
||
import net.fabricmc.api.ModInitializer; | ||
import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory; | ||
import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry; | ||
import net.minecraft.world.GameRules; | ||
|
||
public class UnpersistEndermenMod implements ModInitializer { | ||
public static GameRules.Key<GameRules.BooleanRule> ENDERMEN_PERSIST = GameRuleRegistry.register("endermenPersist", GameRules.Category.MOBS, GameRuleFactory.createBooleanRule(true)); | ||
|
||
@Override | ||
public void onInitialize() { | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/vktec/unpersistendermen/mixin/EndermanEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package vktec.unpersistendermen.mixin; | ||
|
||
import net.minecraft.block.BlockState; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.mob.EndermanEntity; | ||
import net.minecraft.entity.mob.HostileEntity; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import vktec.unpersistendermen.UnpersistEndermenMod; | ||
|
||
@Mixin(EndermanEntity.class) | ||
public abstract class EndermanEntityMixin extends HostileEntity { | ||
public EndermanEntityMixin(EntityType<? extends EndermanEntity> arg, World arg2) { | ||
super(arg, arg2); | ||
} | ||
|
||
@Redirect(method = "cannotDespawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/mob/EndermanEntity;getCarriedBlock()Lnet/minecraft/block/BlockState;")) | ||
public BlockState redirectCarriedBlock(EndermanEntity self) { | ||
if (self.world.isClient || self.world.getGameRules().getBoolean(UnpersistEndermenMod.ENDERMEN_PERSIST)) { | ||
return self.getCarriedBlock(); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,33 @@ | ||
{ | ||
"schemaVersion": 1, | ||
"id": "modid", | ||
"id": "unpersist-endermen", | ||
"version": "${version}", | ||
|
||
"name": "Example Mod", | ||
"description": "This is an example description! Tell everyone what your mod is about!", | ||
"name": "Unpersist Endermen", | ||
"description": "Make Endermen holding blocks non-persistent", | ||
"authors": [ | ||
"Me!" | ||
"vktec" | ||
], | ||
"contact": { | ||
"homepage": "https://fabricmc.net/", | ||
"sources": "https://github.com/FabricMC/fabric-example-mod" | ||
"homepage": "https://github.com/vktec/unpersist-endermen", | ||
"sources": "https://github.com/vktec/unpersist-endermen" | ||
}, | ||
|
||
"license": "CC0-1.0", | ||
"icon": "assets/modid/icon.png", | ||
"license": "Unlicense", | ||
|
||
"environment": "*", | ||
"entrypoints": { | ||
"main": [ | ||
"net.fabricmc.example.ExampleMod" | ||
"vktec.unpersistendermen.UnpersistEndermenMod" | ||
] | ||
}, | ||
"environment": "*", | ||
"mixins": [ | ||
"modid.mixins.json" | ||
"unpersist-endermen.mixins.json" | ||
], | ||
|
||
"depends": { | ||
"fabricloader": ">=0.7.4", | ||
"fabric": "*", | ||
"fabric-game-rule-api-v1": "*", | ||
"minecraft": "1.16.x" | ||
}, | ||
"suggests": { | ||
"another-mod": "*" | ||
} | ||
} |
6 changes: 2 additions & 4 deletions
6
src/main/resources/modid.mixins.json → .../resources/unpersist-endermen.mixins.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters