Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: campfire respawning #346

Merged
merged 13 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/generated/resources/assets/aether_ii/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"accessories.slot.aether_ii.accessory_slot": "Accessory",
"accessories.slot.aether_ii.handwear_slot": "Handwear",
"accessories.slot.aether_ii.relic_slot": "Relic",
"aether_ii.message.campfire_added": "This Outpost Campfire is now a valid respawn option.",
"aether_ii.message.campfire_respawn_failed": "Failed to locate a valid Outpost Campfire.",
"aether_ii.tooltip.item.damage.impact": "§eImpact§r Damage",
"aether_ii.tooltip.item.damage.pierce": "§cPierce§r Damage",
"aether_ii.tooltip.item.damage.slash": "§9Slash§r Damage",
Expand Down Expand Up @@ -364,6 +366,7 @@
"entity.aether_ii.skyroot_lizard": "Skyroot Lizard",
"entity.aether_ii.tempest": "Tempest",
"entity.aether_ii.zephyr": "Zephyr",
"gui.aether_ii.deathScreen.outpost_respawn": "Respawn at Outpost",
"gui.aether_ii.guidebook.button.close": "Inventory",
"gui.aether_ii.guidebook.button.open": "Guidebook",
"gui.aether_ii.guidebook.discovery.bestiary.title": "Bestiary",
Expand Down Expand Up @@ -614,7 +617,7 @@
"subtitles.aether_ii.entity.phyg.hurt": "Phyg hurts",
"subtitles.aether_ii.entity.phyg.saddle": "Saddle equips",
"subtitles.aether_ii.entity.phyg.step": "Footsteps",
"subtitles.aether_ii.entity.sheepuff.ambient": "Sheepuff baahs",
"subtitles.aether_ii.entity.sheepuff.ambient": "Sheepuff baths",
"subtitles.aether_ii.entity.sheepuff.death": "Sheepuff dies",
"subtitles.aether_ii.entity.sheepuff.hurt": "Sheepuff hurts",
"subtitles.aether_ii.entity.sheepuff.step": "Footsteps",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parent": "aether_ii:block/template_outpost_campfire_east",
"render_type": "minecraft:cutout",
"textures": {
"particle": "aether_ii:block/construction/holystone_bricks",
"texture": "aether_ii:block/furniture/outpost_campfire"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parent": "aether_ii:block/template_outpost_campfire_north",
"render_type": "minecraft:cutout",
"textures": {
"particle": "aether_ii:block/construction/holystone_bricks",
"texture": "aether_ii:block/furniture/outpost_campfire"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parent": "aether_ii:block/template_outpost_campfire_south",
"render_type": "minecraft:cutout",
"textures": {
"particle": "aether_ii:block/construction/holystone_bricks",
"texture": "aether_ii:block/furniture/outpost_campfire"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parent": "aether_ii:block/template_outpost_campfire_west",
"render_type": "minecraft:cutout",
"textures": {
"particle": "aether_ii:block/construction/holystone_bricks",
"texture": "aether_ii:block/furniture/outpost_campfire"
}
}
Original file line number Diff line number Diff line change
@@ -1,131 +1,6 @@
{
"parent": "minecraft:item/chest",
"display": {
"firstperson_lefthand": {
"rotation": [
0,
-315,
0
],
"scale": [
0.4,
0.4,
0.4
],
"translation": [
2,
2.5,
-5
]
},
"firstperson_righthand": {
"rotation": [
0,
315,
0
],
"scale": [
0.4,
0.4,
0.4
],
"translation": [
2,
2.5,
-5
]
},
"fixed": {
"rotation": [
0,
180,
0
],
"scale": [
0.5,
0.5,
0.5
],
"translation": [
4,
1,
1
]
},
"ground": {
"scale": [
0.25,
0.25,
0.25
],
"translation": [
-2,
3,
-2
]
},
"gui": {
"rotation": [
30,
45,
0
],
"scale": [
0.425,
0.425,
0.425
],
"translation": [
-4.95,
1.5,
0
]
},
"head": {
"rotation": [
0,
180,
0
],
"translation": [
8,
14.5,
8
]
},
"thirdperson_lefthand": {
"rotation": [
75,
-315,
0
],
"scale": [
0.225,
0.225,
0.225
],
"translation": [
0,
6.25,
0.75
]
},
"thirdperson_righthand": {
"rotation": [
75,
315,
0
],
"scale": [
0.225,
0.225,
0.225
],
"translation": [
0,
6.25,
0.75
]
}
"parent": "minecraft:item/generated",
"textures": {
"layer0": "aether_ii:item/miscellaneous/outpost_campfire"
}
}
13 changes: 11 additions & 2 deletions src/main/java/com/aetherteam/aetherii/AetherII.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import com.aetherteam.aetherii.event.listeners.*;
import com.aetherteam.aetherii.event.listeners.attachment.AerbunnyMountListener;
import com.aetherteam.aetherii.event.listeners.attachment.DamageSystemListener;
import com.aetherteam.aetherii.event.listeners.attachment.DimensionTeleportationListener;
import com.aetherteam.aetherii.event.listeners.attachment.EffectsSystemListeners;
import com.aetherteam.aetherii.event.listeners.attachment.PortalTeleportationListener;
import com.aetherteam.aetherii.inventory.AetherIIRecipeBookTypes;
import com.aetherteam.aetherii.inventory.menu.AetherIIMenuTypes;
import com.aetherteam.aetherii.item.AetherIIArmorMaterials;
Expand All @@ -38,6 +38,11 @@
import com.aetherteam.aetherii.loot.modifiers.AetherIILootModifiers;
import com.aetherteam.aetherii.network.packet.AerbunnyMountSyncPacket;
import com.aetherteam.aetherii.network.packet.DamageSystemSyncPacket;
import com.aetherteam.aetherii.network.packet.OutpostTrackerSyncPacket;
import com.aetherteam.aetherii.network.packet.clientbound.*;
import com.aetherteam.aetherii.network.packet.serverbound.AerbunnyPuffPacket;
import com.aetherteam.aetherii.network.packet.serverbound.OutpostRespawnPacket;
import com.aetherteam.aetherii.network.packet.serverbound.StepHeightPacket;
import com.aetherteam.aetherii.network.packet.clientbound.*;
import com.aetherteam.aetherii.network.packet.serverbound.*;
import com.aetherteam.aetherii.recipe.recipes.AetherIIRecipeTypes;
Expand Down Expand Up @@ -148,11 +153,12 @@ public void eventSetup(IEventBus neoBus) {
DamageSystemListener.listen(bus);
ToolModificationListener.listen(bus);
ToolAbilityListener.listen(bus);
PortalTeleportationListener.listen(bus);
DimensionTeleportationListener.listen(bus);
AerbunnyMountListener.listen(bus);
WorldInteractionListener.listen(bus);
RecipeListener.listen(bus);
BlockInteractionListener.listen(bus);
OutpostTrackerListener.listen(bus);
EntityInteractionListener.listen(bus);

bus.addListener(ReloadListeners::reloadListenerSetup);
Expand All @@ -173,17 +179,20 @@ public void registerPackets(RegisterPayloadHandlersEvent event) {
registrar.playToClient(DamageTypeParticlePacket.TYPE, DamageTypeParticlePacket.STREAM_CODEC, DamageTypeParticlePacket::execute);
registrar.playToClient(PortalTravelSoundPacket.TYPE, PortalTravelSoundPacket.STREAM_CODEC, PortalTravelSoundPacket::execute);
registrar.playToClient(RemountAerbunnyPacket.TYPE, RemountAerbunnyPacket.STREAM_CODEC, RemountAerbunnyPacket::execute);
registrar.playToClient(SetVehiclePacket.TYPE, SetVehiclePacket.STREAM_CODEC, SetVehiclePacket::execute);

// SERVERBOUND
registrar.playToServer(AerbunnyPuffPacket.TYPE, AerbunnyPuffPacket.STREAM_CODEC, AerbunnyPuffPacket::execute);
registrar.playToServer(ClearItemPacket.TYPE, ClearItemPacket.STREAM_CODEC, ClearItemPacket::execute);
registrar.playToServer(OpenGuidebookPacket.TYPE, OpenGuidebookPacket.STREAM_CODEC, OpenGuidebookPacket::execute);
registrar.playToServer(OpenInventoryPacket.TYPE, OpenInventoryPacket.STREAM_CODEC, OpenInventoryPacket::execute);
registrar.playToServer(OutpostRespawnPacket.TYPE, OutpostRespawnPacket.STREAM_CODEC, OutpostRespawnPacket::execute);
registrar.playToServer(StepHeightPacket.TYPE, StepHeightPacket.STREAM_CODEC, StepHeightPacket::execute);

// BOTH
registrar.playBidirectional(AerbunnyMountSyncPacket.TYPE, AerbunnyMountSyncPacket.STREAM_CODEC, AerbunnyMountSyncPacket::execute);
registrar.playBidirectional(DamageSystemSyncPacket.TYPE, DamageSystemSyncPacket.STREAM_CODEC, DamageSystemSyncPacket::execute);
registrar.playBidirectional(OutpostTrackerSyncPacket.TYPE, OutpostTrackerSyncPacket.STREAM_CODEC, OutpostTrackerSyncPacket::execute);
}

private void registerDispenserBehaviors() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.aetherteam.aetherii.attachment;

import com.aetherteam.aetherii.AetherII;
import com.aetherteam.aetherii.attachment.entity.DroppedItemAttachment;
import com.aetherteam.aetherii.attachment.living.DamageSystemAttachment;
import com.aetherteam.aetherii.attachment.living.EffectsSystemAttachment;
import com.aetherteam.aetherii.attachment.player.AerbunnyMountAttachment;
import com.aetherteam.aetherii.attachment.player.PortalTeleportationAttachment;
import com.aetherteam.aetherii.attachment.player.DimensionTeleportationAttachment;
import com.aetherteam.aetherii.attachment.player.OutpostTrackerAttachment;
import net.minecraft.world.entity.LivingEntity;
import net.neoforged.neoforge.attachment.AttachmentType;
import net.neoforged.neoforge.registries.DeferredHolder;
Expand All @@ -14,11 +16,15 @@
public class AetherIIDataAttachments {
public static final DeferredRegister<AttachmentType<?>> ATTACHMENTS = DeferredRegister.create(NeoForgeRegistries.ATTACHMENT_TYPES, AetherII.MODID);

// Entity
public static final DeferredHolder<AttachmentType<?>, AttachmentType<DroppedItemAttachment>> DROPPED_ITEM = ATTACHMENTS.register("dropped_item", () -> AttachmentType.builder(DroppedItemAttachment::new).serialize(DroppedItemAttachment.CODEC).build());

// Living
public static final DeferredHolder<AttachmentType<?>, AttachmentType<DamageSystemAttachment>> DAMAGE_SYSTEM = ATTACHMENTS.register("damage_system", () -> AttachmentType.builder(DamageSystemAttachment::new).build());
public static final DeferredHolder<AttachmentType<?>, AttachmentType<EffectsSystemAttachment>> EFFECTS_SYSTEM = ATTACHMENTS.register("effects_system", () -> AttachmentType.serializable((entity) -> new EffectsSystemAttachment((LivingEntity) entity)).build());

// Player
public static final DeferredHolder<AttachmentType<?>, AttachmentType<AerbunnyMountAttachment>> AERBUNNY_MOUNT = ATTACHMENTS.register("ride_mob", () -> AttachmentType.builder(attach -> new AerbunnyMountAttachment()).serialize(AerbunnyMountAttachment.CODEC).build());
public static final DeferredHolder<AttachmentType<?>, AttachmentType<PortalTeleportationAttachment>> PORTAL_TELEPORTATION = ATTACHMENTS.register("portal_teleportation", () -> AttachmentType.builder(PortalTeleportationAttachment::new).serialize(PortalTeleportationAttachment.CODEC).copyOnDeath().build());
public static final DeferredHolder<AttachmentType<?>, AttachmentType<DimensionTeleportationAttachment>> DIMENSION_TELEPORTATION = ATTACHMENTS.register("dimension_teleportation", () -> AttachmentType.builder(DimensionTeleportationAttachment::new).serialize(DimensionTeleportationAttachment.CODEC).build());
public static final DeferredHolder<AttachmentType<?>, AttachmentType<OutpostTrackerAttachment>> OUTPOST_TRACKER = ATTACHMENTS.register("outpost_tracker", () -> AttachmentType.builder(OutpostTrackerAttachment::new).serialize(OutpostTrackerAttachment.CODEC).copyOnDeath().build());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.aetherteam.aetherii.attachment.entity;

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;

public class DroppedItemAttachment {
private int ownerID;
@Nullable
private Entity owner;

public static final Codec<DroppedItemAttachment> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.INT.fieldOf("owner_id").forGetter(o -> o.owner.getId())
).apply(instance, DroppedItemAttachment::new));

public DroppedItemAttachment() {

}

private DroppedItemAttachment(int ownerID) {
this.ownerID = ownerID;
}

public void setOwner(Entity owner) {
this.owner = owner;
}

/**
* @return The owner {@link Entity} of the dropped item.
*/
@Nullable
public Entity getOwner(Level level) {
if (this.owner == null) {
this.owner = level.getEntity(this.ownerID);
}
return this.owner;
}
}
Loading