Skip to content

Commit

Permalink
Fix advancements not getting granted when killing different entity bo…
Browse files Browse the repository at this point in the history
…sses.
  • Loading branch information
CaliforniaDemise committed Nov 30, 2024
1 parent 418ea72 commit 11cf5f0
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 177 deletions.
2 changes: 1 addition & 1 deletion src/main/java/twilightforest/TFEventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public static void onBossDeath(LivingDeathEvent event) {
IBossCapability capability = living.getCapability(CapabilityList.BOSS, null);
if (capability == null || !capability.isBoss()) return;
BossVariant variant = capability.getBossVariant();
BlockPos pos = capability.getHomePos();
BlockPos pos = capability.getHomePos(living);
BossEvent.Death death = new BossEvent.Death(world, pos, variant, living);
MinecraftForge.EVENT_BUS.post(death);
if (event.isCanceled()) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,16 @@ public void initBoss(BossVariant variant, BlockPos homePos) {
public NBTTagCompound serializeNBT() {
NBTTagCompound tag = new NBTTagCompound();
if (this.variant != null) tag.setInteger("variant", this.variant.ordinal());
else tag.setInteger("variant", -1);
tag.setTag("homePos", NBTUtil.createPosTag(this.homePos));
return tag;
}

@Override
public void deserializeNBT(NBTTagCompound tag) {
this.initBoss(BossVariant.getVariant(tag.getInteger("variant")), NBTUtil.getPosFromTag(tag.getCompoundTag("homePos")));
int id = tag.getInteger("variant");
BossVariant variant = null;
if (id > -1) variant = BossVariant.getVariant(id);
this.initBoss(variant, NBTUtil.getPosFromTag(tag.getCompoundTag("homePos")));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package twilightforest.capabilities.boss;

import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
Expand All @@ -17,6 +18,12 @@ public interface IBossCapability extends INBTSerializable<NBTTagCompound> {

BlockPos getHomePos();

default BlockPos getHomePos(EntityLivingBase entity) {
BlockPos position = entity instanceof EntityCreature && this.getHomePos() == BlockPos.ORIGIN ? ((EntityCreature) entity).getHomePosition() : this.getHomePos();
if (position == null) position = BlockPos.ORIGIN;
return position;
}

default boolean isBoss() {
return this.getBossVariant() != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
"parent": "twilightforest:progress_thorns",
"criteria": {
"discover": {
"trigger": "minecraft:location",
"conditions": { "feature": "twilightforest:final_castle" }
"trigger": "twilightforest:structure_cleared",
"conditions": {
"structure": "final_castle"
}
},
"previous_progression": {
"trigger": "twilightforest:has_advancement",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,9 @@
"parent": "twilightforest:progress_yeti",
"criteria": {
"queen": {
"trigger": "minecraft:player_killed_entity",
"trigger": "twilightforest:structure_cleared",
"conditions": {
"entity": {
"type": "twilightforest:snow_queen"
}
}
},
"trophy": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "twilightforest:trophy",
"data": 5
}
]
"structure": "ice_tower"
}
},
"previous_progression": {
Expand All @@ -45,7 +32,7 @@
}
},
"requirements": [
[ "queen", "trophy" ],
[ "queen" ],
[ "previous_progression" ]
],
"rewards": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,9 @@
"parent": "twilightforest:progress_labyrinth",
"criteria": {
"hydra": {
"trigger": "minecraft:player_killed_entity",
"trigger": "twilightforest:structure_cleared",
"conditions": {
"entity": {
"type": "twilightforest:hydra"
}
}
},
"trophy": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "twilightforest:trophy",
"data": 2
}
]
}
},
"blood": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "twilightforest:fiery_blood"
}
]
"structure": "hydra_lair"
}
},
"stroganoff": {
Expand All @@ -54,7 +31,7 @@
}
},
"requirements": [
[ "hydra", "trophy", "blood" ],
[ "hydra" ],
[ "stroganoff" ]
],
"rewards": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,6 @@
},
"parent": "twilightforest:progress_trophy_pedestal",
"criteria": {
"knight": {
"trigger": "minecraft:player_killed_entity",
"conditions": {
"entity": {
"type": "twilightforest:knight_phantom"
}
}
},
"trophy": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "twilightforest:trophy",
"data": 4
}
]
}
},
"structure": {
"trigger": "twilightforest:structure_cleared",
"conditions": {
Expand All @@ -47,7 +28,6 @@
}
},
"requirements": [
[ "knight", "trophy" ],
[ "structure" ],
[ "previous_progression" ]
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,62 +18,9 @@
"parent": "twilightforest:progress_naga",
"criteria": {
"kill_lich": {
"trigger": "minecraft:player_killed_entity",
"trigger": "twilightforest:structure_cleared",
"conditions": {
"entity": {
"type": "twilightforest:lich"
}
}
},
"trophy": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "twilightforest:trophy",
"data": 1
}
]
}
},
"lifedrain_scepter": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "twilightforest:lifedrain_scepter"
}
]
}
},
"twilight_scepter": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "twilightforest:twilight_scepter"
}
]
}
},
"zombie_scepter": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "twilightforest:zombie_scepter"
}
]
}
},
"shield_scepter": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "twilightforest:shield_scepter"
}
]
"structure": "lich_tower"
}
},
"kill_naga": {
Expand All @@ -84,7 +31,7 @@
}
},
"requirements": [
[ "kill_lich", "trophy", "lifedrain_scepter", "twilight_scepter", "zombie_scepter", "shield_scepter" ],
[ "kill_lich" ],
[ "kill_naga" ]
],
"rewards": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,14 @@
"parent": "twilightforest:twilight_hunter",
"criteria": {
"naga": {
"trigger": "minecraft:player_killed_entity",
"trigger": "twilightforest:structure_cleared",
"conditions": {
"entity": {
"type": "twilightforest:naga"
}
}
},
"scale": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "twilightforest:naga_scale"
}
]
}
},
"kill_mob": {
"trigger": "twilightforest:has_advancement",
"conditions": {
"advancement": "twilightforest:twilight_hunter"
"structure": "naga_courtyard"
}
}
},
"requirements": [
[ "naga", "scale" ],
[ "kill_mob" ]
[ "naga" ]
],
"rewards": {
"function": "twilightforest:give_3_shields"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,9 @@
"parent": "twilightforest:ghast_trap",
"criteria": {
"ghast": {
"trigger": "minecraft:player_killed_entity",
"trigger": "twilightforest:structure_cleared",
"conditions": {
"entity": {
"type": "twilightforest:ur_ghast"
}
}
},
"trophy": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "twilightforest:trophy",
"data": 3
}
]
}
},
"tear": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "twilightforest:fiery_tears"
}
]
"structure": "dark_tower"
}
},
"previous_progression": {
Expand All @@ -54,7 +31,7 @@
}
},
"requirements": [
[ "ghast", "trophy", "tear" ],
[ "ghast" ],
[ "previous_progression" ]
],
"rewards": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,18 @@
"parent": "twilightforest:progress_lich",
"criteria": {
"yeti": {
"trigger": "minecraft:player_killed_entity",
"conditions": { "entity": { "type": "twilightforest:yeti_alpha" } }
},
"fur": {
"trigger": "minecraft:inventory_changed",
"conditions": { "items": [ { "item": "twilightforest:alpha_fur" } ] }
"trigger": "twilightforest:structure_cleared",
"conditions": {
"structure": "yeti_lairs"
}
},
"previous_progression": {
"trigger": "twilightforest:has_advancement",
"conditions": { "advancement": "twilightforest:progress_lich" }
}
},
"requirements": [
[ "yeti", "fur" ],
[ "yeti" ],
[ "previous_progression" ]
],
"rewards": {
Expand Down

0 comments on commit 11cf5f0

Please sign in to comment.