Skip to content

Commit

Permalink
[Reliquary support] Powered creeper drop (#99)
Browse files Browse the repository at this point in the history
* Powered creeper drop

* Update Reliquarry.java
  • Loading branch information
kuba6000 authored Sep 13, 2024
1 parent dfdf25a commit c01c219
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 32 deletions.
19 changes: 19 additions & 0 deletions src/main/java/com/kuba6000/mobsinfo/api/IChanceModifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -417,4 +418,22 @@ public void readFromByteBuf(ByteBuf byteBuf) {
change = byteBuf.readDouble();
}
}

class PoweredCreeper implements IChanceModifier {

@Override
public String getDescription() {
return Translations.POWERED_CREEPER.get();
}

@Override
public double apply(double chance, @Nonnull World world, @Nonnull List<ItemStack> drops, Entity attacker,
EntityLiving victim) {
if (chance == 0d) return 0d;
if (victim == null) return 0d;
if (victim instanceof EntityCreeper && ((EntityCreeper) victim).getPowered()) return chance;
return 0d;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.annotation.Nonnull;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

import com.kuba6000.mobsinfo.api.IChanceModifier;
import com.kuba6000.mobsinfo.api.MobDrop;
Expand All @@ -33,7 +27,8 @@ public void process(String k, ArrayList<MobDrop> drops, MobRecipe recipe) {
false,
false);
drop.variableChance = true;
drop.chanceModifiers.addAll(Arrays.asList(new IChanceModifier.NormalChance(100d), new EMTCreeper()));
drop.chanceModifiers
.addAll(Arrays.asList(new IChanceModifier.NormalChance(100d), new IChanceModifier.PoweredCreeper()));
drops.add(drop);
}
if (recipe.entity instanceof EntityTaintChicken) {
Expand All @@ -50,21 +45,4 @@ public void process(String k, ArrayList<MobDrop> drops, MobRecipe recipe) {
}
}

private static class EMTCreeper implements IChanceModifier {

@Override
public String getDescription() {
return Translations.EMT_CREEPER.get();
}

@Override
public double apply(double chance, @Nonnull World world, @Nonnull List<ItemStack> drops, Entity attacker,
EntityLiving victim) {
if (chance == 0d) return 0d;
if (victim == null) return 0d;
if (victim instanceof EntityCreeper && ((EntityCreeper) victim).getPowered()) return chance;
return 0d;
}

}
}
14 changes: 10 additions & 4 deletions src/main/java/com/kuba6000/mobsinfo/loader/extras/Reliquarry.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import com.kuba6000.mobsinfo.api.IChanceModifier;
import com.kuba6000.mobsinfo.api.MobDrop;
import com.kuba6000.mobsinfo.api.MobRecipe;

Expand Down Expand Up @@ -67,9 +68,13 @@ public void process(String k, ArrayList<MobDrop> drops, MobRecipe recipe) {
addDrop(drops, XRRecipes.ingredient(Reference.CREEPER_INGREDIENT_META), Names.ghast_gland);
} else if (recipe.entity instanceof EntityCreeper) {
addDrop(drops, XRRecipes.ingredient(Reference.CREEPER_INGREDIENT_META), Names.creeper_gland);
if (((EntityCreeper) recipe.entity).getPowered()) {
addDrop(drops, XRRecipes.ingredient(Reference.STORM_INGREDIENT_META), Names.eye_of_the_storm);
}
MobDrop drop = addDrop(
drops,
XRRecipes.ingredient(Reference.STORM_INGREDIENT_META),
Names.eye_of_the_storm);
drop.withChanceModifiers(
new IChanceModifier.NormalChance(drop.chance * 0.01d),
new IChanceModifier.PoweredCreeper());
} else if (recipe.entity instanceof EntityEnderman) {
addDrop(drops, XRRecipes.ingredient(Reference.ENDER_INGREDIENT_META), Names.ender_heart);
} else if (recipe.entity instanceof EntityBat) {
Expand All @@ -79,7 +84,7 @@ public void process(String k, ArrayList<MobDrop> drops, MobRecipe recipe) {
}
}

