Port to 1.21.4 and more datagen

- Polymer mode is currently still broken
This commit is contained in:
Martin Prokoph
2024-12-30 22:32:35 +01:00
parent 75f9937035
commit f00ac39b79
365 changed files with 3364 additions and 1786 deletions

View File

@@ -9,7 +9,7 @@ import net.minecraft.util.math.Vec3d;
public class ParticleUtil {
public static void spawnParticle(ServerPlayerEntity player, ParticleType<?> type, Vec3d pos, Vec3d offset, float speed) {
ServerPlayNetworking.getSender(player).sendPacket(new ParticleS2CPacket((ParticleEffect) type, false, pos.x, pos.y, pos.z,
ServerPlayNetworking.getSender(player).sendPacket(new ParticleS2CPacket((ParticleEffect) type, false, true, pos.x, pos.y, pos.z,
(float) offset.x / 16f, (float) offset.y / 16f, (float) offset.z / 16f, speed, 1));
}
}

View File

@@ -25,12 +25,12 @@ import static eu.midnightdust.motschen.rocks.RocksMain.polymerMode;
public class RegistryUtil {
public static <T extends Block> T registerBlockWithItem(Identifier id, T block) {
Registry.register(Registries.BLOCK, id, block);
registerItem(id, blockItem(block));
registerItem(id, blockItem(block, id));
return block;
}
public static Item blockItem(Block block) {
if (polymerMode) return PolyUtil.polymerBlockItem(block);
return new BlockItem(block, new Item.Settings());
public static Item blockItem(Block block, Identifier id) {
if (polymerMode) return PolyUtil.polymerBlockItem(block, id);
return new BlockItem(block, new Item.Settings().registryKey(RegistryKey.of(RegistryKeys.ITEM, id)));
}
public static Item registerItem(Identifier id, Item item) {
Registry.register(Registries.ITEM, id, item);

View File

@@ -1,5 +1,7 @@
package eu.midnightdust.motschen.rocks.util;
import net.minecraft.block.Block;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;
import java.util.Arrays;
@@ -26,6 +28,12 @@ public enum RockType {
if (this.equals(RockType.STONE)) splitterName = "cobblestone_splitter";
return splitterName;
}
public Identifier getStoneId() {
return Identifier.ofVanilla(this.toString().toLowerCase());
}
public Block getStoneBlock() {
return Registries.BLOCK.get(getStoneId());
}
public Identifier[] getVariations() {
var variations = new Identifier[4];

View File

@@ -1,6 +1,10 @@
package eu.midnightdust.motschen.rocks.util;
import net.minecraft.block.Block;
import net.minecraft.block.WoodType;
import net.minecraft.registry.Registries;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;
import java.util.Objects;
@@ -10,4 +14,15 @@ public class StickType {
.replace("block.rocks.", "").replace("_stick", "")
)).findFirst().orElse(WoodType.OAK);
}
public static Block getBaseBlock(WoodType woodType) {
String logName = woodType.name() + "_";
if (woodType.soundType() == BlockSoundGroup.NETHER_WOOD) logName += "stem";
else if (woodType.soundType() == BlockSoundGroup.BAMBOO_WOOD) logName += "block";
else logName += "log";
if (Registries.BLOCK.containsId(Identifier.ofVanilla(logName))) {
return Registries.BLOCK.get(Identifier.ofVanilla(logName));
}
return null;
}
}

View File

@@ -9,12 +9,12 @@ import eu.midnightdust.motschen.rocks.block.polymer.model.*;
import eu.midnightdust.motschen.rocks.item.polymer.StarfishItemPolymer;
import eu.midnightdust.motschen.rocks.util.RockType;
import eu.pb4.factorytools.api.item.FactoryBlockItem;
import eu.pb4.factorytools.api.item.ModeledItem;
import eu.pb4.polymer.blocks.api.BlockModelType;
import eu.pb4.polymer.blocks.api.PolymerBlockResourceUtils;
import eu.pb4.polymer.core.api.block.PolymerBlock;
import eu.pb4.polymer.core.api.block.PolymerBlockUtils;
import eu.pb4.polymer.core.api.item.PolymerItemGroupUtils;
import eu.pb4.polymer.core.api.item.SimplePolymerItem;
import eu.pb4.polymer.core.api.utils.PolymerSyncUtils;
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
import eu.pb4.polymer.virtualentity.api.ElementHolder;
@@ -27,6 +27,8 @@ import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
@@ -66,13 +68,14 @@ public class PolyUtil {
return playersWithMod.contains(player);
}
public static Item polymerBlockItem(Block block) {
if (block instanceof Starfish) return new StarfishItemPolymer((Block & PolymerBlock) block, new Item.Settings(), Items.KELP);
else return new FactoryBlockItem((Block & PolymerBlock) block, new Item.Settings(), Items.KELP);
public static Item polymerBlockItem(Block block, Identifier id) {
if (block instanceof Starfish) return new StarfishItemPolymer((Block & PolymerBlock) block, new Item.Settings().registryKey(RegistryKey.of(RegistryKeys.ITEM, id)), Items.KELP);
else return new FactoryBlockItem((Block & PolymerBlock) block, new Item.Settings().registryKey(RegistryKey.of(RegistryKeys.ITEM, id)), Items.KELP);
}
public static Item simplePolymerItem() {
return new ModeledItem(Items.FLINT, new Item.Settings());
public static Item simplePolymerItem(Identifier id) {
return new SimplePolymerItem(new Item.Settings().registryKey(RegistryKey.of(RegistryKeys.ITEM, id)), Items.FLINT, true);
//return new ModeledItem(Items.FLINT, new Item.Settings());
}
public static void registerPolymerGroup() {
@@ -100,11 +103,11 @@ public class PolyUtil {
}
}
public static Rock newRockPolymer() {return new RockPolymer();}
public static Stick newStickPolymer() {return new StickPolymer();}
public static Block newPineconePolymer() {return new PineconePolymer();}
public static Block newSeashellPolymer() {return new SeashellPolymer();}
public static Block newStarfishPolymer() {return new StarfishPolymer();}
public static Block newOverworldGeyserPolymer() {return new OverworldGeyserPolymer();}
public static Block newNetherGeyserPolymer() {return new NetherGeyserPolymer();}
public static Rock newRockPolymer(Identifier id) {return new RockPolymer(id);}
public static Stick newStickPolymer(Identifier id) {return new StickPolymer(id);}
public static Block newPineconePolymer(Identifier id) {return new PineconePolymer(id);}
public static Block newSeashellPolymer(Identifier id) {return new SeashellPolymer(id);}
public static Block newStarfishPolymer(Identifier id) {return new StarfishPolymer(id);}
public static Block newOverworldGeyserPolymer(Identifier id) {return new OverworldGeyserPolymer(id);}
public static Block newNetherGeyserPolymer(Identifier id) {return new NetherGeyserPolymer(id);}
}