Skip to content

Commit

Permalink
Fix pulling and placing skulls/heads from creative inventory (#5114)
Browse files Browse the repository at this point in the history
* fix: pulling and placing skulls/heads from creative inventory

* fix: getting values of map

* fix: correct submodule permalink
  • Loading branch information
Tjorven-Liebe authored Oct 30, 2024
1 parent 74b25ea commit 448c75e
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public class Conversion685_671 {

static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) {
mapping = Conversion712_685.remapItem(item, mapping);

String identifer = mapping.getBedrockIdentifier();
String identifier = mapping.getBedrockIdentifier();

if (NEW_MUSIC_DISCS.contains(item)) {
return mapping.withBedrockIdentifier("minecraft:music_disc_otherside");
Expand All @@ -59,12 +58,12 @@ static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) {
return mapping.withBedrockIdentifier("minecraft:glass_bottle");
}

if (!NEW_BLOCKS.contains(identifer)) {
if (!NEW_BLOCKS.contains(identifier)) {
return mapping;
}

if (NEW_CORAL_BLOCKS.contains(identifer)) {
switch (identifer) {
if (NEW_CORAL_BLOCKS.contains(identifier)) {
switch (identifier) {
case "minecraft:tube_coral_block" -> { return mapping.withBedrockIdentifier("minecraft:coral_block").withBedrockData(0); }
case "minecraft:brain_coral_block" -> { return mapping.withBedrockIdentifier("minecraft:coral_block").withBedrockData(1); }
case "minecraft:bubble_coral_block" -> { return mapping.withBedrockIdentifier("minecraft:coral_block").withBedrockData(2); }
Expand All @@ -78,8 +77,8 @@ static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) {
}
}

if (NEW_DOUBLE_PLANTS.contains(identifer)) {
switch (identifer) {
if (NEW_DOUBLE_PLANTS.contains(identifier)) {
switch (identifier) {
case "minecraft:sunflower" -> { return mapping.withBedrockIdentifier("minecraft:double_plant").withBedrockData(0); }
case "minecraft:lilac" -> { return mapping.withBedrockIdentifier("minecraft:double_plant").withBedrockData(1); }
case "minecraft:tall_grass" -> { return mapping.withBedrockIdentifier("minecraft:double_plant").withBedrockData(2); }
Expand All @@ -89,8 +88,8 @@ static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) {
}
}

if (NEW_STONE_BLOCK_SLABS.contains(identifer)) {
switch (identifer) {
if (NEW_STONE_BLOCK_SLABS.contains(identifier)) {
switch (identifier) {
case "minecraft:smooth_stone_slab" -> { return mapping.withBedrockIdentifier("minecraft:stone_block_slab").withBedrockData(0); }
case "minecraft:sandstone_slab" -> { return mapping.withBedrockIdentifier("minecraft:stone_block_slab").withBedrockData(1); }
case "minecraft:petrified_oak_slab" -> { return mapping.withBedrockIdentifier("minecraft:stone_block_slab").withBedrockData(2); }
Expand All @@ -102,8 +101,8 @@ static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) {
}
}

if (NEW_TALLGRASSES.contains(identifer)) {
switch (identifer) {
if (NEW_TALLGRASSES.contains(identifier)) {
switch (identifier) {
case "minecraft:short_grass" -> { return mapping.withBedrockIdentifier("minecraft:tallgrass").withBedrockData(1); }
case "minecraft:fern" -> { return mapping.withBedrockIdentifier("minecraft:tallgrass").withBedrockData(2); }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,62 +33,61 @@ public class Conversion712_685 {

static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) {
mapping = Conversion729_712.remapItem(item, mapping);
String identifier = mapping.getBedrockIdentifier();

String identifer = mapping.getBedrockIdentifier();

if (!NEW_BLOCKS.contains(identifer)) {
if (!NEW_BLOCKS.contains(identifier)) {
return mapping;
}

if (identifer.equals("minecraft:coarse_dirt")) {
if (identifier.equals("minecraft:coarse_dirt")) {
return mapping.withBedrockIdentifier("minecraft:dirt").withBedrockData(1);
}

if (identifer.equals("minecraft:dandelion")) {
if (identifier.equals("minecraft:dandelion")) {
return mapping.withBedrockIdentifier("minecraft:yellow_flower").withBedrockData(0);
}

if (identifer.equals("minecraft:red_sand")) {
if (identifier.equals("minecraft:red_sand")) {
return mapping.withBedrockIdentifier("minecraft:sand").withBedrockData(1);
}

if (NEW_PRISMARINE_BLOCKS.contains(identifer)) {
switch (identifer) {
if (NEW_PRISMARINE_BLOCKS.contains(identifier)) {
switch (identifier) {
case "minecraft:prismarine" -> { return mapping.withBedrockIdentifier("minecraft:prismarine").withBedrockData(0); }
case "minecraft:dark_prismarine" -> { return mapping.withBedrockIdentifier("minecraft:prismarine").withBedrockData(1); }
case "minecraft:prismarine_bricks" -> { return mapping.withBedrockIdentifier("minecraft:prismarine").withBedrockData(2); }
}
}

if (NEW_SANDSTONE_BLOCKS.contains(identifer)) {
switch (identifer) {
if (NEW_SANDSTONE_BLOCKS.contains(identifier)) {
switch (identifier) {
case "minecraft:sandstone" -> { return mapping.withBedrockIdentifier("minecraft:sandstone").withBedrockData(0); }
case "minecraft:chiseled_sandstone" -> { return mapping.withBedrockIdentifier("minecraft:sandstone").withBedrockData(1); }
case "minecraft:cut_sandstone" -> { return mapping.withBedrockIdentifier("minecraft:sandstone").withBedrockData(2); }
case "minecraft:smooth_sandstone" -> { return mapping.withBedrockIdentifier("minecraft:sandstone").withBedrockData(3); }
}
}

if (NEW_RED_SANDSTONE_BLOCKS.contains(identifer)) {
switch (identifer) {
if (NEW_RED_SANDSTONE_BLOCKS.contains(identifier)) {
switch (identifier) {
case "minecraft:red_sandstone" -> { return mapping.withBedrockIdentifier("minecraft:red_sandstone").withBedrockData(0); }
case "minecraft:chiseled_red_sandstone" -> { return mapping.withBedrockIdentifier("minecraft:red_sandstone").withBedrockData(1); }
case "minecraft:cut_red_sandstone" -> { return mapping.withBedrockIdentifier("minecraft:red_sandstone").withBedrockData(2); }
case "minecraft:smooth_red_sandstone" -> { return mapping.withBedrockIdentifier("minecraft:red_sandstone").withBedrockData(3); }
}
}

if (NEW_QUARTZ_BLOCKS.contains(identifer)) {
switch (identifer) {
if (NEW_QUARTZ_BLOCKS.contains(identifier)) {
switch (identifier) {
case "minecraft:quartz_block" -> { return mapping.withBedrockIdentifier("minecraft:quartz_block").withBedrockData(0); }
case "minecraft:chiseled_quartz_block" -> { return mapping.withBedrockIdentifier("minecraft:quartz_block").withBedrockData(1); }
case "minecraft:quartz_pillar" -> { return mapping.withBedrockIdentifier("minecraft:quartz_block").withBedrockData(2); }
case "minecraft:smooth_quartz" -> { return mapping.withBedrockIdentifier("minecraft:quartz_block").withBedrockData(3); }
}
}

if (NEW_STONE_BLOCK_SLABS_2.contains(identifer)) {
switch (identifer) {
if (NEW_STONE_BLOCK_SLABS_2.contains(identifier)) {
switch (identifier) {
case "minecraft:red_sandstone_slab" -> { return mapping.withBedrockIdentifier("minecraft:stone_block_slab2").withBedrockData(0); }
case "minecraft:purpur_slab" -> { return mapping.withBedrockIdentifier("minecraft:stone_block_slab2").withBedrockData(1); }
case "minecraft:prismarine_slab" -> { return mapping.withBedrockIdentifier("minecraft:stone_block_slab2").withBedrockData(2); }
Expand All @@ -100,8 +99,8 @@ static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) {
}
}

if (NEW_STONE_BLOCK_SLABS_3.contains(identifer)) {
switch (identifer) {
if (NEW_STONE_BLOCK_SLABS_3.contains(identifier)) {
switch (identifier) {
case "minecraft:end_stone_brick_slab" -> { return mapping.withBedrockIdentifier("minecraft:stone_block_slab3").withBedrockData(0); }
case "minecraft:smooth_red_sandstone_slab" -> { return mapping.withBedrockIdentifier("minecraft:stone_block_slab3").withBedrockData(1); }
case "minecraft:polished_andesite_slab" -> { return mapping.withBedrockIdentifier("minecraft:stone_block_slab3").withBedrockData(2); }
Expand All @@ -113,8 +112,8 @@ static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) {
}
}

if (NEW_STONE_BLOCK_SLABS_4.contains(identifer)) {
switch (identifer) {
if (NEW_STONE_BLOCK_SLABS_4.contains(identifier)) {
switch (identifier) {
case "minecraft:mossy_stone_brick_slab" -> { return mapping.withBedrockIdentifier("minecraft:stone_block_slab4").withBedrockData(0); }
case "minecraft:smooth_quartz_slab" -> { return mapping.withBedrockIdentifier("minecraft:stone_block_slab4").withBedrockData(1); }
case "minecraft:normal_stone_slab" -> { return mapping.withBedrockIdentifier("minecraft:stone_block_slab4").withBedrockData(2); }
Expand All @@ -123,8 +122,8 @@ static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) {
}
}

if (NEW_MONSTER_EGGS.contains(identifer)) {
switch (identifer) {
if (NEW_MONSTER_EGGS.contains(identifier)) {
switch (identifier) {
case "minecraft:infested_stone" -> { return mapping.withBedrockIdentifier("minecraft:monster_egg").withBedrockData(0); }
case "minecraft:infested_cobblestone" -> { return mapping.withBedrockIdentifier("minecraft:monster_egg").withBedrockData(1); }
case "minecraft:infested_stone_bricks" -> { return mapping.withBedrockIdentifier("minecraft:monster_egg").withBedrockData(2); }
Expand All @@ -134,17 +133,17 @@ static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) {
}
}

if (NEW_STONEBRICK_BLOCKS.contains(identifer)) {
switch (identifer) {
if (NEW_STONEBRICK_BLOCKS.contains(identifier)) {
switch (identifier) {
case "minecraft:stone_bricks" -> { return mapping.withBedrockIdentifier("minecraft:stonebrick").withBedrockData(0); }
case "minecraft:mossy_stone_bricks" -> { return mapping.withBedrockIdentifier("minecraft:stonebrick").withBedrockData(1); }
case "minecraft:cracked_stone_bricks" -> { return mapping.withBedrockIdentifier("minecraft:stonebrick").withBedrockData(2); }
case "minecraft:chiseled_stone_bricks" -> { return mapping.withBedrockIdentifier("minecraft:stonebrick").withBedrockData(3); }
}
}

if (NEW_ANVILS.contains(identifer)) {
switch (identifer) {
if (NEW_ANVILS.contains(identifier)) {
switch (identifier) {
case "minecraft:anvil" -> { return mapping.withBedrockIdentifier("minecraft:anvil").withBedrockData(0); }
case "minecraft:chipped_anvil" -> { return mapping.withBedrockIdentifier("minecraft:anvil").withBedrockData(4); }
case "minecraft:damaged_anvil" -> { return mapping.withBedrockIdentifier("minecraft:anvil").withBedrockData(8); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class Conversion729_712 {
private static final List<String> NEW_BLOCKS = Stream.of(NEW_PURPUR_BLOCKS, NEW_WALL_BLOCKS, NEW_SPONGE_BLOCKS, NEW_TNT_BLOCKS, STRUCTURE_VOID).flatMap(List::stream).toList();

static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) {
mapping = Conversion748_729.remapItem(item, mapping);
String identifier = mapping.getBedrockIdentifier();

if (!NEW_BLOCKS.contains(identifier)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2024 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

package org.geysermc.geyser.registry.populator;

import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.registry.type.GeyserMappingItem;

import java.util.Map;

public class Conversion748_729 {

private static final Map<String, Integer> NEW_PLAYER_HEADS = Map.of("minecraft:skeleton_skull", 0, "minecraft:wither_skeleton_skull", 1, "minecraft:zombie_head", 2, "minecraft:player_head", 3, "minecraft:creeper_head", 4, "minecraft:dragon_head", 5, "minecraft:piglin_head", 6);

static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) {
String identifier = mapping.getBedrockIdentifier();

if (NEW_PLAYER_HEADS.containsKey(identifier)) {
return mapping.withBedrockIdentifier("minecraft:skull")
.withBedrockData(NEW_PLAYER_HEADS.get(identifier));
}

return mapping;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,8 @@ public static void populate() {
paletteVersions.add(new PaletteVersion("1_20_80", Bedrock_v671.CODEC.getProtocolVersion(), Collections.emptyMap(), Conversion685_671::remapItem));
paletteVersions.add(new PaletteVersion("1_21_0", Bedrock_v685.CODEC.getProtocolVersion(), Collections.emptyMap(), Conversion712_685::remapItem));
paletteVersions.add(new PaletteVersion("1_21_20", Bedrock_v712.CODEC.getProtocolVersion(), Collections.emptyMap(), Conversion729_712::remapItem));
paletteVersions.add(new PaletteVersion("1_21_30", Bedrock_v729.CODEC.getProtocolVersion()));
paletteVersions.add(new PaletteVersion("1_21_40", Bedrock_v748.CODEC.getProtocolVersion(), Collections.emptyMap(), (item, mapping) -> {
String identifier = item.javaIdentifier();
if (identifier.endsWith("_head") || identifier.endsWith("_skull")) {
return mapping.withBedrockIdentifier(item.javaIdentifier());
}
return mapping;
}));
paletteVersions.add(new PaletteVersion("1_21_30", Bedrock_v729.CODEC.getProtocolVersion(), Collections.emptyMap(), Conversion748_729::remapItem));
paletteVersions.add(new PaletteVersion("1_21_40", Bedrock_v748.CODEC.getProtocolVersion()));

GeyserBootstrap bootstrap = GeyserImpl.getInstance().getBootstrap();

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/mappings
Submodule mappings updated 1 files
+13 −13 items.json

0 comments on commit 448c75e

Please sign in to comment.