mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Add advancement for killing mobs with a horseshoe
This commit is contained in:
parent
5ac68a3df9
commit
0c26827790
7 changed files with 78 additions and 8 deletions
|
@ -30,6 +30,7 @@ public interface UDamageTypes {
|
||||||
RegistryKey<DamageType> SUNLIGHT = register("sunlight");
|
RegistryKey<DamageType> SUNLIGHT = register("sunlight");
|
||||||
RegistryKey<DamageType> PETRIFIED = register("petrified");
|
RegistryKey<DamageType> PETRIFIED = register("petrified");
|
||||||
RegistryKey<DamageType> ROCK = register("rock");
|
RegistryKey<DamageType> ROCK = register("rock");
|
||||||
|
RegistryKey<DamageType> HORSESHOE = register("horseshoe");
|
||||||
|
|
||||||
private static RegistryKey<DamageType> register(String name) {
|
private static RegistryKey<DamageType> register(String name) {
|
||||||
var key = RegistryKey.of(RegistryKeys.DAMAGE_TYPE, Unicopia.id(name));
|
var key = RegistryKey.of(RegistryKeys.DAMAGE_TYPE, Unicopia.id(name));
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.google.common.collect.Multimap;
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.USounds;
|
import com.minelittlepony.unicopia.USounds;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
|
import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
|
||||||
import com.minelittlepony.unicopia.entity.mob.UEntityAttributes;
|
import com.minelittlepony.unicopia.entity.mob.UEntityAttributes;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.projectile.PhysicsBodyProjectileEntity;
|
import com.minelittlepony.unicopia.projectile.PhysicsBodyProjectileEntity;
|
||||||
|
@ -75,6 +76,7 @@ public class HorseShoeItem extends HeavyProjectileItem {
|
||||||
@Override
|
@Override
|
||||||
protected PhysicsBodyProjectileEntity createProjectile(ItemStack stack, World world, @Nullable PlayerEntity player) {
|
protected PhysicsBodyProjectileEntity createProjectile(ItemStack stack, World world, @Nullable PlayerEntity player) {
|
||||||
PhysicsBodyProjectileEntity projectile = super.createProjectile(stack, world, player);
|
PhysicsBodyProjectileEntity projectile = super.createProjectile(stack, world, player);
|
||||||
|
projectile.setDamageType(UDamageTypes.HORSESHOE);
|
||||||
|
|
||||||
float degradation = (stack.getDamage() / (float)stack.getMaxDamage());
|
float degradation = (stack.getDamage() / (float)stack.getMaxDamage());
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.projectile;
|
package com.minelittlepony.unicopia.projectile;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.USounds;
|
import com.minelittlepony.unicopia.USounds;
|
||||||
|
@ -19,6 +21,7 @@ import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.MovementType;
|
import net.minecraft.entity.MovementType;
|
||||||
import net.minecraft.entity.damage.DamageSource;
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
import net.minecraft.entity.damage.DamageSources;
|
import net.minecraft.entity.damage.DamageSources;
|
||||||
|
import net.minecraft.entity.damage.DamageType;
|
||||||
import net.minecraft.entity.data.DataTracker;
|
import net.minecraft.entity.data.DataTracker;
|
||||||
import net.minecraft.entity.data.TrackedData;
|
import net.minecraft.entity.data.TrackedData;
|
||||||
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
||||||
|
@ -27,9 +30,13 @@ import net.minecraft.entity.projectile.PersistentProjectileEntity;
|
||||||
import net.minecraft.inventory.Inventory;
|
import net.minecraft.inventory.Inventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
|
import net.minecraft.nbt.NbtElement;
|
||||||
|
import net.minecraft.registry.RegistryKey;
|
||||||
|
import net.minecraft.registry.RegistryKeys;
|
||||||
import net.minecraft.registry.tag.BlockTags;
|
import net.minecraft.registry.tag.BlockTags;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.hit.EntityHitResult;
|
import net.minecraft.util.hit.EntityHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -46,6 +53,8 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
||||||
|
|
||||||
private int inWaterTime;
|
private int inWaterTime;
|
||||||
|
|
||||||
|
private RegistryKey<DamageType> damageType = UDamageTypes.ROCK;
|
||||||
|
|
||||||
public PhysicsBodyProjectileEntity(EntityType<PhysicsBodyProjectileEntity> type, World world) {
|
public PhysicsBodyProjectileEntity(EntityType<PhysicsBodyProjectileEntity> type, World world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
}
|
}
|
||||||
|
@ -74,6 +83,10 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
||||||
return getDataTracker().get(ITEM);
|
return getDataTracker().get(ITEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDamageType(RegistryKey<DamageType> damageType) {
|
||||||
|
this.damageType = damageType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemStack asItemStack() {
|
protected ItemStack asItemStack() {
|
||||||
return getStack();
|
return getStack();
|
||||||
|
@ -149,7 +162,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
||||||
return new DamageSources(getWorld().getRegistryManager()) {
|
return new DamageSources(getWorld().getRegistryManager()) {
|
||||||
@Override
|
@Override
|
||||||
public DamageSource arrow(PersistentProjectileEntity source, @Nullable Entity attacker) {
|
public DamageSource arrow(PersistentProjectileEntity source, @Nullable Entity attacker) {
|
||||||
return create(UDamageTypes.ROCK, source, attacker);
|
return create(damageType, source, attacker);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -262,11 +275,17 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
nbt.put("Item", stack.writeNbt(new NbtCompound()));
|
nbt.put("Item", stack.writeNbt(new NbtCompound()));
|
||||||
}
|
}
|
||||||
|
nbt.putString("damageType", damageType.getValue().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readCustomDataFromNbt(NbtCompound nbt) {
|
public void readCustomDataFromNbt(NbtCompound nbt) {
|
||||||
super.readCustomDataFromNbt(nbt);
|
super.readCustomDataFromNbt(nbt);
|
||||||
setStack(ItemStack.fromNbt(nbt.getCompound("Item")));
|
setStack(ItemStack.fromNbt(nbt.getCompound("Item")));
|
||||||
|
if (nbt.contains("damageType", NbtElement.STRING_TYPE)) {
|
||||||
|
Optional.ofNullable(Identifier.tryParse(nbt.getString("damageType"))).ifPresent(id -> {
|
||||||
|
setDamageType(RegistryKey.of(RegistryKeys.DAMAGE_TYPE, id));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -993,6 +993,10 @@
|
||||||
"death.attack.unicopia.rock.self": "%1$s was pummeled",
|
"death.attack.unicopia.rock.self": "%1$s was pummeled",
|
||||||
"death.attack.unicopia.rock.item": "%1$s was pummelled by %2$s using %3$s",
|
"death.attack.unicopia.rock.item": "%1$s was pummelled by %2$s using %3$s",
|
||||||
"death.attack.unicopia.rock.player": "%1$s was pummelled by %2$s",
|
"death.attack.unicopia.rock.player": "%1$s was pummelled by %2$s",
|
||||||
|
"death.attack.unicopia.horseshoe": "%1$s went ding",
|
||||||
|
"death.attack.unicopia.horseshoe.self": "%1$s dinged himself",
|
||||||
|
"death.attack.unicopia.horseshoe.item": "%1$s was dinged by %2$s using %3$s",
|
||||||
|
"death.attack.unicopia.horseshoe.player": "%1$s was dinged by %2$s",
|
||||||
|
|
||||||
"death.fell.accident.ladder.pegasus": "%1$s forgot they could fly and fell off a ladder",
|
"death.fell.accident.ladder.pegasus": "%1$s forgot they could fly and fell off a ladder",
|
||||||
"death.fell.accident.vines.pegasus": "%1$s forgot they could fly and fell off some vines",
|
"death.fell.accident.vines.pegasus": "%1$s forgot they could fly and fell off some vines",
|
||||||
|
@ -1158,7 +1162,9 @@
|
||||||
"advancements.unicopia.earth_route.title": "Path of the Pony",
|
"advancements.unicopia.earth_route.title": "Path of the Pony",
|
||||||
"advancements.unicopia.earth_route.description": "Join the Apple Clan",
|
"advancements.unicopia.earth_route.description": "Join the Apple Clan",
|
||||||
"advancements.unicopia.sticks_and_stones.title": "Sticks and Stones",
|
"advancements.unicopia.sticks_and_stones.title": "Sticks and Stones",
|
||||||
"advancements.unicopia.sticks_and_stones.description": "Kill an mob by throwing rocks at it",
|
"advancements.unicopia.sticks_and_stones.description": "Kill a mob by throwing rocks at it",
|
||||||
|
"advancements.unicopia.dead_ringer.title": "Dead Ringer",
|
||||||
|
"advancements.unicopia.dead_ringer.description": "Kill a mob with a horseshoe",
|
||||||
"advancements.unicopia.born_on_a_rock_farm.title": "Born on a Rock Farm",
|
"advancements.unicopia.born_on_a_rock_farm.title": "Born on a Rock Farm",
|
||||||
"advancements.unicopia.born_on_a_rock_farm.description": "Successfully farm your first rock",
|
"advancements.unicopia.born_on_a_rock_farm.description": "Successfully farm your first rock",
|
||||||
"advancements.unicopia.thats_unusual.title": "That's Unusual",
|
"advancements.unicopia.thats_unusual.title": "That's Unusual",
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
"parent": "unicopia:unicopia/earth/born_on_a_rock_farm",
|
||||||
|
"display": {
|
||||||
|
"icon": {
|
||||||
|
"item": "unicopia:rock"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"translate": "advancements.unicopia.sticks_and_stones.title"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"translate": "advancements.unicopia.sticks_and_stones.description"
|
||||||
|
},
|
||||||
|
"frame": "task",
|
||||||
|
"show_toast": true,
|
||||||
|
"announce_to_chat": true,
|
||||||
|
"hidden": true
|
||||||
|
},
|
||||||
|
"criteria": {
|
||||||
|
"killed_entity_with_rock": {
|
||||||
|
"trigger": "minecraft:player_killed_entity",
|
||||||
|
"conditions": {
|
||||||
|
"killing_blow": {
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"id": "unicopia:from_rocks",
|
||||||
|
"expected": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"requirements": [
|
||||||
|
[ "killed_entity_with_rock" ]
|
||||||
|
]
|
||||||
|
}
|
|
@ -2,13 +2,13 @@
|
||||||
"parent": "unicopia:unicopia/earth/born_on_a_rock_farm",
|
"parent": "unicopia:unicopia/earth/born_on_a_rock_farm",
|
||||||
"display": {
|
"display": {
|
||||||
"icon": {
|
"icon": {
|
||||||
"item": "unicopia:rock"
|
"item": "unicopia:horseshoe"
|
||||||
},
|
},
|
||||||
"title": {
|
"title": {
|
||||||
"translate": "advancements.unicopia.sticks_and_stones.title"
|
"translate": "advancements.unicopia.dead_ringer.title"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
"translate": "advancements.unicopia.sticks_and_stones.description"
|
"translate": "advancements.unicopia.dead_ringer.description"
|
||||||
},
|
},
|
||||||
"frame": "task",
|
"frame": "task",
|
||||||
"show_toast": true,
|
"show_toast": true,
|
||||||
|
@ -16,13 +16,13 @@
|
||||||
"hidden": true
|
"hidden": true
|
||||||
},
|
},
|
||||||
"criteria": {
|
"criteria": {
|
||||||
"killed_entity_with_rock": {
|
"killed_entity_with_horseshoe": {
|
||||||
"trigger": "minecraft:player_killed_entity",
|
"trigger": "minecraft:player_killed_entity",
|
||||||
"conditions": {
|
"conditions": {
|
||||||
"killing_blow": {
|
"killing_blow": {
|
||||||
"tags": [
|
"tags": [
|
||||||
{
|
{
|
||||||
"id": "unicopia:from_rocks",
|
"id": "unicopia:from_horseshoes",
|
||||||
"expected": true
|
"expected": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -31,6 +31,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"requirements": [
|
"requirements": [
|
||||||
[ "killed_entity_with_rock" ]
|
[ "killed_entity_with_horseshoe" ]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"replace": false,
|
||||||
|
"values": [
|
||||||
|
"unicopia:horseshoe"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in a new issue