private void addDrop(ArrayList<MobDrop> drops, ItemStack item, String name) {
private MobDrop addDrop(ArrayList<MobDrop> drops, ItemStack item, String name) {
MobDrop drop = new MobDrop(
item,
MobDrop.DropType.Normal,
Expand All @@ -89,5 +94,6 @@ private void addDrop(ArrayList<MobDrop> drops, ItemStack item, String name) {
eventHandler.getLootingDrop(name) > 0.01f,
false);
drops.add(drop);
return drop;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public enum Translations {
DRACONIC_EVOLUTION_MOB_SOUL_3,
DRACONIC_EVOLUTION_MOB_SOUL_4,
DRACONIC_EVOLUTION_MOB_SOUL_5,
EMT_CREEPER,
POWERED_CREEPER,
FORBIDDEN_MAGIC_NON_PLAYER,
OPEN_BLOCKS_SMALL_CHANCE,
TINKERS_CONSTRUCT_BEHEADING,
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/mobsinfo/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ mobsinfo.extras.draconic_evolution_mob_soul_2=Any/None | %.2f%% | %.2f%% | %.2f%
mobsinfo.extras.draconic_evolution_mob_soul_3=Wyvern Sword/Bow | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%%
mobsinfo.extras.draconic_evolution_mob_soul_4=Draconic Sword/Bow | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%%
mobsinfo.extras.draconic_evolution_mob_soul_5=Draconic Staff of Power | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%%
mobsinfo.extras.emt_creeper=Drops only when Creeper is powered
mobsinfo.extras.powered_creeper=Drops only when Creeper is powered
mobsinfo.extras.forbidden_magic_non_player=Drops only when killed by non player entity
mobsinfo.extras.open_blocks_small_chance=Chance: Small
mobsinfo.extras.tinkers_construct_beheading=Each level of beheading on your weapon gives additional %.2f%%
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/mobsinfo/lang/ru_RU.lang
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ mobsinfo.extras.draconic_evolution_mob_soul_2=Любой/Нет | %.2f
mobsinfo.extras.draconic_evolution_mob_soul_3=Меч виверны/Лук | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% |
mobsinfo.extras.draconic_evolution_mob_soul_4=Драконий меч/лук | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% |
mobsinfo.extras.draconic_evolution_mob_soul_5=Драконий посох силы | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% |
mobsinfo.extras.emt_creeper=Выпадает только если крипер заряжен
mobsinfo.extras.powered_creeper=Выпадает только если крипер заряжен
mobsinfo.extras.forbidden_magic_non_player=Выпадает только при убийстве не игроком
mobsinfo.extras.open_blocks_small_chance=Шанс: малый
mobsinfo.extras.tinkers_construct_beheading=Каждый уровень обезглавливания на вашем оружии дает дополнительные %.2f%%
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/mobsinfo/lang/zh_CN.lang
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ mobsinfo.extras.draconic_evolution_mob_soul_2=任意/没有 | %.2f%% | %.2f%% |
mobsinfo.extras.draconic_evolution_mob_soul_3=双足飞龙剑/双足飞龙弓 | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%%
mobsinfo.extras.draconic_evolution_mob_soul_4=神龙剑/神龙弓 | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%%
mobsinfo.extras.draconic_evolution_mob_soul_5=神龙物品的能力 | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%%
mobsinfo.extras.emt_creeper=当且仅当被苦力怕炸飞时,才会掉落。
mobsinfo.extras.powered_creeper=当且仅当被苦力怕炸飞时,才会掉落。
mobsinfo.extras.forbidden_magic_non_player=当且仅当被非玩家实体干掉时候,才会掉落。
mobsinfo.extras.open_blocks_small_chance=几率:小
mobsinfo.extras.tinkers_construct_beheading=每一级斩首强化都会增加%.2f%%的几率。
Expand Down

0 comments on commit c01c219

Please sign in to comment.