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

Fix taters not being equippable #190

Merged
merged 1 commit into from
Nov 17, 2024
Merged
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
12 changes: 9 additions & 3 deletions src/main/java/xyz/nucleoid/extras/lobby/NEItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.minecraft.block.Block;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.EquippableComponent;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
Expand Down Expand Up @@ -497,13 +499,17 @@ public class NEItems {
.component(DataComponentTypes.ENCHANTMENT_GLINT_OVERRIDE, true), settings -> new RuleBookItem(settings));

private static Item registerHead(String id, Block head) {
Item.Settings baseSettings = new Item.Settings()
.useBlockPrefixedTranslationKey()
.equippableUnswappable(EquipmentSlot.HEAD);

if (head instanceof TinyPotatoBlock tinyPotatoBlock) {
return register(id, new Item.Settings().useBlockPrefixedTranslationKey(), settings -> new LobbyHeadItem(head, settings, tinyPotatoBlock.getItemTexture()));
return register(id, baseSettings, settings -> new LobbyHeadItem(head, settings, tinyPotatoBlock.getItemTexture()));
} else if (head instanceof PolymerHeadBlock headBlock) {
return register(id, new Item.Settings().useBlockPrefixedTranslationKey(), settings -> new LobbyHeadItem(head, settings, headBlock.getPolymerSkinValue(head.getDefaultState(), BlockPos.ORIGIN, null)));
return register(id, baseSettings, settings -> new LobbyHeadItem(head, settings, headBlock.getPolymerSkinValue(head.getDefaultState(), BlockPos.ORIGIN, null)));
}

return registerSimple(id, head, Items.STONE);
throw new IllegalArgumentException("Cannot register " + id + " as a head item because " + head + " is not a head");
}

private static Item registerSimple(String id, Block block, Item virtual) {
Expand Down
Loading