Skip to content

Commit

Permalink
Merge pull request #1540 from YocyCraft/dev/mob_amber_drop
Browse files Browse the repository at this point in the history
Fix drop of mob amber blocks 修复生物琥珀块挖掘掉落物问题
  • Loading branch information
Gu-ZT authored Jan 31, 2025
2 parents ae23724 + 030d54a commit 3676bbd
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 92 deletions.
2 changes: 1 addition & 1 deletion src/generated/resources/assets/anvilcraft/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@
"screen.anvilcraft.item_collector.range": "ǝbuɐᴚ",
"screen.anvilcraft.item_collector.title": "ɹoʇɔǝןןoƆ ɯǝʇI",
"screen.anvilcraft.royal_grindstone.remove_curse_count": "%s / %s :sǝsɹnɔ pǝʌoɯǝᴚ",
"screen.anvilcraft.royal_grindstone.remove_repair_cost": "ǝ%s / %s :ʇsoɔ ɹıɐdǝɹ pǝʌoɯǝᴚ",
"screen.anvilcraft.royal_grindstone.remove_repair_cost": "%s / %s :ʇsoɔ ɹıɐdǝɹ pǝʌoɯǝᴚ",
"screen.anvilcraft.royal_grindstone.title": "ʇsoɔ ɹıɐdǝɹ puɐ ǝsɹnɔ ǝʌoɯǝᴚ",
"screen.anvilcraft.royal_steel_upgrade_smithing_template": "ǝpɐɹbd∩ ןǝǝʇS ןɐʎoᴚ",
"screen.anvilcraft.slot.disable.tooltip": "ɹǝʇןıɟ ʇǝs oʇ sʞɔıןɔ ɯǝʇı ǝs∩",
Expand Down
2 changes: 1 addition & 1 deletion src/generated/resources/assets/anvilcraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@
"screen.anvilcraft.item_collector.range": "Range",
"screen.anvilcraft.item_collector.title": "Item Collector",
"screen.anvilcraft.royal_grindstone.remove_curse_count": "Removed curses: %s / %s",
"screen.anvilcraft.royal_grindstone.remove_repair_cost": "Removed repair cost: %s / %se",
"screen.anvilcraft.royal_grindstone.remove_repair_cost": "Removed repair cost: %s / %s",
"screen.anvilcraft.royal_grindstone.title": "Remove curse and repair cost",
"screen.anvilcraft.royal_steel_upgrade_smithing_template": "Royal Steel Upgrade",
"screen.anvilcraft.slot.disable.tooltip": "Use item clicks to set filter",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{
"function": "minecraft:copy_components",
"include": [
"minecraft:block_entity_data"
"anvilcraft:saved_entity"
],
"source": "block_entity"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{
"function": "minecraft:copy_components",
"include": [
"minecraft:block_entity_data"
"anvilcraft:saved_entity"
],
"source": "block_entity"
}
Expand Down
42 changes: 21 additions & 21 deletions src/generated/resources/data/c/tags/fluid/cement.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
{
"values": [
"anvilcraft:black_cement",
"anvilcraft:blue_cement",
"anvilcraft:brown_cement",
"anvilcraft:cyan_cement",
"anvilcraft:gray_cement",
"anvilcraft:green_cement",
"anvilcraft:light_blue_cement",
"anvilcraft:light_gray_cement",
"anvilcraft:lime_cement",
"anvilcraft:magenta_cement",
"anvilcraft:orange_cement",
"anvilcraft:pink_cement",
"anvilcraft:purple_cement",
"anvilcraft:light_blue_cement",
"anvilcraft:cyan_cement",
"anvilcraft:red_cement",
"anvilcraft:brown_cement",
"anvilcraft:pink_cement",
"anvilcraft:black_cement",
"anvilcraft:magenta_cement",
"anvilcraft:lime_cement",
"anvilcraft:green_cement",
"anvilcraft:white_cement",
"anvilcraft:gray_cement",
"anvilcraft:yellow_cement",
"anvilcraft:light_gray_cement",
"anvilcraft:flowing_black_cement",
"anvilcraft:flowing_blue_cement",
"anvilcraft:flowing_brown_cement",
"anvilcraft:flowing_cyan_cement",
"anvilcraft:flowing_gray_cement",
"anvilcraft:flowing_green_cement",
"anvilcraft:flowing_light_blue_cement",
"anvilcraft:flowing_light_gray_cement",
"anvilcraft:flowing_lime_cement",
"anvilcraft:flowing_magenta_cement",
"anvilcraft:flowing_orange_cement",
"anvilcraft:flowing_pink_cement",
"anvilcraft:flowing_purple_cement",
"anvilcraft:flowing_light_blue_cement",
"anvilcraft:flowing_cyan_cement",
"anvilcraft:flowing_red_cement",
"anvilcraft:flowing_brown_cement",
"anvilcraft:flowing_pink_cement",
"anvilcraft:flowing_black_cement",
"anvilcraft:flowing_magenta_cement",
"anvilcraft:flowing_lime_cement",
"anvilcraft:flowing_green_cement",
"anvilcraft:flowing_white_cement",
"anvilcraft:flowing_gray_cement",
"anvilcraft:flowing_yellow_cement",
"anvilcraft:flowing_light_gray_cement"
"anvilcraft:flowing_yellow_cement"
]
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
package dev.dubhe.anvilcraft.block.entity;

import dev.dubhe.anvilcraft.init.ModComponents;
import dev.dubhe.anvilcraft.item.HasMobBlockItem;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Optional;

@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public abstract class HasMobBlockEntity extends BlockEntity {
private CompoundTag entity = null;
private Entity displayEntity = null;
Expand All @@ -29,7 +35,7 @@ protected HasMobBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState bl
/**
* 设置实体
*/
public void setEntity(Entity entity) {
public void setEntity(@Nullable Entity entity) {
if (entity == null) return;
if (this.entity == null) this.entity = new CompoundTag();
entity.save(this.entity);
Expand All @@ -39,22 +45,22 @@ public void setEntity(Entity entity) {
/**
* 设置实体
*/
public void setEntity(CompoundTag entity) {
public void setEntity(@Nullable CompoundTag entity) {
if (entity == null) return;
this.entity = entity;
this.entity.remove(Entity.UUID_TAG);
}

@Override
protected void saveAdditional(@NotNull CompoundTag tag, HolderLookup.Provider provider) {
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider provider) {
super.saveAdditional(tag, provider);
if (this.entity != null) {
tag.put("entity", this.entity);
}
}

@Override
public void loadAdditional(@NotNull CompoundTag tag, HolderLookup.Provider provider) {
public void loadAdditional(CompoundTag tag, HolderLookup.Provider provider) {
if (tag.contains("entity")) {
this.entity = tag.getCompound("entity");
if (this.level != null) {
Expand All @@ -65,7 +71,7 @@ public void loadAdditional(@NotNull CompoundTag tag, HolderLookup.Provider provi
}

@Override
public @NotNull CompoundTag getUpdateTag(HolderLookup.Provider provider) {
public CompoundTag getUpdateTag(HolderLookup.Provider provider) {
return this.saveWithoutMetadata(provider);
}

Expand Down Expand Up @@ -97,4 +103,29 @@ private void getEntity(Level level) {
this.displayEntity = entity;
this.displayEntity.noPhysics = true;
}

@Override
protected void applyImplicitComponents(DataComponentInput componentInput) {
super.applyImplicitComponents(componentInput);
HasMobBlockItem.SavedEntity savedEntity = componentInput.get(ModComponents.SAVED_ENTITY);
if (savedEntity == null) return;
this.setEntity(savedEntity.getTag());
}

@Override
protected void collectImplicitComponents(DataComponentMap.Builder components) {
super.collectImplicitComponents(components);
if (this.displayEntity == null && this.level != null) {
this.getEntity(this.level);
}
if (!(this.displayEntity instanceof Mob mob)) return;
components.set(ModComponents.SAVED_ENTITY, HasMobBlockItem.SavedEntity.fromMob(mob));
}

@Override
@SuppressWarnings("deprecation")
public void removeComponentsFromTag(CompoundTag tag) {
super.removeComponentsFromTag(tag);
tag.remove("entity");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void init(RegistrateLangProvider provider) {
provider.add("screen.anvilcraft.filter.shift_to_scroll_faster", "Hold Shift to scroll faster");
provider.add("screen.anvilcraft.slot.disable.tooltip", "Use item clicks to set filter");
provider.add("screen.anvilcraft.royal_grindstone.remove_curse_count", "Removed curses: %s / %s");
provider.add("screen.anvilcraft.royal_grindstone.remove_repair_cost", "Removed repair cost: %s / %se");
provider.add("screen.anvilcraft.royal_grindstone.remove_repair_cost", "Removed repair cost: %s / %s");
provider.add("screen.anvilcraft.royal_grindstone.title", "Remove curse and repair cost");
provider.add(
"screen.anvilcraft.royal_steel_upgrade_smithing_template", "Royal Steel Upgrade");
Expand Down
Loading

0 comments on commit 3676bbd

Please sign in to comment.