-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bc32d4
commit 00afbad
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/java/turniplabs/halplibe/helper/SpecialMobDropHelper.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,23 @@ | ||
package turniplabs.halplibe.helper; | ||
|
||
import net.minecraft.core.WeightedRandomBag; | ||
import net.minecraft.core.WeightedRandomLootObject; | ||
|
||
public class SpecialMobDropHelper { | ||
|
||
/** | ||
* Manipulates the loot that can drop when a creeper is killed by a skeleton. | ||
*/ | ||
public static class Creeper { | ||
private static final WeightedRandomBag<WeightedRandomLootObject> creeperDrops = new WeightedRandomBag<>(); | ||
|
||
public static void addDrop(WeightedRandomLootObject drop, int weight) { | ||
creeperDrops.addEntry(drop,weight); | ||
} | ||
|
||
public static WeightedRandomBag<WeightedRandomLootObject> getDrops() { | ||
return creeperDrops; | ||
} | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/turniplabs/halplibe/mixin/MobCreeperMixin.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,33 @@ | ||
package turniplabs.halplibe.mixin; | ||
|
||
import net.minecraft.core.WeightedRandomLootObject; | ||
import net.minecraft.core.entity.Entity; | ||
import net.minecraft.core.entity.monster.MobCreeper; | ||
import net.minecraft.core.entity.monster.MobMonster; | ||
import net.minecraft.core.item.ItemStack; | ||
import net.minecraft.core.world.World; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Intrinsic; | ||
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.CallbackInfo; | ||
import turniplabs.halplibe.helper.SpecialMobDropHelper; | ||
|
||
@Mixin(value = MobCreeper.class,remap = false) | ||
public abstract class MobCreeperMixin extends MobMonster { | ||
|
||
private MobCreeperMixin(@Nullable World world) { | ||
super(world); | ||
} | ||
|
||
@Inject(method = "onDeath", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/entity/monster/MobCreeper;dropItem(II)Lnet/minecraft/core/entity/EntityItem;",shift = At.Shift.AFTER)) | ||
public void dropItemsOnDeath(Entity entityKilledBy, CallbackInfo ci) { | ||
for (WeightedRandomLootObject entry : SpecialMobDropHelper.Creeper.getDrops().getEntries()) { | ||
ItemStack stack = entry.getItemStack(); | ||
if(stack != null){ | ||
dropItem(stack,0.0f); | ||
} | ||
} | ||
} | ||
} |
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