diff --git a/build.gradle b/build.gradle index c6bbdec8..fbed7c74 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.7-SNAPSHOT' + id 'fabric-loom' version '0.6-SNAPSHOT' id 'maven-publish' } @@ -24,7 +24,7 @@ apply plugin: 'maven' dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.minecraft_version}+build.${project.yarn_mappings}:v2" + mappings minecraft.officialMojangMappings() modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" diff --git a/gradle.properties b/gradle.properties index a2b058f6..5afb5c05 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,6 +15,6 @@ # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api patchouli_version = 50-FABRIC - fabric_version = 0.32.0+1.16 + fabric_version = 0.32.5+1.16 canvas_version = 1.0.+ rei_version = 5.8.10 \ No newline at end of file diff --git a/src/main/java/ru/betterend/BetterEnd.java b/src/main/java/ru/betterend/BetterEnd.java index 23ec25d5..154a40a3 100644 --- a/src/main/java/ru/betterend/BetterEnd.java +++ b/src/main/java/ru/betterend/BetterEnd.java @@ -3,8 +3,8 @@ package ru.betterend; import net.fabricmc.api.EnvType; import net.fabricmc.api.ModInitializer; import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; import ru.betterend.api.BetterEndPlugin; import ru.betterend.config.Configs; import ru.betterend.effects.EndEnchantments; @@ -39,6 +39,7 @@ import ru.betterend.world.surface.SurfaceBuilders; public class BetterEnd implements ModInitializer { public static final String MOD_ID = "betterend"; public static final Logger LOGGER = Logger.get(); + @Override public void onInitialize() { EndPortals.loadPortals(); @@ -66,40 +67,41 @@ public class BetterEnd implements ModInitializer { GeneratorOptions.init(); DataFixerUtil.init(); LootTableUtil.init(); - + if (hasGuideBook()) { GuideBookItem.register(); } - - FabricLoader.getInstance().getEntrypoints("betterend", BetterEndPlugin.class).forEach(BetterEndPlugin::register); + + FabricLoader.getInstance().getEntrypoints("betterend", BetterEndPlugin.class) + .forEach(BetterEndPlugin::register); Configs.saveConfigs(); - + if (hasGuideBook()) { - PlayerAdvancementsEvents.PLAYER_ADVENCEMENT_COMPLETE.register((player, advancement, criterionName) -> { - Identifier advId = new Identifier("minecraft:end/enter_end_gateway"); + PlayerAdvancementsEvents.PLAYER_ADVANCEMENT_COMPLETE.register((player, advancement, criterionName) -> { + ResourceLocation advId = new ResourceLocation("minecraft:end/enter_end_gateway"); if (advId.equals(advancement.getId())) { player.giveItemStack(new ItemStack(GuideBookItem.GUIDE_BOOK)); } }); } } - + public static boolean hasGuideBook() { return FabricLoader.getInstance().isModLoaded("patchouli"); } - - public static Identifier makeID(String path) { - return new Identifier(MOD_ID, path); + + public static ResourceLocation makeID(String path) { + return new ResourceLocation(MOD_ID, path); } - + public static String getStringId(String id) { return String.format("%s:%s", MOD_ID, id); } - + public static boolean isDevEnvironment() { return FabricLoader.getInstance().isDevelopmentEnvironment(); } - + public static boolean isClient() { return FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT; } diff --git a/src/main/java/ru/betterend/blocks/AeterniumAnvil.java b/src/main/java/ru/betterend/blocks/AeterniumAnvil.java index a57ca9c6..fcebb3eb 100644 --- a/src/main/java/ru/betterend/blocks/AeterniumAnvil.java +++ b/src/main/java/ru/betterend/blocks/AeterniumAnvil.java @@ -1,35 +1,35 @@ package ru.betterend.blocks; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.Identifier; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.resources.ResourceLocation; import ru.betterend.blocks.basis.EndAnvilBlock; import ru.betterend.item.material.EndToolMaterial; import ru.betterend.patterns.Patterns; import ru.betterend.registry.EndBlocks; public class AeterniumAnvil extends EndAnvilBlock { - private static final IntProperty DESTRUCTION = BlockProperties.DESTRUCTION_LONG; - + private static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION_LONG; + public AeterniumAnvil() { - super(EndBlocks.AETERNIUM_BLOCK.getDefaultMaterialColor(), EndToolMaterial.AETERNIUM.getMiningLevel()); + super(EndBlocks.AETERNIUM_BLOCK.defaultMaterialColor(), EndToolMaterial.AETERNIUM.getLevel()); } - + @Override - protected void appendProperties(StateManager.Builder builder) { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(DESTRUCTION); builder.add(FACING); } @Override - public IntProperty getDestructionProperty() { + public IntegerProperty getDESTRUCTION() { return DESTRUCTION; } @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_ANVIL_LONG; } } diff --git a/src/main/java/ru/betterend/blocks/AeterniumBlock.java b/src/main/java/ru/betterend/blocks/AeterniumBlock.java index e5e11578..32a52412 100644 --- a/src/main/java/ru/betterend/blocks/AeterniumBlock.java +++ b/src/main/java/ru/betterend/blocks/AeterniumBlock.java @@ -3,26 +3,23 @@ package ru.betterend.blocks; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.block.SoundType; import ru.betterend.blocks.basis.BlockBase; public class AeterniumBlock extends BlockBase { public AeterniumBlock() { - super(FabricBlockSettings.of(Material.METAL, MaterialColor.GRAY) - .hardness(65F) - .resistance(1200F) - .requiresTool() - .sounds(BlockSoundGroup.NETHERITE)); + super(FabricBlockSettings.of(Material.METAL, MaterialColor.COLOR_GRAY).hardness(65F).resistance(1200F) + .requiresTool().sounds(SoundType.NETHERITE_BLOCK)); } @Environment(EnvType.CLIENT) - public int getColor(BlockState state, BlockView world, BlockPos pos) { + public int getColor(BlockState state, BlockGetter world, BlockPos pos) { return 0xFF657A7A; } } diff --git a/src/main/java/ru/betterend/blocks/AmaranitaCapBlock.java b/src/main/java/ru/betterend/blocks/AmaranitaCapBlock.java index 2af9deb0..717228df 100644 --- a/src/main/java/ru/betterend/blocks/AmaranitaCapBlock.java +++ b/src/main/java/ru/betterend/blocks/AmaranitaCapBlock.java @@ -2,12 +2,12 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Material; -import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.SoundType; import ru.betterend.blocks.basis.BlockBase; public class AmaranitaCapBlock extends BlockBase { public AmaranitaCapBlock() { - super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WOOD)); + super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(SoundType.WOOD)); } } diff --git a/src/main/java/ru/betterend/blocks/AmaranitaHymenophoreBlock.java b/src/main/java/ru/betterend/blocks/AmaranitaHymenophoreBlock.java index 36c8310c..100c4d24 100644 --- a/src/main/java/ru/betterend/blocks/AmaranitaHymenophoreBlock.java +++ b/src/main/java/ru/betterend/blocks/AmaranitaHymenophoreBlock.java @@ -2,15 +2,15 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Material; -import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.SoundType; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; public class AmaranitaHymenophoreBlock extends BlockBase implements IRenderTypeable { public AmaranitaHymenophoreBlock() { - super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WOOD)); + super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(SoundType.WOOD)); } @Override diff --git a/src/main/java/ru/betterend/blocks/AmaranitaStemBlock.java b/src/main/java/ru/betterend/blocks/AmaranitaStemBlock.java index 7e0a5702..2aa563ae 100644 --- a/src/main/java/ru/betterend/blocks/AmaranitaStemBlock.java +++ b/src/main/java/ru/betterend/blocks/AmaranitaStemBlock.java @@ -1,12 +1,12 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Blocks; -import net.minecraft.block.MaterialColor; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.MaterialColor; import ru.betterend.blocks.basis.EndPillarBlock; public class AmaranitaStemBlock extends EndPillarBlock { public AmaranitaStemBlock() { - super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS).materialColor(MaterialColor.LIME)); + super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS).materialColor(MaterialColor.COLOR_LIGHT_GREEN)); } } diff --git a/src/main/java/ru/betterend/blocks/AmberBlock.java b/src/main/java/ru/betterend/blocks/AmberBlock.java index 54e7ee94..6dbef462 100644 --- a/src/main/java/ru/betterend/blocks/AmberBlock.java +++ b/src/main/java/ru/betterend/blocks/AmberBlock.java @@ -1,12 +1,12 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Blocks; -import net.minecraft.block.MaterialColor; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.MaterialColor; import ru.betterend.blocks.basis.BlockBase; public class AmberBlock extends BlockBase { public AmberBlock() { - super(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK).materialColor(MaterialColor.YELLOW)); + super(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK).materialColor(MaterialColor.COLOR_YELLOW)); } } diff --git a/src/main/java/ru/betterend/blocks/AncientEmeraldIceBlock.java b/src/main/java/ru/betterend/blocks/AncientEmeraldIceBlock.java index 7c1395d3..616279c7 100644 --- a/src/main/java/ru/betterend/blocks/AncientEmeraldIceBlock.java +++ b/src/main/java/ru/betterend/blocks/AncientEmeraldIceBlock.java @@ -3,11 +3,11 @@ package ru.betterend.blocks; import java.util.Random; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndParticles; @@ -18,35 +18,35 @@ public class AncientEmeraldIceBlock extends BlockBase { public AncientEmeraldIceBlock() { super(FabricBlockSettings.copyOf(Blocks.BLUE_ICE).ticksRandomly()); } - + @Override - public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { Direction dir = BlocksHelper.randomDirection(random); - + if (random.nextBoolean()) { int x = MHelper.randRange(-2, 2, random); int y = MHelper.randRange(-2, 2, random); int z = MHelper.randRange(-2, 2, random); - BlockPos p = pos.add(x, y, z); - if (world.getBlockState(p).isOf(Blocks.WATER)) { - world.setBlockState(p, EndBlocks.EMERALD_ICE.getDefaultState()); + BlockPos p = pos.offset(x, y, z); + if (world.getBlockState(p).is(Blocks.WATER)) { + world.setBlockAndUpdate(p, EndBlocks.EMERALD_ICE.defaultBlockState()); makeParticles(world, p, random); } } - - pos = pos.offset(dir); + + pos = pos.relative(dir); state = world.getBlockState(pos); - if (state.isOf(Blocks.WATER)) { - world.setBlockState(pos, EndBlocks.EMERALD_ICE.getDefaultState()); + if (state.is(Blocks.WATER)) { + world.setBlockAndUpdate(pos, EndBlocks.EMERALD_ICE.defaultBlockState()); makeParticles(world, pos, random); - } - else if (state.isOf(EndBlocks.EMERALD_ICE)) { - world.setBlockState(pos, EndBlocks.DENSE_EMERALD_ICE.getDefaultState()); + } else if (state.is(EndBlocks.EMERALD_ICE)) { + world.setBlockAndUpdate(pos, EndBlocks.DENSE_EMERALD_ICE.defaultBlockState()); makeParticles(world, pos, random); } } - - private void makeParticles(ServerWorld world, BlockPos pos, Random random) { - world.spawnParticles(EndParticles.SNOWFLAKE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 20, 0.5, 0.5, 0.5, 0); + + private void makeParticles(ServerLevel world, BlockPos pos, Random random) { + world.sendParticles(EndParticles.SNOWFLAKE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 20, 0.5, 0.5, + 0.5, 0); } } diff --git a/src/main/java/ru/betterend/blocks/AuroraCrystalBlock.java b/src/main/java/ru/betterend/blocks/AuroraCrystalBlock.java index ba5edf0c..73b3580a 100644 --- a/src/main/java/ru/betterend/blocks/AuroraCrystalBlock.java +++ b/src/main/java/ru/betterend/blocks/AuroraCrystalBlock.java @@ -6,19 +6,19 @@ import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.AbstractGlassBlock; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.client.color.block.BlockColorProvider; -import net.minecraft.client.color.item.ItemColorProvider; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3i; +import net.minecraft.core.Vec3i; +import net.minecraft.util.Mth; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.level.block.AbstractGlassBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.client.color.block.BlockColor; +import net.minecraft.client.color.item.ItemColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.level.block.SoundType; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IColorProvider; import ru.betterend.interfaces.IRenderTypeable; @@ -29,20 +29,15 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp public static final Vec3i[] COLORS; private static final int MIN_DROP = 1; private static final int MAX_DROP = 4; - + public AuroraCrystalBlock() { - super(FabricBlockSettings.of(Material.GLASS) - .breakByTool(FabricToolTags.PICKAXES) - .suffocates((state, world, pos) -> { return false; }) - .hardness(1F) - .resistance(1F) - .sounds(BlockSoundGroup.GLASS) - .luminance(15) - .nonOpaque()); + super(FabricBlockSettings.of(Material.GLASS).breakByTool(FabricToolTags.PICKAXES) + .suffocates((state, world, pos) -> false).hardness(1F).resistance(1F).sounds(SoundType.GLASS) + .luminance(15).nonOpaque()); } @Override - public BlockColorProvider getProvider() { + public BlockColor getBlockProvider() { return (state, world, pos, tintIndex) -> { long i = (long) pos.getX() + (long) pos.getY() + (long) pos.getZ(); double delta = i * 0.1; @@ -50,43 +45,41 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp int index2 = (index + 1) & 3; delta -= index; index &= 3; - + Vec3i color1 = COLORS[index]; Vec3i color2 = COLORS[index2]; - - int r = MHelper.floor(MathHelper.lerp(delta, color1.getX(), color2.getX())); - int g = MHelper.floor(MathHelper.lerp(delta, color1.getY(), color2.getY())); - int b = MHelper.floor(MathHelper.lerp(delta, color1.getZ(), color2.getZ())); - + + int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX())); + int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY())); + int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ())); + return MHelper.color(r, g, b); }; } @Override - public ItemColorProvider getItemProvider() { - return (stack, tintIndex) -> { - return MHelper.color(COLORS[3].getX(), COLORS[3].getY(), COLORS[3].getZ()); - }; + public ItemColor getItemProvider() { + return (stack, tintIndex) -> MHelper.color(COLORS[3].getX(), COLORS[3].getY(), COLORS[3].getZ()); } @Override public ERenderLayer getRenderLayer() { return ERenderLayer.TRANSLUCENT; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && tool.isEffectiveOn(state)) { + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && tool.isCorrectToolForDrops(state)) { int count = 0; - int enchant = EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool); + int enchant = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool); if (enchant > 0) { return Lists.newArrayList(new ItemStack(this)); } - enchant = EnchantmentHelper.getLevel(Enchantments.FORTUNE, tool); + enchant = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool); if (enchant > 0) { - int min = MathHelper.clamp(MIN_DROP + enchant, MIN_DROP, MAX_DROP); - int max = MAX_DROP + (enchant / Enchantments.FORTUNE.getMaxLevel()); + int min = Mth.clamp(MIN_DROP + enchant, MIN_DROP, MAX_DROP); + int max = MAX_DROP + (enchant / Enchantments.BLOCK_FORTUNE.getMaxLevel()); if (min == max) { return Lists.newArrayList(new ItemStack(EndItems.CRYSTAL_SHARDS, max)); } @@ -98,13 +91,9 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp } return Lists.newArrayList(); } - + static { - COLORS = new Vec3i[] { - new Vec3i(247, 77, 161), - new Vec3i(120, 184, 255), - new Vec3i(120, 255, 168), - new Vec3i(243, 58, 255) - }; + COLORS = new Vec3i[] { new Vec3i(247, 77, 161), new Vec3i(120, 184, 255), new Vec3i(120, 255, 168), + new Vec3i(243, 58, 255) }; } } diff --git a/src/main/java/ru/betterend/blocks/BlockProperties.java b/src/main/java/ru/betterend/blocks/BlockProperties.java index 331980be..5d153ab1 100644 --- a/src/main/java/ru/betterend/blocks/BlockProperties.java +++ b/src/main/java/ru/betterend/blocks/BlockProperties.java @@ -2,7 +2,7 @@ package ru.betterend.blocks; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.EnumProperty; -import net.minecraft.state.property.IntProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; import net.minecraft.util.StringIdentifiable; import ru.betterend.registry.EndPortals; @@ -11,7 +11,7 @@ public class BlockProperties { public final static EnumProperty PEDESTAL_STATE = EnumProperty.of("state", PedestalState.class); public static final EnumProperty TRIPLE_SHAPE = EnumProperty.of("shape", TripleShape.class); public static final EnumProperty PENTA_SHAPE = EnumProperty.of("shape", PentaShape.class); - + public static final BooleanProperty TRANSITION = BooleanProperty.of("transition"); public static final BooleanProperty HAS_LIGHT = BooleanProperty.of("has_light"); public static final BooleanProperty HAS_ITEM = BooleanProperty.of("has_item"); @@ -19,23 +19,21 @@ public class BlockProperties { public static final BooleanProperty NATURAL = BooleanProperty.of("natural"); public static final BooleanProperty ACTIVE = BooleanProperty.of("active"); public static final BooleanProperty SMALL = BooleanProperty.of("small"); - - public static final IntProperty DESTRUCTION_LONG = IntProperty.of("destruction", 0, 8); - public static final IntProperty DESTRUCTION = IntProperty.of("destruction", 0, 2); - public static final IntProperty ROTATION = IntProperty.of("rotation", 0, 3); - public static final IntProperty FULLNESS = IntProperty.of("fullness", 0, 3); - public static final IntProperty COLOR = IntProperty.of("color", 0, 7); - public static final IntProperty PORTAL = IntProperty.of("portal", 0, EndPortals.getCount()); - public static final IntProperty SIZE = IntProperty.of("size", 0, 7); - public static final IntProperty AGE = IntProperty.of("age", 0, 3); - + + public static final IntegerProperty DESTRUCTION_LONG = IntegerProperty.of("destruction", 0, 8); + public static final IntegerProperty DESTRUCTION = IntegerProperty.of("destruction", 0, 2); + public static final IntegerProperty ROTATION = IntegerProperty.of("rotation", 0, 3); + public static final IntegerProperty FULLNESS = IntegerProperty.of("fullness", 0, 3); + public static final IntegerProperty COLOR = IntegerProperty.of("color", 0, 7); + public static final IntegerProperty PORTAL = IntegerProperty.of("portal", 0, EndPortals.getCount()); + public static final IntegerProperty SIZE = IntegerProperty.of("size", 0, 7); + public static final IntegerProperty AGE = IntegerProperty.of("age", 0, 3); + public static enum TripleShape implements StringIdentifiable { - TOP("top"), - MIDDLE("middle"), - BOTTOM("bottom"); - + TOP("top"), MIDDLE("middle"), BOTTOM("bottom"); + private final String name; - + TripleShape(String name) { this.name = name; } @@ -44,7 +42,7 @@ public class BlockProperties { public String asString() { return name; } - + @Override public String toString() { return name; @@ -52,41 +50,34 @@ public class BlockProperties { } public static enum PedestalState implements StringIdentifiable { - PEDESTAL_TOP("pedestal_top"), - COLUMN_TOP("column_top"), - BOTTOM("bottom"), - PILLAR("pillar"), - COLUMN("column"), + PEDESTAL_TOP("pedestal_top"), COLUMN_TOP("column_top"), BOTTOM("bottom"), PILLAR("pillar"), COLUMN("column"), DEFAULT("default"); - + private final String name; - + PedestalState(String name) { this.name = name; } - + @Override public String asString() { return this.name; } - + @Override public String toString() { return this.name; } } - + public static enum HydraluxShape implements StringIdentifiable { - FLOWER_BIG_BOTTOM("flower_big_bottom", true), - FLOWER_BIG_TOP("flower_big_top", true), - FLOWER_SMALL_BOTTOM("flower_small_bottom", true), - FLOWER_SMALL_TOP("flower_small_top", true), - VINE("vine", false), - ROOTS("roots", false); - + FLOWER_BIG_BOTTOM("flower_big_bottom", true), FLOWER_BIG_TOP("flower_big_top", true), + FLOWER_SMALL_BOTTOM("flower_small_bottom", true), FLOWER_SMALL_TOP("flower_small_top", true), + VINE("vine", false), ROOTS("roots", false); + private final String name; private final boolean glow; - + HydraluxShape(String name, boolean glow) { this.name = name; this.glow = glow; @@ -96,26 +87,22 @@ public class BlockProperties { public String asString() { return name; } - + @Override public String toString() { return name; } - + public boolean hasGlow() { return glow; } } - + public static enum PentaShape implements StringIdentifiable { - BOTTOM("bottom"), - PRE_BOTTOM("pre_bottom"), - MIDDLE("middle"), - PRE_TOP("pre_top"), - TOP("top"); - + BOTTOM("bottom"), PRE_BOTTOM("pre_bottom"), MIDDLE("middle"), PRE_TOP("pre_top"), TOP("top"); + private final String name; - + PentaShape(String name) { this.name = name; } @@ -124,25 +111,21 @@ public class BlockProperties { public String asString() { return name; } - + @Override public String toString() { return name; } } - + public static enum LumecornShape implements StringIdentifiable { - LIGHT_TOP("light_top", 15), - LIGHT_TOP_MIDDLE("light_top_middle", 15), - LIGHT_MIDDLE("light_middle", 15), - LIGHT_BOTTOM("light_bottom", 15), - MIDDLE("middle", 0), - BOTTOM_BIG("bottom_big", 0), + LIGHT_TOP("light_top", 15), LIGHT_TOP_MIDDLE("light_top_middle", 15), LIGHT_MIDDLE("light_middle", 15), + LIGHT_BOTTOM("light_bottom", 15), MIDDLE("middle", 0), BOTTOM_BIG("bottom_big", 0), BOTTOM_SMALL("bottom_small", 0); - + private final String name; private final int light; - + LumecornShape(String name, int light) { this.name = name; this.light = light; @@ -152,12 +135,12 @@ public class BlockProperties { public String asString() { return name; } - + @Override public String toString() { return name; } - + public int getLight() { return light; } diff --git a/src/main/java/ru/betterend/blocks/BlockSounds.java b/src/main/java/ru/betterend/blocks/BlockSounds.java index cf39c972..75c2ac41 100644 --- a/src/main/java/ru/betterend/blocks/BlockSounds.java +++ b/src/main/java/ru/betterend/blocks/BlockSounds.java @@ -1,13 +1,10 @@ package ru.betterend.blocks; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.sound.SoundEvents; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.sounds.SoundEvents; public class BlockSounds { - public static final BlockSoundGroup TERRAIN_SOUND = new BlockSoundGroup(1.0F, 1.0F, - SoundEvents.BLOCK_STONE_BREAK, - SoundEvents.BLOCK_WART_BLOCK_STEP, - SoundEvents.BLOCK_STONE_PLACE, - SoundEvents.BLOCK_STONE_HIT, + public static final SoundType TERRAIN_SOUND = new SoundType(1.0F, 1.0F, SoundEvents.BLOCK_STONE_BREAK, + SoundEvents.BLOCK_WART_BLOCK_STEP, SoundEvents.BLOCK_STONE_PLACE, SoundEvents.BLOCK_STONE_HIT, SoundEvents.BLOCK_STONE_FALL); } diff --git a/src/main/java/ru/betterend/blocks/BlueVineBlock.java b/src/main/java/ru/betterend/blocks/BlueVineBlock.java index 122225ae..0d1b0643 100644 --- a/src/main/java/ru/betterend/blocks/BlueVineBlock.java +++ b/src/main/java/ru/betterend/blocks/BlueVineBlock.java @@ -1,8 +1,8 @@ package ru.betterend.blocks; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.EnumProperty; import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.blocks.basis.UpDownPlantBlock; @@ -10,12 +10,12 @@ import ru.betterend.registry.EndBlocks; public class BlueVineBlock extends UpDownPlantBlock { public static final EnumProperty SHAPE = BlockProperties.TRIPLE_SHAPE; - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(SHAPE); } - + @Override protected boolean isTerrain(BlockState state) { return state.getBlock() == EndBlocks.END_MOSS || state.getBlock() == EndBlocks.END_MYCELIUM; diff --git a/src/main/java/ru/betterend/blocks/BlueVineLanternBlock.java b/src/main/java/ru/betterend/blocks/BlueVineLanternBlock.java index a79781a6..44de7d10 100644 --- a/src/main/java/ru/betterend/blocks/BlueVineLanternBlock.java +++ b/src/main/java/ru/betterend/blocks/BlueVineLanternBlock.java @@ -2,45 +2,46 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.WorldAccess; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.registry.EndBlocks; public class BlueVineLanternBlock extends BlockBase { public static final BooleanProperty NATURAL = BlockProperties.NATURAL; - + public BlueVineLanternBlock() { - super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WART_BLOCK).luminance(15)); - this.setDefaultState(this.stateManager.getDefaultState().with(NATURAL, false)); + super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(SoundType.WART_BLOCK) + .luminance(15)); + this.setDefaultState(this.stateManager.defaultBlockState().with(NATURAL, false)); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - return state.get(NATURAL) ? world.getBlockState(pos.down()).getBlock() == EndBlocks.BLUE_VINE : true; + return state.getValue(NATURAL) ? world.getBlockState(pos.below()).getBlock() == EndBlocks.BLUE_VINE : true; } - + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (!canPlaceAt(state, world, pos)) { - return Blocks.AIR.getDefaultState(); - } - else { + return Blocks.AIR.defaultBlockState(); + } else { return state; } } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(NATURAL); } } diff --git a/src/main/java/ru/betterend/blocks/BlueVineSeedBlock.java b/src/main/java/ru/betterend/blocks/BlueVineSeedBlock.java index a4710621..f5ff9a39 100644 --- a/src/main/java/ru/betterend/blocks/BlueVineSeedBlock.java +++ b/src/main/java/ru/betterend/blocks/BlueVineSeedBlock.java @@ -2,10 +2,10 @@ package ru.betterend.blocks; import java.util.Random; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.blocks.basis.EndPlantWithAgeBlock; @@ -22,32 +22,38 @@ public class BlueVineSeedBlock extends EndPlantWithAgeBlock { if (h < height + 1) { return; } - BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BLUE_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM)); + BlocksHelper.setWithoutUpdate(world, pos, + EndBlocks.BLUE_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM)); for (int i = 1; i < height; i++) { - BlocksHelper.setWithoutUpdate(world, pos.up(i), EndBlocks.BLUE_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE)); + BlocksHelper.setWithoutUpdate(world, pos.up(i), + EndBlocks.BLUE_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE)); } - BlocksHelper.setWithoutUpdate(world, pos.up(height), EndBlocks.BLUE_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP)); + BlocksHelper.setWithoutUpdate(world, pos.up(height), + EndBlocks.BLUE_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP)); placeLantern(world, pos.up(height + 1)); } - + private void placeLantern(StructureWorldAccess world, BlockPos pos) { - BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BLUE_VINE_LANTERN.getDefaultState().with(BlueVineLanternBlock.NATURAL, true)); - for (Direction dir: BlocksHelper.HORIZONTAL) { - BlockPos p = pos.offset(dir); + BlocksHelper.setWithoutUpdate(world, pos, + EndBlocks.BLUE_VINE_LANTERN.defaultBlockState().with(BlueVineLanternBlock.NATURAL, true)); + for (Direction dir : BlocksHelper.HORIZONTAL) { + BlockPos p = pos.relative(dir); if (world.isAir(p)) { - BlocksHelper.setWithoutUpdate(world, p, EndBlocks.BLUE_VINE_FUR.getDefaultState().with(FurBlock.FACING, dir)); + BlocksHelper.setWithoutUpdate(world, p, + EndBlocks.BLUE_VINE_FUR.defaultBlockState().with(FurBlock.FACING, dir)); } } if (world.isAir(pos.up())) { - BlocksHelper.setWithoutUpdate(world, pos.up(), EndBlocks.BLUE_VINE_FUR.getDefaultState().with(FurBlock.FACING, Direction.UP)); + BlocksHelper.setWithoutUpdate(world, pos.up(), + EndBlocks.BLUE_VINE_FUR.defaultBlockState().with(FurBlock.FACING, Direction.UP)); } } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.END_MOSS) || state.isOf(EndBlocks.END_MYCELIUM); + return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM); } - + @Override public AbstractBlock.OffsetType getOffsetType() { return AbstractBlock.OffsetType.NONE; diff --git a/src/main/java/ru/betterend/blocks/BoluxMushroomBlock.java b/src/main/java/ru/betterend/blocks/BoluxMushroomBlock.java index e59a4283..338016be 100644 --- a/src/main/java/ru/betterend/blocks/BoluxMushroomBlock.java +++ b/src/main/java/ru/betterend/blocks/BoluxMushroomBlock.java @@ -5,31 +5,31 @@ import java.util.Random; import com.google.common.collect.Lists; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.ShapeContext; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.core.BlockPos; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.registry.EndBlocks; public class BoluxMushroomBlock extends EndPlantBlock { private static final VoxelShape SHAPE = Block.createCuboidShape(1, 0, 1, 15, 9, 15); - + public BoluxMushroomBlock() { super(10); } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.RUTISCUS); + return state.is(EndBlocks.RUTISCUS); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { return SHAPE; @@ -39,19 +39,19 @@ public class BoluxMushroomBlock extends EndPlantBlock { public AbstractBlock.OffsetType getOffsetType() { return AbstractBlock.OffsetType.NONE; } - + @Override public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { return false; } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { return false; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Lists.newArrayList(new ItemStack(this)); } } diff --git a/src/main/java/ru/betterend/blocks/BrimstoneBlock.java b/src/main/java/ru/betterend/blocks/BrimstoneBlock.java index 8b832d94..804b2442 100644 --- a/src/main/java/ru/betterend/blocks/BrimstoneBlock.java +++ b/src/main/java/ru/betterend/blocks/BrimstoneBlock.java @@ -5,52 +5,53 @@ import java.util.Random; import org.jetbrains.annotations.Nullable; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.MaterialColor; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.state.StateManager; +import net.minecraft.world.item.ItemStack; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.registry.EndBlocks; import ru.betterend.util.BlocksHelper; public class BrimstoneBlock extends BlockBase { public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE; - + public BrimstoneBlock() { - super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(MaterialColor.BROWN).ticksRandomly()); - setDefaultState(stateManager.getDefaultState().with(ACTIVATED, false)); + super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(MaterialColor.COLOR_BROWN).ticksRandomly()); + setDefaultState(stateManager.defaultBlockState().with(ACTIVATED, false)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(ACTIVATED); } @Override - public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) { - if (world.isClient()) { - updateChunks((ClientWorld) world, pos); + public void onPlaced(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, + ItemStack itemStack) { + if (world.isClientSide()) { + updateChunks((ClientLevel) world, pos); } } - - public void onBroken(WorldAccess world, BlockPos pos, BlockState state) { - if (world.isClient()) { - updateChunks((ClientWorld) world, pos); + + public void onBroken(LevelAccessor world, BlockPos pos, BlockState state) { + if (world.isClientSide()) { + updateChunks((ClientLevel) world, pos); } } - - private void updateChunks(ClientWorld world, BlockPos pos) { + + private void updateChunks(ClientLevel world, BlockPos pos) { int y = pos.getY() >> 4; int x1 = (pos.getX() - 2) >> 4; int z1 = (pos.getZ() - 2) >> 4; @@ -62,41 +63,37 @@ public class BrimstoneBlock extends BlockBase { } } } - + @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { boolean deactivate = true; - for (Direction dir: BlocksHelper.DIRECTIONS) { - if (world.getFluidState(pos.offset(dir)).getFluid().equals(Fluids.WATER)) { + for (Direction dir : BlocksHelper.DIRECTIONS) { + if (world.getFluidState(pos.relative(dir)).getFluid().equals(Fluids.WATER)) { deactivate = false; break; } } - if (state.get(ACTIVATED)) { + if (state.getValue(ACTIVATED)) { if (deactivate) { - world.setBlockState(pos, getDefaultState().with(ACTIVATED, false)); - } - else if (state.get(ACTIVATED) && random.nextInt(16) == 0) { + world.setBlockAndUpdate(pos, getDefaultState().with(ACTIVATED, false)); + } else if (state.getValue(ACTIVATED) && random.nextInt(16) == 0) { Direction dir = BlocksHelper.randomDirection(random); - BlockPos side = pos.offset(dir); + BlockPos side = pos.relative(dir); BlockState sideState = world.getBlockState(side); if (sideState.getBlock() instanceof SulphurCrystalBlock) { if (sideState.get(SulphurCrystalBlock.AGE) < 2 && sideState.get(SulphurCrystalBlock.WATERLOGGED)) { int age = sideState.get(SulphurCrystalBlock.AGE) + 1; - world.setBlockState(side, sideState.with(SulphurCrystalBlock.AGE, age)); + world.setBlockAndUpdate(side, sideState.with(SulphurCrystalBlock.AGE, age)); } - } - else if (sideState.getFluidState().getFluid() == Fluids.WATER) { - BlockState crystal = EndBlocks.SULPHUR_CRYSTAL.getDefaultState() - .with(SulphurCrystalBlock.FACING, dir) - .with(SulphurCrystalBlock.WATERLOGGED, true) + } else if (sideState.getFluidState().getFluid() == Fluids.WATER) { + BlockState crystal = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState() + .with(SulphurCrystalBlock.FACING, dir).with(SulphurCrystalBlock.WATERLOGGED, true) .with(SulphurCrystalBlock.AGE, 0); - world.setBlockState(side, crystal); + world.setBlockAndUpdate(side, crystal); } } - } - else if (!deactivate && !state.get(ACTIVATED)) { - world.setBlockState(pos, getDefaultState().with(ACTIVATED, true)); + } else if (!deactivate && !state.getValue(ACTIVATED)) { + world.setBlockAndUpdate(pos, getDefaultState().with(ACTIVATED, true)); } } } diff --git a/src/main/java/ru/betterend/blocks/BubbleCoralBlock.java b/src/main/java/ru/betterend/blocks/BubbleCoralBlock.java index 0cab0586..4eed7a40 100644 --- a/src/main/java/ru/betterend/blocks/BubbleCoralBlock.java +++ b/src/main/java/ru/betterend/blocks/BubbleCoralBlock.java @@ -6,55 +6,52 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.core.BlockPos; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import ru.betterend.blocks.basis.UnderwaterPlantBlock; public class BubbleCoralBlock extends UnderwaterPlantBlock { private static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 14, 16); - + public BubbleCoralBlock() { - super(FabricBlockSettings.of(Material.UNDERWATER_PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.CORAL) - .breakByHand(true) - .noCollision()); + super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS) + .sounds(SoundType.CORAL).breakByHand(true).noCollision()); } - + @Override public AbstractBlock.OffsetType getOffsetType() { return AbstractBlock.OffsetType.NONE; } @Environment(EnvType.CLIENT) - public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { + public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { double x = pos.getX() + random.nextDouble(); double y = pos.getY() + random.nextDouble() * 0.5F + 0.5F; double z = pos.getZ() + random.nextDouble(); world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0.0D, 0.0D, 0.0D); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { return SHAPE; } - + @Override public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { return false; } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { return false; } } diff --git a/src/main/java/ru/betterend/blocks/BulbVineBlock.java b/src/main/java/ru/betterend/blocks/BulbVineBlock.java index d88e55aa..53e2b1cf 100644 --- a/src/main/java/ru/betterend/blocks/BulbVineBlock.java +++ b/src/main/java/ru/betterend/blocks/BulbVineBlock.java @@ -4,11 +4,11 @@ import java.util.List; import com.google.common.collect.Lists; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; import net.minecraft.world.WorldView; import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.blocks.basis.VineBlock; @@ -20,28 +20,27 @@ public class BulbVineBlock extends VineBlock { public BulbVineBlock() { super(15, true); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - if (state.get(SHAPE) == TripleShape.BOTTOM) { + public List getDrops(BlockState state, LootContext.Builder builder) { + if (state.getValue(SHAPE) == TripleShape.BOTTOM) { return Lists.newArrayList(new ItemStack(EndItems.GLOWING_BULB)); - } - else if (MHelper.RANDOM.nextInt(8) == 0) { + } else if (MHelper.RANDOM.nextInt(8) == 0) { return Lists.newArrayList(new ItemStack(EndBlocks.BULB_VINE_SEED)); - } - else { + } else { return Lists.newArrayList(); } } - + @Override public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { return false; } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { boolean canPlace = super.canPlaceAt(state, world, pos); - return (state.isOf(this) && state.get(SHAPE) == TripleShape.BOTTOM) ? canPlace : canPlace && world.getBlockState(pos.down()).isOf(this); + return (state.is(this) && state.getValue(SHAPE) == TripleShape.BOTTOM) ? canPlace + : canPlace && world.getBlockState(pos.below()).is(this); } } diff --git a/src/main/java/ru/betterend/blocks/BulbVineLanternBlock.java b/src/main/java/ru/betterend/blocks/BulbVineLanternBlock.java index 00775b1f..714bb717 100644 --- a/src/main/java/ru/betterend/blocks/BulbVineLanternBlock.java +++ b/src/main/java/ru/betterend/blocks/BulbVineLanternBlock.java @@ -7,17 +7,17 @@ import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; -import net.minecraft.block.ShapeContext; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Registry; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.BlockGetter; import ru.betterend.blocks.basis.EndLanternBlock; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; @@ -27,64 +27,58 @@ import ru.betterend.patterns.Patterns; public class BulbVineLanternBlock extends EndLanternBlock implements IRenderTypeable, BlockPatterned { private static final VoxelShape SHAPE_CEIL = Block.createCuboidShape(4, 4, 4, 12, 16, 12); private static final VoxelShape SHAPE_FLOOR = Block.createCuboidShape(4, 0, 4, 12, 12, 12); - + public BulbVineLanternBlock() { - this(FabricBlockSettings.of(Material.METAL) - .sounds(BlockSoundGroup.LANTERN) - .hardness(1) - .resistance(1) - .breakByTool(FabricToolTags.PICKAXES) - .materialColor(MaterialColor.LIGHT_GRAY) - .requiresTool() + this(FabricBlockSettings.of(Material.METAL).sounds(SoundType.LANTERN).hardness(1).resistance(1) + .breakByTool(FabricToolTags.PICKAXES).materialColor(MaterialColor.LIGHT_GRAY).requiresTool() .luminance(15)); } - + public BulbVineLanternBlock(FabricBlockSettings settings) { super(settings); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return state.get(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL; + return state.getValue(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL; } @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); return Patterns.createJson(data, blockId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); Map map = Maps.newHashMap(); map.put("%glow%", getGlowTexture()); map.put("%metal%", getMetalTexture(blockId)); if (block.contains("item") || block.contains("ceil")) { return Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_CEIL, map); - } - else { + } else { return Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_FLOOR, map); } } - - protected String getMetalTexture(Identifier blockId) { + + protected String getMetalTexture(ResourceLocation blockId) { String name = blockId.getPath(); name = name.substring(0, name.indexOf('_')); return name + "_bulb_vine_lantern_metal"; } - + protected String getGlowTexture() { return "bulb_vine_lantern_bulb"; } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_BULB_LANTERN; } } diff --git a/src/main/java/ru/betterend/blocks/BulbVineLanternColoredBlock.java b/src/main/java/ru/betterend/blocks/BulbVineLanternColoredBlock.java index a1c7262f..80031b50 100644 --- a/src/main/java/ru/betterend/blocks/BulbVineLanternColoredBlock.java +++ b/src/main/java/ru/betterend/blocks/BulbVineLanternColoredBlock.java @@ -1,8 +1,8 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.client.color.block.BlockColorProvider; -import net.minecraft.client.color.item.ItemColorProvider; +import net.minecraft.client.color.block.BlockColor; +import net.minecraft.client.color.item.ItemColor; import ru.betterend.interfaces.IColorProvider; import ru.betterend.util.BlocksHelper; import ru.betterend.util.MHelper; @@ -13,19 +13,19 @@ public class BulbVineLanternColoredBlock extends BulbVineLanternBlock implements } @Override - public BlockColorProvider getProvider() { + public BlockColor getBlockProvider() { return (state, world, pos, tintIndex) -> { return getColor(); }; } @Override - public ItemColorProvider getItemProvider() { + public ItemColor getItemProvider() { return (stack, tintIndex) -> { return getColor(); }; } - + private int getColor() { int color = BlocksHelper.getBlockColor(this); int b = (color & 255); @@ -34,7 +34,7 @@ public class BulbVineLanternColoredBlock extends BulbVineLanternBlock implements float[] hsv = MHelper.fromRGBtoHSB(r, g, b); return MHelper.fromHSBtoRGB(hsv[0], hsv[1], hsv[1] > 0.2 ? 1 : hsv[2]); } - + @Override protected String getGlowTexture() { return "bulb_vine_lantern_overlay"; diff --git a/src/main/java/ru/betterend/blocks/BulbVineSeedBlock.java b/src/main/java/ru/betterend/blocks/BulbVineSeedBlock.java index 9df8ecc2..adc98069 100644 --- a/src/main/java/ru/betterend/blocks/BulbVineSeedBlock.java +++ b/src/main/java/ru/betterend/blocks/BulbVineSeedBlock.java @@ -2,9 +2,9 @@ package ru.betterend.blocks; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.tag.BlockTags; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.tags.BlockTags; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.WorldView; import ru.betterend.blocks.BlockProperties.TripleShape; @@ -24,11 +24,14 @@ public class BulbVineSeedBlock extends EndPlantWithAgeBlock { public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) { int h = BlocksHelper.downRay(world, pos, random.nextInt(24)) - 1; if (h > 2) { - BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BULB_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP)); + BlocksHelper.setWithoutUpdate(world, pos, + EndBlocks.BULB_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP)); for (int i = 1; i < h; i++) { - BlocksHelper.setWithoutUpdate(world, pos.down(i), EndBlocks.BULB_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE)); + BlocksHelper.setWithoutUpdate(world, pos.down(i), + EndBlocks.BULB_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE)); } - BlocksHelper.setWithoutUpdate(world, pos.down(h), EndBlocks.BULB_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM)); + BlocksHelper.setWithoutUpdate(world, pos.down(h), + EndBlocks.BULB_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM)); } } } diff --git a/src/main/java/ru/betterend/blocks/CavePumpkinBlock.java b/src/main/java/ru/betterend/blocks/CavePumpkinBlock.java index 9cc43f34..ce6fe814 100644 --- a/src/main/java/ru/betterend/blocks/CavePumpkinBlock.java +++ b/src/main/java/ru/betterend/blocks/CavePumpkinBlock.java @@ -4,18 +4,18 @@ import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ShapeContext; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.BlockGetter; import ru.betterend.blocks.basis.BlockBaseNotFull; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; @@ -25,38 +25,39 @@ public class CavePumpkinBlock extends BlockBaseNotFull implements IRenderTypeabl public static final BooleanProperty SMALL = BlockProperties.SMALL; private static final VoxelShape SHAPE_SMALL; private static final VoxelShape SHAPE_BIG; - + public CavePumpkinBlock() { - super(FabricBlockSettings.copyOf(Blocks.PUMPKIN).luminance((state) -> state.get(SMALL) ? 10 : 15)); + super(FabricBlockSettings.copyOf(Blocks.PUMPKIN).luminance((state) -> state.getValue(SMALL) ? 10 : 15)); setDefaultState(getDefaultState().with(SMALL, false)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(SMALL); } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { - return state.get(SMALL) ? SHAPE_SMALL : SHAPE_BIG; + return state.getValue(SMALL) ? SHAPE_SMALL : SHAPE_BIG; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - return state.get(SMALL) ? Collections.singletonList(new ItemStack(EndBlocks.CAVE_PUMPKIN_SEED)) : Collections.singletonList(new ItemStack(this)); + public List getDrops(BlockState state, LootContext.Builder builder) { + return state.getValue(SMALL) ? Collections.singletonList(new ItemStack(EndBlocks.CAVE_PUMPKIN_SEED)) + : Collections.singletonList(new ItemStack(this)); } - + static { VoxelShape lantern = Block.createCuboidShape(1, 0, 1, 15, 13, 15); VoxelShape cap = Block.createCuboidShape(0, 12, 0, 16, 15, 16); VoxelShape top = Block.createCuboidShape(5, 15, 5, 11, 16, 11); SHAPE_BIG = VoxelShapes.union(lantern, cap, top); - + lantern = Block.createCuboidShape(1, 7, 1, 15, 13, 15); cap = Block.createCuboidShape(4, 12, 4, 12, 15, 12); top = Block.createCuboidShape(6, 15, 6, 10, 16, 10); diff --git a/src/main/java/ru/betterend/blocks/CavePumpkinVineBlock.java b/src/main/java/ru/betterend/blocks/CavePumpkinVineBlock.java index 732497db..9402a564 100644 --- a/src/main/java/ru/betterend/blocks/CavePumpkinVineBlock.java +++ b/src/main/java/ru/betterend/blocks/CavePumpkinVineBlock.java @@ -2,67 +2,70 @@ package ru.betterend.blocks; import java.util.Random; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.ShapeContext; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.BlockGetter; import net.minecraft.world.StructureWorldAccess; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.blocks.basis.EndPlantWithAgeBlock; import ru.betterend.registry.EndBlocks; public class CavePumpkinVineBlock extends EndPlantWithAgeBlock { private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 16, 12); - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { BlockState down = world.getBlockState(pos.up()); return isTerrain(down); } - + @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - int age = state.get(AGE); - BlockState down = world.getBlockState(pos.down()); - if (down.getMaterial().isReplaceable() || (down.isOf(EndBlocks.CAVE_PUMPKIN) && down.get(BlockProperties.SMALL))) { + public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) { + int age = state.getValue(AGE); + BlockState down = world.getBlockState(pos.below()); + if (down.getMaterial().isReplaceable() + || (down.is(EndBlocks.CAVE_PUMPKIN) && down.get(BlockProperties.SMALL))) { if (age < 3) { - world.setBlockState(pos, state.with(AGE, age + 1)); + world.setBlockAndUpdate(pos, state.with(AGE, age + 1)); } if (age == 2) { - world.setBlockState(pos.down(), EndBlocks.CAVE_PUMPKIN.getDefaultState().with(BlockProperties.SMALL, true)); - } - else if (age == 3) { - world.setBlockState(pos.down(), EndBlocks.CAVE_PUMPKIN.getDefaultState()); + world.setBlockAndUpdate(pos.below(), + EndBlocks.CAVE_PUMPKIN.defaultBlockState().with(BlockProperties.SMALL, true)); + } else if (age == 3) { + world.setBlockAndUpdate(pos.below(), EndBlocks.CAVE_PUMPKIN.defaultBlockState()); } } } @Override - public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) {} - + public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) { + } + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { - state = super.getStateForNeighborUpdate(state, facing, neighborState, world, pos, neighborPos); - if (state.isOf(this) && state.get(BlockProperties.AGE) > 1) { - BlockState down = world.getBlockState(pos.down()); - if (!down.isOf(EndBlocks.CAVE_PUMPKIN)) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { + state = super.updateShape(state, facing, neighborState, world, pos, neighborPos); + if (state.is(this) && state.getValue(BlockProperties.AGE) > 1) { + BlockState down = world.getBlockState(pos.below()); + if (!down.is(EndBlocks.CAVE_PUMPKIN)) { state = state.with(BlockProperties.AGE, 1); } } return state; } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { return SHAPE; } - + @Override public AbstractBlock.OffsetType getOffsetType() { return AbstractBlock.OffsetType.NONE; diff --git a/src/main/java/ru/betterend/blocks/ChandelierBlock.java b/src/main/java/ru/betterend/blocks/ChandelierBlock.java index aa711298..7f89ecb2 100644 --- a/src/main/java/ru/betterend/blocks/ChandelierBlock.java +++ b/src/main/java/ru/betterend/blocks/ChandelierBlock.java @@ -6,16 +6,16 @@ import java.util.EnumMap; import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.ShapeContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Registry; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.BlockGetter; import ru.betterend.blocks.basis.AttachedBlock; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; @@ -24,49 +24,46 @@ import ru.betterend.patterns.Patterns; public class ChandelierBlock extends AttachedBlock implements IRenderTypeable, BlockPatterned { private static final EnumMap BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); - + public ChandelierBlock(Block source) { super(FabricBlockSettings.copyOf(source).noCollision().nonOpaque().requiresTool().luminance(15)); } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return BOUNDING_SHAPES.get(state.get(FACING)); + return BOUNDING_SHAPES.get(state.getValue(FACING)); } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); return Patterns.createJson(data, blockId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); if (block.contains("item")) { return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath()); - } - else if (block.contains("ceil")) { + } else if (block.contains("ceil")) { return Patterns.createJson(Patterns.BLOCK_CHANDELIER_CEIL, blockId.getPath()); - } - else if (block.contains("wall")) { + } else if (block.contains("wall")) { return Patterns.createJson(Patterns.BLOCK_CHANDELIER_WALL, blockId.getPath()); - } - else { + } else { return Patterns.createJson(Patterns.BLOCK_CHANDELIER_FLOOR, blockId.getPath()); } } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_CHANDELIER; } - + static { BOUNDING_SHAPES.put(Direction.UP, Block.createCuboidShape(5, 0, 5, 11, 13, 11)); BOUNDING_SHAPES.put(Direction.DOWN, Block.createCuboidShape(5, 3, 5, 11, 16, 11)); diff --git a/src/main/java/ru/betterend/blocks/CharcoalBlock.java b/src/main/java/ru/betterend/blocks/CharcoalBlock.java index 8f82f792..f9878f5e 100644 --- a/src/main/java/ru/betterend/blocks/CharcoalBlock.java +++ b/src/main/java/ru/betterend/blocks/CharcoalBlock.java @@ -2,7 +2,7 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.registry.FuelRegistry; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import ru.betterend.blocks.basis.BlockBase; public class CharcoalBlock extends BlockBase { diff --git a/src/main/java/ru/betterend/blocks/CharniaBlock.java b/src/main/java/ru/betterend/blocks/CharniaBlock.java index e1162d4b..d6279ce6 100644 --- a/src/main/java/ru/betterend/blocks/CharniaBlock.java +++ b/src/main/java/ru/betterend/blocks/CharniaBlock.java @@ -1,15 +1,16 @@ package ru.betterend.blocks; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.fluid.Fluids; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.WorldView; import ru.betterend.blocks.basis.UnderwaterPlantBlock; public class CharniaBlock extends UnderwaterPlantBlock { @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - return sideCoversSmallSquare(world, pos.down(), Direction.UP) && world.getFluidState(pos).getFluid() == Fluids.WATER; + return sideCoversSmallSquare(world, pos.below(), Direction.UP) + && world.getFluidState(pos).getFluid() == Fluids.WATER; } } diff --git a/src/main/java/ru/betterend/blocks/ChorusGrassBlock.java b/src/main/java/ru/betterend/blocks/ChorusGrassBlock.java index 2b603a45..66bb0d7d 100644 --- a/src/main/java/ru/betterend/blocks/ChorusGrassBlock.java +++ b/src/main/java/ru/betterend/blocks/ChorusGrassBlock.java @@ -1,6 +1,6 @@ package ru.betterend.blocks; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.registry.EndBlocks; @@ -8,7 +8,7 @@ public class ChorusGrassBlock extends EndPlantBlock { public ChorusGrassBlock() { super(true); } - + @Override protected boolean isTerrain(BlockState state) { return state.getBlock() == EndBlocks.CHORUS_NYLIUM; diff --git a/src/main/java/ru/betterend/blocks/DenseEmeraldIceBlock.java b/src/main/java/ru/betterend/blocks/DenseEmeraldIceBlock.java index 48c1059a..43a13c76 100644 --- a/src/main/java/ru/betterend/blocks/DenseEmeraldIceBlock.java +++ b/src/main/java/ru/betterend/blocks/DenseEmeraldIceBlock.java @@ -1,7 +1,7 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; diff --git a/src/main/java/ru/betterend/blocks/DenseSnowBlock.java b/src/main/java/ru/betterend/blocks/DenseSnowBlock.java index d0c9ecf6..f369dd2a 100644 --- a/src/main/java/ru/betterend/blocks/DenseSnowBlock.java +++ b/src/main/java/ru/betterend/blocks/DenseSnowBlock.java @@ -1,12 +1,12 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Material; -import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.SoundType; import ru.betterend.blocks.basis.BlockBase; public class DenseSnowBlock extends BlockBase { public DenseSnowBlock() { - super(FabricBlockSettings.of(Material.SNOW_BLOCK).strength(0.2F).sounds(BlockSoundGroup.SNOW)); + super(FabricBlockSettings.of(Material.SNOW_BLOCK).strength(0.2F).sounds(SoundType.SNOW)); } } diff --git a/src/main/java/ru/betterend/blocks/DragonTreeSaplingBlock.java b/src/main/java/ru/betterend/blocks/DragonTreeSaplingBlock.java index 5fdd924e..258f1733 100644 --- a/src/main/java/ru/betterend/blocks/DragonTreeSaplingBlock.java +++ b/src/main/java/ru/betterend/blocks/DragonTreeSaplingBlock.java @@ -1,7 +1,7 @@ package ru.betterend.blocks; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; import net.minecraft.world.WorldView; import net.minecraft.world.gen.feature.Feature; import ru.betterend.blocks.basis.FeatureSaplingBlock; @@ -17,9 +17,9 @@ public class DragonTreeSaplingBlock extends FeatureSaplingBlock { protected Feature getFeature() { return EndFeatures.DRAGON_TREE.getFeature(); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - return world.getBlockState(pos.down()).isOf(EndBlocks.SHADOW_GRASS); + return world.getBlockState(pos.below()).is(EndBlocks.SHADOW_GRASS); } } diff --git a/src/main/java/ru/betterend/blocks/EmeraldIceBlock.java b/src/main/java/ru/betterend/blocks/EmeraldIceBlock.java index ee96f6a1..f428f331 100644 --- a/src/main/java/ru/betterend/blocks/EmeraldIceBlock.java +++ b/src/main/java/ru/betterend/blocks/EmeraldIceBlock.java @@ -8,22 +8,22 @@ import java.util.Random; import org.jetbrains.annotations.Nullable; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; -import net.minecraft.block.TransparentBlock; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.TransparentBlock; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Registry; import net.minecraft.world.LightType; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.patterns.BlockPatterned; @@ -40,59 +40,59 @@ public class EmeraldIceBlock extends TransparentBlock implements IRenderTypeable } @Override - public void afterBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack stack) { + public void afterBreak(Level world, PlayerEntity player, BlockPos pos, BlockState state, + @Nullable BlockEntity blockEntity, ItemStack stack) { super.afterBreak(world, player, pos, state, blockEntity, stack); - if (EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, stack) == 0) { + if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) == 0) { if (world.getDimension().isUltrawarm()) { world.removeBlock(pos, false); return; } - Material material = world.getBlockState(pos.down()).getMaterial(); + Material material = world.getBlockState(pos.below()).getMaterial(); if (material.blocksMovement() || material.isLiquid()) { - world.setBlockState(pos, Blocks.WATER.getDefaultState()); + world.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState()); } } } @Override - public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { if (world.getLightLevel(LightType.BLOCK, pos) > 11 - state.getOpacity(world, pos)) { this.melt(state, world, pos); } } - protected void melt(BlockState state, World world, BlockPos pos) { + protected void melt(BlockState state, Level world, BlockPos pos) { if (world.getDimension().isUltrawarm()) { world.removeBlock(pos, false); - } - else { - world.setBlockState(pos, Blocks.WATER.getDefaultState()); + } else { + world.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState()); world.updateNeighbor(pos, Blocks.WATER, pos); } } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - String block = Registry.BLOCK.getId(this).getPath(); + String block = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, block, block); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_SIMPLE; } } diff --git a/src/main/java/ru/betterend/blocks/EndLilyBlock.java b/src/main/java/ru/betterend/blocks/EndLilyBlock.java index 6d43dd97..3d4a8ae7 100644 --- a/src/main/java/ru/betterend/blocks/EndLilyBlock.java +++ b/src/main/java/ru/betterend/blocks/EndLilyBlock.java @@ -10,25 +10,25 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.EnumProperty; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.blocks.basis.UnderwaterPlantBlock; @@ -40,79 +40,78 @@ public class EndLilyBlock extends UnderwaterPlantBlock { public static final EnumProperty SHAPE = BlockProperties.TRIPLE_SHAPE; private static final VoxelShape SHAPE_BOTTOM = Block.createCuboidShape(4, 0, 4, 12, 16, 12); private static final VoxelShape SHAPE_TOP = Block.createCuboidShape(2, 0, 2, 14, 6, 14); - + public EndLilyBlock() { - super(FabricBlockSettings.of(Material.UNDERWATER_PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.WET_GRASS) - .breakByHand(true) - .luminance((state) -> { return state.get(SHAPE) == TripleShape.TOP ? 13 : 0; }) - .noCollision()); + super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS) + .sounds(SoundType.WET_GRASS).breakByHand(true).luminance((state) -> { + return state.getValue(SHAPE) == TripleShape.TOP ? 13 : 0; + }).noCollision()); } - + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (!canPlaceAt(state, world, pos)) { - return state.get(SHAPE) == TripleShape.TOP ? Blocks.AIR.getDefaultState() : Blocks.WATER.getDefaultState(); - } - else { + return state.getValue(SHAPE) == TripleShape.TOP ? Blocks.AIR.defaultBlockState() + : Blocks.WATER.defaultBlockState(); + } else { return state; } } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { Vec3d vec3d = state.getModelOffset(view, pos); - VoxelShape shape = state.get(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM; + VoxelShape shape = state.getValue(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM; return shape.offset(vec3d.x, vec3d.y, vec3d.z); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(SHAPE); } - + @Override public FluidState getFluidState(BlockState state) { - return state.get(SHAPE) == TripleShape.TOP ? Fluids.EMPTY.getDefaultState() : Fluids.WATER.getStill(false); + return state.getValue(SHAPE) == TripleShape.TOP ? Fluids.EMPTY.defaultBlockState() + : Fluids.WATER.getStill(false); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - if (state.get(SHAPE) == TripleShape.TOP) { - return world.getBlockState(pos.down()).getBlock() == this; - } - else if (state.get(SHAPE) == TripleShape.BOTTOM) { - return isTerrain(world.getBlockState(pos.down())); - } - else { + if (state.getValue(SHAPE) == TripleShape.TOP) { + return world.getBlockState(pos.below()).getBlock() == this; + } else if (state.getValue(SHAPE) == TripleShape.BOTTOM) { + return isTerrain(world.getBlockState(pos.below())); + } else { BlockState up = world.getBlockState(pos.up()); - BlockState down = world.getBlockState(pos.down()); + BlockState down = world.getBlockState(pos.below()); return up.getBlock() == this && down.getBlock() == this; } } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - if (state.get(SHAPE) == TripleShape.TOP) { - return Lists.newArrayList(new ItemStack(EndItems.END_LILY_LEAF, MHelper.randRange(1, 2, MHelper.RANDOM)), new ItemStack(EndBlocks.END_LILY_SEED, MHelper.randRange(1, 2, MHelper.RANDOM))); + public List getDrops(BlockState state, LootContext.Builder builder) { + if (state.getValue(SHAPE) == TripleShape.TOP) { + return Lists.newArrayList(new ItemStack(EndItems.END_LILY_LEAF, MHelper.randRange(1, 2, MHelper.RANDOM)), + new ItemStack(EndBlocks.END_LILY_SEED, MHelper.randRange(1, 2, MHelper.RANDOM))); } return Collections.emptyList(); } - + @Override @Environment(EnvType.CLIENT) public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { return new ItemStack(EndBlocks.END_LILY_SEED); } - + @Override public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { return false; } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { return false; } } diff --git a/src/main/java/ru/betterend/blocks/EndLilySeedBlock.java b/src/main/java/ru/betterend/blocks/EndLilySeedBlock.java index 05226df8..86173da4 100644 --- a/src/main/java/ru/betterend/blocks/EndLilySeedBlock.java +++ b/src/main/java/ru/betterend/blocks/EndLilySeedBlock.java @@ -3,7 +3,7 @@ package ru.betterend.blocks; import java.util.Random; import net.minecraft.fluid.Fluids; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.blocks.basis.UnderwaterPlantWithAgeBlock; @@ -14,16 +14,19 @@ public class EndLilySeedBlock extends UnderwaterPlantWithAgeBlock { @Override public void grow(StructureWorldAccess world, Random random, BlockPos pos) { if (canGrow(world, pos)) { - BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.END_LILY.getDefaultState().with(EndLilyBlock.SHAPE, TripleShape.BOTTOM)); + BlocksHelper.setWithoutUpdate(world, pos, + EndBlocks.END_LILY.defaultBlockState().with(EndLilyBlock.SHAPE, TripleShape.BOTTOM)); BlockPos up = pos.up(); while (world.getFluidState(up).isStill()) { - BlocksHelper.setWithoutUpdate(world, up, EndBlocks.END_LILY.getDefaultState().with(EndLilyBlock.SHAPE, TripleShape.MIDDLE)); + BlocksHelper.setWithoutUpdate(world, up, + EndBlocks.END_LILY.defaultBlockState().with(EndLilyBlock.SHAPE, TripleShape.MIDDLE)); up = up.up(); } - BlocksHelper.setWithoutUpdate(world, up, EndBlocks.END_LILY.getDefaultState().with(EndLilyBlock.SHAPE, TripleShape.TOP)); + BlocksHelper.setWithoutUpdate(world, up, + EndBlocks.END_LILY.defaultBlockState().with(EndLilyBlock.SHAPE, TripleShape.TOP)); } } - + private boolean canGrow(StructureWorldAccess world, BlockPos pos) { BlockPos up = pos.up(); while (world.getBlockState(up).getFluidState().getFluid().equals(Fluids.WATER.getStill())) { diff --git a/src/main/java/ru/betterend/blocks/EndLotusFlowerBlock.java b/src/main/java/ru/betterend/blocks/EndLotusFlowerBlock.java index 8222111e..71f36555 100644 --- a/src/main/java/ru/betterend/blocks/EndLotusFlowerBlock.java +++ b/src/main/java/ru/betterend/blocks/EndLotusFlowerBlock.java @@ -7,16 +7,16 @@ import com.google.common.collect.Lists; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.core.BlockPos; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.BlockGetter; import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.registry.EndBlocks; import ru.betterend.util.MHelper; @@ -24,37 +24,37 @@ import ru.betterend.util.MHelper; public class EndLotusFlowerBlock extends EndPlantBlock { private static final VoxelShape SHAPE_OUTLINE = Block.createCuboidShape(2, 0, 2, 14, 14, 14); private static final VoxelShape SHAPE_COLLISION = Block.createCuboidShape(0, 0, 0, 16, 2, 16); - + public EndLotusFlowerBlock() { super(FabricBlockSettings.of(Material.PLANT).nonOpaque().luminance(15)); } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.END_LOTUS_STEM); + return state.is(EndBlocks.END_LOTUS_STEM); } - + @Override public AbstractBlock.OffsetType getOffsetType() { return AbstractBlock.OffsetType.NONE; } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { return SHAPE_OUTLINE; } - + @Override public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { return SHAPE_COLLISION; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { int count = MHelper.randRange(1, 2, MHelper.RANDOM); return Lists.newArrayList(new ItemStack(EndBlocks.END_LOTUS_SEED, count)); } - + @Override @Environment(EnvType.CLIENT) public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { diff --git a/src/main/java/ru/betterend/blocks/EndLotusLeafBlock.java b/src/main/java/ru/betterend/blocks/EndLotusLeafBlock.java index cb15f1e5..4cf66025 100644 --- a/src/main/java/ru/betterend/blocks/EndLotusLeafBlock.java +++ b/src/main/java/ru/betterend/blocks/EndLotusLeafBlock.java @@ -3,22 +3,22 @@ package ru.betterend.blocks; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; import net.minecraft.fluid.WaterFluid; -import net.minecraft.item.ItemStack; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.EnumProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.BlockGetter; import net.minecraft.world.WorldView; import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.blocks.basis.BlockBaseNotFull; @@ -31,29 +31,29 @@ public class EndLotusLeafBlock extends BlockBaseNotFull implements IRenderTypeab public static final EnumProperty HORIZONTAL_FACING = Properties.HORIZONTAL_FACING; public static final EnumProperty SHAPE = BlockProperties.TRIPLE_SHAPE; private static final VoxelShape VSHAPE = Block.createCuboidShape(0, 0, 0, 16, 1, 16); - + public EndLotusLeafBlock() { - super(FabricBlockSettings.of(Material.PLANT).nonOpaque().sounds(BlockSoundGroup.WET_GRASS)); + super(FabricBlockSettings.of(Material.PLANT).nonOpaque().sounds(SoundType.WET_GRASS)); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - BlockState down = world.getBlockState(pos.down()); + BlockState down = world.getBlockState(pos.below()); return !down.getFluidState().isEmpty() && down.getFluidState().getFluid() instanceof WaterFluid; } - + @Override - protected void appendProperties(StateManager.Builder builder) { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(SHAPE, HORIZONTAL_FACING); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { return VSHAPE; } - + @Override - public BlockState rotate(BlockState state, BlockRotation rotation) { + public BlockState rotate(BlockState state, Rotation rotation) { return BlocksHelper.rotateHorizontal(state, rotation, HORIZONTAL_FACING); } @@ -61,12 +61,12 @@ public class EndLotusLeafBlock extends BlockBaseNotFull implements IRenderTypeab public BlockState mirror(BlockState state, BlockMirror mirror) { return BlocksHelper.mirrorHorizontal(state, mirror, HORIZONTAL_FACING); } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override @Environment(EnvType.CLIENT) public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { diff --git a/src/main/java/ru/betterend/blocks/EndLotusSeedBlock.java b/src/main/java/ru/betterend/blocks/EndLotusSeedBlock.java index ce8fc56a..ebcfd741 100644 --- a/src/main/java/ru/betterend/blocks/EndLotusSeedBlock.java +++ b/src/main/java/ru/betterend/blocks/EndLotusSeedBlock.java @@ -2,11 +2,11 @@ package ru.betterend.blocks; import java.util.Random; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.fluid.Fluids; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.blocks.basis.UnderwaterPlantWithAgeBlock; @@ -17,31 +17,32 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock { @Override public void grow(StructureWorldAccess world, Random random, BlockPos pos) { if (canGrow(world, pos)) { - BlockState startLeaf = EndBlocks.END_LOTUS_STEM.getDefaultState().with(EndLotusStemBlock.LEAF, true); - BlockState roots = EndBlocks.END_LOTUS_STEM.getDefaultState().with(EndLotusStemBlock.SHAPE, TripleShape.BOTTOM).with(EndLotusStemBlock.WATERLOGGED, true); - BlockState stem = EndBlocks.END_LOTUS_STEM.getDefaultState(); - BlockState flower = EndBlocks.END_LOTUS_FLOWER.getDefaultState(); - + BlockState startLeaf = EndBlocks.END_LOTUS_STEM.defaultBlockState().with(EndLotusStemBlock.LEAF, true); + BlockState roots = EndBlocks.END_LOTUS_STEM.defaultBlockState() + .with(EndLotusStemBlock.SHAPE, TripleShape.BOTTOM).with(EndLotusStemBlock.WATERLOGGED, true); + BlockState stem = EndBlocks.END_LOTUS_STEM.defaultBlockState(); + BlockState flower = EndBlocks.END_LOTUS_FLOWER.defaultBlockState(); + BlocksHelper.setWithoutUpdate(world, pos, roots); - Mutable bpos = new Mutable().set(pos); + MutableBlockPos bpos = new MutableBlockPos().set(pos); bpos.setY(bpos.getY() + 1); while (world.getFluidState(bpos).isStill()) { BlocksHelper.setWithoutUpdate(world, bpos, stem.with(EndLotusStemBlock.WATERLOGGED, true)); bpos.setY(bpos.getY() + 1); } - + int height = random.nextBoolean() ? 0 : random.nextBoolean() ? 1 : random.nextBoolean() ? 1 : -1; TripleShape shape = (height == 0) ? TripleShape.TOP : TripleShape.MIDDLE; Direction dir = BlocksHelper.randomHorizontal(random); BlockPos leafCenter = bpos.toImmutable().offset(dir); if (hasLeaf(world, leafCenter)) { generateLeaf(world, leafCenter); - BlocksHelper.setWithoutUpdate(world, bpos, startLeaf.with(EndLotusStemBlock.SHAPE, shape).with(EndLotusStemBlock.FACING, dir)); - } - else { + BlocksHelper.setWithoutUpdate(world, bpos, + startLeaf.with(EndLotusStemBlock.SHAPE, shape).with(EndLotusStemBlock.FACING, dir)); + } else { BlocksHelper.setWithoutUpdate(world, bpos, stem.with(EndLotusStemBlock.SHAPE, shape)); } - + bpos.setY(bpos.getY() + 1); for (int i = 1; i <= height; i++) { if (!world.isAir(bpos)) { @@ -55,62 +56,64 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock { BlocksHelper.setWithoutUpdate(world, bpos, stem); bpos.setY(bpos.getY() + 1); } - + if (!world.isAir(bpos) || height < 0) { bpos.setY(bpos.getY() - 1); } - + BlocksHelper.setWithoutUpdate(world, bpos, flower); bpos.setY(bpos.getY() - 1); stem = world.getBlockState(bpos); - if (!stem.isOf(EndBlocks.END_LOTUS_STEM)) { - stem = EndBlocks.END_LOTUS_STEM.getDefaultState(); + if (!stem.is(EndBlocks.END_LOTUS_STEM)) { + stem = EndBlocks.END_LOTUS_STEM.defaultBlockState(); if (!world.getBlockState(bpos.north()).getFluidState().isEmpty()) { stem = stem.with(EndLotusStemBlock.WATERLOGGED, true); } } - - if (world.getBlockState(bpos.offset(dir)).isOf(EndBlocks.END_LOTUS_LEAF)) { + + if (world.getBlockState(bpos.offset(dir)).is(EndBlocks.END_LOTUS_LEAF)) { stem = stem.with(EndLotusStemBlock.LEAF, true).with(EndLotusStemBlock.FACING, dir); } - + BlocksHelper.setWithoutUpdate(world, bpos, stem.with(EndLotusStemBlock.SHAPE, TripleShape.TOP)); } } - + private boolean canGrow(StructureWorldAccess world, BlockPos pos) { - Mutable bpos = new Mutable(); + MutableBlockPos bpos = new MutableBlockPos(); bpos.set(pos); while (world.getBlockState(bpos).getFluidState().getFluid().equals(Fluids.WATER.getStill())) { bpos.setY(bpos.getY() + 1); } return world.isAir(bpos) && world.isAir(bpos.up()); } - + private void generateLeaf(StructureWorldAccess world, BlockPos pos) { - Mutable p = new Mutable(); - BlockState leaf = EndBlocks.END_LOTUS_LEAF.getDefaultState(); + MutableBlockPos p = new MutableBlockPos(); + BlockState leaf = EndBlocks.END_LOTUS_LEAF.defaultBlockState(); BlocksHelper.setWithoutUpdate(world, pos, leaf.with(EndLotusLeafBlock.SHAPE, TripleShape.BOTTOM)); - for (Direction move: BlocksHelper.HORIZONTAL) { - BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf.with(EndLotusLeafBlock.HORIZONTAL_FACING, move).with(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE)); + for (Direction move : BlocksHelper.HORIZONTAL) { + BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf + .with(EndLotusLeafBlock.HORIZONTAL_FACING, move).with(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE)); } - for (int i = 0; i < 4; i ++) { + for (int i = 0; i < 4; i++) { Direction d1 = BlocksHelper.HORIZONTAL[i]; Direction d2 = BlocksHelper.HORIZONTAL[(i + 1) & 3]; - BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2), leaf.with(EndLotusLeafBlock.HORIZONTAL_FACING, d1).with(EndLotusLeafBlock.SHAPE, TripleShape.TOP)); + BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2), + leaf.with(EndLotusLeafBlock.HORIZONTAL_FACING, d1).with(EndLotusLeafBlock.SHAPE, TripleShape.TOP)); } } - + private boolean hasLeaf(StructureWorldAccess world, BlockPos pos) { - Mutable p = new Mutable(); + MutableBlockPos p = new MutableBlockPos(); p.setY(pos.getY()); int count = 0; - for (int x = -1; x < 2; x ++) { + for (int x = -1; x < 2; x++) { p.setX(pos.getX() + x); - for (int z = -1; z < 2; z ++) { + for (int z = -1; z < 2; z++) { p.setZ(pos.getZ() + z); - if (world.isAir(p) && !world.getFluidState(p.down()).isEmpty()) - count ++; + if (world.isAir(p) && !world.getFluidState(p.below()).isEmpty()) + count++; } } return count == 9; diff --git a/src/main/java/ru/betterend/blocks/EndLotusStemBlock.java b/src/main/java/ru/betterend/blocks/EndLotusStemBlock.java index 33a8d215..89506156 100644 --- a/src/main/java/ru/betterend/blocks/EndLotusStemBlock.java +++ b/src/main/java/ru/betterend/blocks/EndLotusStemBlock.java @@ -5,26 +5,26 @@ import java.util.Map; import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ShapeContext; -import net.minecraft.block.Waterloggable; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.level.block.Waterloggable; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.state.StateManager; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.EnumProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Direction.Axis; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.client.render.ERenderLayer; @@ -37,36 +37,39 @@ public class EndLotusStemBlock extends BlockBase implements Waterloggable, IRend public static final BooleanProperty LEAF = BooleanProperty.of("leaf"); public static final EnumProperty SHAPE = BlockProperties.TRIPLE_SHAPE; private static final Map SHAPES = Maps.newEnumMap(Axis.class); - + public EndLotusStemBlock() { super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS)); - this.setDefaultState(getDefaultState().with(WATERLOGGED, false).with(SHAPE, TripleShape.MIDDLE).with(LEAF, false).with(FACING, Direction.UP)); + this.setDefaultState(getDefaultState().with(WATERLOGGED, false).with(SHAPE, TripleShape.MIDDLE) + .with(LEAF, false).with(FACING, Direction.UP)); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return state.get(LEAF) ? SHAPES.get(Axis.Y) : SHAPES.get(state.get(FACING).getAxis()); + return state.getValue(LEAF) ? SHAPES.get(Axis.Y) : SHAPES.get(state.getValue(FACING).getAxis()); } - + @Override - protected void appendProperties(StateManager.Builder builder) { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(FACING, WATERLOGGED, SHAPE, LEAF); } - + @Override public FluidState getFluidState(BlockState state) { - return (Boolean) state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); + return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); } @Override public BlockState getPlacementState(ItemPlacementContext ctx) { - WorldAccess worldAccess = ctx.getWorld(); + LevelAccessor worldAccess = ctx.getLevel(); BlockPos blockPos = ctx.getBlockPos(); - return this.getDefaultState().with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER).with(FACING, ctx.getSide()); + return this.defaultBlockState() + .with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER) + .with(FACING, ctx.getSide()); } - + @Override - public BlockState rotate(BlockState state, BlockRotation rotation) { + public BlockState rotate(BlockState state, Rotation rotation) { return BlocksHelper.rotateHorizontal(state, rotation, FACING); } @@ -76,18 +79,19 @@ public class EndLotusStemBlock extends BlockBase implements Waterloggable, IRend } @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) { - if ((Boolean) state.get(WATERLOGGED)) { + public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, + BlockPos pos, BlockPos posFrom) { + if ((Boolean) state.getValue(WATERLOGGED)) { world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } return state; } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + static { SHAPES.put(Axis.X, Block.createCuboidShape(0, 6, 6, 16, 10, 10)); SHAPES.put(Axis.Y, Block.createCuboidShape(6, 0, 6, 10, 16, 10)); diff --git a/src/main/java/ru/betterend/blocks/EndPathBlock.java b/src/main/java/ru/betterend/blocks/EndPathBlock.java index 5d4534d9..5381aa6c 100644 --- a/src/main/java/ru/betterend/blocks/EndPathBlock.java +++ b/src/main/java/ru/betterend/blocks/EndPathBlock.java @@ -7,64 +7,66 @@ import java.util.Map; import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ShapeContext; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Registry; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.BlockGetter; import ru.betterend.blocks.basis.BlockBaseNotFull; import ru.betterend.patterns.Patterns; public class EndPathBlock extends BlockBaseNotFull { private static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 15, 16); - + public EndPathBlock(Block source) { - super(FabricBlockSettings.copyOf(source).allowsSpawning((state, world, pos, type) -> { return false; })); + super(FabricBlockSettings.copyOf(source).allowsSpawning((state, world, pos, type) -> { + return false; + })); if (source instanceof EndTerrainBlock) { EndTerrainBlock terrain = (EndTerrainBlock) source; terrain.setPathBlock(this); } } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Collections.singletonList(new ItemStack(this)); } return Collections.singletonList(new ItemStack(Blocks.END_STONE)); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { return SHAPE; } - + @Override public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { return SHAPE; } - + @Override public String getModelPattern(String block) { - String name = Registry.BLOCK.getId(this).getPath(); + String name = Registry.BLOCK.getKey(this).getPath(); Map map = Maps.newHashMap(); map.put("%top%", name + "_top"); map.put("%side%", name.replace("_path", "") + "_side"); return Patterns.createJson(Patterns.BLOCK_PATH, map); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_ROTATED_TOP; } } diff --git a/src/main/java/ru/betterend/blocks/EndPedestal.java b/src/main/java/ru/betterend/blocks/EndPedestal.java index e46e154f..8a157ba4 100644 --- a/src/main/java/ru/betterend/blocks/EndPedestal.java +++ b/src/main/java/ru/betterend/blocks/EndPedestal.java @@ -3,9 +3,9 @@ package ru.betterend.blocks; import java.util.HashMap; import java.util.Map; -import net.minecraft.block.Block; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; import ru.betterend.blocks.basis.PedestalBlock; import ru.betterend.patterns.Patterns; @@ -15,15 +15,15 @@ public class EndPedestal extends PedestalBlock { public EndPedestal(Block parent) { super(parent); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(parent); String name = blockId.getPath(); Map textures = new HashMap() { private static final long serialVersionUID = 1L; { - put("%mod%", BetterEnd.MOD_ID ); + put("%mod%", BetterEnd.MOD_ID); put("%top%", name + "_polished"); put("%base%", name + "_polished"); put("%pillar%", name + "_pillar_side"); diff --git a/src/main/java/ru/betterend/blocks/EndPortalBlock.java b/src/main/java/ru/betterend/blocks/EndPortalBlock.java index 8c39d171..dfed2978 100644 --- a/src/main/java/ru/betterend/blocks/EndPortalBlock.java +++ b/src/main/java/ru/betterend/blocks/EndPortalBlock.java @@ -6,30 +6,30 @@ import java.util.Random; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.NetherPortalBlock; -import net.minecraft.client.color.block.BlockColorProvider; -import net.minecraft.client.color.item.ItemColorProvider; -import net.minecraft.entity.Entity; +import net.minecraft.core.Direction; +import net.minecraft.core.Registry; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.NetherPortalBlock; +import net.minecraft.client.color.block.BlockColor; +import net.minecraft.client.color.item.ItemColor; +import net.minecraft.world.entity.Entity; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Direction.Axis; -import net.minecraft.util.math.Direction.AxisDirection; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; -import net.minecraft.world.dimension.DimensionType; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.level.dimension.DimensionType; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IColorProvider; import ru.betterend.interfaces.IRenderTypeable; @@ -39,30 +39,32 @@ import ru.betterend.registry.EndPortals; import ru.betterend.rituals.EternalRitual; public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable, IColorProvider { - public static final IntProperty PORTAL = BlockProperties.PORTAL; + public static final IntegerProperty PORTAL = BlockProperties.PORTAL; public EndPortalBlock() { - super(FabricBlockSettings.copyOf(Blocks.NETHER_PORTAL).resistance(Blocks.BEDROCK.getBlastResistance()).luminance(15)); + super(FabricBlockSettings.copyOf(Blocks.NETHER_PORTAL).resistance(Blocks.BEDROCK.getExplosionResistance()) + .luminance(15)); } @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + super.createBlockStateDefinition(builder); builder.add(PORTAL); } - + @Override @Environment(EnvType.CLIENT) - public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { + public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { if (random.nextInt(100) == 0) { - world.playSound(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, SoundEvents.BLOCK_PORTAL_AMBIENT, SoundCategory.BLOCKS, 0.5F, random.nextFloat() * 0.4F + 0.8F, false); + world.playLocalSound(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, SoundEvents.PORTAL_AMBIENT, + SoundSource.BLOCKS, 0.5F, random.nextFloat() * 0.4F + 0.8F, false); } double x = pos.getX() + random.nextDouble(); double y = pos.getY() + random.nextDouble(); double z = pos.getZ() + random.nextDouble(); int k = random.nextInt(2) * 2 - 1; - if (!world.getBlockState(pos.west()).isOf(this) && !world.getBlockState(pos.east()).isOf(this)) { + if (!world.getBlockState(pos.west()).is(this) && !world.getBlockState(pos.east()).is(this)) { x = pos.getX() + 0.5D + 0.25D * k; } else { z = pos.getZ() + 0.5D + 0.25D * k; @@ -72,121 +74,127 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable } @Override - public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {} - - @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) { + public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, + BlockPos pos, BlockPos posFrom) { return state; } - + @Override - public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { - if (world.isClient || !validate(entity)) return; - entity.resetNetherPortalCooldown(); - ServerWorld currentWorld = (ServerWorld) world; + public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { + if (world.isClientSide() || !validate(entity)) + return; + entity.setPortalCooldown(); + ServerLevel currentWorld = (ServerLevel) world; MinecraftServer server = currentWorld.getServer(); - ServerWorld targetWorld = EndPortals.getWorld(server, state.get(PORTAL)); - boolean isInEnd = currentWorld.getRegistryKey().equals(World.END); - ServerWorld destination = isInEnd ? targetWorld : server.getWorld(World.END); + ServerLevel targetWorld = EndPortals.getLevel(server, state.getValue(PORTAL)); + boolean isInEnd = currentWorld.dimension().equals(Level.END); + ServerLevel destination = isInEnd ? targetWorld : server.getLevel(Level.END); BlockPos exitPos = findExitPos(currentWorld, destination, pos, entity); - if (exitPos == null) return; - if (entity instanceof ServerPlayerEntity) { - ServerPlayerEntity player = (ServerPlayerEntity) entity; + if (exitPos == null) + return; + if (entity instanceof ServerPlayer) { + ServerPlayer player = (ServerPlayer) entity; teleportPlayer(player, destination, exitPos); } else { TeleportingEntity teleEntity = (TeleportingEntity) entity; teleEntity.beSetExitPos(exitPos); - Entity teleported = entity.moveToWorld(destination); + Entity teleported = entity.changeDimension(destination); if (teleported != null) { - teleported.resetNetherPortalCooldown(); + teleported.setPortalCooldown(); } } } private boolean validate(Entity entity) { - return !entity.hasVehicle() && !entity.hasPassengers() && - entity.canUsePortals() && !entity.hasNetherPortalCooldown(); + return !entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions() + && !entity.isOnPortalCooldown(); } - private void teleportPlayer(ServerPlayerEntity player, ServerWorld destination, BlockPos exitPos) { + private void teleportPlayer(ServerPlayer player, ServerLevel destination, BlockPos exitPos) { if (player.isCreative()) { - player.teleport(destination, exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5, player.yaw, player.pitch); + player.teleportTo(destination, exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5, player.yRot, + player.xRot); } else { TeleportingEntity teleEntity = (TeleportingEntity) player; teleEntity.beSetExitPos(exitPos); - player.moveToWorld(destination); + player.changeDimension(destination); } } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.TRANSLUCENT; } - - private BlockPos findExitPos(ServerWorld currentWorld, ServerWorld targetWorld, BlockPos currentPos, Entity entity) { - if (targetWorld == null) return null; - Registry registry = targetWorld.getRegistryManager().getDimensionTypes(); - Identifier targetWorldId = targetWorld.getRegistryKey().getValue(); - Identifier currentWorldId = currentWorld.getRegistryKey().getValue(); - double targetMultiplier = Objects.requireNonNull(registry.get(targetWorldId)).getCoordinateScale(); - double currentMultiplier = Objects.requireNonNull(registry.get(currentWorldId)).getCoordinateScale(); + + private BlockPos findExitPos(ServerLevel currentWorld, ServerLevel targetWorld, BlockPos currentPos, + Entity entity) { + if (targetWorld == null) + return null; + Registry registry = targetWorld.registryAccess().dimensionTypes(); + ResourceLocation targetWorldId = targetWorld.dimension().location(); + ResourceLocation currentWorldId = currentWorld.dimension().location(); + double targetMultiplier = Objects.requireNonNull(registry.get(targetWorldId)).coordinateScale(); + double currentMultiplier = Objects.requireNonNull(registry.get(currentWorldId)).coordinateScale(); double multiplier = targetMultiplier > currentMultiplier ? 1.0 / targetMultiplier : currentMultiplier; - BlockPos.Mutable basePos = currentPos.mutableCopy().set(currentPos.getX() * multiplier, currentPos.getY(), currentPos.getZ() * multiplier); - BlockPos.Mutable checkPos = basePos.mutableCopy(); + BlockPos.MutableBlockPos basePos = currentPos.mutable().set(currentPos.getX() * multiplier, currentPos.getY(), + currentPos.getZ() * multiplier); + BlockPos.MutableBlockPos checkPos = basePos.mutable(); BlockState currentState = currentWorld.getBlockState(currentPos); int radius = (EternalRitual.SEARCH_RADIUS >> 4) + 1; - checkPos = EternalRitual.findBlockPos(targetWorld, checkPos, radius, this, state -> state.isOf(this) && - state.get(PORTAL).equals(currentState.get(PORTAL))); + checkPos = EternalRitual.findBlockPos(targetWorld, checkPos, radius, this, + state -> state.is(this) && state.getValue(PORTAL).equals(currentState.getValue(PORTAL))); if (checkPos != null) { BlockState checkState = targetWorld.getBlockState(checkPos); - Axis axis = checkState.get(AXIS); + Axis axis = checkState.getValue(AXIS); checkPos = findCenter(targetWorld, checkPos, axis); - Direction frontDir = Direction.from(axis, AxisDirection.POSITIVE).rotateYClockwise(); - Direction entityDir = entity.getMovementDirection(); + Direction frontDir = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE).getClockWise(); + Direction entityDir = entity.getMotionDirection(); if (entityDir.getAxis().isVertical()) { entityDir = frontDir; } if (frontDir != entityDir && frontDir.getOpposite() != entityDir) { - entity.applyRotation(BlockRotation.CLOCKWISE_90); - entityDir = entityDir.rotateYClockwise(); + entity.rotate(Rotation.CLOCKWISE_90); + entityDir = entityDir.getClockWise(); } - return checkPos.offset(entityDir); + return checkPos.move(entityDir); } return null; } - - private BlockPos.Mutable findCenter(World world, BlockPos.Mutable pos, Direction.Axis axis) { + + private BlockPos.MutableBlockPos findCenter(Level world, BlockPos.MutableBlockPos pos, Direction.Axis axis) { return findCenter(world, pos, axis, 1); } - - private BlockPos.Mutable findCenter(World world, BlockPos.Mutable pos, Direction.Axis axis, int step) { - if (step > 8) return pos; + + private BlockPos.MutableBlockPos findCenter(Level world, BlockPos.MutableBlockPos pos, Direction.Axis axis, + int step) { + if (step > 8) + return pos; BlockState right, left; Direction rightDir, leftDir; - rightDir = Direction.from(axis, AxisDirection.POSITIVE); + rightDir = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE); leftDir = rightDir.getOpposite(); - right = world.getBlockState(pos.offset(rightDir)); - left = world.getBlockState(pos.offset(leftDir)); - BlockState down = world.getBlockState(pos.down()); - if (down.isOf(this)) { + right = world.getBlockState(pos.relative(rightDir)); + left = world.getBlockState(pos.relative(leftDir)); + BlockState down = world.getBlockState(pos.below()); + if (down.is(this)) { return findCenter(world, pos.move(Direction.DOWN), axis, step); - } else if (right.isOf(this) && left.isOf(this)) { + } else if (right.is(this) && left.is(this)) { return pos; - } else if (right.isOf(this)) { + } else if (right.is(this)) { return findCenter(world, pos.move(rightDir), axis, ++step); - } else if (left.isOf(this)) { + } else if (left.is(this)) { return findCenter(world, pos.move(leftDir), axis, ++step); } return pos; } @Override - public BlockColorProvider getProvider() { - return (state, world, pos, tintIndex) -> EndPortals.getColor(state.get(PORTAL)); + public BlockColor getBlockProvider() { + return (state, world, pos, tintIndex) -> EndPortals.getColor(state.getValue(PORTAL)); } @Override - public ItemColorProvider getItemProvider() { + public ItemColor getItemProvider() { return (stack, tintIndex) -> EndPortals.getColor(0); } } diff --git a/src/main/java/ru/betterend/blocks/EndStoneBlock.java b/src/main/java/ru/betterend/blocks/EndStoneBlock.java index 4bfa9cb4..ddc17d9f 100644 --- a/src/main/java/ru/betterend/blocks/EndStoneBlock.java +++ b/src/main/java/ru/betterend/blocks/EndStoneBlock.java @@ -1,13 +1,13 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Blocks; -import net.minecraft.block.MaterialColor; -import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.block.SoundType; import ru.betterend.blocks.basis.BlockBase; public class EndStoneBlock extends BlockBase { public EndStoneBlock(MaterialColor color) { - super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(BlockSoundGroup.STONE)); + super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(SoundType.STONE)); } } diff --git a/src/main/java/ru/betterend/blocks/EndStoneSmelter.java b/src/main/java/ru/betterend/blocks/EndStoneSmelter.java index 53d03e42..9fb70e5a 100644 --- a/src/main/java/ru/betterend/blocks/EndStoneSmelter.java +++ b/src/main/java/ru/betterend/blocks/EndStoneSmelter.java @@ -8,36 +8,36 @@ import com.google.common.collect.Lists; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockRenderType; -import net.minecraft.block.BlockState; -import net.minecraft.block.HorizontalFacingBlock; -import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.particle.ParticleTypes; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.BlockRenderType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.HorizontalFacingBlock; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.screen.ScreenHandler; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.ActionResult; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; +import net.minecraft.world.level.block.Rotation; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import ru.betterend.blocks.basis.BaseBlockWithEntity; import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity; @@ -47,18 +47,14 @@ public class EndStoneSmelter extends BaseBlockWithEntity { public static final String ID = "end_stone_smelter"; public EndStoneSmelter() { - super(FabricBlockSettings.of(Material.STONE, MaterialColor.GRAY) - .hardness(4F) - .resistance(100F) - .requiresTool() - .sounds(BlockSoundGroup.STONE)); - this.setDefaultState(this.stateManager.getDefaultState() - .with(FACING, Direction.NORTH) - .with(LIT, false)); + super(FabricBlockSettings.of(Material.STONE, MaterialColor.COLOR_GRAY).hardness(4F).resistance(100F) + .requiresTool().sounds(SoundType.STONE)); + this.setDefaultState(this.stateManager.defaultBlockState().with(FACING, Direction.NORTH).with(LIT, false)); } - - public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - if (world.isClient) { + + public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand, + BlockHitResult hit) { + if (world.isClientSide) { return ActionResult.SUCCESS; } else { this.openScreen(world, pos, player); @@ -66,27 +62,27 @@ public class EndStoneSmelter extends BaseBlockWithEntity { } } - private void openScreen(World world, BlockPos pos, PlayerEntity player) { + private void openScreen(Level world, BlockPos pos, PlayerEntity player) { BlockEntity blockEntity = world.getBlockEntity(pos); if (blockEntity instanceof EndStoneSmelterBlockEntity) { player.openHandledScreen((EndStoneSmelterBlockEntity) blockEntity); } } - + @Override public BlockState getPlacementState(ItemPlacementContext ctx) { - return this.getDefaultState().with(FACING, ctx.getPlayerFacing().getOpposite()); + return this.defaultBlockState().with(FACING, ctx.getPlayerFacing().getOpposite()); } - + @Override public BlockEntity createBlockEntity(BlockView world) { return new EndStoneSmelterBlockEntity(); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { List drop = Lists.newArrayList(new ItemStack(this)); - BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY); + BlockEntity blockEntity = builder.getNullable(LootContextParams.BLOCK_ENTITY); if (blockEntity instanceof EndStoneSmelterBlockEntity) { EndStoneSmelterBlockEntity smelterBlockEntity = (EndStoneSmelterBlockEntity) blockEntity; for (int i = 0; i < smelterBlockEntity.size(); i++) { @@ -105,8 +101,8 @@ public class EndStoneSmelter extends BaseBlockWithEntity { } @Override - public int getComparatorOutput(BlockState state, World world, BlockPos pos) { - //TODO + public int getComparatorOutput(BlockState state, Level world, BlockPos pos) { + // TODO return ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos)); } @@ -116,31 +112,32 @@ public class EndStoneSmelter extends BaseBlockWithEntity { } @Override - public BlockState rotate(BlockState state, BlockRotation rotation) { - return (BlockState)state.with(FACING, rotation.rotate((Direction)state.get(FACING))); + public BlockState rotate(BlockState state, Rotation rotation) { + return (BlockState) state.with(FACING, rotation.rotate((Direction) state.getValue(FACING))); } @Override public BlockState mirror(BlockState state, BlockMirror mirror) { - return state.rotate(mirror.getRotation((Direction)state.get(FACING))); + return state.rotate(mirror.getRotation((Direction) state.getValue(FACING))); } @Override - protected void appendProperties(StateManager.Builder builder) { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(FACING, LIT); } - + @Environment(EnvType.CLIENT) - public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { - if (state.get(LIT)) { + public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { + if (state.getValue(LIT)) { double x = pos.getX() + 0.5D; double y = pos.getY(); double z = pos.getZ() + 0.5D; if (random.nextDouble() < 0.1D) { - world.playSound(x, y, z, SoundEvents.BLOCK_BLASTFURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false); + world.playLocalSound(x, y, z, SoundEvents.BLOCK_BLASTFURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1.0F, + 1.0F, false); } - Direction direction = (Direction)state.get(FACING); + Direction direction = (Direction) state.getValue(FACING); Direction.Axis axis = direction.getAxis(); double defOffset = random.nextDouble() * 0.6D - 0.3D; double offX = axis == Direction.Axis.X ? direction.getOffsetX() * 0.52D : defOffset; diff --git a/src/main/java/ru/betterend/blocks/EndTerrainBlock.java b/src/main/java/ru/betterend/blocks/EndTerrainBlock.java index 51c6a48f..6b98418e 100644 --- a/src/main/java/ru/betterend/blocks/EndTerrainBlock.java +++ b/src/main/java/ru/betterend/blocks/EndTerrainBlock.java @@ -9,29 +9,29 @@ import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.MaterialColor; -import net.minecraft.block.SnowBlock; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.block.SnowBlock; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Registry; +import net.minecraft.world.level.Level; import net.minecraft.world.WorldView; import net.minecraft.world.chunk.light.ChunkLightProvider; import ru.betterend.blocks.basis.BlockBase; @@ -39,73 +39,74 @@ import ru.betterend.patterns.Patterns; public class EndTerrainBlock extends BlockBase { private Block pathBlock; - + public EndTerrainBlock(MaterialColor color) { - super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(BlockSounds.TERRAIN_SOUND).ticksRandomly()); + super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(BlockSounds.TERRAIN_SOUND) + .ticksRandomly()); } - + public void setPathBlock(Block roadBlock) { this.pathBlock = roadBlock; } - + @Override - public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand, + BlockHitResult hit) { if (pathBlock != null && player.getMainHandStack().getItem().isIn(FabricToolTags.SHOVELS)) { - world.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F); - if (!world.isClient) { - world.setBlockState(pos, pathBlock.getDefaultState()); + world.playLocalSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); + if (!world.isClientSide) { + world.setBlockAndUpdate(pos, pathBlock.defaultBlockState()); if (player != null && !player.isCreative()) { - player.getMainHandStack().damage(1, world.random, (ServerPlayerEntity) player); + player.getMainHandStack().damage(1, world.random, (ServerPlayer) player); } } return ActionResult.SUCCESS; } return ActionResult.FAIL; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Collections.singletonList(new ItemStack(this)); } return Collections.singletonList(new ItemStack(Blocks.END_STONE)); } - + @Override - public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) { - world.setBlockState(pos, Blocks.END_STONE.getDefaultState()); + world.setBlockAndUpdate(pos, Blocks.END_STONE.defaultBlockState()); } } - + protected boolean canSurvive(BlockState state, WorldView worldView, BlockPos pos) { BlockPos blockPos = pos.up(); BlockState blockState = worldView.getBlockState(blockPos); - if (blockState.isOf(Blocks.SNOW) && (Integer) blockState.get(SnowBlock.LAYERS) == 1) { + if (blockState.is(Blocks.SNOW) && (Integer) blockState.get(SnowBlock.LAYERS) == 1) { return true; - } - else if (blockState.getFluidState().getLevel() == 8) { + } else if (blockState.getFluidState().getLevel() == 8) { return false; - } - else { - int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getOpacity(worldView, blockPos)); + } else { + int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP, + blockState.getOpacity(worldView, blockPos)); return i < 5; } } - + @Override public String getModelPattern(String block) { - String name = Registry.BLOCK.getId(this).getPath(); + String name = Registry.BLOCK.getKey(this).getPath(); Map map = Maps.newHashMap(); map.put("%top%", "betterend:block/" + name + "_top"); map.put("%side%", "betterend:block/" + name + "_side"); map.put("%bottom%", "minecraft:block/end_stone"); return Patterns.createJson(Patterns.BLOCK_TOP_SIDE_BOTTOM, map); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_ROTATED_TOP; } } diff --git a/src/main/java/ru/betterend/blocks/EnderBlock.java b/src/main/java/ru/betterend/blocks/EnderBlock.java index 1b80fabd..3458aa07 100644 --- a/src/main/java/ru/betterend/blocks/EnderBlock.java +++ b/src/main/java/ru/betterend/blocks/EnderBlock.java @@ -3,22 +3,19 @@ package ru.betterend.blocks; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; import ru.betterend.blocks.basis.BlockBase; public class EnderBlock extends BlockBase { public EnderBlock() { - super(FabricBlockSettings.of(Material.STONE, MaterialColor.field_25708) - .hardness(5F) - .resistance(6F) - .requiresTool() - .sounds(BlockSoundGroup.STONE)); + super(FabricBlockSettings.of(Material.STONE, MaterialColor.field_25708).hardness(5F).resistance(6F) + .requiresTool().sounds(SoundType.STONE)); } @Environment(EnvType.CLIENT) diff --git a/src/main/java/ru/betterend/blocks/EndstoneDustBlock.java b/src/main/java/ru/betterend/blocks/EndstoneDustBlock.java index 3dae7b77..51664204 100644 --- a/src/main/java/ru/betterend/blocks/EndstoneDustBlock.java +++ b/src/main/java/ru/betterend/blocks/EndstoneDustBlock.java @@ -7,27 +7,26 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FallingBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FallingBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; import ru.betterend.util.MHelper; public class EndstoneDustBlock extends FallingBlock { @Environment(EnvType.CLIENT) private static final int COLOR = MHelper.color(226, 239, 168); - + public EndstoneDustBlock() { - super(FabricBlockSettings.copyOf(Blocks.SAND) - .breakByTool(FabricToolTags.SHOVELS) - .materialColor(Blocks.END_STONE.getDefaultMaterialColor())); + super(FabricBlockSettings.copyOf(Blocks.SAND).breakByTool(FabricToolTags.SHOVELS) + .materialColor(Blocks.END_STONE.defaultMaterialColor())); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } diff --git a/src/main/java/ru/betterend/blocks/EternalPedestal.java b/src/main/java/ru/betterend/blocks/EternalPedestal.java index aad5bea7..3344dc76 100644 --- a/src/main/java/ru/betterend/blocks/EternalPedestal.java +++ b/src/main/java/ru/betterend/blocks/EternalPedestal.java @@ -4,23 +4,23 @@ import java.util.List; import com.google.common.collect.Lists; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Registry; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.explosion.Explosion; import ru.betterend.blocks.basis.PedestalBlock; import ru.betterend.blocks.entities.EternalPedestalEntity; @@ -30,14 +30,14 @@ import ru.betterend.rituals.EternalRitual; public class EternalPedestal extends PedestalBlock { public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE; - + public EternalPedestal() { super(EndBlocks.FLAVOLITE_RUNED_ETERNAL); this.setDefaultState(getDefaultState().with(ACTIVATED, false)); } - + @Override - public void checkRitual(World world, BlockPos pos) { + public void checkRitual(Level world, BlockPos pos) { BlockEntity blockEntity = world.getBlockEntity(pos); if (blockEntity instanceof EternalPedestalEntity) { EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity; @@ -46,7 +46,7 @@ public class EternalPedestal extends PedestalBlock { if (pedestal.hasRitual()) { EternalRitual ritual = pedestal.getRitual(); if (ritual.isActive()) { - Identifier targetWorld = ritual.getTargetWorldId(); + ResourceLocation targetWorld = ritual.getTargetWorldId(); int portalId; if (targetWorld != null) { portalId = EndPortals.getPortalIdByWorld(targetWorld); @@ -56,12 +56,12 @@ public class EternalPedestal extends PedestalBlock { ritual.disablePortal(portalId); } } - world.setBlockState(pos, updatedState.with(ACTIVATED, false).with(HAS_LIGHT, false)); + world.setBlockAndUpdate(pos, updatedState.with(ACTIVATED, false).with(HAS_LIGHT, false)); } else { ItemStack itemStack = pedestal.getStack(0); - Identifier id = Registry.ITEM.getId(itemStack.getItem()); + ResourceLocation id = Registry.ITEM.getId(itemStack.getItem()); if (EndPortals.isAvailableItem(id)) { - world.setBlockState(pos, updatedState.with(ACTIVATED, true).with(HAS_LIGHT, true)); + world.setBlockAndUpdate(pos, updatedState.with(ACTIVATED, true).with(HAS_LIGHT, true)); if (pedestal.hasRitual()) { pedestal.getRitual().checkStructure(); } else { @@ -72,42 +72,45 @@ public class EternalPedestal extends PedestalBlock { } } } - + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) { - BlockState updated = super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom); - if (!updated.isOf(this)) return updated; + public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, + BlockPos pos, BlockPos posFrom) { + BlockState updated = super.updateShape(state, direction, newState, world, pos, posFrom); + if (!updated.is(this)) + return updated; if (!this.isPlaceable(updated)) { return updated.with(ACTIVATED, false); } return updated; } - + @Override public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) { return 0.0F; } - + @Override public float getBlastResistance() { - return Blocks.BEDROCK.getBlastResistance(); + return Blocks.BEDROCK.getExplosionResistance(); } - + @Override public boolean shouldDropItemsOnExplosion(Explosion explosion) { return false; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - if (state.isOf(this)) { - BlockProperties.PedestalState currentState = state.get(BlockProperties.PEDESTAL_STATE); - if (currentState.equals(BlockProperties.PedestalState.BOTTOM) || currentState.equals(BlockProperties.PedestalState.PILLAR)) { + public List getDrops(BlockState state, LootContext.Builder builder) { + if (state.is(this)) { + BlockProperties.PedestalState currentState = state.getValue(BlockProperties.PEDESTAL_STATE); + if (currentState.equals(BlockProperties.PedestalState.BOTTOM) + || currentState.equals(BlockProperties.PedestalState.PILLAR)) { return Lists.newArrayList(); } } List drop = Lists.newArrayList(); - BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY); + BlockEntity blockEntity = builder.getNullable(LootContextParams.BLOCK_ENTITY); if (blockEntity instanceof EternalPedestalEntity) { EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity; if (!pedestal.isEmpty()) { @@ -116,10 +119,10 @@ public class EternalPedestal extends PedestalBlock { } return drop; } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { - super.appendProperties(stateManager); + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { + super.createBlockStateDefinition(stateManager); stateManager.add(ACTIVATED); } diff --git a/src/main/java/ru/betterend/blocks/EternalRunedFlavolite.java b/src/main/java/ru/betterend/blocks/EternalRunedFlavolite.java index e8fd7644..f1c505d9 100644 --- a/src/main/java/ru/betterend/blocks/EternalRunedFlavolite.java +++ b/src/main/java/ru/betterend/blocks/EternalRunedFlavolite.java @@ -4,13 +4,13 @@ import java.util.List; import com.google.common.collect.Lists; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; import net.minecraft.world.explosion.Explosion; public class EternalRunedFlavolite extends RunedFlavolite { @@ -19,19 +19,19 @@ public class EternalRunedFlavolite extends RunedFlavolite { public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) { return 0.0F; } - + @Override public float getBlastResistance() { - return Blocks.BEDROCK.getBlastResistance(); + return Blocks.BEDROCK.getExplosionResistance(); } - + @Override public boolean shouldDropItemsOnExplosion(Explosion explosion) { return false; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Lists.newArrayList(); } } diff --git a/src/main/java/ru/betterend/blocks/FilaluxLanternBlock.java b/src/main/java/ru/betterend/blocks/FilaluxLanternBlock.java index 0363bd80..cb775ead 100644 --- a/src/main/java/ru/betterend/blocks/FilaluxLanternBlock.java +++ b/src/main/java/ru/betterend/blocks/FilaluxLanternBlock.java @@ -2,12 +2,13 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Material; -import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.SoundType; import ru.betterend.blocks.basis.BlockBase; public class FilaluxLanternBlock extends BlockBase { public FilaluxLanternBlock() { - super(FabricBlockSettings.of(Material.WOOD).luminance(15).sounds(BlockSoundGroup.WOOD).breakByTool(FabricToolTags.AXES)); + super(FabricBlockSettings.of(Material.WOOD).luminance(15).sounds(SoundType.WOOD) + .breakByTool(FabricToolTags.AXES)); } } diff --git a/src/main/java/ru/betterend/blocks/FlamaeaBlock.java b/src/main/java/ru/betterend/blocks/FlamaeaBlock.java index 183891c3..4a9b575c 100644 --- a/src/main/java/ru/betterend/blocks/FlamaeaBlock.java +++ b/src/main/java/ru/betterend/blocks/FlamaeaBlock.java @@ -6,36 +6,34 @@ import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.core.BlockPos; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.BlockGetter; import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.interfaces.ISpetialItem; public class FlamaeaBlock extends EndPlantBlock implements ISpetialItem { private static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 1, 16); - + public FlamaeaBlock() { - super(FabricBlockSettings.of(Material.PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.WET_GRASS) + super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.WET_GRASS) .breakByHand(true)); } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(Blocks.WATER); + return state.is(Blocks.WATER); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { return SHAPE; @@ -45,9 +43,9 @@ public class FlamaeaBlock extends EndPlantBlock implements ISpetialItem { public AbstractBlock.OffsetType getOffsetType() { return AbstractBlock.OffsetType.NONE; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Lists.newArrayList(new ItemStack(this)); } diff --git a/src/main/java/ru/betterend/blocks/GlowingHymenophoreBlock.java b/src/main/java/ru/betterend/blocks/GlowingHymenophoreBlock.java index 42dfda2d..ab65538b 100644 --- a/src/main/java/ru/betterend/blocks/GlowingHymenophoreBlock.java +++ b/src/main/java/ru/betterend/blocks/GlowingHymenophoreBlock.java @@ -2,12 +2,13 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Material; -import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.SoundType; import ru.betterend.blocks.basis.BlockBase; public class GlowingHymenophoreBlock extends BlockBase { public GlowingHymenophoreBlock() { - super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WART_BLOCK).luminance(15)); + super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(SoundType.WART_BLOCK) + .luminance(15)); } } diff --git a/src/main/java/ru/betterend/blocks/GlowingMossBlock.java b/src/main/java/ru/betterend/blocks/GlowingMossBlock.java index 6b8aee7c..62814731 100644 --- a/src/main/java/ru/betterend/blocks/GlowingMossBlock.java +++ b/src/main/java/ru/betterend/blocks/GlowingMossBlock.java @@ -2,9 +2,9 @@ package ru.betterend.blocks; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.registry.EndBlocks; @@ -12,19 +12,19 @@ public class GlowingMossBlock extends EndPlantBlock { public GlowingMossBlock(int light) { super(light); } - + @Override protected boolean isTerrain(BlockState state) { return state.getBlock() == EndBlocks.END_MOSS || state.getBlock() == EndBlocks.END_MYCELIUM; } - - @Environment(EnvType.CLIENT) - public boolean hasEmissiveLighting(BlockView world, BlockPos pos) { - return true; - } - @Environment(EnvType.CLIENT) - public float getAmbientOcclusionLightLevel(BlockView world, BlockPos pos) { - return 1F; - } + @Environment(EnvType.CLIENT) + public boolean hasEmissiveLighting(BlockView world, BlockPos pos) { + return true; + } + + @Environment(EnvType.CLIENT) + public float getAmbientOcclusionLightLevel(BlockView world, BlockPos pos) { + return 1F; + } } \ No newline at end of file diff --git a/src/main/java/ru/betterend/blocks/GlowingPillarLuminophorBlock.java b/src/main/java/ru/betterend/blocks/GlowingPillarLuminophorBlock.java index ea26f658..ec778642 100644 --- a/src/main/java/ru/betterend/blocks/GlowingPillarLuminophorBlock.java +++ b/src/main/java/ru/betterend/blocks/GlowingPillarLuminophorBlock.java @@ -2,51 +2,47 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.WorldAccess; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.registry.EndBlocks; public class GlowingPillarLuminophorBlock extends BlockBase { public static final BooleanProperty NATURAL = BlockProperties.NATURAL; - + public GlowingPillarLuminophorBlock() { - super(FabricBlockSettings.of(Material.LEAVES) - .materialColor(MaterialColor.ORANGE) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.GRASS) - .strength(0.2F) - .luminance(15)); - this.setDefaultState(this.stateManager.getDefaultState().with(NATURAL, false)); + super(FabricBlockSettings.of(Material.LEAVES).materialColor(MaterialColor.COLOR_ORANGE) + .breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS).strength(0.2F).luminance(15)); + this.setDefaultState(this.stateManager.defaultBlockState().with(NATURAL, false)); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - return state.get(NATURAL) ? world.getBlockState(pos.down()).isOf(EndBlocks.GLOWING_PILLAR_ROOTS) : true; + return state.getValue(NATURAL) ? world.getBlockState(pos.below()).is(EndBlocks.GLOWING_PILLAR_ROOTS) : true; } - + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (!canPlaceAt(state, world, pos)) { - return Blocks.AIR.getDefaultState(); - } - else { + return Blocks.AIR.defaultBlockState(); + } else { return state; } } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(NATURAL); } } diff --git a/src/main/java/ru/betterend/blocks/GlowingPillarRootsBlock.java b/src/main/java/ru/betterend/blocks/GlowingPillarRootsBlock.java index c6e5d493..ddc4aeb9 100644 --- a/src/main/java/ru/betterend/blocks/GlowingPillarRootsBlock.java +++ b/src/main/java/ru/betterend/blocks/GlowingPillarRootsBlock.java @@ -2,30 +2,30 @@ package ru.betterend.blocks; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.EnumProperty; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.blocks.basis.UpDownPlantBlock; import ru.betterend.registry.EndBlocks; public class GlowingPillarRootsBlock extends UpDownPlantBlock { public static final EnumProperty SHAPE = BlockProperties.TRIPLE_SHAPE; - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(SHAPE); } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.AMBER_MOSS); + return state.is(EndBlocks.AMBER_MOSS); } - + @Override @Environment(EnvType.CLIENT) public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { diff --git a/src/main/java/ru/betterend/blocks/GlowingPillarSeedBlock.java b/src/main/java/ru/betterend/blocks/GlowingPillarSeedBlock.java index 3c29919f..bd8fcb81 100644 --- a/src/main/java/ru/betterend/blocks/GlowingPillarSeedBlock.java +++ b/src/main/java/ru/betterend/blocks/GlowingPillarSeedBlock.java @@ -4,14 +4,14 @@ import java.util.Random; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.SoundType; import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.blocks.basis.EndPlantWithAgeBlock; @@ -21,15 +21,11 @@ import ru.betterend.util.MHelper; public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock { public GlowingPillarSeedBlock() { - super(FabricBlockSettings.of(Material.PLANT) - .luminance((state) -> { return state.get(AGE) * 3 + 3; }) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.GRASS) - .breakByHand(true) - .ticksRandomly() - .noCollision()); + super(FabricBlockSettings.of(Material.PLANT).luminance((state) -> { + return state.getValue(AGE) * 3 + 3; + }).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS).breakByHand(true).ticksRandomly().noCollision()); } - + @Override public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) { int height = MHelper.randRange(1, 2, random); @@ -37,37 +33,39 @@ public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock { if (h < height) { return; } - - Mutable mut = new Mutable().set(pos); - BlockState roots = EndBlocks.GLOWING_PILLAR_ROOTS.getDefaultState(); + + MutableBlockPos mut = new MutableBlockPos().set(pos); + BlockState roots = EndBlocks.GLOWING_PILLAR_ROOTS.defaultBlockState(); if (height < 2) { BlocksHelper.setWithUpdate(world, mut, roots.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE)); mut.move(Direction.UP); - } - else { + } else { BlocksHelper.setWithUpdate(world, mut, roots.with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM)); mut.move(Direction.UP); BlocksHelper.setWithUpdate(world, mut, roots.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP)); mut.move(Direction.UP); } - BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LUMINOPHOR.getDefaultState().with(BlueVineLanternBlock.NATURAL, true)); - for (Direction dir: BlocksHelper.DIRECTIONS) { + BlocksHelper.setWithUpdate(world, mut, + EndBlocks.GLOWING_PILLAR_LUMINOPHOR.defaultBlockState().with(BlueVineLanternBlock.NATURAL, true)); + for (Direction dir : BlocksHelper.DIRECTIONS) { pos = mut.offset(dir); if (world.isAir(pos)) { - BlocksHelper.setWithUpdate(world, pos, EndBlocks.GLOWING_PILLAR_LEAVES.getDefaultState().with(Properties.FACING, dir)); + BlocksHelper.setWithUpdate(world, pos, + EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().with(Properties.FACING, dir)); } } mut.move(Direction.UP); if (world.isAir(mut)) { - BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LEAVES.getDefaultState().with(Properties.FACING, Direction.UP)); + BlocksHelper.setWithUpdate(world, mut, + EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().with(Properties.FACING, Direction.UP)); } } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.AMBER_MOSS); + return state.is(EndBlocks.AMBER_MOSS); } - + @Override public AbstractBlock.OffsetType getOffsetType() { return AbstractBlock.OffsetType.NONE; diff --git a/src/main/java/ru/betterend/blocks/HelixTreeLeavesBlock.java b/src/main/java/ru/betterend/blocks/HelixTreeLeavesBlock.java index 7d4eaba6..02808f0a 100644 --- a/src/main/java/ru/betterend/blocks/HelixTreeLeavesBlock.java +++ b/src/main/java/ru/betterend/blocks/HelixTreeLeavesBlock.java @@ -7,22 +7,22 @@ import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; -import net.minecraft.client.color.block.BlockColorProvider; -import net.minecraft.client.color.item.ItemColorProvider; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.math.MathHelper; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.client.color.block.BlockColor; +import net.minecraft.client.color.item.ItemColor; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.util.Mth; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.interfaces.IColorProvider; import ru.betterend.noise.OpenSimplexNoise; @@ -30,63 +30,62 @@ import ru.betterend.registry.EndBlocks; import ru.betterend.util.MHelper; public class HelixTreeLeavesBlock extends BlockBase implements IColorProvider { - public static final IntProperty COLOR = BlockProperties.COLOR; + public static final IntegerProperty COLOR = BlockProperties.COLOR; private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0); - + public HelixTreeLeavesBlock() { - super(FabricBlockSettings.of(Material.LEAVES) - .materialColor(MaterialColor.ORANGE) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.WART_BLOCK) - .sounds(BlockSoundGroup.GRASS) + super(FabricBlockSettings.of(Material.LEAVES).materialColor(MaterialColor.COLOR_ORANGE) + .breakByTool(FabricToolTags.SHEARS).sounds(SoundType.WART_BLOCK).sounds(SoundType.GRASS) .strength(0.2F)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(COLOR); } @Override - public BlockColorProvider getProvider() { + public BlockColor getBlockProvider() { return (state, world, pos, tintIndex) -> { - return MHelper.color(237, getGreen(state.get(COLOR)), 20); + return MHelper.color(237, getGreen(state.getValue(COLOR)), 20); }; } @Override - public ItemColorProvider getItemProvider() { + public ItemColor getItemProvider() { return (stack, tintIndex) -> { return MHelper.color(237, getGreen(4), 20); }; } - + @Override public BlockState getPlacementState(ItemPlacementContext ctx) { double px = ctx.getBlockPos().getX() * 0.1; double py = ctx.getBlockPos().getY() * 0.1; double pz = ctx.getBlockPos().getZ() * 0.1; - return this.getDefaultState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4)); + return this.defaultBlockState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4)); } - + private int getGreen(int color) { float delta = color / 7F; - return (int) MathHelper.lerp(delta, 80, 158); + return (int) Mth.lerp(delta, 80, 158); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); if (tool != null) { - if (tool.getItem().isIn(FabricToolTags.SHEARS) || tool.isEffectiveOn(state) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + if (tool.getItem().isIn(FabricToolTags.SHEARS) || tool.isCorrectToolForDrops(state) + || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Collections.singletonList(new ItemStack(this)); } - int fortune = EnchantmentHelper.getLevel(Enchantments.FORTUNE, tool); + int fortune = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool); if (MHelper.RANDOM.nextInt(16) <= fortune) { return Lists.newArrayList(new ItemStack(EndBlocks.HELIX_TREE_SAPLING)); } return Lists.newArrayList(); } - return MHelper.RANDOM.nextInt(32) == 0 ? Lists.newArrayList(new ItemStack(EndBlocks.HELIX_TREE_SAPLING)) : Lists.newArrayList(); + return MHelper.RANDOM.nextInt(32) == 0 ? Lists.newArrayList(new ItemStack(EndBlocks.HELIX_TREE_SAPLING)) + : Lists.newArrayList(); } } diff --git a/src/main/java/ru/betterend/blocks/HydraluxBlock.java b/src/main/java/ru/betterend/blocks/HydraluxBlock.java index 53fc0eb2..eff201bb 100644 --- a/src/main/java/ru/betterend/blocks/HydraluxBlock.java +++ b/src/main/java/ru/betterend/blocks/HydraluxBlock.java @@ -10,17 +10,17 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.EnumProperty; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraft.world.WorldView; import ru.betterend.blocks.BlockProperties.HydraluxShape; import ru.betterend.blocks.basis.UnderwaterPlantBlock; @@ -30,60 +30,56 @@ import ru.betterend.util.MHelper; public class HydraluxBlock extends UnderwaterPlantBlock { public static final EnumProperty SHAPE = BlockProperties.HYDRALUX_SHAPE; - + public HydraluxBlock() { - super(FabricBlockSettings.of(Material.UNDERWATER_PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.WET_GRASS) - .breakByHand(true) - .luminance((state) -> { return state.get(SHAPE).hasGlow() ? 15 : 0; }) - .noCollision()); + super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS) + .sounds(SoundType.WET_GRASS).breakByHand(true).luminance((state) -> { + return state.getValue(SHAPE).hasGlow() ? 15 : 0; + }).noCollision()); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(SHAPE); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - BlockState down = world.getBlockState(pos.down()); - HydraluxShape shape = state.get(SHAPE); + BlockState down = world.getBlockState(pos.below()); + HydraluxShape shape = state.getValue(SHAPE); if (shape == HydraluxShape.FLOWER_BIG_TOP || shape == HydraluxShape.FLOWER_SMALL_TOP) { - return down.isOf(this); - } - else if (shape == HydraluxShape.ROOTS) { - return down.isOf(EndBlocks.SULPHURIC_ROCK.stone) && world.getBlockState(pos.up()).isOf(this); - } - else { - return down.isOf(this) && world.getBlockState(pos.up()).isOf(this); + return down.is(this); + } else if (shape == HydraluxShape.ROOTS) { + return down.is(EndBlocks.SULPHURIC_ROCK.stone) && world.getBlockState(pos.up()).is(this); + } else { + return down.is(this) && world.getBlockState(pos.up()).is(this); } } - + @Override public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { return false; } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { return false; } - + @Override @Environment(EnvType.CLIENT) public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { return new ItemStack(EndBlocks.HYDRALUX_SAPLING); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - HydraluxShape shape = state.get(SHAPE); + public List getDrops(BlockState state, LootContext.Builder builder) { + HydraluxShape shape = state.getValue(SHAPE); if (shape == HydraluxShape.FLOWER_BIG_BOTTOM || shape == HydraluxShape.FLOWER_SMALL_BOTTOM) { return Lists.newArrayList(new ItemStack(EndItems.HYDRALUX_PETAL, MHelper.randRange(1, 4, MHelper.RANDOM))); - } - else if (shape == HydraluxShape.ROOTS) { - return Lists.newArrayList(new ItemStack(EndBlocks.HYDRALUX_SAPLING, MHelper.randRange(1, 2, MHelper.RANDOM))); + } else if (shape == HydraluxShape.ROOTS) { + return Lists + .newArrayList(new ItemStack(EndBlocks.HYDRALUX_SAPLING, MHelper.randRange(1, 2, MHelper.RANDOM))); } return Collections.emptyList(); } diff --git a/src/main/java/ru/betterend/blocks/HydraluxPetalBlock.java b/src/main/java/ru/betterend/blocks/HydraluxPetalBlock.java index b514b7ef..7a111875 100644 --- a/src/main/java/ru/betterend/blocks/HydraluxPetalBlock.java +++ b/src/main/java/ru/betterend/blocks/HydraluxPetalBlock.java @@ -2,29 +2,25 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; -import net.minecraft.entity.Entity; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import ru.betterend.blocks.basis.BlockBase; public class HydraluxPetalBlock extends BlockBase { public HydraluxPetalBlock() { - this(FabricBlockSettings.of(Material.PLANT) - .materialColor(MaterialColor.SPRUCE) - .sounds(BlockSoundGroup.WART_BLOCK) - .breakByTool(FabricToolTags.AXES) - .hardness(1) - .resistance(1) - .breakByHand(true)); + this(FabricBlockSettings.of(Material.PLANT).materialColor(MaterialColor.SPRUCE).sounds(SoundType.WART_BLOCK) + .breakByTool(FabricToolTags.AXES).hardness(1).resistance(1).breakByHand(true)); } - + public HydraluxPetalBlock(FabricBlockSettings settings) { super(settings); } - + @Override - public void onLandedUpon(World world, BlockPos pos, Entity entity, float distance) {} + public void onLandedUpon(Level world, BlockPos pos, Entity entity, float distance) { + } } diff --git a/src/main/java/ru/betterend/blocks/HydraluxPetalColoredBlock.java b/src/main/java/ru/betterend/blocks/HydraluxPetalColoredBlock.java index 5e1a0eed..e8c3731f 100644 --- a/src/main/java/ru/betterend/blocks/HydraluxPetalColoredBlock.java +++ b/src/main/java/ru/betterend/blocks/HydraluxPetalColoredBlock.java @@ -3,9 +3,9 @@ package ru.betterend.blocks; import java.io.Reader; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.client.color.block.BlockColorProvider; -import net.minecraft.client.color.item.ItemColorProvider; -import net.minecraft.util.Identifier; +import net.minecraft.client.color.block.BlockColor; +import net.minecraft.client.color.item.ItemColor; +import net.minecraft.resources.ResourceLocation; import ru.betterend.interfaces.IColorProvider; import ru.betterend.patterns.Patterns; import ru.betterend.util.BlocksHelper; @@ -14,35 +14,35 @@ public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements ICo public HydraluxPetalColoredBlock(FabricBlockSettings settings) { super(settings); } - + @Override - public BlockColorProvider getProvider() { + public BlockColor getBlockProvider() { return (state, world, pos, tintIndex) -> { return BlocksHelper.getBlockColor(this); }; } @Override - public ItemColorProvider getItemProvider() { + public ItemColor getItemProvider() { return (stack, tintIndex) -> { return BlocksHelper.getBlockColor(this); }; } - + @Override public String getStatesPattern(Reader data) { String path = "betterend:block/block_petal_colored"; return Patterns.createJson(data, path, path); } - + @Override public String getModelPattern(String block) { String path = "betterend:block/block_petal_colored"; return Patterns.createJson(Patterns.BLOCK_PETAL_COLORED, path, path); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_DIRECT; } } diff --git a/src/main/java/ru/betterend/blocks/HydraluxSaplingBlock.java b/src/main/java/ru/betterend/blocks/HydraluxSaplingBlock.java index ae1544c0..05b7696e 100644 --- a/src/main/java/ru/betterend/blocks/HydraluxSaplingBlock.java +++ b/src/main/java/ru/betterend/blocks/HydraluxSaplingBlock.java @@ -2,10 +2,10 @@ package ru.betterend.blocks; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.BlockProperties.HydraluxShape; import ru.betterend.blocks.basis.UnderwaterPlantWithAgeBlock; @@ -17,33 +17,35 @@ public class HydraluxSaplingBlock extends UnderwaterPlantWithAgeBlock { @Override public void grow(StructureWorldAccess world, Random random, BlockPos pos) { int h = MHelper.randRange(4, 8, random); - Mutable mut = new Mutable().set(pos); - + MutableBlockPos mut = new MutableBlockPos().set(pos); + for (int i = 1; i < h; i++) { mut.setY(pos.getY() + i); - if (!world.getBlockState(mut).isOf(Blocks.WATER)) { + if (!world.getBlockState(mut).is(Blocks.WATER)) { return; } } - + mut.setY(pos.getY()); - BlockState state = EndBlocks.HYDRALUX.getDefaultState(); + BlockState state = EndBlocks.HYDRALUX.defaultBlockState(); BlocksHelper.setWithoutUpdate(world, pos, state.with(BlockProperties.HYDRALUX_SHAPE, HydraluxShape.ROOTS)); for (int i = 1; i < h - 2; i++) { mut.setY(pos.getY() + i); BlocksHelper.setWithoutUpdate(world, mut, state.with(BlockProperties.HYDRALUX_SHAPE, HydraluxShape.VINE)); } - + mut.setY(mut.getY() + 1); boolean big = random.nextBoolean(); - BlocksHelper.setWithoutUpdate(world, mut, state.with(BlockProperties.HYDRALUX_SHAPE, big ? HydraluxShape.FLOWER_BIG_BOTTOM : HydraluxShape.FLOWER_SMALL_BOTTOM)); - + BlocksHelper.setWithoutUpdate(world, mut, state.with(BlockProperties.HYDRALUX_SHAPE, + big ? HydraluxShape.FLOWER_BIG_BOTTOM : HydraluxShape.FLOWER_SMALL_BOTTOM)); + mut.setY(mut.getY() + 1); - BlocksHelper.setWithoutUpdate(world, mut, state.with(BlockProperties.HYDRALUX_SHAPE, big ? HydraluxShape.FLOWER_BIG_TOP : HydraluxShape.FLOWER_SMALL_TOP)); + BlocksHelper.setWithoutUpdate(world, mut, state.with(BlockProperties.HYDRALUX_SHAPE, + big ? HydraluxShape.FLOWER_BIG_TOP : HydraluxShape.FLOWER_SMALL_TOP)); } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.SULPHURIC_ROCK.stone); + return state.is(EndBlocks.SULPHURIC_ROCK.stone); } } diff --git a/src/main/java/ru/betterend/blocks/HydrothermalVentBlock.java b/src/main/java/ru/betterend/blocks/HydrothermalVentBlock.java index 262cad10..999ca172 100644 --- a/src/main/java/ru/betterend/blocks/HydrothermalVentBlock.java +++ b/src/main/java/ru/betterend/blocks/HydrothermalVentBlock.java @@ -8,33 +8,33 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockEntityProvider; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FluidFillable; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.block.Waterloggable; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.BlockEntityProvider; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FluidFillable; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.level.block.Waterloggable; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.blocks.basis.BlockBaseNotFull; import ru.betterend.blocks.entities.BlockEntityHydrothermalVent; @@ -42,67 +42,66 @@ import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndParticles; import ru.betterend.util.BlocksHelper; -public class HydrothermalVentBlock extends BlockBaseNotFull implements BlockEntityProvider, FluidFillable, Waterloggable { +public class HydrothermalVentBlock extends BlockBaseNotFull + implements BlockEntityProvider, FluidFillable, Waterloggable { public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE; private static final VoxelShape SHAPE = Block.createCuboidShape(1, 1, 1, 15, 16, 15); - + public HydrothermalVentBlock() { - super(FabricBlockSettings.of(Material.STONE) - .breakByTool(FabricToolTags.PICKAXES) - .sounds(BlockSoundGroup.STONE) - .noCollision() - .requiresTool()); + super(FabricBlockSettings.of(Material.STONE).breakByTool(FabricToolTags.PICKAXES).sounds(SoundType.STONE) + .noCollision().requiresTool()); this.setDefaultState(getDefaultState().with(WATERLOGGED, true).with(ACTIVATED, false)); } - + @Override - protected void appendProperties(StateManager.Builder builder) { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(WATERLOGGED, ACTIVATED); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { return SHAPE; } - + @Override public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) { return false; } @Override - public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) { + public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) { return false; } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - state = world.getBlockState(pos.down()); - return state.isOf(EndBlocks.SULPHURIC_ROCK.stone); + state = world.getBlockState(pos.below()); + return state.is(EndBlocks.SULPHURIC_ROCK.stone); } - + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (!canPlaceAt(state, world, pos)) { - return Blocks.WATER.getDefaultState(); - } - else if (state.get(WATERLOGGED) && facing == Direction.UP && neighborState.isOf(Blocks.WATER)) { + return Blocks.WATER.defaultBlockState(); + } else if (state.getValue(WATERLOGGED) && facing == Direction.UP && neighborState.is(Blocks.WATER)) { world.getBlockTickScheduler().schedule(pos, this, 20); } return state; } - + @Override public BlockState getPlacementState(ItemPlacementContext ctx) { - WorldAccess worldAccess = ctx.getWorld(); + LevelAccessor worldAccess = ctx.getLevel(); BlockPos blockPos = ctx.getBlockPos(); - return this.getDefaultState().with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER); + return this.defaultBlockState().with(WATERLOGGED, + worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER); } - + @Override public FluidState getFluidState(BlockState state) { - return (Boolean) state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); + return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); } @Override @@ -111,32 +110,33 @@ public class HydrothermalVentBlock extends BlockBaseNotFull implements BlockEnti } @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { BlockPos up = pos.up(); - if (world.getBlockState(up).isOf(Blocks.WATER)) { + if (world.getBlockState(up).is(Blocks.WATER)) { BlocksHelper.setWithoutUpdate(world, up, EndBlocks.VENT_BUBBLE_COLUMN); world.getBlockTickScheduler().schedule(up, EndBlocks.VENT_BUBBLE_COLUMN, 5); } } - + @Override - public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) { - if (world instanceof ServerWorld && state.get(WATERLOGGED) && world.getBlockState(pos.up()).isOf(Blocks.WATER)) { - scheduledTick(state,(ServerWorld) world, pos, world.random); + public void onPlaced(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, + ItemStack itemStack) { + if (world instanceof ServerLevel && state.getValue(WATERLOGGED) + && world.getBlockState(pos.up()).is(Blocks.WATER)) { + scheduledTick(state, (ServerLevel) world, pos, world.random); } } - + @Environment(EnvType.CLIENT) - public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { - if (!state.get(ACTIVATED) && random.nextBoolean()) { - super.randomDisplayTick(state, world, pos, random); + public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { + if (!state.getValue(ACTIVATED) && random.nextBoolean()) { + super.animateTick(state, world, pos, random); double x = pos.getX() + random.nextDouble(); double y = pos.getY() + 0.9 + random.nextDouble() * 0.3; double z = pos.getZ() + random.nextDouble(); - if (state.get(WATERLOGGED)) { + if (state.getValue(WATERLOGGED)) { world.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0); - } - else { + } else { world.addParticle(ParticleTypes.SMOKE, x, y, z, 0, 0, 0); } } diff --git a/src/main/java/ru/betterend/blocks/InfusionPedestal.java b/src/main/java/ru/betterend/blocks/InfusionPedestal.java index 062cdd8e..081cc4aa 100644 --- a/src/main/java/ru/betterend/blocks/InfusionPedestal.java +++ b/src/main/java/ru/betterend/blocks/InfusionPedestal.java @@ -1,15 +1,15 @@ package ru.betterend.blocks; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ShapeContext; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.BlockPos; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import ru.betterend.blocks.basis.PedestalBlock; import ru.betterend.blocks.entities.InfusionPedestalEntity; import ru.betterend.rituals.InfusionRitual; @@ -22,9 +22,9 @@ public class InfusionPedestal extends PedestalBlock { super(Blocks.OBSIDIAN); this.height = 1.08F; } - + @Override - public void checkRitual(World world, BlockPos pos) { + public void checkRitual(Level world, BlockPos pos) { BlockEntity blockEntity = world.getBlockEntity(pos); if (blockEntity instanceof InfusionPedestalEntity) { InfusionPedestalEntity pedestal = (InfusionPedestalEntity) blockEntity; @@ -37,30 +37,30 @@ public class InfusionPedestal extends PedestalBlock { } } } - + @Override public BlockEntity createBlockEntity(BlockView world) { return new InfusionPedestalEntity(); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { - if (state.isOf(this)) { - switch(state.get(STATE)) { - case PEDESTAL_TOP: { - return SHAPE_PEDESTAL_TOP; - } - case DEFAULT: { - return SHAPE_DEFAULT; - } - default: { - return super.getOutlineShape(state, world, pos, context); - } + if (state.is(this)) { + switch (state.getValue(STATE)) { + case PEDESTAL_TOP: { + return SHAPE_PEDESTAL_TOP; + } + case DEFAULT: { + return SHAPE_DEFAULT; + } + default: { + return super.getOutlineShape(state, world, pos, context); + } } } return super.getOutlineShape(state, world, pos, context); } - + static { VoxelShape basinUp = Block.createCuboidShape(2, 3, 2, 14, 4, 14); VoxelShape basinDown = Block.createCuboidShape(0, 0, 0, 16, 3, 16); diff --git a/src/main/java/ru/betterend/blocks/JellyshroomCapBlock.java b/src/main/java/ru/betterend/blocks/JellyshroomCapBlock.java index 0812cfb4..411f0598 100644 --- a/src/main/java/ru/betterend/blocks/JellyshroomCapBlock.java +++ b/src/main/java/ru/betterend/blocks/JellyshroomCapBlock.java @@ -6,21 +6,21 @@ import java.util.List; import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.SlimeBlock; -import net.minecraft.client.color.block.BlockColorProvider; -import net.minecraft.client.color.item.ItemColorProvider; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3i; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SlimeBlock; +import net.minecraft.client.color.block.BlockColor; +import net.minecraft.client.color.item.ItemColor; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import net.minecraft.core.Vec3i; +import net.minecraft.core.Registry; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IColorProvider; import ru.betterend.interfaces.IRenderTypeable; @@ -30,71 +30,71 @@ import ru.betterend.patterns.Patterns; import ru.betterend.util.MHelper; public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable, BlockPatterned, IColorProvider { - public static final IntProperty COLOR = BlockProperties.COLOR; + public static final IntegerProperty COLOR = BlockProperties.COLOR; private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0); private final Vec3i colorStart; private final Vec3i colorEnd; private final int coloritem; - + public JellyshroomCapBlock(int r1, int g1, int b1, int r2, int g2, int b2) { super(FabricBlockSettings.copyOf(Blocks.SLIME_BLOCK)); colorStart = new Vec3i(r1, g1, b1); colorEnd = new Vec3i(r2, g2, b2); coloritem = MHelper.color((r1 + r2) >> 1, (g1 + g2) >> 1, (b1 + b2) >> 1); } - + @Override public BlockState getPlacementState(ItemPlacementContext ctx) { double px = ctx.getBlockPos().getX() * 0.1; double py = ctx.getBlockPos().getY() * 0.1; double pz = ctx.getBlockPos().getZ() * 0.1; - return this.getDefaultState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4)); + return this.defaultBlockState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(COLOR); } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.TRANSLUCENT; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Lists.newArrayList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - String block = Registry.BLOCK.getId(this).getPath(); + String block = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, block, block); } - + @Override public String getModelPattern(String block) { return Patterns.createJson(Patterns.BLOCK_COLORED, "jellyshroom_cap"); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_SIMPLE; } - + @Override - public BlockColorProvider getProvider() { + public BlockColor getBlockProvider() { return (state, world, pos, tintIndex) -> { - float delta = (float) state.get(COLOR) / 7F; - int r = MathHelper.floor(MathHelper.lerp(delta, colorStart.getX() / 255F, colorEnd.getX() / 255F) * 255F); - int g = MathHelper.floor(MathHelper.lerp(delta, colorStart.getY() / 255F, colorEnd.getY() / 255F) * 255F); - int b = MathHelper.floor(MathHelper.lerp(delta, colorStart.getZ() / 255F, colorEnd.getZ() / 255F) * 255F); + float delta = (float) state.getValue(COLOR) / 7F; + int r = Mth.floor(Mth.lerp(delta, colorStart.getX() / 255F, colorEnd.getX() / 255F) * 255F); + int g = Mth.floor(Mth.lerp(delta, colorStart.getY() / 255F, colorEnd.getY() / 255F) * 255F); + int b = Mth.floor(Mth.lerp(delta, colorStart.getZ() / 255F, colorEnd.getZ() / 255F) * 255F); return MHelper.color(r, g, b); }; } @Override - public ItemColorProvider getItemProvider() { + public ItemColor getItemProvider() { return (stack, tintIndex) -> { return coloritem; }; diff --git a/src/main/java/ru/betterend/blocks/LacugroveSaplingBlock.java b/src/main/java/ru/betterend/blocks/LacugroveSaplingBlock.java index 7302e964..e737242a 100644 --- a/src/main/java/ru/betterend/blocks/LacugroveSaplingBlock.java +++ b/src/main/java/ru/betterend/blocks/LacugroveSaplingBlock.java @@ -1,7 +1,7 @@ package ru.betterend.blocks; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; import net.minecraft.world.WorldView; import net.minecraft.world.gen.feature.Feature; import ru.betterend.blocks.basis.FeatureSaplingBlock; @@ -17,9 +17,10 @@ public class LacugroveSaplingBlock extends FeatureSaplingBlock { protected Feature getFeature() { return EndFeatures.LACUGROVE.getFeature(); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - return world.getBlockState(pos.down()).isOf(EndBlocks.END_MOSS) || world.getBlockState(pos.down()).isOf(EndBlocks.ENDSTONE_DUST); + return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS) + || world.getBlockState(pos.below()).is(EndBlocks.ENDSTONE_DUST); } } diff --git a/src/main/java/ru/betterend/blocks/LanceleafBlock.java b/src/main/java/ru/betterend/blocks/LanceleafBlock.java index 5c3fec89..ed5294b3 100644 --- a/src/main/java/ru/betterend/blocks/LanceleafBlock.java +++ b/src/main/java/ru/betterend/blocks/LanceleafBlock.java @@ -3,17 +3,17 @@ package ru.betterend.blocks; import java.util.Collections; import java.util.List; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.EnumProperty; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.blocks.BlockProperties.PentaShape; import ru.betterend.blocks.basis.EndPlantBlock; @@ -22,46 +22,45 @@ import ru.betterend.util.MHelper; public class LanceleafBlock extends EndPlantBlock { public static final EnumProperty SHAPE = BlockProperties.PENTA_SHAPE; - public static final IntProperty ROTATION = BlockProperties.ROTATION; - + public static final IntegerProperty ROTATION = BlockProperties.ROTATION; + public LanceleafBlock() { super(); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(SHAPE, ROTATION); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - PentaShape shape = state.get(SHAPE); + PentaShape shape = state.getValue(SHAPE); if (shape == PentaShape.TOP) { - return world.getBlockState(pos.down()).isOf(this); - } - else if (shape == PentaShape.BOTTOM) { - return world.getBlockState(pos.down()).isOf(EndBlocks.AMBER_MOSS) && world.getBlockState(pos.up()).isOf(this); - } - else { - return world.getBlockState(pos.down()).isOf(this) && world.getBlockState(pos.up()).isOf(this); + return world.getBlockState(pos.below()).is(this); + } else if (shape == PentaShape.BOTTOM) { + return world.getBlockState(pos.below()).is(EndBlocks.AMBER_MOSS) && world.getBlockState(pos.up()).is(this); + } else { + return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.up()).is(this); } } - + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (!canPlaceAt(state, world, pos)) { - return Blocks.AIR.getDefaultState(); - } - else { + return Blocks.AIR.defaultBlockState(); + } else { return state; } } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - if (state.get(SHAPE) == PentaShape.BOTTOM) { + public List getDrops(BlockState state, LootContext.Builder builder) { + if (state.getValue(SHAPE) == PentaShape.BOTTOM) { return Collections.singletonList(new ItemStack(EndBlocks.LANCELEAF_SEED)); } - return MHelper.RANDOM.nextBoolean() ? Collections.emptyList() : Collections.singletonList(new ItemStack(EndBlocks.LANCELEAF_SEED)); + return MHelper.RANDOM.nextBoolean() ? Collections.emptyList() + : Collections.singletonList(new ItemStack(EndBlocks.LANCELEAF_SEED)); } } diff --git a/src/main/java/ru/betterend/blocks/LanceleafSeedBlock.java b/src/main/java/ru/betterend/blocks/LanceleafSeedBlock.java index 182519aa..8f0ca538 100644 --- a/src/main/java/ru/betterend/blocks/LanceleafSeedBlock.java +++ b/src/main/java/ru/betterend/blocks/LanceleafSeedBlock.java @@ -2,11 +2,11 @@ package ru.betterend.blocks; import java.util.Random; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.BlockProperties.PentaShape; import ru.betterend.blocks.basis.EndPlantWithAgeBlock; @@ -23,22 +23,26 @@ public class LanceleafSeedBlock extends EndPlantWithAgeBlock { return; } int rotation = random.nextInt(4); - Mutable mut = new Mutable().set(pos); - BlockState plant = EndBlocks.LANCELEAF.getDefaultState().with(BlockProperties.ROTATION, rotation); + MutableBlockPos mut = new MutableBlockPos().set(pos); + BlockState plant = EndBlocks.LANCELEAF.defaultBlockState().with(BlockProperties.ROTATION, rotation); BlocksHelper.setWithoutUpdate(world, mut, plant.with(BlockProperties.PENTA_SHAPE, PentaShape.BOTTOM)); - BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.with(BlockProperties.PENTA_SHAPE, PentaShape.PRE_BOTTOM)); + BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), + plant.with(BlockProperties.PENTA_SHAPE, PentaShape.PRE_BOTTOM)); for (int i = 2; i < height - 2; i++) { - BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.with(BlockProperties.PENTA_SHAPE, PentaShape.MIDDLE)); + BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), + plant.with(BlockProperties.PENTA_SHAPE, PentaShape.MIDDLE)); } - BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.with(BlockProperties.PENTA_SHAPE, PentaShape.PRE_TOP)); - BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.with(BlockProperties.PENTA_SHAPE, PentaShape.TOP)); + BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), + plant.with(BlockProperties.PENTA_SHAPE, PentaShape.PRE_TOP)); + BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), + plant.with(BlockProperties.PENTA_SHAPE, PentaShape.TOP)); } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.AMBER_MOSS); + return state.is(EndBlocks.AMBER_MOSS); } - + @Override public AbstractBlock.OffsetType getOffsetType() { return AbstractBlock.OffsetType.NONE; diff --git a/src/main/java/ru/betterend/blocks/LargeAmaranitaBlock.java b/src/main/java/ru/betterend/blocks/LargeAmaranitaBlock.java index 35b14b54..fac9f8d2 100644 --- a/src/main/java/ru/betterend/blocks/LargeAmaranitaBlock.java +++ b/src/main/java/ru/betterend/blocks/LargeAmaranitaBlock.java @@ -4,18 +4,18 @@ import java.util.Random; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.EnumProperty; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraft.world.WorldView; import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.blocks.basis.EndPlantBlock; @@ -24,57 +24,55 @@ import ru.betterend.registry.EndBlocks; public class LargeAmaranitaBlock extends EndPlantBlock { public static final EnumProperty SHAPE = BlockProperties.TRIPLE_SHAPE; private static final VoxelShape SHAPE_BOTTOM = Block.createCuboidShape(4, 0, 4, 12, 14, 12); - private static final VoxelShape SHAPE_TOP = VoxelShapes.union(Block.createCuboidShape(1, 3, 1, 15, 16, 15), SHAPE_BOTTOM); - + private static final VoxelShape SHAPE_TOP = VoxelShapes.union(Block.createCuboidShape(1, 3, 1, 15, 16, 15), + SHAPE_BOTTOM); + public LargeAmaranitaBlock() { super(FabricBlockSettings.of(Material.PLANT) - .luminance((state) -> (state.get(SHAPE) == TripleShape.TOP) ? 15 : 0) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.GRASS) - .breakByHand(true)); + .luminance((state) -> (state.getValue(SHAPE) == TripleShape.TOP) ? 15 : 0) + .breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS).breakByHand(true)); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return state.get(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM; + return state.getValue(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM; } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.SANGNUM) || state.isOf(EndBlocks.MOSSY_OBSIDIAN) || state.isOf(EndBlocks.MOSSY_DRAGON_BONE); + return state.is(EndBlocks.SANGNUM) || state.is(EndBlocks.MOSSY_OBSIDIAN) + || state.is(EndBlocks.MOSSY_DRAGON_BONE); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(SHAPE); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - TripleShape shape = state.get(SHAPE); + TripleShape shape = state.getValue(SHAPE); if (shape == TripleShape.BOTTOM) { - return isTerrain(world.getBlockState(pos.down())) && world.getBlockState(pos.up()).isOf(this); - } - else if (shape == TripleShape.TOP) { - return world.getBlockState(pos.down()).isOf(this); - } - else { - return world.getBlockState(pos.down()).isOf(this) && world.getBlockState(pos.up()).isOf(this); + return isTerrain(world.getBlockState(pos.below())) && world.getBlockState(pos.up()).is(this); + } else if (shape == TripleShape.TOP) { + return world.getBlockState(pos.below()).is(this); + } else { + return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.up()).is(this); } } - + @Override public OffsetType getOffsetType() { return OffsetType.NONE; } - + @Override public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { return false; } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { return false; } } diff --git a/src/main/java/ru/betterend/blocks/LumecornBlock.java b/src/main/java/ru/betterend/blocks/LumecornBlock.java index 0fd64805..a1ccdd25 100644 --- a/src/main/java/ru/betterend/blocks/LumecornBlock.java +++ b/src/main/java/ru/betterend/blocks/LumecornBlock.java @@ -7,20 +7,20 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.EnumProperty; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.blocks.BlockProperties.LumecornShape; import ru.betterend.blocks.basis.BlockBaseNotFull; @@ -35,18 +35,16 @@ public class LumecornBlock extends BlockBaseNotFull implements IRenderTypeable { public static final EnumProperty SHAPE = EnumProperty.of("shape", LumecornShape.class); private static final VoxelShape SHAPE_BOTTOM = Block.createCuboidShape(6, 0, 6, 10, 16, 10); private static final VoxelShape SHAPE_TOP = Block.createCuboidShape(6, 0, 6, 10, 8, 10); - + public LumecornBlock() { - super(FabricBlockSettings.of(Material.WOOD) - .breakByTool(FabricToolTags.AXES) - .hardness(0.5F) + super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).hardness(0.5F) .luminance((state) -> { - return state.get(SHAPE).getLight(); - })); + return state.getValue(SHAPE).getLight(); + })); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(SHAPE); } @@ -54,49 +52,49 @@ public class LumecornBlock extends BlockBaseNotFull implements IRenderTypeable { public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return state.get(SHAPE) == LumecornShape.LIGHT_TOP ? SHAPE_TOP : SHAPE_BOTTOM; + return state.getValue(SHAPE) == LumecornShape.LIGHT_TOP ? SHAPE_TOP : SHAPE_BOTTOM; } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - LumecornShape shape = state.get(SHAPE); + LumecornShape shape = state.getValue(SHAPE); if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL) { - return world.getBlockState(pos.down()).isIn(EndTags.END_GROUND); - } - else if (shape == LumecornShape.LIGHT_TOP) { - return world.getBlockState(pos.down()).isOf(this); - } - else { - return world.getBlockState(pos.down()).isOf(this) && world.getBlockState(pos.up()).isOf(this); + return world.getBlockState(pos.below()).isIn(EndTags.END_GROUND); + } else if (shape == LumecornShape.LIGHT_TOP) { + return world.getBlockState(pos.below()).is(this); + } else { + return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.up()).is(this); } } - + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (!canPlaceAt(state, world, pos)) { - return Blocks.AIR.getDefaultState(); - } - else { + return Blocks.AIR.defaultBlockState(); + } else { return state; } } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - LumecornShape shape = state.get(SHAPE); + public List getDrops(BlockState state, LootContext.Builder builder) { + LumecornShape shape = state.getValue(SHAPE); if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL || shape == LumecornShape.MIDDLE) { - return Collections.singletonList(new ItemStack(EndBlocks.LUMECORN_SEED, MHelper.randRange(1, 2, MHelper.RANDOM))); + return Collections + .singletonList(new ItemStack(EndBlocks.LUMECORN_SEED, MHelper.randRange(1, 2, MHelper.RANDOM))); } - return MHelper.RANDOM.nextBoolean() ? Collections.singletonList(new ItemStack(EndItems.LUMECORN_ROD)) : Collections.emptyList(); + return MHelper.RANDOM.nextBoolean() ? Collections.singletonList(new ItemStack(EndItems.LUMECORN_ROD)) + : Collections.emptyList(); } - + @Override @Environment(EnvType.CLIENT) public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { - LumecornShape shape = state.get(SHAPE); + LumecornShape shape = state.getValue(SHAPE); if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL || shape == LumecornShape.MIDDLE) { return new ItemStack(EndBlocks.LUMECORN_SEED); } diff --git a/src/main/java/ru/betterend/blocks/LumecornSeedBlock.java b/src/main/java/ru/betterend/blocks/LumecornSeedBlock.java index de06b251..85b05d0e 100644 --- a/src/main/java/ru/betterend/blocks/LumecornSeedBlock.java +++ b/src/main/java/ru/betterend/blocks/LumecornSeedBlock.java @@ -2,9 +2,9 @@ package ru.betterend.blocks; import java.util.Random; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.basis.EndPlantWithAgeBlock; import ru.betterend.registry.EndBlocks; @@ -15,12 +15,12 @@ public class LumecornSeedBlock extends EndPlantWithAgeBlock { public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) { EndFeatures.LUMECORN.getFeature().generate(world, null, random, pos, null); } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.END_MOSS); + return state.is(EndBlocks.END_MOSS); } - + @Override public AbstractBlock.OffsetType getOffsetType() { return AbstractBlock.OffsetType.NONE; diff --git a/src/main/java/ru/betterend/blocks/MengerSpongeBlock.java b/src/main/java/ru/betterend/blocks/MengerSpongeBlock.java index abefc6e1..9d18449a 100644 --- a/src/main/java/ru/betterend/blocks/MengerSpongeBlock.java +++ b/src/main/java/ru/betterend/blocks/MengerSpongeBlock.java @@ -5,20 +5,20 @@ import java.util.Queue; import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FluidBlock; -import net.minecraft.block.FluidDrainable; -import net.minecraft.block.Material; -import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FluidBlock; +import net.minecraft.world.level.block.FluidDrainable; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.tag.FluidTags; +import net.minecraft.tags.FluidTags; import net.minecraft.util.Pair; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import ru.betterend.blocks.basis.BlockBaseNotFull; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; @@ -28,23 +28,24 @@ public class MengerSpongeBlock extends BlockBaseNotFull implements IRenderTypeab public MengerSpongeBlock() { super(FabricBlockSettings.copyOf(Blocks.SPONGE).nonOpaque()); } - + @Override - public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) { + public void onBlockAdded(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { if (absorbWater(world, pos)) { - world.setBlockState(pos, EndBlocks.MENGER_SPONGE_WET.getDefaultState()); + world.setBlockAndUpdate(pos, EndBlocks.MENGER_SPONGE_WET.defaultBlockState()); } } - + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (absorbWater(world, pos)) { - return EndBlocks.MENGER_SPONGE_WET.getDefaultState(); + return EndBlocks.MENGER_SPONGE_WET.defaultBlockState(); } return state; } - private boolean absorbWater(WorldAccess world, BlockPos pos) { + private boolean absorbWater(LevelAccessor world, BlockPos pos) { Queue> queue = Lists.newLinkedList(); queue.add(new Pair(pos, 0)); int i = 0; @@ -63,23 +64,25 @@ public class MengerSpongeBlock extends BlockBaseNotFull implements IRenderTypeab FluidState fluidState = world.getFluidState(blockPos2); Material material = blockState.getMaterial(); if (fluidState.isIn(FluidTags.WATER)) { - if (blockState.getBlock() instanceof FluidDrainable && ((FluidDrainable) blockState.getBlock()).tryDrainFluid(world, blockPos2, blockState) != Fluids.EMPTY) { + if (blockState.getBlock() instanceof FluidDrainable && ((FluidDrainable) blockState.getBlock()) + .tryDrainFluid(world, blockPos2, blockState) != Fluids.EMPTY) { ++i; if (j < 6) { queue.add(new Pair(blockPos2, j + 1)); } - } - else if (blockState.getBlock() instanceof FluidBlock) { - world.setBlockState(blockPos2, Blocks.AIR.getDefaultState(), 3); + } else if (blockState.getBlock() instanceof FluidBlock) { + world.setBlockAndUpdate(blockPos2, Blocks.AIR.defaultBlockState(), 3); ++i; if (j < 6) { queue.add(new Pair(blockPos2, j + 1)); } - } - else if (material == Material.UNDERWATER_PLANT || material == Material.REPLACEABLE_UNDERWATER_PLANT) { - BlockEntity blockEntity = blockState.getBlock().hasBlockEntity() ? world.getBlockEntity(blockPos2) : null; + } else if (material == Material.UNDERWATER_PLANT + || material == Material.REPLACEABLE_UNDERWATER_PLANT) { + BlockEntity blockEntity = blockState.getBlock().hasBlockEntity() + ? world.getBlockEntity(blockPos2) + : null; dropStacks(blockState, world, blockPos2, blockEntity); - world.setBlockState(blockPos2, Blocks.AIR.getDefaultState(), 3); + world.setBlockAndUpdate(blockPos2, Blocks.AIR.defaultBlockState(), 3); ++i; if (j < 6) { queue.add(new Pair(blockPos2, j + 1)); @@ -95,7 +98,7 @@ public class MengerSpongeBlock extends BlockBaseNotFull implements IRenderTypeab return i > 0; } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; diff --git a/src/main/java/ru/betterend/blocks/MengerSpongeWetBlock.java b/src/main/java/ru/betterend/blocks/MengerSpongeWetBlock.java index 81ecce04..98c0e68b 100644 --- a/src/main/java/ru/betterend/blocks/MengerSpongeWetBlock.java +++ b/src/main/java/ru/betterend/blocks/MengerSpongeWetBlock.java @@ -5,20 +5,20 @@ import java.util.Random; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.ItemEntity; +import net.minecraft.world.entity.player.PlayerEntity; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.item.ItemStack; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.GameRules; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.blocks.basis.BlockBaseNotFull; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; @@ -31,20 +31,21 @@ public class MengerSpongeWetBlock extends BlockBaseNotFull implements IRenderTyp } @Override - public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) { + public void onBlockAdded(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { if (world.getDimension().isUltrawarm()) { - world.setBlockState(pos, EndBlocks.MENGER_SPONGE.getDefaultState(), 3); + world.setBlockAndUpdate(pos, EndBlocks.MENGER_SPONGE.defaultBlockState(), 3); world.syncWorldEvent(2009, pos, 0); - world.playSound((PlayerEntity) null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 1.0F, (1.0F + world.getRandom().nextFloat() * 0.2F) * 0.7F); + world.playLocalSound((PlayerEntity) null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundSource.BLOCKS, 1.0F, + (1.0F + world.getRandom().nextFloat() * 0.2F) * 0.7F); } } @Override @Environment(EnvType.CLIENT) - public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { + public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { Direction direction = Direction.random(random); if (direction != Direction.UP) { - BlockPos blockPos = pos.offset(direction); + BlockPos blockPos = pos.relative(direction); BlockState blockState = world.getBlockState(blockPos); if (!state.isOpaque() || !blockState.isSideSolidFullSquare(world, blockPos, direction.getOpposite())) { double x = (double) pos.getX(); @@ -54,24 +55,20 @@ public class MengerSpongeWetBlock extends BlockBaseNotFull implements IRenderTyp y -= 0.05; x += random.nextDouble(); z += random.nextDouble(); - } - else { + } else { y += random.nextDouble() * 0.8; if (direction.getAxis() == Direction.Axis.X) { z += random.nextDouble(); if (direction == Direction.EAST) { ++x; - } - else { + } else { x += 0.05; } - } - else { + } else { x += random.nextDouble(); if (direction == Direction.SOUTH) { ++z; - } - else { + } else { z += 0.05; } } @@ -83,22 +80,23 @@ public class MengerSpongeWetBlock extends BlockBaseNotFull implements IRenderTyp } @Override - public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) { + public void onBreak(Level world, BlockPos pos, BlockState state, PlayerEntity player) { BlocksHelper.setWithUpdate(world, pos, Blocks.AIR); - if (!world.isClient()) { + if (!world.isClientSide()) { world.syncWorldEvent(2001, pos, getRawIdFromState(state)); } if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS) && (player == null || !player.isCreative())) { - ItemEntity drop = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(this)); + ItemEntity drop = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, + new ItemStack(this)); world.spawnEntity(drop); } } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override public FluidState getFluidState(BlockState state) { return Fluids.WATER.getStill(false); diff --git a/src/main/java/ru/betterend/blocks/MissingTileBlock.java b/src/main/java/ru/betterend/blocks/MissingTileBlock.java index 1e361549..a9c7eb5e 100644 --- a/src/main/java/ru/betterend/blocks/MissingTileBlock.java +++ b/src/main/java/ru/betterend/blocks/MissingTileBlock.java @@ -1,7 +1,7 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import ru.betterend.blocks.basis.BlockBase; public class MissingTileBlock extends BlockBase { diff --git a/src/main/java/ru/betterend/blocks/MossyDragonBoneBlock.java b/src/main/java/ru/betterend/blocks/MossyDragonBoneBlock.java index 35e7f49d..fe928885 100644 --- a/src/main/java/ru/betterend/blocks/MossyDragonBoneBlock.java +++ b/src/main/java/ru/betterend/blocks/MossyDragonBoneBlock.java @@ -5,17 +5,17 @@ import java.util.List; import java.util.Random; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.SnowBlock; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SnowBlock; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.WorldView; import net.minecraft.world.chunk.light.ChunkLightProvider; import ru.betterend.blocks.basis.EndPillarBlock; @@ -25,33 +25,34 @@ public class MossyDragonBoneBlock extends EndPillarBlock { public MossyDragonBoneBlock() { super(FabricBlockSettings.copyOf(Blocks.BONE_BLOCK).hardness(0.5F).ticksRandomly()); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Collections.singletonList(new ItemStack(this)); } return Collections.singletonList(new ItemStack(EndBlocks.DRAGON_BONE_BLOCK)); } - + @Override - public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) { - world.setBlockState(pos, Blocks.BONE_BLOCK.getDefaultState().with(AXIS, state.get(AXIS))); + world.setBlockAndUpdate(pos, Blocks.BONE_BLOCK.defaultBlockState().with(AXIS, state.getValue(AXIS))); } } - + public static boolean canSurvive(BlockState state, WorldView worldView, BlockPos pos) { - BlockPos blockPos = pos.up(); - BlockState blockState = worldView.getBlockState(blockPos); - if (blockState.isOf(Blocks.SNOW) && (Integer)blockState.get(SnowBlock.LAYERS) == 1) { - return true; - } else if (blockState.getFluidState().getLevel() == 8) { - return false; - } else { - int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getOpacity(worldView, blockPos)); - return i < 5; - } - } + BlockPos blockPos = pos.up(); + BlockState blockState = worldView.getBlockState(blockPos); + if (blockState.is(Blocks.SNOW) && (Integer) blockState.get(SnowBlock.LAYERS) == 1) { + return true; + } else if (blockState.getFluidState().getLevel() == 8) { + return false; + } else { + int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP, + blockState.getOpacity(worldView, blockPos)); + return i < 5; + } + } } diff --git a/src/main/java/ru/betterend/blocks/MossyGlowshroomCapBlock.java b/src/main/java/ru/betterend/blocks/MossyGlowshroomCapBlock.java index 7f635583..bec58eb8 100644 --- a/src/main/java/ru/betterend/blocks/MossyGlowshroomCapBlock.java +++ b/src/main/java/ru/betterend/blocks/MossyGlowshroomCapBlock.java @@ -2,29 +2,30 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.registry.EndBlocks; public class MossyGlowshroomCapBlock extends BlockBase { public static final BooleanProperty TRANSITION = BlockProperties.TRANSITION; - + public MossyGlowshroomCapBlock() { - super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WOOD)); - this.setDefaultState(this.stateManager.getDefaultState().with(TRANSITION, false)); - } - - public BlockState getPlacementState(ItemPlacementContext ctx) { - return this.getDefaultState().with(TRANSITION, EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(ctx.getWorld().getBlockState(ctx.getBlockPos().down()))); + super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(SoundType.WOOD)); + this.setDefaultState(this.stateManager.defaultBlockState().with(TRANSITION, false)); } - protected void appendProperties(StateManager.Builder builder) { + public BlockState getPlacementState(ItemPlacementContext ctx) { + return this.defaultBlockState().with(TRANSITION, + EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(ctx.getLevel().getBlockState(ctx.getBlockPos().below()))); + } + + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(TRANSITION); } } diff --git a/src/main/java/ru/betterend/blocks/MossyGlowshroomSaplingBlock.java b/src/main/java/ru/betterend/blocks/MossyGlowshroomSaplingBlock.java index 24c1ffff..e6d6330e 100644 --- a/src/main/java/ru/betterend/blocks/MossyGlowshroomSaplingBlock.java +++ b/src/main/java/ru/betterend/blocks/MossyGlowshroomSaplingBlock.java @@ -1,7 +1,7 @@ package ru.betterend.blocks; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; import net.minecraft.world.WorldView; import net.minecraft.world.gen.feature.Feature; import ru.betterend.blocks.basis.FeatureSaplingBlock; @@ -17,9 +17,10 @@ public class MossyGlowshroomSaplingBlock extends FeatureSaplingBlock { protected Feature getFeature() { return EndFeatures.MOSSY_GLOWSHROOM.getFeature(); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - return world.getBlockState(pos.down()).isOf(EndBlocks.END_MOSS) || world.getBlockState(pos.down()).isOf(EndBlocks.END_MYCELIUM); + return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS) + || world.getBlockState(pos.below()).is(EndBlocks.END_MYCELIUM); } } diff --git a/src/main/java/ru/betterend/blocks/MossyObsidian.java b/src/main/java/ru/betterend/blocks/MossyObsidian.java index 2122c64e..ecb15503 100644 --- a/src/main/java/ru/betterend/blocks/MossyObsidian.java +++ b/src/main/java/ru/betterend/blocks/MossyObsidian.java @@ -5,17 +5,17 @@ import java.util.List; import java.util.Random; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.SnowBlock; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SnowBlock; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.WorldView; import net.minecraft.world.chunk.light.ChunkLightProvider; import ru.betterend.blocks.basis.BlockBase; @@ -24,33 +24,34 @@ public class MossyObsidian extends BlockBase { public MossyObsidian() { super(FabricBlockSettings.copyOf(Blocks.OBSIDIAN).hardness(3).ticksRandomly()); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Collections.singletonList(new ItemStack(this)); } return Collections.singletonList(new ItemStack(Blocks.OBSIDIAN)); } - + @Override - public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) { - world.setBlockState(pos, Blocks.OBSIDIAN.getDefaultState()); + world.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState()); } } - + public static boolean canSurvive(BlockState state, WorldView worldView, BlockPos pos) { - BlockPos blockPos = pos.up(); - BlockState blockState = worldView.getBlockState(blockPos); - if (blockState.isOf(Blocks.SNOW) && (Integer)blockState.get(SnowBlock.LAYERS) == 1) { - return true; - } else if (blockState.getFluidState().getLevel() == 8) { - return false; - } else { - int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getOpacity(worldView, blockPos)); - return i < 5; - } - } + BlockPos blockPos = pos.up(); + BlockState blockState = worldView.getBlockState(blockPos); + if (blockState.is(Blocks.SNOW) && (Integer) blockState.get(SnowBlock.LAYERS) == 1) { + return true; + } else if (blockState.getFluidState().getLevel() == 8) { + return false; + } else { + int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP, + blockState.getOpacity(worldView, blockPos)); + return i < 5; + } + } } diff --git a/src/main/java/ru/betterend/blocks/MurkweedBlock.java b/src/main/java/ru/betterend/blocks/MurkweedBlock.java index 6dac38de..f2c7f8b8 100644 --- a/src/main/java/ru/betterend/blocks/MurkweedBlock.java +++ b/src/main/java/ru/betterend/blocks/MurkweedBlock.java @@ -4,42 +4,42 @@ import java.util.Random; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.ai.pathing.NavigationType; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.pathing.NavigationType; +import net.minecraft.world.entity.effect.StatusEffectInstance; +import net.minecraft.world.entity.effect.StatusEffects; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.registry.EndBlocks; public class MurkweedBlock extends EndPlantBlock { @Override @Environment(EnvType.CLIENT) - public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { + public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { double x = pos.getX() + random.nextDouble(); double y = pos.getY() + random.nextDouble() * 0.5 + 0.5; double z = pos.getZ() + random.nextDouble(); double v = random.nextDouble() * 0.1; world.addParticle(ParticleTypes.ENTITY_EFFECT, x, y, z, v, v, v); } - + @Override - public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { + public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { if (entity instanceof LivingEntity && !((LivingEntity) entity).hasStatusEffect(StatusEffects.BLINDNESS)) { ((LivingEntity) entity).addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 50)); } } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.SHADOW_GRASS); + return state.is(EndBlocks.SHADOW_GRASS); } - + @Override public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) { return false; diff --git a/src/main/java/ru/betterend/blocks/NeedlegrassBlock.java b/src/main/java/ru/betterend/blocks/NeedlegrassBlock.java index e55699eb..1b5f83dd 100644 --- a/src/main/java/ru/betterend/blocks/NeedlegrassBlock.java +++ b/src/main/java/ru/betterend/blocks/NeedlegrassBlock.java @@ -5,46 +5,46 @@ import java.util.List; import com.google.common.collect.Lists; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.BlockState; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.ai.pathing.NavigationType; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.pathing.NavigationType; +import net.minecraft.world.entity.damage.DamageSource; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.registry.EndBlocks; import ru.betterend.util.MHelper; public class NeedlegrassBlock extends EndPlantBlock { @Override - public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { + public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { if (entity instanceof LivingEntity) { entity.damage(DamageSource.CACTUS, 0.1F); } } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) + || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Lists.newArrayList(new ItemStack(this)); - } - else { + } else { return Lists.newArrayList(new ItemStack(Items.STICK, MHelper.randRange(0, 2, MHelper.RANDOM))); } } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.SHADOW_GRASS); + return state.is(EndBlocks.SHADOW_GRASS); } @Override diff --git a/src/main/java/ru/betterend/blocks/NeonCactusBlock.java b/src/main/java/ru/betterend/blocks/NeonCactusBlock.java index b746f5a6..eb3cb7e0 100644 --- a/src/main/java/ru/betterend/blocks/NeonCactusBlock.java +++ b/src/main/java/ru/betterend/blocks/NeonCactusBlock.java @@ -5,28 +5,28 @@ import java.util.EnumMap; import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ShapeContext; -import net.minecraft.block.Waterloggable; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.level.block.Waterloggable; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.state.StateManager; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.EnumProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Direction.Axis; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.blocks.basis.BlockBaseNotFull; import ru.betterend.client.render.ERenderLayer; @@ -37,37 +37,40 @@ public class NeonCactusBlock extends BlockBaseNotFull implements Waterloggable, public static final EnumProperty SHAPE = BlockProperties.TRIPLE_SHAPE; public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; public static final DirectionProperty FACING = Properties.FACING; - + private static final EnumMap MEDIUM_SHAPES_OPEN = Maps.newEnumMap(Direction.class); private static final EnumMap SMALL_SHAPES_OPEN = Maps.newEnumMap(Direction.class); private static final EnumMap MEDIUM_SHAPES = Maps.newEnumMap(Axis.class); private static final EnumMap SMALL_SHAPES = Maps.newEnumMap(Axis.class); - + public NeonCactusBlock() { super(FabricBlockSettings.copyOf(Blocks.CACTUS).luminance(state -> { - TripleShape shape = state.get(SHAPE); + TripleShape shape = state.getValue(SHAPE); if (shape == TripleShape.TOP) { return 15; } return shape == TripleShape.MIDDLE ? 13 : 10; })); - setDefaultState(getDefaultState().with(WATERLOGGED, false).with(FACING, Direction.UP).with(SHAPE, TripleShape.TOP)); + setDefaultState( + getDefaultState().with(WATERLOGGED, false).with(FACING, Direction.UP).with(SHAPE, TripleShape.TOP)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(SHAPE, WATERLOGGED, FACING); } - + @Override public BlockState getPlacementState(ItemPlacementContext ctx) { - WorldAccess worldAccess = ctx.getWorld(); + LevelAccessor worldAccess = ctx.getLevel(); BlockPos blockPos = ctx.getBlockPos(); - return this.getDefaultState().with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER).with(FACING, ctx.getSide()); + return this.defaultBlockState() + .with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER) + .with(FACING, ctx.getSide()); } - + @Override - public BlockState rotate(BlockState state, BlockRotation rotation) { + public BlockState rotate(BlockState state, Rotation rotation) { return BlocksHelper.rotateHorizontal(state, rotation, FACING); } @@ -75,64 +78,64 @@ public class NeonCactusBlock extends BlockBaseNotFull implements Waterloggable, public BlockState mirror(BlockState state, BlockMirror mirror) { return BlocksHelper.mirrorHorizontal(state, mirror, FACING); } - + @Override public FluidState getFluidState(BlockState state) { - return (Boolean) state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); + return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); } - + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) { - if ((Boolean) state.get(WATERLOGGED)) { + public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, + BlockPos pos, BlockPos posFrom) { + if ((Boolean) state.getValue(WATERLOGGED)) { world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } return state; } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - TripleShape shape = state.get(SHAPE); - + TripleShape shape = state.getValue(SHAPE); + if (shape == TripleShape.BOTTOM) { return VoxelShapes.fullCube(); } - Direction dir = state.get(FACING); - BlockState next = view.getBlockState(pos.offset(dir)); - if (next.isOf(this)) { + Direction dir = state.getValue(FACING); + BlockState next = view.getBlockState(pos.relative(dir)); + if (next.is(this)) { Axis axis = dir.getAxis(); return shape == TripleShape.MIDDLE ? MEDIUM_SHAPES.get(axis) : SMALL_SHAPES.get(axis); - } - else { + } else { return shape == TripleShape.MIDDLE ? MEDIUM_SHAPES_OPEN.get(dir) : SMALL_SHAPES_OPEN.get(dir); } } - + static { MEDIUM_SHAPES.put(Axis.X, Block.createCuboidShape(0, 2, 2, 16, 14, 14)); MEDIUM_SHAPES.put(Axis.Y, Block.createCuboidShape(2, 0, 2, 14, 16, 14)); MEDIUM_SHAPES.put(Axis.Z, Block.createCuboidShape(2, 2, 0, 14, 14, 16)); - + SMALL_SHAPES.put(Axis.X, Block.createCuboidShape(0, 4, 4, 16, 12, 12)); SMALL_SHAPES.put(Axis.Y, Block.createCuboidShape(4, 0, 4, 12, 16, 12)); SMALL_SHAPES.put(Axis.Z, Block.createCuboidShape(4, 4, 0, 12, 12, 16)); - - MEDIUM_SHAPES_OPEN.put(Direction.UP, Block.createCuboidShape(2, 0, 2, 14, 14, 14)); - MEDIUM_SHAPES_OPEN.put(Direction.DOWN, Block.createCuboidShape(2, 2, 2, 14, 16, 14)); + + MEDIUM_SHAPES_OPEN.put(Direction.UP, Block.createCuboidShape(2, 0, 2, 14, 14, 14)); + MEDIUM_SHAPES_OPEN.put(Direction.DOWN, Block.createCuboidShape(2, 2, 2, 14, 16, 14)); MEDIUM_SHAPES_OPEN.put(Direction.NORTH, Block.createCuboidShape(2, 2, 2, 14, 14, 16)); MEDIUM_SHAPES_OPEN.put(Direction.SOUTH, Block.createCuboidShape(2, 2, 0, 14, 14, 14)); - MEDIUM_SHAPES_OPEN.put(Direction.WEST, Block.createCuboidShape(2, 2, 2, 16, 14, 14)); - MEDIUM_SHAPES_OPEN.put(Direction.EAST, Block.createCuboidShape(0, 2, 2, 14, 14, 14)); - - SMALL_SHAPES_OPEN.put(Direction.UP, Block.createCuboidShape(4, 0, 4, 12, 12, 12)); - SMALL_SHAPES_OPEN.put(Direction.DOWN, Block.createCuboidShape(4, 4, 4, 12, 16, 12)); + MEDIUM_SHAPES_OPEN.put(Direction.WEST, Block.createCuboidShape(2, 2, 2, 16, 14, 14)); + MEDIUM_SHAPES_OPEN.put(Direction.EAST, Block.createCuboidShape(0, 2, 2, 14, 14, 14)); + + SMALL_SHAPES_OPEN.put(Direction.UP, Block.createCuboidShape(4, 0, 4, 12, 12, 12)); + SMALL_SHAPES_OPEN.put(Direction.DOWN, Block.createCuboidShape(4, 4, 4, 12, 16, 12)); SMALL_SHAPES_OPEN.put(Direction.NORTH, Block.createCuboidShape(4, 4, 4, 12, 12, 16)); SMALL_SHAPES_OPEN.put(Direction.SOUTH, Block.createCuboidShape(4, 4, 0, 12, 12, 12)); - SMALL_SHAPES_OPEN.put(Direction.WEST, Block.createCuboidShape(4, 4, 4, 16, 12, 12)); - SMALL_SHAPES_OPEN.put(Direction.EAST, Block.createCuboidShape(0, 4, 4, 12, 12, 12)); + SMALL_SHAPES_OPEN.put(Direction.WEST, Block.createCuboidShape(4, 4, 4, 16, 12, 12)); + SMALL_SHAPES_OPEN.put(Direction.EAST, Block.createCuboidShape(0, 4, 4, 12, 12, 12)); } } diff --git a/src/main/java/ru/betterend/blocks/PedestalVanilla.java b/src/main/java/ru/betterend/blocks/PedestalVanilla.java index b7848ce1..a25460c1 100644 --- a/src/main/java/ru/betterend/blocks/PedestalVanilla.java +++ b/src/main/java/ru/betterend/blocks/PedestalVanilla.java @@ -3,9 +3,9 @@ package ru.betterend.blocks; import java.util.HashMap; import java.util.Map; -import net.minecraft.block.Block; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.blocks.basis.PedestalBlock; import ru.betterend.patterns.Patterns; @@ -14,15 +14,15 @@ public class PedestalVanilla extends PedestalBlock { public PedestalVanilla(Block parent) { super(parent); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(parent); String name = blockId.getPath().replace("_block", ""); Map textures = new HashMap() { private static final long serialVersionUID = 1L; { - put("%mod%", blockId.getNamespace() ); + put("%mod%", blockId.getNamespace()); put("%top%", "polished_" + name); put("%base%", "polished_" + name); put("%pillar%", name + "_pillar"); diff --git a/src/main/java/ru/betterend/blocks/PythadendronSaplingBlock.java b/src/main/java/ru/betterend/blocks/PythadendronSaplingBlock.java index 40926215..fbb7dddd 100644 --- a/src/main/java/ru/betterend/blocks/PythadendronSaplingBlock.java +++ b/src/main/java/ru/betterend/blocks/PythadendronSaplingBlock.java @@ -1,7 +1,7 @@ package ru.betterend.blocks; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; import net.minecraft.world.WorldView; import net.minecraft.world.gen.feature.Feature; import ru.betterend.blocks.basis.FeatureSaplingBlock; @@ -17,9 +17,9 @@ public class PythadendronSaplingBlock extends FeatureSaplingBlock { protected Feature getFeature() { return EndFeatures.PYTHADENDRON_TREE.getFeature(); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - return world.getBlockState(pos.down()).isOf(EndBlocks.CHORUS_NYLIUM); + return world.getBlockState(pos.below()).is(EndBlocks.CHORUS_NYLIUM); } } diff --git a/src/main/java/ru/betterend/blocks/RespawnObeliskBlock.java b/src/main/java/ru/betterend/blocks/RespawnObeliskBlock.java index 269ddc43..c69410ab 100644 --- a/src/main/java/ru/betterend/blocks/RespawnObeliskBlock.java +++ b/src/main/java/ru/betterend/blocks/RespawnObeliskBlock.java @@ -7,33 +7,33 @@ import org.jetbrains.annotations.Nullable; import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ShapeContext; -import net.minecraft.client.color.block.BlockColorProvider; -import net.minecraft.client.color.item.ItemColorProvider; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.client.color.block.BlockColor; +import net.minecraft.client.color.item.ItemColor; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.EnumProperty; import net.minecraft.text.TranslatableText; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.blocks.basis.BlockBase; @@ -49,25 +49,25 @@ import ru.betterend.util.MHelper; public class RespawnObeliskBlock extends BlockBase implements IColorProvider, IRenderTypeable { private static final VoxelShape VOXEL_SHAPE_BOTTOM = Block.createCuboidShape(1, 0, 1, 15, 16, 15); private static final VoxelShape VOXEL_SHAPE_MIDDLE_TOP = Block.createCuboidShape(2, 0, 2, 14, 16, 14); - + public static final EnumProperty SHAPE = BlockProperties.TRIPLE_SHAPE; - + public RespawnObeliskBlock() { super(FabricBlockSettings.copyOf(Blocks.END_STONE).luminance((state) -> { - return (state.get(SHAPE) == TripleShape.BOTTOM) ? 0 : 15; + return (state.getValue(SHAPE) == TripleShape.BOTTOM) ? 0 : 15; })); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return (state.get(SHAPE) == TripleShape.BOTTOM) ? VOXEL_SHAPE_BOTTOM : VOXEL_SHAPE_MIDDLE_TOP; + return (state.getValue(SHAPE) == TripleShape.BOTTOM) ? VOXEL_SHAPE_BOTTOM : VOXEL_SHAPE_MIDDLE_TOP; } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(SHAPE); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { for (int i = 0; i < 3; i++) { @@ -77,64 +77,59 @@ public class RespawnObeliskBlock extends BlockBase implements IColorProvider, IR } return true; } - + @Override - public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) { - state = this.getDefaultState(); + public void onPlaced(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, + ItemStack itemStack) { + state = this.defaultBlockState(); BlocksHelper.setWithUpdate(world, pos, state.with(SHAPE, TripleShape.BOTTOM)); BlocksHelper.setWithUpdate(world, pos.up(), state.with(SHAPE, TripleShape.MIDDLE)); BlocksHelper.setWithUpdate(world, pos.up(2), state.with(SHAPE, TripleShape.TOP)); } - + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { - TripleShape shape = state.get(SHAPE); + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { + TripleShape shape = state.getValue(SHAPE); if (shape == TripleShape.BOTTOM) { - if (world.getBlockState(pos.up()).isOf(this)) { + if (world.getBlockState(pos.up()).is(this)) { return state; + } else { + return Blocks.AIR.defaultBlockState(); } - else { - return Blocks.AIR.getDefaultState(); - } - } - else if (shape == TripleShape.MIDDLE) { - if (world.getBlockState(pos.up()).isOf(this) && world.getBlockState(pos.down()).isOf(this)) { + } else if (shape == TripleShape.MIDDLE) { + if (world.getBlockState(pos.up()).is(this) && world.getBlockState(pos.below()).is(this)) { return state; + } else { + return Blocks.AIR.defaultBlockState(); } - else { - return Blocks.AIR.getDefaultState(); - } - } - else { - if (world.getBlockState(pos.down()).isOf(this)) { + } else { + if (world.getBlockState(pos.below()).is(this)) { return state; - } - else { - return Blocks.AIR.getDefaultState(); + } else { + return Blocks.AIR.defaultBlockState(); } } } - + @Override - public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) { + public void onBreak(Level world, BlockPos pos, BlockState state, PlayerEntity player) { if (player.isCreative()) { - TripleShape shape = state.get(SHAPE); + TripleShape shape = state.getValue(SHAPE); if (shape == TripleShape.MIDDLE) { - BlocksHelper.setWithUpdate(world, pos.down(), Blocks.AIR); - } - else if (shape == TripleShape.TOP) { + BlocksHelper.setWithUpdate(world, pos.below(), Blocks.AIR); + } else if (shape == TripleShape.TOP) { BlocksHelper.setWithUpdate(world, pos.down(2), Blocks.AIR); } } super.onBreak(world, pos, state, player); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - if (state.get(SHAPE) == TripleShape.BOTTOM) { + public List getDrops(BlockState state, LootContext.Builder builder) { + if (state.getValue(SHAPE) == TripleShape.BOTTOM) { return Lists.newArrayList(new ItemStack(this)); - } - else { + } else { return Lists.newArrayList(); } } @@ -143,60 +138,59 @@ public class RespawnObeliskBlock extends BlockBase implements IColorProvider, IR public ERenderLayer getRenderLayer() { return ERenderLayer.TRANSLUCENT; } - + @Override - public BlockColorProvider getProvider() { - return ((IColorProvider) EndBlocks.AURORA_CRYSTAL).getProvider(); + public BlockColor getBlockProvider() { + return ((IColorProvider) EndBlocks.AURORA_CRYSTAL).getBlockProvider(); } - + @Override - public ItemColorProvider getItemProvider() { + public ItemColor getItemProvider() { return (stack, tintIndex) -> { return MHelper.color(255, 255, 255); }; } @Override - public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand, + BlockHitResult hit) { ItemStack itemStack = player.getStackInHand(hand); boolean canActivate = itemStack.getItem() == EndItems.AMBER_GEM && itemStack.getCount() > 5; if (hand != Hand.MAIN_HAND || !canActivate) { - if (!world.isClient && !(itemStack.getItem() instanceof BlockItem) && !player.isCreative()) { - ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) player; + if (!world.isClientSide && !(itemStack.getItem() instanceof BlockItem) && !player.isCreative()) { + ServerPlayer serverPlayerEntity = (ServerPlayer) player; serverPlayerEntity.sendMessage(new TranslatableText("message.betterend.fail_spawn"), true); } return ActionResult.FAIL; - } - else if (!world.isClient) { - ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) player; - serverPlayerEntity.setSpawnPoint(world.getRegistryKey(), pos, 0.0F, false, false); + } else if (!world.isClientSide) { + ServerPlayer serverPlayerEntity = (ServerPlayer) player; + serverPlayerEntity.setSpawnPoint(world.dimension(), pos, 0.0F, false, false); serverPlayerEntity.sendMessage(new TranslatableText("message.betterend.set_spawn"), true); double px = pos.getX() + 0.5; double py = pos.getY() + 0.5; double pz = pos.getZ() + 0.5; InfusionParticleType particle = new InfusionParticleType(new ItemStack(EndItems.AMBER_GEM)); - if (world instanceof ServerWorld) { + if (world instanceof ServerLevel) { double py1 = py; double py2 = py - 0.2; - if (state.get(SHAPE) == TripleShape.BOTTOM) { + if (state.getValue(SHAPE) == TripleShape.BOTTOM) { py1 += 1; py2 += 2; - } - else if (state.get(SHAPE) == TripleShape.MIDDLE) { + } else if (state.getValue(SHAPE) == TripleShape.MIDDLE) { py1 += 0; py2 += 1; - } - else { + } else { py1 -= 2; } - ((ServerWorld) world).spawnParticles(particle, px, py1, pz, 20, 0.14, 0.5, 0.14, 0.1); - ((ServerWorld) world).spawnParticles(particle, px, py2, pz, 20, 0.14, 0.3, 0.14, 0.1); + ((ServerLevel) world).sendParticles(particle, px, py1, pz, 20, 0.14, 0.5, 0.14, 0.1); + ((ServerLevel) world).sendParticles(particle, px, py2, pz, 20, 0.14, 0.3, 0.14, 0.1); + } + world.playLocalSound(null, px, py, py, SoundEvents.BLOCK_RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1F, + 1F); + if (!player.isCreative()) { + itemStack.decrement(6); } - world.playSound(null, px, py, py, SoundEvents.BLOCK_RESPAWN_ANCHOR_SET_SPAWN, SoundCategory.BLOCKS, 1F, 1F); - if (!player.isCreative()) { - itemStack.decrement(6); - } } - return player.isCreative() ? ActionResult.PASS : ActionResult.success(world.isClient); + return player.isCreative() ? ActionResult.PASS : ActionResult.success(world.isClientSide); } } diff --git a/src/main/java/ru/betterend/blocks/RunedFlavolite.java b/src/main/java/ru/betterend/blocks/RunedFlavolite.java index 9e4b18d4..d1f66d6a 100644 --- a/src/main/java/ru/betterend/blocks/RunedFlavolite.java +++ b/src/main/java/ru/betterend/blocks/RunedFlavolite.java @@ -1,10 +1,10 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.registry.EndBlocks; @@ -13,14 +13,15 @@ public class RunedFlavolite extends BlockBase { public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE; public RunedFlavolite() { - super(FabricBlockSettings.copyOf(EndBlocks.FLAVOLITE.polished).resistance(Blocks.OBSIDIAN.getBlastResistance()).luminance(state -> { - return state.get(ACTIVATED) ? 8 : 0; - })); - this.setDefaultState(stateManager.getDefaultState().with(ACTIVATED, false)); + super(FabricBlockSettings.copyOf(EndBlocks.FLAVOLITE.polished) + .resistance(Blocks.OBSIDIAN.getExplosionResistance()).luminance(state -> { + return state.getValue(ACTIVATED) ? 8 : 0; + })); + this.setDefaultState(stateManager.defaultBlockState().with(ACTIVATED, false)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(ACTIVATED); } } diff --git a/src/main/java/ru/betterend/blocks/ShadowBerryBlock.java b/src/main/java/ru/betterend/blocks/ShadowBerryBlock.java index 28851136..781fbdf6 100644 --- a/src/main/java/ru/betterend/blocks/ShadowBerryBlock.java +++ b/src/main/java/ru/betterend/blocks/ShadowBerryBlock.java @@ -1,22 +1,22 @@ package ru.betterend.blocks; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.ShapeContext; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.core.BlockPos; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.BlockGetter; import ru.betterend.blocks.basis.EndCropBlock; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndItems; public class ShadowBerryBlock extends EndCropBlock { private static final VoxelShape SHAPE = Block.createCuboidShape(1, 0, 1, 15, 8, 15); - + public ShadowBerryBlock() { super(EndItems.SHADOW_BERRY_RAW, EndBlocks.SHADOW_GRASS); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { return SHAPE; diff --git a/src/main/java/ru/betterend/blocks/ShadowGrassBlock.java b/src/main/java/ru/betterend/blocks/ShadowGrassBlock.java index 20ca5978..a9b1c26f 100644 --- a/src/main/java/ru/betterend/blocks/ShadowGrassBlock.java +++ b/src/main/java/ru/betterend/blocks/ShadowGrassBlock.java @@ -4,22 +4,23 @@ import java.util.Random; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.block.BlockState; -import net.minecraft.block.MaterialColor; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import ru.betterend.registry.EndParticles; public class ShadowGrassBlock extends EndTerrainBlock { public ShadowGrassBlock() { - super(MaterialColor.BLACK); + super(MaterialColor.COLOR_BLACK); } @Environment(EnvType.CLIENT) - public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { - super.randomDisplayTick(state, world, pos, random); + public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { + super.animateTick(state, world, pos, random); if (random.nextInt(32) == 0) { - world.addParticle(EndParticles.BLACK_SPORE, (double) pos.getX() + random.nextDouble(), (double) pos.getY() + 1.1D, (double) pos.getZ() + random.nextDouble(), 0.0D, 0.0D, 0.0D); + world.addParticle(EndParticles.BLACK_SPORE, (double) pos.getX() + random.nextDouble(), + (double) pos.getY() + 1.1D, (double) pos.getZ() + random.nextDouble(), 0.0D, 0.0D, 0.0D); } } } diff --git a/src/main/java/ru/betterend/blocks/SilkMothHiveBlock.java b/src/main/java/ru/betterend/blocks/SilkMothHiveBlock.java index a2cc925e..2c09ec3e 100644 --- a/src/main/java/ru/betterend/blocks/SilkMothHiveBlock.java +++ b/src/main/java/ru/betterend/blocks/SilkMothHiveBlock.java @@ -4,31 +4,31 @@ import java.util.Random; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.entity.ItemEntity; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.DirectionProperty; -import net.minecraft.state.property.IntProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.ActionResult; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; +import net.minecraft.world.level.block.Rotation; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.Box; -import net.minecraft.util.math.Direction; +import net.minecraft.core.Direction; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.entity.SilkMothEntity; import ru.betterend.registry.EndEntities; @@ -38,26 +38,27 @@ import ru.betterend.util.MHelper; public class SilkMothHiveBlock extends BlockBase { public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING; - public static final IntProperty FULLNESS = BlockProperties.FULLNESS; - + public static final IntegerProperty FULLNESS = BlockProperties.FULLNESS; + public SilkMothHiveBlock() { - super(FabricBlockSettings.of(Material.WOOD).hardness(0.5F).resistance(0.1F).sounds(BlockSoundGroup.WOOL).nonOpaque().ticksRandomly().breakByHand(true)); + super(FabricBlockSettings.of(Material.WOOD).hardness(0.5F).resistance(0.1F).sounds(SoundType.WOOL).nonOpaque() + .ticksRandomly().breakByHand(true)); this.setDefaultState(getDefaultState().with(FULLNESS, 0)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(FACING, FULLNESS); } - + @Override public BlockState getPlacementState(ItemPlacementContext ctx) { Direction dir = ctx.getPlayerFacing().getOpposite(); - return this.getDefaultState().with(FACING, dir); + return this.defaultBlockState().with(FACING, dir); } - + @Override - public BlockState rotate(BlockState state, BlockRotation rotation) { + public BlockState rotate(BlockState state, Rotation rotation) { return BlocksHelper.rotateHorizontal(state, rotation, FACING); } @@ -65,15 +66,17 @@ public class SilkMothHiveBlock extends BlockBase { public BlockState mirror(BlockState state, BlockMirror mirror) { return BlocksHelper.mirrorHorizontal(state, mirror, FACING); } - + @Override - public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - Direction dir = state.get(FACING); - BlockPos spawn = pos.offset(dir); + public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { + Direction dir = state.getValue(FACING); + BlockPos spawn = pos.relative(dir); if (!world.getBlockState(spawn).isAir()) { return; } - int count = world.getEntitiesByType(EndEntities.SILK_MOTH, new Box(pos).expand(16), (entity) -> { return true; }).size(); + int count = world.getEntitiesByType(EndEntities.SILK_MOTH, new Box(pos).expand(16), (entity) -> { + return true; + }).size(); if (count > 6) { return; } @@ -82,16 +85,17 @@ public class SilkMothHiveBlock extends BlockBase { moth.setVelocity(new Vec3d(dir.getOffsetX() * 0.4, 0, dir.getOffsetZ() * 0.4)); moth.setHive(world, pos); world.spawnEntity(moth); - world.playSound(null, pos, SoundEvents.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1, 1); + world.playLocalSound(null, pos, SoundEvents.BLOCK_BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1); } - + @Override - public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand, + BlockHitResult hit) { if (hand == Hand.MAIN_HAND) { ItemStack stack = player.getMainHandStack(); - if (stack.getItem().isIn(FabricToolTags.SHEARS) && state.get(FULLNESS) == 3) { + if (stack.getItem().isIn(FabricToolTags.SHEARS) && state.getValue(FULLNESS) == 3) { BlocksHelper.setWithUpdate(world, pos, state.with(FULLNESS, 0)); - Direction dir = state.get(FACING); + Direction dir = state.getValue(FACING); double px = pos.getX() + dir.getOffsetX() + 0.5; double py = pos.getY() + dir.getOffsetY() + 0.5; double pz = pos.getZ() + dir.getOffsetZ() + 0.5; diff --git a/src/main/java/ru/betterend/blocks/SilkMothNestBlock.java b/src/main/java/ru/betterend/blocks/SilkMothNestBlock.java index 09a3a197..3feee50d 100644 --- a/src/main/java/ru/betterend/blocks/SilkMothNestBlock.java +++ b/src/main/java/ru/betterend/blocks/SilkMothNestBlock.java @@ -6,39 +6,39 @@ import java.util.Random; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.entity.ItemEntity; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.DirectionProperty; -import net.minecraft.state.property.IntProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; import net.minecraft.state.property.Properties; -import net.minecraft.tag.BlockTags; +import net.minecraft.tags.BlockTags; import net.minecraft.util.ActionResult; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; +import net.minecraft.world.level.block.Rotation; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.Box; -import net.minecraft.util.math.Direction; +import net.minecraft.core.Direction; import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.client.render.ERenderLayer; import ru.betterend.entity.SilkMothEntity; @@ -51,51 +51,53 @@ import ru.betterend.util.MHelper; public class SilkMothNestBlock extends BlockBase implements IRenderTypeable { public static final BooleanProperty ACTIVE = BlockProperties.ACTIVE; public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING; - public static final IntProperty FULLNESS = BlockProperties.FULLNESS; + public static final IntegerProperty FULLNESS = BlockProperties.FULLNESS; private static final VoxelShape TOP = createCuboidShape(6, 0, 6, 10, 16, 10); private static final VoxelShape BOTTOM = createCuboidShape(0, 0, 0, 16, 16, 16); - + public SilkMothNestBlock() { - super(FabricBlockSettings.of(Material.WOOL).hardness(0.5F).resistance(0.1F).sounds(BlockSoundGroup.WOOL).nonOpaque().ticksRandomly()); + super(FabricBlockSettings.of(Material.WOOL).hardness(0.5F).resistance(0.1F).sounds(SoundType.WOOL).nonOpaque() + .ticksRandomly()); this.setDefaultState(getDefaultState().with(ACTIVE, true).with(FULLNESS, 0)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(ACTIVE, FACING, FULLNESS); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return state.get(ACTIVE) ? BOTTOM : TOP; + return state.getValue(ACTIVE) ? BOTTOM : TOP; } @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override public BlockState getPlacementState(ItemPlacementContext ctx) { Direction dir = ctx.getPlayerFacing().getOpposite(); - return this.getDefaultState().with(FACING, dir); + return this.defaultBlockState().with(FACING, dir); } - + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { - if (!state.get(ACTIVE)) { - if (sideCoversSmallSquare(world, pos.up(), Direction.DOWN) || world.getBlockState(pos.up()).isIn(BlockTags.LEAVES)) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { + if (!state.getValue(ACTIVE)) { + if (sideCoversSmallSquare(world, pos.up(), Direction.DOWN) + || world.getBlockState(pos.up()).isIn(BlockTags.LEAVES)) { return state; - } - else { - return Blocks.AIR.getDefaultState(); + } else { + return Blocks.AIR.defaultBlockState(); } } return state; } - + @Override - public BlockState rotate(BlockState state, BlockRotation rotation) { + public BlockState rotate(BlockState state, Rotation rotation) { return BlocksHelper.rotateHorizontal(state, rotation, FACING); } @@ -103,38 +105,40 @@ public class SilkMothNestBlock extends BlockBase implements IRenderTypeable { public BlockState mirror(BlockState state, BlockMirror mirror) { return BlocksHelper.mirrorHorizontal(state, mirror, FACING); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - return state.get(ACTIVE) ? Collections.singletonList(new ItemStack(this)) : Collections.emptyList(); + public List getDrops(BlockState state, LootContext.Builder builder) { + return state.getValue(ACTIVE) ? Collections.singletonList(new ItemStack(this)) : Collections.emptyList(); } - + @Override - public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) { - if (!state.get(ACTIVE) && player.isCreative()) { - BlocksHelper.setWithUpdate(world, pos.down(), Blocks.AIR); + public void onBreak(Level world, BlockPos pos, BlockState state, PlayerEntity player) { + if (!state.getValue(ACTIVE) && player.isCreative()) { + BlocksHelper.setWithUpdate(world, pos.below(), Blocks.AIR); } BlockState up = world.getBlockState(pos.up()); - if (up.isOf(this) && !up.get(ACTIVE)) { + if (up.is(this) && !up.get(ACTIVE)) { BlocksHelper.setWithUpdate(world, pos.up(), Blocks.AIR); } super.onBreak(world, pos, state, player); } - + @Override - public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (!state.get(ACTIVE)) { + public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { + if (!state.getValue(ACTIVE)) { return; } if (random.nextBoolean()) { return; } - Direction dir = state.get(FACING); - BlockPos spawn = pos.offset(dir); + Direction dir = state.getValue(FACING); + BlockPos spawn = pos.relative(dir); if (!world.getBlockState(spawn).isAir()) { return; } - int count = world.getEntitiesByType(EndEntities.SILK_MOTH, new Box(pos).expand(16), (entity) -> { return true; }).size(); + int count = world.getEntitiesByType(EndEntities.SILK_MOTH, new Box(pos).expand(16), (entity) -> { + return true; + }).size(); if (count > 6) { return; } @@ -143,16 +147,18 @@ public class SilkMothNestBlock extends BlockBase implements IRenderTypeable { moth.setVelocity(new Vec3d(dir.getOffsetX() * 0.4, 0, dir.getOffsetZ() * 0.4)); moth.setHive(world, pos); world.spawnEntity(moth); - world.playSound(null, pos, SoundEvents.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1, 1); + world.playLocalSound(null, pos, SoundEvents.BLOCK_BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1); } - + @Override - public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand, + BlockHitResult hit) { if (hand == Hand.MAIN_HAND) { ItemStack stack = player.getMainHandStack(); - if (stack.getItem().isIn(FabricToolTags.SHEARS) && state.get(ACTIVE) && state.get(FULLNESS) == 3) { + if (stack.getItem().isIn(FabricToolTags.SHEARS) && state.getValue(ACTIVE) + && state.getValue(FULLNESS) == 3) { BlocksHelper.setWithUpdate(world, pos, state.with(FULLNESS, 0)); - Direction dir = state.get(FACING); + Direction dir = state.getValue(FACING); double px = pos.getX() + dir.getOffsetX() + 0.5; double py = pos.getY() + dir.getOffsetY() + 0.5; double pz = pos.getZ() + dir.getOffsetZ() + 0.5; diff --git a/src/main/java/ru/betterend/blocks/SmallAmaranitaBlock.java b/src/main/java/ru/betterend/blocks/SmallAmaranitaBlock.java index aff0ad4c..9d3092fe 100644 --- a/src/main/java/ru/betterend/blocks/SmallAmaranitaBlock.java +++ b/src/main/java/ru/betterend/blocks/SmallAmaranitaBlock.java @@ -2,16 +2,16 @@ package ru.betterend.blocks; import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ShapeContext; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndFeatures; @@ -19,14 +19,15 @@ import ru.betterend.util.BlocksHelper; public class SmallAmaranitaBlock extends EndPlantBlock { private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 10, 12); - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.SANGNUM) || state.isOf(EndBlocks.MOSSY_OBSIDIAN) || state.isOf(EndBlocks.MOSSY_DRAGON_BONE); + return state.is(EndBlocks.SANGNUM) || state.is(EndBlocks.MOSSY_OBSIDIAN) + || state.is(EndBlocks.MOSSY_DRAGON_BONE); } - + @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { + public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) { BlockPos bigPos = growBig(world, pos); if (bigPos != null) { if (EndFeatures.GIGANTIC_AMARANITA.getFeature().generate(world, null, random, bigPos, null)) { @@ -39,17 +40,17 @@ public class SmallAmaranitaBlock extends EndPlantBlock { } EndFeatures.LARGE_AMARANITA.getFeature().generate(world, null, random, pos, null); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { Vec3d vec3d = state.getModelOffset(view, pos); return SHAPE.offset(vec3d.x, vec3d.y, vec3d.z); } - - private BlockPos growBig(ServerWorld world, BlockPos pos) { + + private BlockPos growBig(ServerLevel world, BlockPos pos) { for (int x = -1; x < 2; x++) { for (int z = -1; z < 2; z++) { - BlockPos p = pos.add(x, 0, z); + BlockPos p = pos.offset(x, 0, z); if (checkFrame(world, p)) { return p; } @@ -57,22 +58,20 @@ public class SmallAmaranitaBlock extends EndPlantBlock { } return null; } - - private boolean checkFrame(ServerWorld world, BlockPos pos) { - return world.getBlockState(pos).isOf(this) && - world.getBlockState(pos.south()).isOf(this) && - world.getBlockState(pos.east()).isOf(this) && - world.getBlockState(pos.south().east()).isOf(this); + + private boolean checkFrame(ServerLevel world, BlockPos pos) { + return world.getBlockState(pos).is(this) && world.getBlockState(pos.south()).is(this) + && world.getBlockState(pos.east()).is(this) && world.getBlockState(pos.south().east()).is(this); } - - private void replaceMushroom(ServerWorld world, BlockPos pos) { - if (world.getBlockState(pos).isOf(this)) { + + private void replaceMushroom(ServerLevel world, BlockPos pos) { + if (world.getBlockState(pos).is(this)) { BlocksHelper.setWithUpdate(world, pos, Blocks.AIR); } } - + @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { return random.nextInt(8) == 0; } } diff --git a/src/main/java/ru/betterend/blocks/SmallJellyshroomBlock.java b/src/main/java/ru/betterend/blocks/SmallJellyshroomBlock.java index 01b16b4c..4432dd5c 100644 --- a/src/main/java/ru/betterend/blocks/SmallJellyshroomBlock.java +++ b/src/main/java/ru/betterend/blocks/SmallJellyshroomBlock.java @@ -9,25 +9,25 @@ import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Fertilizable; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.Fertilizable; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraft.world.WorldView; import ru.betterend.blocks.basis.AttachedBlock; import ru.betterend.client.render.ERenderLayer; @@ -38,44 +38,41 @@ import ru.betterend.util.BlocksHelper; public class SmallJellyshroomBlock extends AttachedBlock implements IRenderTypeable, Fertilizable { private static final EnumMap BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); - + public SmallJellyshroomBlock() { - super(FabricBlockSettings.of(Material.PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.NETHER_WART) - .breakByHand(true) - .noCollision()); + super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.NETHER_WART) + .breakByHand(true).noCollision()); } @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return BOUNDING_SHAPES.get(state.get(FACING)); + return BOUNDING_SHAPES.get(state.getValue(FACING)); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) + || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Lists.newArrayList(new ItemStack(this)); - } - else { + } else { return Lists.newArrayList(); } } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - Direction direction = state.get(FACING); - BlockPos blockPos = pos.offset(direction.getOpposite()); + Direction direction = state.getValue(FACING); + BlockPos blockPos = pos.relative(direction.getOpposite()); BlockState support = world.getBlockState(blockPos); return sideCoversSmallSquare(world, blockPos, direction) && support.isOpaque() && support.getLuminance() == 0; } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + static { BOUNDING_SHAPES.put(Direction.UP, Block.createCuboidShape(3, 0, 3, 13, 16, 13)); BOUNDING_SHAPES.put(Direction.DOWN, Block.createCuboidShape(3, 0, 3, 13, 16, 13)); @@ -87,16 +84,16 @@ public class SmallJellyshroomBlock extends AttachedBlock implements IRenderTypea @Override public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { - return state.get(FACING) == Direction.UP && world.getBlockState(pos.down()).isIn(EndTags.END_GROUND); + return state.getValue(FACING) == Direction.UP && world.getBlockState(pos.below()).isIn(EndTags.END_GROUND); } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { return random.nextInt(16) == 0; } @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { + public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) { BlocksHelper.setWithUpdate(world, pos, Blocks.AIR); EndFeatures.JELLYSHROOM.getFeature().generate(world, null, random, pos, null); } diff --git a/src/main/java/ru/betterend/blocks/SmaragdantCrystalBlock.java b/src/main/java/ru/betterend/blocks/SmaragdantCrystalBlock.java index 8b5fa12e..cdd80120 100644 --- a/src/main/java/ru/betterend/blocks/SmaragdantCrystalBlock.java +++ b/src/main/java/ru/betterend/blocks/SmaragdantCrystalBlock.java @@ -2,18 +2,13 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Material; -import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.SoundType; import ru.betterend.blocks.basis.EndPillarBlock; public class SmaragdantCrystalBlock extends EndPillarBlock { public SmaragdantCrystalBlock() { - super(FabricBlockSettings.of(Material.GLASS) - .breakByTool(FabricToolTags.PICKAXES) - .sounds(BlockSoundGroup.GLASS) - .luminance(15) - .hardness(1F) - .resistance(1F) - .nonOpaque()); + super(FabricBlockSettings.of(Material.GLASS).breakByTool(FabricToolTags.PICKAXES).sounds(SoundType.GLASS) + .luminance(15).hardness(1F).resistance(1F).nonOpaque()); } } diff --git a/src/main/java/ru/betterend/blocks/SmaragdantCrystalShardBlock.java b/src/main/java/ru/betterend/blocks/SmaragdantCrystalShardBlock.java index 69b88741..b15ac81c 100644 --- a/src/main/java/ru/betterend/blocks/SmaragdantCrystalShardBlock.java +++ b/src/main/java/ru/betterend/blocks/SmaragdantCrystalShardBlock.java @@ -6,96 +6,93 @@ import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.FluidFillable; -import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; -import net.minecraft.block.ShapeContext; -import net.minecraft.block.Waterloggable; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.FluidFillable; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.level.block.Waterloggable; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.blocks.basis.AttachedBlock; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; -public class SmaragdantCrystalShardBlock extends AttachedBlock implements IRenderTypeable, Waterloggable, FluidFillable { +public class SmaragdantCrystalShardBlock extends AttachedBlock + implements IRenderTypeable, Waterloggable, FluidFillable { private static final EnumMap BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; - + public SmaragdantCrystalShardBlock() { - super(FabricBlockSettings.of(Material.STONE) - .materialColor(MaterialColor.GREEN) - .breakByTool(FabricToolTags.PICKAXES) - .sounds(BlockSoundGroup.GLASS) - .luminance(15) - .requiresTool() + super(FabricBlockSettings.of(Material.STONE).materialColor(MaterialColor.COLOR_GREEN) + .breakByTool(FabricToolTags.PICKAXES).sounds(SoundType.GLASS).luminance(15).requiresTool() .noCollision()); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { - super.appendProperties(stateManager); + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { + super.createBlockStateDefinition(stateManager); stateManager.add(WATERLOGGED); } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) { - return !state.get(WATERLOGGED); + return !state.getValue(WATERLOGGED); } @Override - public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) { - return !state.get(WATERLOGGED); + public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) { + return !state.getValue(WATERLOGGED); } - + @Override public BlockState getPlacementState(ItemPlacementContext ctx) { BlockState state = super.getPlacementState(ctx); if (state != null) { - WorldView worldView = ctx.getWorld(); + WorldView worldView = ctx.getLevel(); BlockPos blockPos = ctx.getBlockPos(); boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER; return state.with(WATERLOGGED, water); } return null; } - + @Override public FluidState getFluidState(BlockState state) { - return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.getDefaultState(); + return state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.defaultBlockState(); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return BOUNDING_SHAPES.get(state.get(FACING)); + return BOUNDING_SHAPES.get(state.getValue(FACING)); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - Direction direction = (Direction) state.get(FACING); - BlockPos blockPos = pos.offset(direction.getOpposite()); + Direction direction = (Direction) state.getValue(FACING); + BlockPos blockPos = pos.relative(direction.getOpposite()); return world.getBlockState(blockPos).isSideSolidFullSquare(world, blockPos, direction); } - + static { BOUNDING_SHAPES.put(Direction.UP, VoxelShapes.cuboid(0.125, 0.0, 0.125, 0.875F, 0.875F, 0.875F)); BOUNDING_SHAPES.put(Direction.DOWN, VoxelShapes.cuboid(0.125, 0.125, 0.125, 0.875F, 1.0, 0.875F)); diff --git a/src/main/java/ru/betterend/blocks/SulphurCrystalBlock.java b/src/main/java/ru/betterend/blocks/SulphurCrystalBlock.java index 17ba297c..4bc940b3 100644 --- a/src/main/java/ru/betterend/blocks/SulphurCrystalBlock.java +++ b/src/main/java/ru/betterend/blocks/SulphurCrystalBlock.java @@ -9,30 +9,30 @@ import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.FluidFillable; -import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; -import net.minecraft.block.ShapeContext; -import net.minecraft.block.Waterloggable; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.FluidFillable; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.level.block.Waterloggable; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; -import net.minecraft.state.property.IntProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.blocks.basis.AttachedBlock; import ru.betterend.client.render.ERenderLayer; @@ -43,73 +43,71 @@ import ru.betterend.util.MHelper; public class SulphurCrystalBlock extends AttachedBlock implements IRenderTypeable, Waterloggable, FluidFillable { private static final EnumMap BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); - public static final IntProperty AGE = IntProperty.of("age", 0, 2); + public static final IntegerProperty AGE = IntegerProperty.of("age", 0, 2); public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; - + public SulphurCrystalBlock() { - super(FabricBlockSettings.of(Material.STONE) - .materialColor(MaterialColor.YELLOW) - .breakByTool(FabricToolTags.PICKAXES) - .sounds(BlockSoundGroup.GLASS) - .requiresTool() - .noCollision()); + super(FabricBlockSettings.of(Material.STONE).materialColor(MaterialColor.COLOR_YELLOW) + .breakByTool(FabricToolTags.PICKAXES).sounds(SoundType.GLASS).requiresTool().noCollision()); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { - super.appendProperties(stateManager); + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { + super.createBlockStateDefinition(stateManager); stateManager.add(AGE, WATERLOGGED); } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - return state.get(AGE) < 2 ? Collections.emptyList() : Lists.newArrayList(new ItemStack(EndItems.CRYSTALLINE_SULPHUR, MHelper.randRange(1, 3, MHelper.RANDOM))); - } - - @Override - public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) { - return !state.get(WATERLOGGED); + public List getDrops(BlockState state, LootContext.Builder builder) { + return state.getValue(AGE) < 2 ? Collections.emptyList() + : Lists.newArrayList( + new ItemStack(EndItems.CRYSTALLINE_SULPHUR, MHelper.randRange(1, 3, MHelper.RANDOM))); } @Override - public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) { - return !state.get(WATERLOGGED); + public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) { + return !state.getValue(WATERLOGGED); } - + + @Override + public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) { + return !state.getValue(WATERLOGGED); + } + @Override public BlockState getPlacementState(ItemPlacementContext ctx) { BlockState state = super.getPlacementState(ctx); if (state != null) { - WorldView worldView = ctx.getWorld(); + WorldView worldView = ctx.getLevel(); BlockPos blockPos = ctx.getBlockPos(); boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER; return state.with(WATERLOGGED, water); } return null; } - + @Override public FluidState getFluidState(BlockState state) { - return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.getDefaultState(); + return state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.defaultBlockState(); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return BOUNDING_SHAPES.get(state.get(FACING)); + return BOUNDING_SHAPES.get(state.getValue(FACING)); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - Direction direction = (Direction) state.get(FACING); - BlockPos blockPos = pos.offset(direction.getOpposite()); - return world.getBlockState(blockPos).isOf(EndBlocks.BRIMSTONE); + Direction direction = (Direction) state.getValue(FACING); + BlockPos blockPos = pos.relative(direction.getOpposite()); + return world.getBlockState(blockPos).is(EndBlocks.BRIMSTONE); } - + static { BOUNDING_SHAPES.put(Direction.UP, VoxelShapes.cuboid(0.125, 0.0, 0.125, 0.875F, 0.5, 0.875F)); BOUNDING_SHAPES.put(Direction.DOWN, VoxelShapes.cuboid(0.125, 0.5, 0.125, 0.875F, 1.0, 0.875F)); diff --git a/src/main/java/ru/betterend/blocks/TenaneaFlowersBlock.java b/src/main/java/ru/betterend/blocks/TenaneaFlowersBlock.java index 447f2635..4059ca38 100644 --- a/src/main/java/ru/betterend/blocks/TenaneaFlowersBlock.java +++ b/src/main/java/ru/betterend/blocks/TenaneaFlowersBlock.java @@ -4,14 +4,14 @@ import java.util.Random; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.block.BlockState; -import net.minecraft.client.color.block.BlockColorProvider; -import net.minecraft.client.color.item.ItemColorProvider; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3i; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.color.block.BlockColor; +import net.minecraft.client.color.item.ItemColor; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import ru.betterend.blocks.basis.VineBlock; import ru.betterend.interfaces.IColorProvider; import ru.betterend.registry.EndParticles; @@ -19,13 +19,13 @@ import ru.betterend.util.MHelper; public class TenaneaFlowersBlock extends VineBlock implements IColorProvider { public static final Vec3i[] COLORS; - + public TenaneaFlowersBlock() { super(15); } @Override - public BlockColorProvider getProvider() { + public BlockColor getBlockProvider() { return (state, world, pos, tintIndex) -> { long i = (MHelper.getRandom(pos.getX(), pos.getZ()) & 63) + pos.getY(); double delta = i * 0.1; @@ -33,34 +33,34 @@ public class TenaneaFlowersBlock extends VineBlock implements IColorProvider { int index2 = (index + 1) & 3; delta -= index; index &= 3; - + Vec3i color1 = COLORS[index]; Vec3i color2 = COLORS[index2]; - - int r = MHelper.floor(MathHelper.lerp(delta, color1.getX(), color2.getX())); - int g = MHelper.floor(MathHelper.lerp(delta, color1.getY(), color2.getY())); - int b = MHelper.floor(MathHelper.lerp(delta, color1.getZ(), color2.getZ())); + + int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX())); + int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY())); + int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ())); float[] hsb = MHelper.fromRGBtoHSB(r, g, b); - + return MHelper.fromHSBtoRGB(hsb[0], MHelper.max(0.5F, hsb[1]), hsb[2]); }; } @Override - public ItemColorProvider getItemProvider() { + public ItemColor getItemProvider() { return (stack, tintIndex) -> { return MHelper.color(255, 255, 255); }; } - + @Override public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { return false; } - + @Environment(EnvType.CLIENT) - public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { - super.randomDisplayTick(state, world, pos, random); + public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { + super.animateTick(state, world, pos, random); if (random.nextInt(32) == 0) { double x = (double) pos.getX() + random.nextGaussian() + 0.5; double z = (double) pos.getZ() + random.nextGaussian() + 0.5; @@ -68,13 +68,9 @@ public class TenaneaFlowersBlock extends VineBlock implements IColorProvider { world.addParticle(EndParticles.TENANEA_PETAL, x, y, z, 0, 0, 0); } } - + static { - COLORS = new Vec3i[] { - new Vec3i(250, 111, 222), - new Vec3i(167, 89, 255), - new Vec3i(120, 207, 239), - new Vec3i(255, 87, 182) - }; + COLORS = new Vec3i[] { new Vec3i(250, 111, 222), new Vec3i(167, 89, 255), new Vec3i(120, 207, 239), + new Vec3i(255, 87, 182) }; } } diff --git a/src/main/java/ru/betterend/blocks/TenaneaSaplingBlock.java b/src/main/java/ru/betterend/blocks/TenaneaSaplingBlock.java index d3cba539..1ba74736 100644 --- a/src/main/java/ru/betterend/blocks/TenaneaSaplingBlock.java +++ b/src/main/java/ru/betterend/blocks/TenaneaSaplingBlock.java @@ -1,7 +1,7 @@ package ru.betterend.blocks; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; import net.minecraft.world.WorldView; import net.minecraft.world.gen.feature.Feature; import ru.betterend.blocks.basis.FeatureSaplingBlock; @@ -17,9 +17,9 @@ public class TenaneaSaplingBlock extends FeatureSaplingBlock { protected Feature getFeature() { return EndFeatures.LUCERNIA.getFeature(); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - return world.getBlockState(pos.down()).isOf(EndBlocks.RUTISCUS); + return world.getBlockState(pos.below()).is(EndBlocks.RUTISCUS); } } diff --git a/src/main/java/ru/betterend/blocks/TerminiteBlock.java b/src/main/java/ru/betterend/blocks/TerminiteBlock.java index 204a2e55..a7a1b6eb 100644 --- a/src/main/java/ru/betterend/blocks/TerminiteBlock.java +++ b/src/main/java/ru/betterend/blocks/TerminiteBlock.java @@ -1,17 +1,14 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; -import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.block.SoundType; import ru.betterend.blocks.basis.BlockBase; public class TerminiteBlock extends BlockBase { public TerminiteBlock() { - super(FabricBlockSettings.of(Material.METAL, MaterialColor.field_25708) - .hardness(7F) - .resistance(9F) - .requiresTool() - .sounds(BlockSoundGroup.METAL)); + super(FabricBlockSettings.of(Material.METAL, MaterialColor.field_25708).hardness(7F).resistance(9F) + .requiresTool().sounds(SoundType.METAL)); } } diff --git a/src/main/java/ru/betterend/blocks/TerrainPlantBlock.java b/src/main/java/ru/betterend/blocks/TerrainPlantBlock.java index f558395d..3f1ba358 100644 --- a/src/main/java/ru/betterend/blocks/TerrainPlantBlock.java +++ b/src/main/java/ru/betterend/blocks/TerrainPlantBlock.java @@ -1,21 +1,21 @@ package ru.betterend.blocks; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; import ru.betterend.blocks.basis.EndPlantBlock; public class TerrainPlantBlock extends EndPlantBlock { private final Block[] ground; - + public TerrainPlantBlock(Block... ground) { super(true); this.ground = ground; } - + @Override protected boolean isTerrain(BlockState state) { - for (Block block: ground) { - if (state.isOf(block)) { + for (Block block : ground) { + if (state.is(block)) { return true; } } diff --git a/src/main/java/ru/betterend/blocks/TwistedUmbrellaMossBlock.java b/src/main/java/ru/betterend/blocks/TwistedUmbrellaMossBlock.java index af0257a6..fe4d215e 100644 --- a/src/main/java/ru/betterend/blocks/TwistedUmbrellaMossBlock.java +++ b/src/main/java/ru/betterend/blocks/TwistedUmbrellaMossBlock.java @@ -4,11 +4,11 @@ import java.util.Random; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.block.BlockState; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import ru.betterend.blocks.basis.DoublePlantBlock; import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.registry.EndBlocks; @@ -18,31 +18,31 @@ public class TwistedUmbrellaMossBlock extends EndPlantBlock { public TwistedUmbrellaMossBlock() { super(11); } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.END_MOSS) || state.isOf(EndBlocks.END_MYCELIUM) || state.isOf(EndBlocks.JUNGLE_MOSS); + return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS); } - - @Environment(EnvType.CLIENT) - public boolean hasEmissiveLighting(BlockView world, BlockPos pos) { - return true; - } - @Environment(EnvType.CLIENT) - public float getAmbientOcclusionLightLevel(BlockView world, BlockPos pos) { - return 1F; - } - - @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + @Environment(EnvType.CLIENT) + public boolean hasEmissiveLighting(BlockView world, BlockPos pos) { + return true; + } + + @Environment(EnvType.CLIENT) + public float getAmbientOcclusionLightLevel(BlockView world, BlockPos pos) { + return 1F; + } + + @Override + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { return world.isAir(pos.up()); } - - @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - int rot = world.random.nextInt(4); - BlockState bs = EndBlocks.TWISTED_UMBRELLA_MOSS_TALL.getDefaultState().with(DoublePlantBlock.ROTATION, rot); + + @Override + public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) { + int rot = world.random.nextInt(4); + BlockState bs = EndBlocks.TWISTED_UMBRELLA_MOSS_TALL.defaultBlockState().with(DoublePlantBlock.ROTATION, rot); BlocksHelper.setWithoutUpdate(world, pos, bs); BlocksHelper.setWithoutUpdate(world, pos.up(), bs.with(DoublePlantBlock.TOP, true)); } diff --git a/src/main/java/ru/betterend/blocks/TwistedUmbrellaMossTallBlock.java b/src/main/java/ru/betterend/blocks/TwistedUmbrellaMossTallBlock.java index fbad6c9c..b344ba20 100644 --- a/src/main/java/ru/betterend/blocks/TwistedUmbrellaMossTallBlock.java +++ b/src/main/java/ru/betterend/blocks/TwistedUmbrellaMossTallBlock.java @@ -2,11 +2,11 @@ package ru.betterend.blocks; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.entity.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.core.BlockPos; import ru.betterend.blocks.basis.DoublePlantBlock; import ru.betterend.registry.EndBlocks; @@ -14,15 +14,16 @@ public class TwistedUmbrellaMossTallBlock extends DoublePlantBlock { public TwistedUmbrellaMossTallBlock() { super(12); } - + @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(EndBlocks.TWISTED_UMBRELLA_MOSS)); + public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) { + ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, + new ItemStack(EndBlocks.TWISTED_UMBRELLA_MOSS)); world.spawnEntity(item); } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.END_MOSS) || state.isOf(EndBlocks.END_MYCELIUM) || state.isOf(EndBlocks.JUNGLE_MOSS); + return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS); } } diff --git a/src/main/java/ru/betterend/blocks/UmbrellaMossBlock.java b/src/main/java/ru/betterend/blocks/UmbrellaMossBlock.java index 90173d0d..bef8a773 100644 --- a/src/main/java/ru/betterend/blocks/UmbrellaMossBlock.java +++ b/src/main/java/ru/betterend/blocks/UmbrellaMossBlock.java @@ -4,11 +4,11 @@ import java.util.Random; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.block.BlockState; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import ru.betterend.blocks.basis.DoublePlantBlock; import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.registry.EndBlocks; @@ -18,31 +18,31 @@ public class UmbrellaMossBlock extends EndPlantBlock { public UmbrellaMossBlock() { super(11); } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.END_MOSS) || state.isOf(EndBlocks.END_MYCELIUM) || state.isOf(EndBlocks.JUNGLE_MOSS); + return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS); } - - @Environment(EnvType.CLIENT) - public boolean hasEmissiveLighting(BlockView world, BlockPos pos) { - return true; - } - @Environment(EnvType.CLIENT) - public float getAmbientOcclusionLightLevel(BlockView world, BlockPos pos) { - return 1F; - } - - @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + @Environment(EnvType.CLIENT) + public boolean hasEmissiveLighting(BlockView world, BlockPos pos) { + return true; + } + + @Environment(EnvType.CLIENT) + public float getAmbientOcclusionLightLevel(BlockView world, BlockPos pos) { + return 1F; + } + + @Override + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { return world.isAir(pos.up()); } - - @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - int rot = world.random.nextInt(4); - BlockState bs = EndBlocks.UMBRELLA_MOSS_TALL.getDefaultState().with(DoublePlantBlock.ROTATION, rot); + + @Override + public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) { + int rot = world.random.nextInt(4); + BlockState bs = EndBlocks.UMBRELLA_MOSS_TALL.defaultBlockState().with(DoublePlantBlock.ROTATION, rot); BlocksHelper.setWithoutUpdate(world, pos, bs); BlocksHelper.setWithoutUpdate(world, pos.up(), bs.with(DoublePlantBlock.TOP, true)); } diff --git a/src/main/java/ru/betterend/blocks/UmbrellaMossTallBlock.java b/src/main/java/ru/betterend/blocks/UmbrellaMossTallBlock.java index c3a90063..0ab0434c 100644 --- a/src/main/java/ru/betterend/blocks/UmbrellaMossTallBlock.java +++ b/src/main/java/ru/betterend/blocks/UmbrellaMossTallBlock.java @@ -2,11 +2,11 @@ package ru.betterend.blocks; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.entity.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.core.BlockPos; import ru.betterend.blocks.basis.DoublePlantBlock; import ru.betterend.registry.EndBlocks; @@ -14,15 +14,16 @@ public class UmbrellaMossTallBlock extends DoublePlantBlock { public UmbrellaMossTallBlock() { super(12); } - + @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(EndBlocks.UMBRELLA_MOSS)); + public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) { + ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, + new ItemStack(EndBlocks.UMBRELLA_MOSS)); world.spawnEntity(item); } - + @Override protected boolean isTerrain(BlockState state) { - return state.isOf(EndBlocks.END_MOSS) || state.isOf(EndBlocks.END_MYCELIUM) || state.isOf(EndBlocks.JUNGLE_MOSS); + return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS); } } diff --git a/src/main/java/ru/betterend/blocks/UmbrellaTreeClusterBlock.java b/src/main/java/ru/betterend/blocks/UmbrellaTreeClusterBlock.java index e1a6b8a9..7b2139ec 100644 --- a/src/main/java/ru/betterend/blocks/UmbrellaTreeClusterBlock.java +++ b/src/main/java/ru/betterend/blocks/UmbrellaTreeClusterBlock.java @@ -1,22 +1,22 @@ package ru.betterend.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.MaterialColor; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndItems; @@ -24,21 +24,21 @@ import ru.betterend.util.BlocksHelper; public class UmbrellaTreeClusterBlock extends BlockBase { public static final BooleanProperty NATURAL = BlockProperties.NATURAL; - + public UmbrellaTreeClusterBlock() { - super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK) - .materialColor(MaterialColor.PURPLE) + super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK).materialColor(MaterialColor.COLOR_PURPLE) .luminance(15)); - setDefaultState(stateManager.getDefaultState().with(NATURAL, false)); + setDefaultState(stateManager.defaultBlockState().with(NATURAL, false)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(NATURAL); } - + @Override - public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand, + BlockHitResult hit) { ItemStack stack = player.getMainHandStack(); if (stack.getItem() == Items.GLASS_BOTTLE) { if (!player.isCreative()) { @@ -46,8 +46,10 @@ public class UmbrellaTreeClusterBlock extends BlockBase { } stack = new ItemStack(EndItems.UMBRELLA_CLUSTER_JUICE); player.giveItemStack(stack); - world.playSound(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1, 1, false); - BlocksHelper.setWithUpdate(world, pos, EndBlocks.UMBRELLA_TREE_CLUSTER_EMPTY.getDefaultState().with(NATURAL, state.get(NATURAL))); + world.playLocalSound(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.ITEM_BOTTLE_FILL, + SoundSource.BLOCKS, 1, 1, false); + BlocksHelper.setWithUpdate(world, pos, + EndBlocks.UMBRELLA_TREE_CLUSTER_EMPTY.defaultBlockState().with(NATURAL, state.getValue(NATURAL))); return ActionResult.SUCCESS; } return ActionResult.FAIL; diff --git a/src/main/java/ru/betterend/blocks/UmbrellaTreeClusterEmptyBlock.java b/src/main/java/ru/betterend/blocks/UmbrellaTreeClusterEmptyBlock.java index 29e5ba36..b4f1941a 100644 --- a/src/main/java/ru/betterend/blocks/UmbrellaTreeClusterEmptyBlock.java +++ b/src/main/java/ru/betterend/blocks/UmbrellaTreeClusterEmptyBlock.java @@ -3,37 +3,37 @@ package ru.betterend.blocks; import java.util.Random; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.MaterialColor; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.registry.EndBlocks; import ru.betterend.util.BlocksHelper; public class UmbrellaTreeClusterEmptyBlock extends BlockBase { public static final BooleanProperty NATURAL = BlockProperties.NATURAL; - + public UmbrellaTreeClusterEmptyBlock() { - super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK) - .materialColor(MaterialColor.PURPLE) + super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK).materialColor(MaterialColor.COLOR_PURPLE) .ticksRandomly()); - setDefaultState(stateManager.getDefaultState().with(NATURAL, false)); + setDefaultState(stateManager.defaultBlockState().with(NATURAL, false)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(NATURAL); } - + @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (state.get(NATURAL) && random.nextInt(16) == 0) { - BlocksHelper.setWithUpdate(world, pos, EndBlocks.UMBRELLA_TREE_CLUSTER.getDefaultState().with(UmbrellaTreeClusterBlock.NATURAL, true)); + public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { + if (state.getValue(NATURAL) && random.nextInt(16) == 0) { + BlocksHelper.setWithUpdate(world, pos, + EndBlocks.UMBRELLA_TREE_CLUSTER.defaultBlockState().with(UmbrellaTreeClusterBlock.NATURAL, true)); } } } diff --git a/src/main/java/ru/betterend/blocks/UmbrellaTreeMembraneBlock.java b/src/main/java/ru/betterend/blocks/UmbrellaTreeMembraneBlock.java index 3fb85637..31844133 100644 --- a/src/main/java/ru/betterend/blocks/UmbrellaTreeMembraneBlock.java +++ b/src/main/java/ru/betterend/blocks/UmbrellaTreeMembraneBlock.java @@ -9,20 +9,20 @@ import com.google.common.collect.Lists; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.SlimeBlock; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SlimeBlock; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Registry; +import net.minecraft.world.level.BlockGetter; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.noise.OpenSimplexNoise; @@ -32,69 +32,68 @@ import ru.betterend.registry.EndBlocks; import ru.betterend.util.MHelper; public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderTypeable, BlockPatterned { - public static final IntProperty COLOR = BlockProperties.COLOR; + public static final IntegerProperty COLOR = BlockProperties.COLOR; private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0); - + public UmbrellaTreeMembraneBlock() { super(FabricBlockSettings.copyOf(Blocks.SLIME_BLOCK)); } - + @Override public BlockState getPlacementState(ItemPlacementContext ctx) { double px = ctx.getBlockPos().getX() * 0.1; double py = ctx.getBlockPos().getY() * 0.1; double pz = ctx.getBlockPos().getZ() * 0.1; - return this.getDefaultState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4)); + return this.defaultBlockState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(COLOR); } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.TRANSLUCENT; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - if (state.get(COLOR) > 0) { + public List getDrops(BlockState state, LootContext.Builder builder) { + if (state.getValue(COLOR) > 0) { return Lists.newArrayList(new ItemStack(this)); - } - else { - return MHelper.RANDOM.nextInt(4) == 0 ? Lists.newArrayList(new ItemStack(EndBlocks.UMBRELLA_TREE_SAPLING)) : Collections.emptyList(); + } else { + return MHelper.RANDOM.nextInt(4) == 0 ? Lists.newArrayList(new ItemStack(EndBlocks.UMBRELLA_TREE_SAPLING)) + : Collections.emptyList(); } } - + @Override public String getStatesPattern(Reader data) { - String block = Registry.BLOCK.getId(this).getPath(); + String block = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, block, block); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_SIMPLE; } @Override public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) { - return state.get(COLOR) > 0; + return state.getValue(COLOR) > 0; } - + @Environment(EnvType.CLIENT) public boolean isSideInvisible(BlockState state, BlockState stateFrom, Direction direction) { - if (state.get(COLOR) > 0) { + if (state.getValue(COLOR) > 0) { return super.isSideInvisible(state, stateFrom, direction); - } - else { + } else { return false; } } diff --git a/src/main/java/ru/betterend/blocks/UmbrellaTreeSaplingBlock.java b/src/main/java/ru/betterend/blocks/UmbrellaTreeSaplingBlock.java index eba60eff..fc80eff0 100644 --- a/src/main/java/ru/betterend/blocks/UmbrellaTreeSaplingBlock.java +++ b/src/main/java/ru/betterend/blocks/UmbrellaTreeSaplingBlock.java @@ -1,7 +1,7 @@ package ru.betterend.blocks; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; import net.minecraft.world.WorldView; import net.minecraft.world.gen.feature.Feature; import ru.betterend.blocks.basis.FeatureSaplingBlock; @@ -18,12 +18,12 @@ public class UmbrellaTreeSaplingBlock extends FeatureSaplingBlock { protected Feature getFeature() { return EndFeatures.UMBRELLA_TREE.getFeature(); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - return world.getBlockState(pos.down()).isOf(EndBlocks.JUNGLE_MOSS); + return world.getBlockState(pos.below()).is(EndBlocks.JUNGLE_MOSS); } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.TRANSLUCENT; diff --git a/src/main/java/ru/betterend/blocks/VentBubbleColumnBlock.java b/src/main/java/ru/betterend/blocks/VentBubbleColumnBlock.java index 970d866a..8ce6c201 100644 --- a/src/main/java/ru/betterend/blocks/VentBubbleColumnBlock.java +++ b/src/main/java/ru/betterend/blocks/VentBubbleColumnBlock.java @@ -5,29 +5,29 @@ import java.util.Random; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockRenderType; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FluidDrainable; -import net.minecraft.block.FluidFillable; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.entity.Entity; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.BlockRenderType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FluidDrainable; +import net.minecraft.world.level.block.FluidFillable; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.entity.Entity; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.registry.EndBlocks; import ru.betterend.util.BlocksHelper; @@ -38,11 +38,11 @@ public class VentBubbleColumnBlock extends Block implements FluidDrainable, Flui } @Override - public Fluid tryDrainFluid(WorldAccess world, BlockPos pos, BlockState state) { - world.setBlockState(pos, Blocks.AIR.getDefaultState(), 11); + public Fluid tryDrainFluid(LevelAccessor world, BlockPos pos, BlockState state) { + world.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState(), 11); return Fluids.WATER; } - + @Override public BlockRenderType getRenderType(BlockState state) { return BlockRenderType.INVISIBLE; @@ -50,8 +50,8 @@ public class VentBubbleColumnBlock extends Block implements FluidDrainable, Flui @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - BlockState blockState = world.getBlockState(pos.down()); - return blockState.isOf(this) || blockState.isOf(EndBlocks.HYDROTHERMAL_VENT); + BlockState blockState = world.getBlockState(pos.below()); + return blockState.is(this) || blockState.is(EndBlocks.HYDROTHERMAL_VENT); } @Override @@ -60,13 +60,13 @@ public class VentBubbleColumnBlock extends Block implements FluidDrainable, Flui } @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) { + public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, + BlockPos pos, BlockPos posFrom) { if (!state.canPlaceAt(world, pos)) { - return Blocks.WATER.getDefaultState(); - } - else { + return Blocks.WATER.defaultBlockState(); + } else { BlockPos up = pos.up(); - if (world.getBlockState(up).isOf(Blocks.WATER)) { + if (world.getBlockState(up).is(Blocks.WATER)) { BlocksHelper.setWithoutUpdate(world, up, this); world.getBlockTickScheduler().schedule(up, this, 5); } @@ -75,7 +75,7 @@ public class VentBubbleColumnBlock extends Block implements FluidDrainable, Flui } @Environment(EnvType.CLIENT) - public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { + public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { if (random.nextInt(4) == 0) { double px = pos.getX() + random.nextDouble(); double py = pos.getY() + random.nextDouble(); @@ -83,39 +83,43 @@ public class VentBubbleColumnBlock extends Block implements FluidDrainable, Flui world.addImportantParticle(ParticleTypes.BUBBLE_COLUMN_UP, px, py, pz, 0, 0.04, 0); } if (random.nextInt(200) == 0) { - world.playSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT, SoundCategory.BLOCKS, 0.2F + random.nextFloat() * 0.2F, 0.9F + random.nextFloat() * 0.15F, false); + world.playLocalSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT, + SoundSource.BLOCKS, 0.2F + random.nextFloat() * 0.2F, 0.9F + random.nextFloat() * 0.15F, false); } } @Environment(EnvType.CLIENT) - public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { + public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { BlockState blockState = world.getBlockState(pos.up()); if (blockState.isAir()) { entity.onBubbleColumnSurfaceCollision(false); - if (!world.isClient) { - ServerWorld serverWorld = (ServerWorld) world; + if (!world.isClientSide) { + ServerLevel serverWorld = (ServerLevel) world; for (int i = 0; i < 2; ++i) { - serverWorld.spawnParticles(ParticleTypes.SPLASH, (double) pos.getX() + world.random.nextDouble(), (double) (pos.getY() + 1), (double) pos.getZ() + world.random.nextDouble(), 1, 0.0D, 0.0D, 0.0D, 1.0D); - serverWorld.spawnParticles(ParticleTypes.BUBBLE, (double) pos.getX() + world.random.nextDouble(), (double) (pos.getY() + 1), (double) pos.getZ() + world.random.nextDouble(), 1, 0.0D, 0.01D, 0.0D, 0.2D); + serverWorld.sendParticles(ParticleTypes.SPLASH, (double) pos.getX() + world.random.nextDouble(), + (double) (pos.getY() + 1), (double) pos.getZ() + world.random.nextDouble(), 1, 0.0D, 0.0D, + 0.0D, 1.0D); + serverWorld.sendParticles(ParticleTypes.BUBBLE, (double) pos.getX() + world.random.nextDouble(), + (double) (pos.getY() + 1), (double) pos.getZ() + world.random.nextDouble(), 1, 0.0D, 0.01D, + 0.0D, 0.2D); } } - } - else { + } else { entity.onBubbleColumnCollision(false); } } - + @Override public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) { return false; } @Override - public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) { + public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) { return false; } - + @Override public FluidState getFluidState(BlockState state) { return Fluids.WATER.getStill(false); diff --git a/src/main/java/ru/betterend/blocks/basis/AttachedBlock.java b/src/main/java/ru/betterend/blocks/basis/AttachedBlock.java index 25b73d13..6c0919cf 100644 --- a/src/main/java/ru/betterend/blocks/basis/AttachedBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/AttachedBlock.java @@ -1,38 +1,38 @@ package ru.betterend.blocks.basis; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.Properties; -import net.minecraft.tag.BlockTags; +import net.minecraft.tags.BlockTags; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.util.BlocksHelper; public abstract class AttachedBlock extends BlockBaseNotFull { public static final DirectionProperty FACING = Properties.FACING; - - public AttachedBlock(Settings settings) { + + public AttachedBlock(Properties settings) { super(settings); - this.setDefaultState(this.getDefaultState().with(FACING, Direction.UP)); + this.setDefaultState(this.defaultBlockState().with(FACING, Direction.UP)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(FACING); } - + @Override public BlockState getPlacementState(ItemPlacementContext ctx) { - BlockState blockState = this.getDefaultState(); - WorldView worldView = ctx.getWorld(); + BlockState blockState = this.defaultBlockState(); + WorldView worldView = ctx.getLevel(); BlockPos blockPos = ctx.getBlockPos(); Direction[] directions = ctx.getPlacementDirections(); for (int i = 0; i < directions.length; ++i) { @@ -48,24 +48,24 @@ public abstract class AttachedBlock extends BlockBaseNotFull { @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - Direction direction = (Direction) state.get(FACING); - BlockPos blockPos = pos.offset(direction.getOpposite()); - return sideCoversSmallSquare(world, blockPos, direction) || world.getBlockState(blockPos).isIn(BlockTags.LEAVES); + Direction direction = (Direction) state.getValue(FACING); + BlockPos blockPos = pos.relative(direction.getOpposite()); + return sideCoversSmallSquare(world, blockPos, direction) + || world.getBlockState(blockPos).isIn(BlockTags.LEAVES); } @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (!canPlaceAt(state, world, pos)) { - return Blocks.AIR.getDefaultState(); - } - else { + return Blocks.AIR.defaultBlockState(); + } else { return state; } } - @Override - public BlockState rotate(BlockState state, BlockRotation rotation) { + public BlockState rotate(BlockState state, Rotation rotation) { return BlocksHelper.rotateHorizontal(state, rotation, FACING); } diff --git a/src/main/java/ru/betterend/blocks/basis/BarkBlock.java b/src/main/java/ru/betterend/blocks/basis/BarkBlock.java index f6c3587b..36b39146 100644 --- a/src/main/java/ru/betterend/blocks/basis/BarkBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/BarkBlock.java @@ -2,28 +2,28 @@ package ru.betterend.blocks.basis; import java.io.Reader; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.patterns.Patterns; public class BarkBlock extends EndPillarBlock { - public BarkBlock(Settings settings) { + public BarkBlock(Properties settings) { super(settings); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); return Patterns.createJson(Patterns.BLOCK_BASE, getName(blockId), blockId.getPath()); } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); return Patterns.createJson(data, getName(blockId), blockId.getPath()); } - - private String getName(Identifier blockId) { + + private String getName(ResourceLocation blockId) { String name = blockId.getPath(); return name.replace("_bark", "_log_side"); } diff --git a/src/main/java/ru/betterend/blocks/basis/BaseBlockWithEntity.java b/src/main/java/ru/betterend/blocks/basis/BaseBlockWithEntity.java index b0f49174..9f4ead5f 100644 --- a/src/main/java/ru/betterend/blocks/basis/BaseBlockWithEntity.java +++ b/src/main/java/ru/betterend/blocks/basis/BaseBlockWithEntity.java @@ -3,15 +3,15 @@ package ru.betterend.blocks.basis; import java.util.Collections; import java.util.List; -import net.minecraft.block.BlockState; -import net.minecraft.block.BlockWithEntity; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.BlockWithEntity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.BlockGetter; public class BaseBlockWithEntity extends BlockWithEntity { - public BaseBlockWithEntity(Settings settings) { + public BaseBlockWithEntity(Properties settings) { super(settings); } @@ -19,9 +19,9 @@ public class BaseBlockWithEntity extends BlockWithEntity { public BlockEntity createBlockEntity(BlockView world) { return null; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } } diff --git a/src/main/java/ru/betterend/blocks/basis/BlockBase.java b/src/main/java/ru/betterend/blocks/basis/BlockBase.java index cdebbf74..04dddbf3 100644 --- a/src/main/java/ru/betterend/blocks/basis/BlockBase.java +++ b/src/main/java/ru/betterend/blocks/basis/BlockBase.java @@ -4,39 +4,39 @@ import java.io.Reader; import java.util.Collections; import java.util.List; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; +import net.minecraft.world.item.ItemStack; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.storage.loot.LootContext; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; public class BlockBase extends Block implements BlockPatterned { - public BlockBase(Settings settings) { + public BlockBase(Properties settings) { super(settings); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState blockState, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - String block = Registry.BLOCK.getId(this).getPath(); + String block = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, block, block); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_SIMPLE; } } diff --git a/src/main/java/ru/betterend/blocks/basis/BlockBaseNotFull.java b/src/main/java/ru/betterend/blocks/basis/BlockBaseNotFull.java index dbf23923..34d51d6f 100644 --- a/src/main/java/ru/betterend/blocks/basis/BlockBaseNotFull.java +++ b/src/main/java/ru/betterend/blocks/basis/BlockBaseNotFull.java @@ -1,13 +1,13 @@ package ru.betterend.blocks.basis; -import net.minecraft.block.BlockState; -import net.minecraft.entity.EntityType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.EntityType; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; public class BlockBaseNotFull extends BlockBase { - public BlockBaseNotFull(Settings settings) { + public BlockBaseNotFull(Properties settings) { super(settings); } diff --git a/src/main/java/ru/betterend/blocks/basis/DoublePlantBlock.java b/src/main/java/ru/betterend/blocks/basis/DoublePlantBlock.java index fd8f7570..a997b782 100644 --- a/src/main/java/ru/betterend/blocks/basis/DoublePlantBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/DoublePlantBlock.java @@ -7,32 +7,32 @@ import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Fertilizable; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.Fertilizable; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.entity.ItemEntity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.blocks.BlockProperties; import ru.betterend.client.render.ERenderLayer; @@ -42,30 +42,25 @@ import ru.betterend.util.BlocksHelper; public class DoublePlantBlock extends BlockBaseNotFull implements IRenderTypeable, Fertilizable { private static final VoxelShape SHAPE = Block.createCuboidShape(4, 2, 4, 12, 16, 12); - public static final IntProperty ROTATION = BlockProperties.ROTATION; + public static final IntegerProperty ROTATION = BlockProperties.ROTATION; public static final BooleanProperty TOP = BooleanProperty.of("top"); - + public DoublePlantBlock() { - super(FabricBlockSettings.of(Material.PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.WET_GRASS) - .breakByHand(true) - .noCollision()); - this.setDefaultState(this.stateManager.getDefaultState().with(TOP, false)); + super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.WET_GRASS) + .breakByHand(true).noCollision()); + this.setDefaultState(this.stateManager.defaultBlockState().with(TOP, false)); } - + public DoublePlantBlock(int light) { - super(FabricBlockSettings.of(Material.PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.WET_GRASS) - .luminance((state) -> { return state.get(TOP) ? light : 0; }) - .breakByHand(true) - .noCollision()); - this.setDefaultState(this.stateManager.getDefaultState().with(TOP, false)); + super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.WET_GRASS) + .luminance((state) -> { + return state.getValue(TOP) ? light : 0; + }).breakByHand(true).noCollision()); + this.setDefaultState(this.stateManager.defaultBlockState().with(TOP, false)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(TOP, ROTATION); } @@ -82,46 +77,46 @@ public class DoublePlantBlock extends BlockBaseNotFull implements IRenderTypeabl @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - BlockState down = world.getBlockState(pos.down()); + BlockState down = world.getBlockState(pos.below()); BlockState up = world.getBlockState(pos.up()); - return state.get(TOP) ? down.getBlock() == this : isTerrain(down) && (up.getMaterial().isReplaceable()); + return state.getValue(TOP) ? down.getBlock() == this : isTerrain(down) && (up.getMaterial().isReplaceable()); } - + public boolean canStayAt(BlockState state, WorldView world, BlockPos pos) { - BlockState down = world.getBlockState(pos.down()); + BlockState down = world.getBlockState(pos.below()); BlockState up = world.getBlockState(pos.up()); - return state.get(TOP) ? down.getBlock() == this : isTerrain(down) && (up.getBlock() == this); + return state.getValue(TOP) ? down.getBlock() == this : isTerrain(down) && (up.getBlock() == this); } protected boolean isTerrain(BlockState state) { return state.isIn(EndTags.END_GROUND); } - + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (!canStayAt(state, world, pos)) { - return Blocks.AIR.getDefaultState(); - } - else { + return Blocks.AIR.defaultBlockState(); + } else { return state; } } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - if (state.get(TOP)) { + public List getDrops(BlockState state, LootContext.Builder builder) { + if (state.getValue(TOP)) { return Lists.newArrayList(); } - - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) + || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Lists.newArrayList(new ItemStack(this)); - } - else { + } else { return Lists.newArrayList(); } } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; @@ -133,20 +128,21 @@ public class DoublePlantBlock extends BlockBaseNotFull implements IRenderTypeabl } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { return true; } @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(this)); + public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) { + ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, + new ItemStack(this)); world.spawnEntity(item); } - + @Override - public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) { + public void onPlaced(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) { int rot = world.random.nextInt(4); - BlockState bs = this.getDefaultState().with(ROTATION, rot); + BlockState bs = this.defaultBlockState().with(ROTATION, rot); BlocksHelper.setWithoutUpdate(world, pos, bs); BlocksHelper.setWithoutUpdate(world, pos.up(), bs.with(TOP, true)); } diff --git a/src/main/java/ru/betterend/blocks/basis/EndAnvilBlock.java b/src/main/java/ru/betterend/blocks/basis/EndAnvilBlock.java index ca836924..b45bca97 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndAnvilBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndAnvilBlock.java @@ -8,74 +8,74 @@ import java.util.Map; import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.AnvilBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.MaterialColor; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.AnvilBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.blocks.BlockProperties; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; public class EndAnvilBlock extends AnvilBlock implements BlockPatterned { - private static final IntProperty DESTRUCTION = BlockProperties.DESTRUCTION; + private static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION; protected final int level; - + public EndAnvilBlock(MaterialColor color, int level) { super(FabricBlockSettings.copyOf(Blocks.ANVIL).materialColor(color)); this.level = level; } - + @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + super.createBlockStateDefinition(builder); builder.add(DESTRUCTION); } - public IntProperty getDestructionProperty() { + public IntegerProperty getDESTRUCTION() { return DESTRUCTION; } public int getCraftingLevel() { return level; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); return Patterns.createJson(data, blockId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); Map map = Maps.newHashMap(); map.put("%anvil%", blockId.getPath()); map.put("%top%", getTop(blockId, block)); return Patterns.createJson(Patterns.BLOCK_ANVIL, map); } - protected String getTop(Identifier blockId, String block) { + protected String getTop(ResourceLocation blockId, String block) { if (block.contains("item")) { return blockId.getPath() + "_top_0"; } char last = block.charAt(block.length() - 1); return blockId.getPath() + "_top_" + last; } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_ANVIL; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndBarrelBlock.java b/src/main/java/ru/betterend/blocks/basis/EndBarrelBlock.java index 7098b82b..63eb7bf7 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndBarrelBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndBarrelBlock.java @@ -5,26 +5,26 @@ import java.util.List; import java.util.Random; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.BarrelBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockRenderType; -import net.minecraft.block.BlockState; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.mob.PiglinBrain; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.server.world.ServerWorld; +import net.minecraft.world.level.block.BarrelBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.BlockRenderType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.mob.PiglinBrain; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.server.level.ServerLevel; import net.minecraft.stat.Stats; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Registry; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import ru.betterend.blocks.entities.EBarrelBlockEntity; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; @@ -41,16 +41,16 @@ public class EndBarrelBlock extends BarrelBlock implements BlockPatterned { } @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - List drop = super.getDroppedStacks(state, builder); + public List getDrops(BlockState state, LootContext.Builder builder) { + List drop = super.getDrops(state, builder); drop.add(new ItemStack(this.asItem())); return drop; } @Override - public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, + public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - if (world.isClient) { + if (world.isClientSide) { return ActionResult.SUCCESS; } else { BlockEntity blockEntity = world.getBlockEntity(pos); @@ -65,7 +65,7 @@ public class EndBarrelBlock extends BarrelBlock implements BlockPatterned { } @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { BlockEntity blockEntity = world.getBlockEntity(pos); if (blockEntity instanceof EBarrelBlockEntity) { ((EBarrelBlockEntity) blockEntity).tick(); @@ -78,8 +78,7 @@ public class EndBarrelBlock extends BarrelBlock implements BlockPatterned { } @Override - public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, - ItemStack itemStack) { + public void onPlaced(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) { if (itemStack.hasCustomName()) { BlockEntity blockEntity = world.getBlockEntity(pos); if (blockEntity instanceof EBarrelBlockEntity) { @@ -87,24 +86,24 @@ public class EndBarrelBlock extends BarrelBlock implements BlockPatterned { } } } - + @Override public String getStatesPattern(Reader data) { - String block = Registry.BLOCK.getId(this).getPath(); + String block = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, block, block); } - + @Override public String getModelPattern(String block) { - String texture = Registry.BLOCK.getId(this).getPath(); + String texture = Registry.BLOCK.getKey(this).getPath(); if (block.contains("open")) { return Patterns.createJson(Patterns.BLOCK_BARREL_OPEN, texture, texture); } return Patterns.createJson(Patterns.BLOCK_BOTTOM_TOP, texture, texture); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_BARREL; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndBlockStripableLogLog.java b/src/main/java/ru/betterend/blocks/basis/EndBlockStripableLogLog.java index 8813267a..955e3d50 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndBlockStripableLogLog.java +++ b/src/main/java/ru/betterend/blocks/basis/EndBlockStripableLogLog.java @@ -2,36 +2,38 @@ package ru.betterend.blocks.basis; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.MaterialColor; -import net.minecraft.block.PillarBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public class EndBlockStripableLogLog extends EndPillarBlock { private final Block striped; - + public EndBlockStripableLogLog(MaterialColor color, Block striped) { super(FabricBlockSettings.copyOf(striped).materialColor(color)); this.striped = striped; } - + @Override - public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand, + BlockHitResult hit) { if (player.getMainHandStack().getItem().isIn(FabricToolTags.AXES)) { - world.playSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); - if (!world.isClient) { - world.setBlockState(pos, striped.getDefaultState().with(PillarBlock.AXIS, state.get(PillarBlock.AXIS)), 11); + world.playLocalSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F); + if (!world.isClientSide) { + world.setBlockAndUpdate(pos, striped.defaultBlockState().with(RotatedPillarBlock.AXIS, + state.getValue(RotatedPillarBlock.AXIS)), 11); if (player != null && !player.isCreative()) { - player.getMainHandStack().damage(1, world.random, (ServerPlayerEntity) player); + player.getMainHandStack().damage(1, world.random, (ServerPlayer) player); } } return ActionResult.SUCCESS; diff --git a/src/main/java/ru/betterend/blocks/basis/EndBookshelfBlock.java b/src/main/java/ru/betterend/blocks/basis/EndBookshelfBlock.java index 0916c4b0..82688186 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndBookshelfBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndBookshelfBlock.java @@ -5,53 +5,53 @@ import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.patterns.Patterns; public class EndBookshelfBlock extends BlockBase { public EndBookshelfBlock(Block source) { super(FabricBlockSettings.copyOf(source)); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && tool.isEffectiveOn(state)) { - int silk = EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool); + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && tool.isCorrectToolForDrops(state)) { + int silk = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool); if (silk > 0) { return Collections.singletonList(new ItemStack(this)); } } return Collections.singletonList(new ItemStack(Items.BOOK, 3)); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_SIMPLE; } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); return Patterns.createJson(Patterns.BLOCK_BOOKSHELF, getName(blockId), blockId.getPath()); } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); return Patterns.createJson(data, getName(blockId), blockId.getPath()); } - - private String getName(Identifier blockId) { + + private String getName(ResourceLocation blockId) { String name = blockId.getPath(); return name.replace("_bookshelf", ""); } diff --git a/src/main/java/ru/betterend/blocks/basis/EndChainBlock.java b/src/main/java/ru/betterend/blocks/basis/EndChainBlock.java index 993d06a2..a28dac5e 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndChainBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndChainBlock.java @@ -5,14 +5,14 @@ import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ChainBlock; -import net.minecraft.block.MaterialColor; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ChainBlock; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.patterns.BlockPatterned; @@ -22,32 +22,32 @@ public class EndChainBlock extends ChainBlock implements BlockPatterned, IRender public EndChainBlock(MaterialColor color) { super(FabricBlockSettings.copyOf(Blocks.CHAIN).materialColor(color)); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); return Patterns.createJson(data, blockId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); if (block.contains("item")) { return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath()); } return Patterns.createJson(Patterns.BLOCK_CHAIN, blockId.getPath(), blockId.getPath()); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_CHAIN; } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; diff --git a/src/main/java/ru/betterend/blocks/basis/EndChestBlock.java b/src/main/java/ru/betterend/blocks/basis/EndChestBlock.java index 1d4d5582..d146316f 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndChestBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndChestBlock.java @@ -4,62 +4,60 @@ import java.io.Reader; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.ChestBlock; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; +import net.minecraft.world.level.BlockGetter; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; import ru.betterend.registry.EndBlockEntities; public class EndChestBlock extends ChestBlock implements BlockPatterned { private final Block parent; - + public EndChestBlock(Block source) { super(FabricBlockSettings.copyOf(source).nonOpaque(), () -> { return EndBlockEntities.CHEST; }); this.parent = source; } - + @Override - public BlockEntity createBlockEntity(BlockView world) - { + public BlockEntity createBlockEntity(BlockView world) { return EndBlockEntities.CHEST.instantiate(); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) - { - List drop = super.getDroppedStacks(state, builder); + public List getDrops(BlockState state, LootContext.Builder builder) { + List drop = super.getDrops(state, builder); drop.add(new ItemStack(this.asItem())); return drop; } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); return Patterns.createJson(data, parentId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String path) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); if (path.contains("item")) { return Patterns.createJson(Patterns.ITEM_CHEST, blockId.getPath()); } return Patterns.createJson(Patterns.BLOCK_EMPTY, parentId.getPath()); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_SIMPLE; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndComposterBlock.java b/src/main/java/ru/betterend/blocks/basis/EndComposterBlock.java index 8d8a77f2..db82d4bd 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndComposterBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndComposterBlock.java @@ -5,13 +5,13 @@ import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.ComposterBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.ComposterBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; @@ -19,27 +19,27 @@ public class EndComposterBlock extends ComposterBlock implements BlockPatterned public EndComposterBlock(Block source) { super(FabricBlockSettings.copyOf(source)); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this.asItem())); } - + @Override public String getStatesPattern(Reader data) { - String blockId = Registry.BLOCK.getId(this).getPath(); + String blockId = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, blockId, blockId); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); String blockName = blockId.getPath(); return Patterns.createJson(Patterns.BLOCK_COMPOSTER, blockName); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_COMPOSTER; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndCraftingTableBlock.java b/src/main/java/ru/betterend/blocks/basis/EndCraftingTableBlock.java index a918ac34..2e8da6d9 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndCraftingTableBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndCraftingTableBlock.java @@ -6,13 +6,13 @@ import java.util.HashMap; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.CraftingTableBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.CraftingTableBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; @@ -22,19 +22,19 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockPa } @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this.asItem())); } - + @Override public String getStatesPattern(Reader data) { - String blockId = Registry.BLOCK.getId(this).getPath(); + String blockId = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, blockId, blockId); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); String blockName = blockId.getPath(); return Patterns.createJson(Patterns.BLOCK_SIDED, new HashMap() { private static final long serialVersionUID = 1L; @@ -49,9 +49,9 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockPa } }); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_SIMPLE; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndCropBlock.java b/src/main/java/ru/betterend/blocks/basis/EndCropBlock.java index 2ff00d6b..e8e75e3c 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndCropBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndCropBlock.java @@ -8,74 +8,70 @@ import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import ru.betterend.util.BlocksHelper; import ru.betterend.util.MHelper; public class EndCropBlock extends EndPlantBlock { private static final VoxelShape SHAPE = Block.createCuboidShape(2, 0, 2, 14, 14, 14); - public static final IntProperty AGE = IntProperty.of("age", 0, 3); - + public static final IntegerProperty AGE = IntegerProperty.of("age", 0, 3); + private final Block[] terrain; private final Item drop; - + public EndCropBlock(Item drop, Block... terrain) { - super(FabricBlockSettings.of(Material.PLANT) - .breakByTool(FabricToolTags.HOES) - .sounds(BlockSoundGroup.GRASS) - .breakByHand(true) - .ticksRandomly() - .noCollision()); + super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.HOES).sounds(SoundType.GRASS) + .breakByHand(true).ticksRandomly().noCollision()); this.drop = drop; this.terrain = terrain; this.setDefaultState(getDefaultState().with(AGE, 0)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(AGE); } - + @Override protected boolean isTerrain(BlockState state) { - for (Block block: terrain) { - if (state.isOf(block)) { + for (Block block : terrain) { + if (state.is(block)) { return true; } } return false; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - if (state.get(AGE) < 3) { + public List getDrops(BlockState state, LootContext.Builder builder) { + if (state.getValue(AGE) < 3) { return Collections.singletonList(new ItemStack(this)); } - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && tool.isEffectiveOn(state)) { - int enchantment = EnchantmentHelper.getLevel(Enchantments.FORTUNE, tool); + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && tool.isCorrectToolForDrops(state)) { + int enchantment = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool); if (enchantment > 0) { - int countSeeds = MHelper.randRange(MathHelper.clamp(1 + enchantment, 1, 3), 3, MHelper.RANDOM); - int countDrops = MHelper.randRange(MathHelper.clamp(1 + enchantment, 1, 2), 2, MHelper.RANDOM); + int countSeeds = MHelper.randRange(Mth.clamp(1 + enchantment, 1, 3), 3, MHelper.RANDOM); + int countDrops = MHelper.randRange(Mth.clamp(1 + enchantment, 1, 2), 2, MHelper.RANDOM); return Lists.newArrayList(new ItemStack(this, countSeeds), new ItemStack(drop, countDrops)); } } @@ -83,38 +79,38 @@ public class EndCropBlock extends EndPlantBlock { int countDrops = MHelper.randRange(1, 2, MHelper.RANDOM); return Lists.newArrayList(new ItemStack(this, countSeeds), new ItemStack(drop, countDrops)); } - + @Override public AbstractBlock.OffsetType getOffsetType() { return AbstractBlock.OffsetType.NONE; } - + @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - int age = state.get(AGE); + public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) { + int age = state.getValue(AGE); if (age < 3) { BlocksHelper.setWithUpdate(world, pos, state.with(AGE, age + 1)); } } - + @Override public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { - return state.get(AGE) < 3; + return state.getValue(AGE) < 3; } - + @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { - return state.get(AGE) < 3; + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { + return state.getValue(AGE) < 3; } - + @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { super.scheduledTick(state, world, pos, random); if (canGrow(world, random, pos, state) && random.nextInt(8) == 0) { grow(world, random, pos, state); } } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { return SHAPE; diff --git a/src/main/java/ru/betterend/blocks/basis/EndDoorBlock.java b/src/main/java/ru/betterend/blocks/basis/EndDoorBlock.java index 797eb73d..8d6d21f8 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndDoorBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndDoorBlock.java @@ -1,31 +1,31 @@ package ru.betterend.blocks.basis; - + import java.io.Reader; import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.DoorBlock; -import net.minecraft.block.enums.DoubleBlockHalf; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.DoorBlock; +import net.minecraft.world.level.block.enums.DoubleBlockHalf; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.patterns.BlockPatterned; -import ru.betterend.patterns.Patterns; - +import ru.betterend.patterns.Patterns; + public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockPatterned { public EndDoorBlock(Block source) { super(FabricBlockSettings.copyOf(source).strength(3F, 3F).nonOpaque()); } @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - if (state.get(HALF) == DoubleBlockHalf.LOWER) + public List getDrops(BlockState state, LootContext.Builder builder) { + if (state.getValue(HALF) == DoubleBlockHalf.LOWER) return Collections.singletonList(new ItemStack(this.asItem())); else return Collections.emptyList(); @@ -35,16 +35,16 @@ public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockPat public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override public String getStatesPattern(Reader data) { - String blockId = Registry.BLOCK.getId(this).getPath(); + String blockId = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, blockId, blockId); } - + @Override public String getModelPattern(String block) { - String blockId = Registry.BLOCK.getId(this).getPath(); + String blockId = Registry.BLOCK.getKey(this).getPath(); if (block.contains("item")) { return Patterns.createJson(Patterns.ITEM_GENERATED, block); } @@ -59,9 +59,9 @@ public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockPat } return Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM, blockId, blockId); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_DOOR; } -} +} diff --git a/src/main/java/ru/betterend/blocks/basis/EndFenceBlock.java b/src/main/java/ru/betterend/blocks/basis/EndFenceBlock.java index e2c87c5e..30c55f1c 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndFenceBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndFenceBlock.java @@ -5,40 +5,40 @@ import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.FenceBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.FenceBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; public class EndFenceBlock extends FenceBlock implements BlockPatterned { private final Block parent; - + public EndFenceBlock(Block source) { super(FabricBlockSettings.copyOf(source).nonOpaque()); this.parent = source; } @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); return Patterns.createJson(data, parentId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); if (block.contains("item")) { return Patterns.createJson(Patterns.ITEM_FENCE, parentId.getPath(), blockId.getPath()); } @@ -47,9 +47,9 @@ public class EndFenceBlock extends FenceBlock implements BlockPatterned { } return Patterns.createJson(Patterns.BLOCK_FENCE_POST, parentId.getPath(), blockId.getPath()); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_FENCE; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndFurnaceBlock.java b/src/main/java/ru/betterend/blocks/basis/EndFurnaceBlock.java index 8e1daf69..5015766d 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndFurnaceBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndFurnaceBlock.java @@ -8,21 +8,21 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.FurnaceBlock; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.FurnaceBlock; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.screen.NamedScreenHandlerFactory; import net.minecraft.stat.Stats; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Registry; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import ru.betterend.blocks.entities.EFurnaceBlockEntity; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; @@ -32,7 +32,7 @@ import ru.betterend.patterns.Patterns; public class EndFurnaceBlock extends FurnaceBlock implements BlockPatterned, IRenderTypeable { public EndFurnaceBlock(Block source) { super(FabricBlockSettings.copyOf(source).luminance((state) -> { - return state.get(LIT) ? 13 : 0; + return state.getValue(LIT) ? 13 : 0; })); } @@ -40,25 +40,25 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockPatterned, IRe public BlockEntity createBlockEntity(BlockView world) { return new EFurnaceBlockEntity(); } - + @Override - protected void openScreen(World world, BlockPos pos, PlayerEntity player) { + protected void openScreen(Level world, BlockPos pos, PlayerEntity player) { BlockEntity blockEntity = world.getBlockEntity(pos); if (blockEntity instanceof EFurnaceBlockEntity) { player.openHandledScreen((NamedScreenHandlerFactory) blockEntity); player.incrementStat(Stats.INTERACT_WITH_FURNACE); } } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); return Patterns.createJson(data, blockId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); Map map = Maps.newHashMap(); map.put("%top%", blockId.getPath() + "_top"); map.put("%side%", blockId.getPath() + "_side"); @@ -66,15 +66,14 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockPatterned, IRe map.put("%front%", blockId.getPath() + "_front_on"); map.put("%glow%", blockId.getPath() + "_glow"); return Patterns.createJson(Patterns.BLOCK_FURNACE_GLOW, map); - } - else { + } else { map.put("%front%", blockId.getPath() + "_front"); return Patterns.createJson(Patterns.BLOCK_FURNACE, map); } } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_FURNACE; } @@ -82,11 +81,11 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockPatterned, IRe public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { List drop = Lists.newArrayList(new ItemStack(this)); - BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY); + BlockEntity blockEntity = builder.getNullable(LootContextParams.BLOCK_ENTITY); if (blockEntity instanceof EFurnaceBlockEntity) { EFurnaceBlockEntity entity = (EFurnaceBlockEntity) blockEntity; for (int i = 0; i < entity.size(); i++) { diff --git a/src/main/java/ru/betterend/blocks/basis/EndGateBlock.java b/src/main/java/ru/betterend/blocks/basis/EndGateBlock.java index f7c8c240..ed2946e7 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndGateBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndGateBlock.java @@ -5,40 +5,40 @@ import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.FenceGateBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.FenceGateBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; public class EndGateBlock extends FenceGateBlock implements BlockPatterned { private final Block parent; - + public EndGateBlock(Block source) { super(FabricBlockSettings.copyOf(source).nonOpaque()); this.parent = source; } @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); return Patterns.createJson(data, parentId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); if (block.contains("wall")) { if (block.contains("open")) { return Patterns.createJson(Patterns.BLOCK_GATE_OPEN_WALL, parentId.getPath(), blockId.getPath()); @@ -51,9 +51,9 @@ public class EndGateBlock extends FenceGateBlock implements BlockPatterned { } return Patterns.createJson(Patterns.BLOCK_GATE_CLOSED, parentId.getPath(), blockId.getPath()); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_GATE; } } \ No newline at end of file diff --git a/src/main/java/ru/betterend/blocks/basis/EndLadderBlock.java b/src/main/java/ru/betterend/blocks/basis/EndLadderBlock.java index eaade397..f5f264f9 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndLadderBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndLadderBlock.java @@ -3,27 +3,27 @@ package ru.betterend.blocks.basis; import java.io.Reader; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.HorizontalFacingBlock; -import net.minecraft.block.ShapeContext; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.HorizontalFacingBlock; +import net.minecraft.world.level.block.ShapeContext; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.state.StateManager; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Registry; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; @@ -44,13 +44,13 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable, } @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(FACING); stateManager.add(WATERLOGGED); } public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - switch (state.get(FACING)) { + switch (state.getValue(FACING)) { case SOUTH: return SOUTH_SHAPE; case WEST: @@ -69,21 +69,21 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable, @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - Direction direction = (Direction) state.get(FACING); - return this.canPlaceOn(world, pos.offset(direction.getOpposite()), direction); + Direction direction = (Direction) state.getValue(FACING); + return this.canPlaceOn(world, pos.relative(direction.getOpposite()), direction); } @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, - WorldAccess world, BlockPos pos, BlockPos neighborPos) { - if (facing.getOpposite() == state.get(FACING) && !state.canPlaceAt(world, pos)) { - return Blocks.AIR.getDefaultState(); + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { + if (facing.getOpposite() == state.getValue(FACING) && !state.canPlaceAt(world, pos)) { + return Blocks.AIR.defaultBlockState(); } else { - if ((Boolean) state.get(WATERLOGGED)) { + if ((Boolean) state.getValue(WATERLOGGED)) { world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } - return super.getStateForNeighborUpdate(state, facing, neighborState, world, pos, neighborPos); + return super.updateShape(state, facing, neighborState, world, pos, neighborPos); } } @@ -91,16 +91,16 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable, public BlockState getPlacementState(ItemPlacementContext ctx) { BlockState blockState2; if (!ctx.canReplaceExisting()) { - blockState2 = ctx.getWorld().getBlockState(ctx.getBlockPos().offset(ctx.getSide().getOpposite())); + blockState2 = ctx.getLevel().getBlockState(ctx.getBlockPos().offset(ctx.getSide().getOpposite())); if (blockState2.getBlock() == this && blockState2.get(FACING) == ctx.getSide()) { return null; } } - blockState2 = this.getDefaultState(); - WorldView worldView = ctx.getWorld(); + blockState2 = this.defaultBlockState(); + WorldView worldView = ctx.getLevel(); BlockPos blockPos = ctx.getBlockPos(); - FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos()); + FluidState fluidState = ctx.getLevel().getFluidState(ctx.getBlockPos()); Direction[] var6 = ctx.getPlacementDirections(); int var7 = var6.length; @@ -118,7 +118,7 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable, } @Override - public BlockState rotate(BlockState state, BlockRotation rotation) { + public BlockState rotate(BlockState state, Rotation rotation) { return BlocksHelper.rotateHorizontal(state, rotation, FACING); } @@ -129,31 +129,31 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable, @Override public FluidState getFluidState(BlockState state) { - return (Boolean) state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); + return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); } @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override public String getStatesPattern(Reader data) { - String blockId = Registry.BLOCK.getId(this).getPath(); + String blockId = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, blockId, blockId); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); if (block.contains("item")) { return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath()); } return Patterns.createJson(Patterns.BLOCK_LADDER, blockId.getPath()); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_LADDER; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndLanternBlock.java b/src/main/java/ru/betterend/blocks/basis/EndLanternBlock.java index 0b876665..dbbba91d 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndLanternBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndLanternBlock.java @@ -1,119 +1,110 @@ package ru.betterend.blocks.basis; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FluidFillable; -import net.minecraft.block.Waterloggable; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FluidFillable; +import net.minecraft.world.level.block.Waterloggable; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.state.StateManager; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.BlockView; -import net.minecraft.world.WorldAccess; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.blocks.BlockProperties; public class EndLanternBlock extends BlockBaseNotFull implements Waterloggable, FluidFillable { public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR; public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; - + public EndLanternBlock(Block source) { this(FabricBlockSettings.copyOf(source).luminance(15).nonOpaque()); } - + public EndLanternBlock(FabricBlockSettings settings) { super(settings.nonOpaque()); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(IS_FLOOR, WATERLOGGED); } - + @Override public BlockState getPlacementState(ItemPlacementContext ctx) { - WorldView worldView = ctx.getWorld(); + WorldView worldView = ctx.getLevel(); BlockPos blockPos = ctx.getBlockPos(); Direction dir = ctx.getSide(); boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER; if (dir != Direction.DOWN && dir != Direction.UP) { if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) { return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water); - } - else if (sideCoversSmallSquare(worldView, blockPos.down(), Direction.UP)) { + } else if (sideCoversSmallSquare(worldView, blockPos.below(), Direction.UP)) { return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water); - } - else { + } else { return null; } - } - else if (dir == Direction.DOWN) { + } else if (dir == Direction.DOWN) { if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) { return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water); - } - else if (sideCoversSmallSquare(worldView, blockPos.down(), Direction.UP)) { + } else if (sideCoversSmallSquare(worldView, blockPos.below(), Direction.UP)) { return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water); - } - else { + } else { return null; } - } - else { - if (sideCoversSmallSquare(worldView, blockPos.down(), Direction.UP)) { + } else { + if (sideCoversSmallSquare(worldView, blockPos.below(), Direction.UP)) { return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water); - } - else if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) { + } else if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) { return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water); - } - else { + } else { return null; } } } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - if (state.get(IS_FLOOR)) { - return sideCoversSmallSquare(world, pos.down(), Direction.UP); - } - else { + if (state.getValue(IS_FLOOR)) { + return sideCoversSmallSquare(world, pos.below(), Direction.UP); + } else { return sideCoversSmallSquare(world, pos.up(), Direction.DOWN); } } - + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { - Boolean water = state.get(WATERLOGGED); + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { + Boolean water = state.getValue(WATERLOGGED); if (water) { world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } if (!canPlaceAt(state, world, pos)) { - return water ? Blocks.WATER.getDefaultState() : Blocks.AIR.getDefaultState(); - } - else { + return water ? Blocks.WATER.defaultBlockState() : Blocks.AIR.defaultBlockState(); + } else { return state; } } - + @Override public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) { return false; } @Override - public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) { + public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) { return false; } - + @Override public FluidState getFluidState(BlockState state) { - return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.getDefaultState(); + return state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.defaultBlockState(); } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndLeavesBlock.java b/src/main/java/ru/betterend/blocks/basis/EndLeavesBlock.java index cb4e6ee9..b5b45e92 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndLeavesBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndLeavesBlock.java @@ -8,18 +8,18 @@ import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.MaterialColor; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.patterns.BlockPatterned; @@ -28,61 +28,60 @@ import ru.betterend.util.MHelper; public class EndLeavesBlock extends LeavesBlock implements BlockPatterned, IRenderTypeable { private final Block sapling; - + public EndLeavesBlock(Block sapling, MaterialColor color) { - super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES) - .allowsSpawning((state, world, pos, type) -> { return false; }) - .suffocates((state, world, pos) -> { return false; }) - .blockVision((state, world, pos) -> { return false; }) - .materialColor(color) - .breakByTool(FabricToolTags.HOES) - .breakByTool(FabricToolTags.SHEARS) - .breakByHand(true)); + super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES).allowsSpawning((state, world, pos, type) -> { + return false; + }).suffocates((state, world, pos) -> { + return false; + }).blockVision((state, world, pos) -> { + return false; + }).materialColor(color).breakByTool(FabricToolTags.HOES).breakByTool(FabricToolTags.SHEARS).breakByHand(true)); this.sapling = sapling; } - + public EndLeavesBlock(Block sapling, MaterialColor color, int light) { - super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES) - .allowsSpawning((state, world, pos, type) -> { return false; }) - .suffocates((state, world, pos) -> { return false; }) - .blockVision((state, world, pos) -> { return false; }) - .materialColor(color) - .luminance(light) - .breakByTool(FabricToolTags.HOES) - .breakByTool(FabricToolTags.SHEARS)); + super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES).allowsSpawning((state, world, pos, type) -> { + return false; + }).suffocates((state, world, pos) -> { + return false; + }).blockVision((state, world, pos) -> { + return false; + }).materialColor(color).luminance(light).breakByTool(FabricToolTags.HOES).breakByTool(FabricToolTags.SHEARS)); this.sapling = sapling; } - + @Override public String getStatesPattern(Reader data) { - String blockId = Registry.BLOCK.getId(this).getPath(); + String blockId = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, blockId, blockId); } - + @Override public String getModelPattern(String block) { - String blockId = Registry.BLOCK.getId(this).getPath(); + String blockId = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(Patterns.BLOCK_BASE, blockId, blockId); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_SIMPLE; } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); if (tool != null) { - if (tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + if (tool.getItem().isIn(FabricToolTags.SHEARS) + || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Collections.singletonList(new ItemStack(this)); } - int fortune = EnchantmentHelper.getLevel(Enchantments.FORTUNE, tool); + int fortune = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool); if (MHelper.RANDOM.nextInt(16) <= fortune) { return Lists.newArrayList(new ItemStack(sapling)); } diff --git a/src/main/java/ru/betterend/blocks/basis/EndMetalPaneBlock.java b/src/main/java/ru/betterend/blocks/basis/EndMetalPaneBlock.java index 6ec846cd..a83998c1 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndMetalPaneBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndMetalPaneBlock.java @@ -7,14 +7,14 @@ import java.util.List; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.PaneBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.PaneBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Direction; +import net.minecraft.core.Registry; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.patterns.BlockPatterned; @@ -26,30 +26,29 @@ public class EndMetalPaneBlock extends PaneBlock implements BlockPatterned, IRen } @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); return Patterns.createJson(data, blockId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); if (block.contains("item")) { return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath()); } if (block.contains("post")) { return Patterns.createJson(Patterns.BLOCK_BARS_POST, blockId.getPath(), blockId.getPath()); - } - else { + } else { return Patterns.createJson(Patterns.BLOCK_BARS_SIDE, blockId.getPath(), blockId.getPath()); } } - + @Environment(EnvType.CLIENT) public boolean isSideInvisible(BlockState state, BlockState stateFrom, Direction direction) { if (direction.getAxis().isVertical() && stateFrom.getBlock().is(this) && !stateFrom.equals(state)) { @@ -57,12 +56,12 @@ public class EndMetalPaneBlock extends PaneBlock implements BlockPatterned, IRen } return super.isSideInvisible(state, stateFrom, direction); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_BARS; } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; diff --git a/src/main/java/ru/betterend/blocks/basis/EndMetalPlateBlock.java b/src/main/java/ru/betterend/blocks/basis/EndMetalPlateBlock.java index 8b6808f2..17a54773 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndMetalPlateBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndMetalPlateBlock.java @@ -5,48 +5,48 @@ import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.WeightedPressurePlateBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.WeightedPressurePlateBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; public class EndMetalPlateBlock extends WeightedPressurePlateBlock implements BlockPatterned { private final Block parent; - + public EndMetalPlateBlock(Block source) { super(15, FabricBlockSettings.copyOf(source).noCollision().nonOpaque().requiresTool().strength(0.5F)); this.parent = source; } @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); return Patterns.createJson(data, parentId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); if (block.contains("down")) { return Patterns.createJson(Patterns.BLOCK_PLATE_DOWN, parentId.getPath(), blockId.getPath()); } return Patterns.createJson(Patterns.BLOCK_PLATE_UP, parentId.getPath(), blockId.getPath()); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_PLATE; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndOreBlock.java b/src/main/java/ru/betterend/blocks/basis/EndOreBlock.java index 7ccab8b4..7e9750d0 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndOreBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndOreBlock.java @@ -6,20 +6,20 @@ import java.util.List; import java.util.Random; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; -import net.minecraft.block.OreBlock; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.block.OreBlock; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import net.minecraft.core.Registry; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; import ru.betterend.util.MHelper; @@ -29,36 +29,33 @@ public class EndOreBlock extends OreBlock implements BlockPatterned { private final int minCount; private final int maxCount; private final int expirience; - + public EndOreBlock(Item drop, int minCount, int maxCount, int expirience) { - super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND) - .hardness(3F) - .resistance(9F) - .requiresTool() - .sounds(BlockSoundGroup.STONE)); + super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND).hardness(3F).resistance(9F).requiresTool() + .sounds(SoundType.STONE)); this.dropItem = drop; this.minCount = minCount; this.maxCount = maxCount; this.expirience = expirience; } - + @Override protected int getExperienceWhenMined(Random random) { return this.expirience > 0 ? random.nextInt(expirience) + 1 : 0; } @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && tool.isEffectiveOn(state)) { - if (EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && tool.isCorrectToolForDrops(state)) { + if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Collections.singletonList(new ItemStack(this)); } int count = 0; - int enchantment = EnchantmentHelper.getLevel(Enchantments.FORTUNE, tool); + int enchantment = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool); if (enchantment > 0) { - int min = MathHelper.clamp(minCount + enchantment, minCount, maxCount); - int max = maxCount + (enchantment / Enchantments.FORTUNE.getMaxLevel()); + int min = Mth.clamp(minCount + enchantment, minCount, maxCount); + int max = maxCount + (enchantment / Enchantments.BLOCK_FORTUNE.getMaxLevel()); if (min == max) { return Collections.singletonList(new ItemStack(dropItem, max)); } @@ -70,21 +67,21 @@ public class EndOreBlock extends OreBlock implements BlockPatterned { } return Collections.emptyList(); } - + @Override public String getStatesPattern(Reader data) { - String block = Registry.BLOCK.getId(this).getPath(); + String block = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, block, block); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_SIMPLE; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndPillarBlock.java b/src/main/java/ru/betterend/blocks/basis/EndPillarBlock.java index 92941d8e..492115fd 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndPillarBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndPillarBlock.java @@ -5,44 +5,44 @@ import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.PillarBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; -public class EndPillarBlock extends PillarBlock implements BlockPatterned { - public EndPillarBlock(Settings settings) { +public class EndPillarBlock extends RotatedPillarBlock implements BlockPatterned { + public EndPillarBlock(Properties settings) { super(settings); } - + public EndPillarBlock(Block block) { super(FabricBlockSettings.copyOf(block)); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - String texture = Registry.BLOCK.getId(this).getPath(); + String texture = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, texture, texture); } - + @Override public String getModelPattern(String block) { - String texture = Registry.BLOCK.getId(this).getPath(); + String texture = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(Patterns.BLOCK_PILLAR, texture, texture); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_PILLAR; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndPlantBlock.java b/src/main/java/ru/betterend/blocks/basis/EndPlantBlock.java index b684f604..da0e6a7e 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndPlantBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndPlantBlock.java @@ -7,28 +7,28 @@ import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Fertilizable; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.entity.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.Fertilizable; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.entity.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; @@ -36,33 +36,27 @@ import ru.betterend.registry.EndTags; public class EndPlantBlock extends BlockBaseNotFull implements IRenderTypeable, Fertilizable { private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 14, 12); - + public EndPlantBlock() { this(false); } - + public EndPlantBlock(int light) { this(false, light); } - + public EndPlantBlock(boolean replaceable) { super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.GRASS) - .breakByHand(true) - .noCollision()); + .breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS).breakByHand(true).noCollision()); } - + public EndPlantBlock(boolean replaceable, int light) { super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.GRASS) - .luminance(light) - .breakByHand(true) + .breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS).luminance(light).breakByHand(true) .noCollision()); } - - public EndPlantBlock(Settings settings) { + + public EndPlantBlock(Properties settings) { super(settings); } @@ -79,35 +73,35 @@ public class EndPlantBlock extends BlockBaseNotFull implements IRenderTypeable, @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - BlockState down = world.getBlockState(pos.down()); + BlockState down = world.getBlockState(pos.below()); return isTerrain(down); } - + protected boolean isTerrain(BlockState state) { return state.isIn(EndTags.END_GROUND); } @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (!canPlaceAt(state, world, pos)) { - return Blocks.AIR.getDefaultState(); - } - else { + return Blocks.AIR.defaultBlockState(); + } else { return state; } } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) + || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Lists.newArrayList(new ItemStack(this)); - } - else { + } else { return Lists.newArrayList(); } } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; @@ -119,13 +113,14 @@ public class EndPlantBlock extends BlockBaseNotFull implements IRenderTypeable, } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { return true; } @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(this)); + public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) { + ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, + new ItemStack(this)); world.spawnEntity(item); } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndPlantWithAgeBlock.java b/src/main/java/ru/betterend/blocks/basis/EndPlantWithAgeBlock.java index b255d50b..fcdd6240 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndPlantWithAgeBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndPlantWithAgeBlock.java @@ -4,59 +4,54 @@ import java.util.Random; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.blocks.BlockProperties; public abstract class EndPlantWithAgeBlock extends EndPlantBlock { - public static final IntProperty AGE = BlockProperties.AGE; - + public static final IntegerProperty AGE = BlockProperties.AGE; + public EndPlantWithAgeBlock() { - this(FabricBlockSettings.of(Material.PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.GRASS) - .breakByHand(true) - .ticksRandomly() - .noCollision()); + this(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS) + .breakByHand(true).ticksRandomly().noCollision()); } - + public EndPlantWithAgeBlock(FabricBlockSettings settings) { super(settings); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(AGE); } - + public abstract void growAdult(StructureWorldAccess world, Random random, BlockPos pos); - + @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - int age = state.get(AGE); + public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) { + int age = state.getValue(AGE); if (age < 3) { - world.setBlockState(pos, state.with(AGE, age + 1)); - } - else { + world.setBlockAndUpdate(pos, state.with(AGE, age + 1)); + } else { growAdult(world, random, pos); } } - + @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { return true; } - + @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { super.scheduledTick(state, world, pos, random); if (random.nextInt(8) == 0) { grow(world, random, pos, state); diff --git a/src/main/java/ru/betterend/blocks/basis/EndPlateBlock.java b/src/main/java/ru/betterend/blocks/basis/EndPlateBlock.java index c38a3045..9bf2a9b6 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndPlateBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndPlateBlock.java @@ -5,48 +5,48 @@ import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.PressurePlateBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.PressurePlateBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; public class EndPlateBlock extends PressurePlateBlock implements BlockPatterned { private final Block parent; - + public EndPlateBlock(ActivationRule rule, Block source) { super(rule, FabricBlockSettings.copyOf(source).noCollision().nonOpaque().strength(0.5F)); this.parent = source; } @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); return Patterns.createJson(data, parentId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); if (block.contains("down")) { return Patterns.createJson(Patterns.BLOCK_PLATE_DOWN, parentId.getPath(), blockId.getPath()); } return Patterns.createJson(Patterns.BLOCK_PLATE_UP, parentId.getPath(), blockId.getPath()); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return this.stateManager.getProperty("facing") != null ? Patterns.STATE_PLATE_ROTATED : Patterns.STATE_PLATE; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndSignBlock.java b/src/main/java/ru/betterend/blocks/basis/EndSignBlock.java index b194dc26..a5687f85 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndSignBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndSignBlock.java @@ -5,38 +5,38 @@ import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.AbstractSignBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ShapeContext; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.level.block.AbstractSignBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.PlayerEntity; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.network.packet.s2c.play.SignEditorOpenS2CPacket; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.state.StateManager; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; -import net.minecraft.state.property.IntProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.Identifier; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.SignType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; +import net.minecraft.core.Registry; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.blocks.entities.ESignBlockEntity; import ru.betterend.interfaces.ISpetialItem; @@ -45,86 +45,84 @@ import ru.betterend.patterns.Patterns; import ru.betterend.util.BlocksHelper; public class EndSignBlock extends AbstractSignBlock implements BlockPatterned, ISpetialItem { - public static final IntProperty ROTATION = Properties.ROTATION; + public static final IntegerProperty ROTATION = Properties.ROTATION; public static final BooleanProperty FLOOR = BooleanProperty.of("floor"); private static final VoxelShape[] WALL_SHAPES = new VoxelShape[] { - Block.createCuboidShape(0.0D, 4.5D, 14.0D, 16.0D, 12.5D, 16.0D), - Block.createCuboidShape(0.0D, 4.5D, 0.0D, 2.0D, 12.5D, 16.0D), - Block.createCuboidShape(0.0D, 4.5D, 0.0D, 16.0D, 12.5D, 2.0D), - Block.createCuboidShape(14.0D, 4.5D, 0.0D, 16.0D, 12.5D, 16.0D) - }; + Block.createCuboidShape(0.0D, 4.5D, 14.0D, 16.0D, 12.5D, 16.0D), + Block.createCuboidShape(0.0D, 4.5D, 0.0D, 2.0D, 12.5D, 16.0D), + Block.createCuboidShape(0.0D, 4.5D, 0.0D, 16.0D, 12.5D, 2.0D), + Block.createCuboidShape(14.0D, 4.5D, 0.0D, 16.0D, 12.5D, 16.0D) }; private final Block parent; - + public EndSignBlock(Block source) { super(FabricBlockSettings.copyOf(source).strength(1.0F, 1.0F).noCollision().nonOpaque(), SignType.OAK); - this.setDefaultState(this.stateManager.getDefaultState().with(ROTATION, 0).with(FLOOR, false).with(WATERLOGGED, false)); + this.setDefaultState( + this.stateManager.defaultBlockState().with(ROTATION, 0).with(FLOOR, false).with(WATERLOGGED, false)); this.parent = source; } @Override - protected void appendProperties(StateManager.Builder builder) { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(ROTATION, FLOOR, WATERLOGGED); } @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return state.get(FLOOR) ? SHAPE : WALL_SHAPES[state.get(ROTATION) >> 2]; + return state.getValue(FLOOR) ? SHAPE : WALL_SHAPES[state.getValue(ROTATION) >> 2]; } @Override public BlockEntity createBlockEntity(BlockView world) { return new ESignBlockEntity(); } - + @Override - public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) { + public void onPlaced(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) { if (placer != null && placer instanceof PlayerEntity) { ESignBlockEntity sign = (ESignBlockEntity) world.getBlockEntity(pos); - if (!world.isClient) { + if (!world.isClientSide) { sign.setEditor((PlayerEntity) placer); - ((ServerPlayerEntity) placer).networkHandler.sendPacket(new SignEditorOpenS2CPacket(pos)); - } - else { + ((ServerPlayer) placer).networkHandler.sendPacket(new SignEditorOpenS2CPacket(pos)); + } else { sign.setEditable(true); } } } @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { - if ((Boolean) state.get(WATERLOGGED)) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { + if ((Boolean) state.getValue(WATERLOGGED)) { world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } if (!canPlaceAt(state, world, pos)) { - return state.get(WATERLOGGED) ? state.getFluidState().getBlockState() : Blocks.AIR.getDefaultState(); + return state.getValue(WATERLOGGED) ? state.getFluidState().getBlockState() : Blocks.AIR.defaultBlockState(); } - return super.getStateForNeighborUpdate(state, facing, neighborState, world, pos, neighborPos); + return super.updateShape(state, facing, neighborState, world, pos, neighborPos); } @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - if (!state.get(FLOOR)) { - int index = (((state.get(ROTATION) >> 2) + 2)) & 3; - return world.getBlockState(pos.offset(BlocksHelper.HORIZONTAL[index])).getMaterial().isSolid(); - } - else { - return world.getBlockState(pos.down()).getMaterial().isSolid(); + if (!state.getValue(FLOOR)) { + int index = (((state.getValue(ROTATION) >> 2) + 2)) & 3; + return world.getBlockState(pos.relative(BlocksHelper.HORIZONTAL[index])).getMaterial().isSolid(); + } else { + return world.getBlockState(pos.below()).getMaterial().isSolid(); } } @Override public BlockState getPlacementState(ItemPlacementContext ctx) { if (ctx.getSide() == Direction.UP) { - FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos()); - return this.getDefaultState().with(FLOOR, true) - .with(ROTATION, MathHelper.floor((180.0 + ctx.getPlayerYaw() * 16.0 / 360.0) + 0.5 - 12) & 15) + FluidState fluidState = ctx.getLevel().getFluidState(ctx.getBlockPos()); + return this.defaultBlockState().with(FLOOR, true) + .with(ROTATION, Mth.floor((180.0 + ctx.getPlayerYaw() * 16.0 / 360.0) + 0.5 - 12) & 15) .with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER); - } - else if (ctx.getSide() != Direction.DOWN) { - BlockState blockState = this.getDefaultState(); - FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos()); - WorldView worldView = ctx.getWorld(); + } else if (ctx.getSide() != Direction.DOWN) { + BlockState blockState = this.defaultBlockState(); + FluidState fluidState = ctx.getLevel().getFluidState(ctx.getBlockPos()); + WorldView worldView = ctx.getLevel(); BlockPos blockPos = ctx.getBlockPos(); Direction[] directions = ctx.getPlacementDirections(); @@ -132,7 +130,7 @@ public class EndSignBlock extends AbstractSignBlock implements BlockPatterned, I Direction direction = directions[i]; if (direction.getAxis().isHorizontal()) { Direction dir = direction.getOpposite(); - int rot = MathHelper.floor((180.0 + dir.asRotation() * 16.0 / 360.0) + 0.5 + 4) & 15; + int rot = Mth.floor((180.0 + dir.asRotation() * 16.0 / 360.0) + 0.5 + 4) & 15; blockState = blockState.with(ROTATION, rot); if (blockState.canPlaceAt(worldView, blockPos)) { return blockState.with(FLOOR, false).with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER); @@ -143,45 +141,45 @@ public class EndSignBlock extends AbstractSignBlock implements BlockPatterned, I return null; } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); return Patterns.createJson(data, parentId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String path) { - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); if (path.contains("item")) { return Patterns.createJson(Patterns.ITEM_GENERATED, path); } return Patterns.createJson(Patterns.BLOCK_EMPTY, parentId.getPath()); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_SIMPLE; } - + @Override - public BlockState rotate(BlockState state, BlockRotation rotation) { - return (BlockState) state.with(ROTATION, rotation.rotate((Integer) state.get(ROTATION), 16)); + public BlockState rotate(BlockState state, Rotation rotation) { + return (BlockState) state.with(ROTATION, rotation.rotate((Integer) state.getValue(ROTATION), 16)); } @Override public BlockState mirror(BlockState state, BlockMirror mirror) { - return (BlockState) state.with(ROTATION, mirror.mirror((Integer) state.get(ROTATION), 16)); + return (BlockState) state.with(ROTATION, mirror.mirror((Integer) state.getValue(ROTATION), 16)); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } @Override - public Fluid tryDrainFluid(WorldAccess world, BlockPos pos, BlockState state) { + public Fluid tryDrainFluid(LevelAccessor world, BlockPos pos, BlockState state) { // TODO Auto-generated method stub return null; } @@ -193,7 +191,7 @@ public class EndSignBlock extends AbstractSignBlock implements BlockPatterned, I } @Override - public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) { + public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) { // TODO Auto-generated method stub return false; } diff --git a/src/main/java/ru/betterend/blocks/basis/EndSlabBlock.java b/src/main/java/ru/betterend/blocks/basis/EndSlabBlock.java index 102d6966..59139636 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndSlabBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndSlabBlock.java @@ -5,45 +5,45 @@ import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.SlabBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.SlabBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; public class EndSlabBlock extends SlabBlock implements BlockPatterned { private final Block parent; - + public EndSlabBlock(Block source) { super(FabricBlockSettings.copyOf(source)); this.parent = source; } @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); return Patterns.createJson(data, parentId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); return Patterns.createJson(Patterns.BLOCK_SLAB, parentId.getPath(), blockId.getPath()); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_SLAB; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndStairsBlock.java b/src/main/java/ru/betterend/blocks/basis/EndStairsBlock.java index cbbaf6b0..def04b1c 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndStairsBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndStairsBlock.java @@ -5,41 +5,42 @@ import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.StairsBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.StairsBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; public class EndStairsBlock extends StairsBlock implements BlockPatterned { - + private final Block parent; - + public EndStairsBlock(Block source) { - super(source.getDefaultState(), FabricBlockSettings.copyOf(source)); + super(source.defaultBlockState(), FabricBlockSettings.copyOf(source)); this.parent = source; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); return Patterns.createJson(data, parentId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); if (block.contains("inner")) { return Patterns.createJson(Patterns.BLOCK_STAIR_INNER, parentId.getPath(), blockId.getPath()); } @@ -48,9 +49,9 @@ public class EndStairsBlock extends StairsBlock implements BlockPatterned { } return Patterns.createJson(Patterns.BLOCK_STAIR, parentId.getPath(), blockId.getPath()); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_STAIRS; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndStoneButtonBlock.java b/src/main/java/ru/betterend/blocks/basis/EndStoneButtonBlock.java index 2476bd80..e8e51ec5 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndStoneButtonBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndStoneButtonBlock.java @@ -5,40 +5,40 @@ import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.StoneButtonBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.StoneButtonBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; public class EndStoneButtonBlock extends StoneButtonBlock implements BlockPatterned { private final Block parent; - + public EndStoneButtonBlock(Block source) { super(FabricBlockSettings.copyOf(source).nonOpaque()); this.parent = source; } @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); return Patterns.createJson(data, parentId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); if (block.contains("item")) { return Patterns.createJson(Patterns.ITEM_BUTTON, parentId.getPath(), blockId.getPath()); } @@ -47,9 +47,9 @@ public class EndStoneButtonBlock extends StoneButtonBlock implements BlockPatter } return Patterns.createJson(Patterns.BLOCK_BUTTON, parentId.getPath(), blockId.getPath()); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_BUTTON; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndStonelateBlock.java b/src/main/java/ru/betterend/blocks/basis/EndStonelateBlock.java index 0e8b9dd6..80a39785 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndStonelateBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndStonelateBlock.java @@ -1,6 +1,6 @@ package ru.betterend.blocks.basis; -import net.minecraft.block.Block; +import net.minecraft.world.level.block.Block; public class EndStonelateBlock extends EndPlateBlock { public EndStonelateBlock(Block source) { diff --git a/src/main/java/ru/betterend/blocks/basis/EndTrapdoorBlock.java b/src/main/java/ru/betterend/blocks/basis/EndTrapdoorBlock.java index c8dbf0ed..25330f0a 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndTrapdoorBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndTrapdoorBlock.java @@ -6,13 +6,13 @@ import java.util.HashMap; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.TrapdoorBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.TrapdoorBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.patterns.BlockPatterned; @@ -24,24 +24,24 @@ public class EndTrapdoorBlock extends TrapdoorBlock implements IRenderTypeable, } @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override public String getStatesPattern(Reader data) { - String block = Registry.BLOCK.getId(this).getPath(); + String block = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, block, block); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); String name = blockId.getPath(); return Patterns.createJson(Patterns.BLOCK_TRAPDOOR, new HashMap() { private static final long serialVersionUID = 1L; @@ -51,9 +51,9 @@ public class EndTrapdoorBlock extends TrapdoorBlock implements IRenderTypeable, } }); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_TRAPDOOR; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndUnderwaterWallPlantBlock.java b/src/main/java/ru/betterend/blocks/basis/EndUnderwaterWallPlantBlock.java index 3216584d..482c14ca 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndUnderwaterWallPlantBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndUnderwaterWallPlantBlock.java @@ -2,56 +2,49 @@ package ru.betterend.blocks.basis; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.BlockState; -import net.minecraft.block.FluidFillable; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.FluidFillable; +import net.minecraft.world.level.material.Material; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; public class EndUnderwaterWallPlantBlock extends EndWallPlantBlock implements FluidFillable { - + public EndUnderwaterWallPlantBlock() { - super(FabricBlockSettings.of(Material.UNDERWATER_PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.WET_GRASS) - .breakByHand(true) - .noCollision()); + super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS) + .sounds(SoundType.WET_GRASS).breakByHand(true).noCollision()); } - + public EndUnderwaterWallPlantBlock(int light) { - super(FabricBlockSettings.of(Material.UNDERWATER_PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.WET_GRASS) - .luminance(light) - .breakByHand(true) - .noCollision()); + super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS) + .sounds(SoundType.WET_GRASS).luminance(light).breakByHand(true).noCollision()); } - - public EndUnderwaterWallPlantBlock(Settings settings) { + + public EndUnderwaterWallPlantBlock(Properties settings) { super(settings); } - + @Override public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) { return false; } @Override - public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) { + public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) { return false; } - + @Override public FluidState getFluidState(BlockState state) { return Fluids.WATER.getStill(false); } - + @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { return world.getFluidState(pos).getFluid() == Fluids.WATER && super.canPlaceAt(state, world, pos); diff --git a/src/main/java/ru/betterend/blocks/basis/EndWallBlock.java b/src/main/java/ru/betterend/blocks/basis/EndWallBlock.java index 3ce75cd6..b95c3c18 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndWallBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndWallBlock.java @@ -5,41 +5,41 @@ import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.WallBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.WallBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; public class EndWallBlock extends WallBlock implements BlockPatterned { - + private final Block parent; - + public EndWallBlock(Block source) { super(FabricBlockSettings.copyOf(source).nonOpaque()); this.parent = source; } @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); return Patterns.createJson(data, parentId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); if (block.contains("item")) { return Patterns.createJson(Patterns.ITEM_WALL, parentId.getPath(), blockId.getPath()); } @@ -51,9 +51,9 @@ public class EndWallBlock extends WallBlock implements BlockPatterned { } return Patterns.createJson(Patterns.BLOCK_WALL_POST, parentId.getPath(), blockId.getPath()); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_WALL; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndWallPlantBlock.java b/src/main/java/ru/betterend/blocks/basis/EndWallPlantBlock.java index 6de67ec3..25848862 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndWallPlantBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndWallPlantBlock.java @@ -7,64 +7,56 @@ import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.HorizontalFacingBlock; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.HorizontalFacingBlock; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.DirectionProperty; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.util.BlocksHelper; public class EndWallPlantBlock extends EndPlantBlock { - private static final EnumMap SHAPES = Maps.newEnumMap(ImmutableMap.of( - Direction.NORTH, Block.createCuboidShape(1, 1, 8, 15, 15, 16), - Direction.SOUTH, Block.createCuboidShape(1, 1, 0, 15, 15, 8), - Direction.WEST, Block.createCuboidShape(8, 1, 1, 16, 15, 15), - Direction.EAST, Block.createCuboidShape(0, 1, 1, 8, 15, 15))); + private static final EnumMap SHAPES = Maps.newEnumMap(ImmutableMap.of(Direction.NORTH, + Block.createCuboidShape(1, 1, 8, 15, 15, 16), Direction.SOUTH, Block.createCuboidShape(1, 1, 0, 15, 15, 8), + Direction.WEST, Block.createCuboidShape(8, 1, 1, 16, 15, 15), Direction.EAST, + Block.createCuboidShape(0, 1, 1, 8, 15, 15))); public static final DirectionProperty FACING = HorizontalFacingBlock.FACING; - + public EndWallPlantBlock() { - this(FabricBlockSettings.of(Material.PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.GRASS) - .breakByHand(true) - .noCollision()); + this(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS) + .breakByHand(true).noCollision()); } - + public EndWallPlantBlock(int light) { - this(FabricBlockSettings.of(Material.PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.GRASS) - .luminance(light) - .breakByHand(true) - .noCollision()); + this(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS) + .luminance(light).breakByHand(true).noCollision()); } - - public EndWallPlantBlock(Settings settings) { + + public EndWallPlantBlock(Properties settings) { super(settings); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(FACING); } @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return SHAPES.get(state.get(FACING)); + return SHAPES.get(state.getValue(FACING)); } @Override @@ -74,20 +66,20 @@ public class EndWallPlantBlock extends EndPlantBlock { @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - Direction direction = (Direction) state.get(FACING); - BlockPos blockPos = pos.offset(direction.getOpposite()); + Direction direction = (Direction) state.getValue(FACING); + BlockPos blockPos = pos.relative(direction.getOpposite()); BlockState blockState = world.getBlockState(blockPos); return isSupport(world, blockPos, blockState, direction); } - + public boolean isSupport(WorldView world, BlockPos pos, BlockState blockState, Direction direction) { return blockState.getMaterial().isSolid() && blockState.isSideSolidFullSquare(world, pos, direction); } - + @Override public BlockState getPlacementState(ItemPlacementContext ctx) { - BlockState blockState = this.getDefaultState(); - WorldView worldView = ctx.getWorld(); + BlockState blockState = this.defaultBlockState(); + WorldView worldView = ctx.getLevel(); BlockPos blockPos = ctx.getBlockPos(); Direction[] directions = ctx.getPlacementDirections(); for (int i = 0; i < directions.length; ++i) { @@ -104,17 +96,17 @@ public class EndWallPlantBlock extends EndPlantBlock { } @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (!canPlaceAt(state, world, pos)) { - return Blocks.AIR.getDefaultState(); - } - else { + return Blocks.AIR.defaultBlockState(); + } else { return state; } } - + @Override - public BlockState rotate(BlockState state, BlockRotation rotation) { + public BlockState rotate(BlockState state, Rotation rotation) { return BlocksHelper.rotateHorizontal(state, rotation, FACING); } diff --git a/src/main/java/ru/betterend/blocks/basis/EndWoodenButtonBlock.java b/src/main/java/ru/betterend/blocks/basis/EndWoodenButtonBlock.java index d81f8dbc..67493ed2 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndWoodenButtonBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndWoodenButtonBlock.java @@ -5,40 +5,40 @@ import java.util.Collections; import java.util.List; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.WoodenButtonBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.WoodenButtonBlock; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; public class EndWoodenButtonBlock extends WoodenButtonBlock implements BlockPatterned { private final Block parent; - + public EndWoodenButtonBlock(Block source) { super(FabricBlockSettings.copyOf(source).strength(0.5F, 0.5F).nonOpaque()); this.parent = source; } @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); return Patterns.createJson(data, parentId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); - Identifier parentId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(this); + ResourceLocation parentId = Registry.BLOCK.getKey(parent); if (block.contains("item")) { return Patterns.createJson(Patterns.ITEM_BUTTON, parentId.getPath(), blockId.getPath()); } @@ -47,9 +47,9 @@ public class EndWoodenButtonBlock extends WoodenButtonBlock implements BlockPatt } return Patterns.createJson(Patterns.BLOCK_BUTTON, parentId.getPath(), blockId.getPath()); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_BUTTON; } } diff --git a/src/main/java/ru/betterend/blocks/basis/EndWoodenPlateBlock.java b/src/main/java/ru/betterend/blocks/basis/EndWoodenPlateBlock.java index e167c109..005eba94 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndWoodenPlateBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndWoodenPlateBlock.java @@ -1,6 +1,6 @@ package ru.betterend.blocks.basis; -import net.minecraft.block.Block; +import net.minecraft.world.level.block.Block; public class EndWoodenPlateBlock extends EndPlateBlock { public EndWoodenPlateBlock(Block source) { diff --git a/src/main/java/ru/betterend/blocks/basis/FeatureSaplingBlock.java b/src/main/java/ru/betterend/blocks/basis/FeatureSaplingBlock.java index c5bcb65b..3dbe80ba 100644 --- a/src/main/java/ru/betterend/blocks/basis/FeatureSaplingBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/FeatureSaplingBlock.java @@ -4,22 +4,22 @@ import java.io.Reader; import java.util.Random; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Fertilizable; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.Fertilizable; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Registry; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import net.minecraft.world.gen.feature.Feature; import ru.betterend.client.render.ERenderLayer; @@ -29,26 +29,17 @@ import ru.betterend.registry.EndTags; public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Fertilizable, IRenderTypeable { private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 14, 12); - + public FeatureSaplingBlock() { - super(FabricBlockSettings.of(Material.PLANT) - .breakByHand(true) - .collidable(false) - .breakInstantly() - .sounds(BlockSoundGroup.GRASS) - .ticksRandomly()); + super(FabricBlockSettings.of(Material.PLANT).breakByHand(true).collidable(false).breakInstantly() + .sounds(SoundType.GRASS).ticksRandomly()); } - + public FeatureSaplingBlock(int light) { - super(FabricBlockSettings.of(Material.PLANT) - .breakByHand(true) - .collidable(false) - .breakInstantly() - .sounds(BlockSoundGroup.GRASS) - .luminance(light) - .ticksRandomly()); + super(FabricBlockSettings.of(Material.PLANT).breakByHand(true).collidable(false).breakInstantly() + .sounds(SoundType.GRASS).luminance(light).ticksRandomly()); } - + protected abstract Feature getFeature(); @Override @@ -58,13 +49,14 @@ public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Fe @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - return world.getBlockState(pos.down()).isIn(EndTags.END_GROUND); + return world.getBlockState(pos.below()).isIn(EndTags.END_GROUND); } @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (!canPlaceAt(state, world, pos)) - return Blocks.AIR.getDefaultState(); + return Blocks.AIR.defaultBlockState(); else return state; } @@ -75,34 +67,34 @@ public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Fe } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { return random.nextInt(16) == 0; } @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - getFeature().generate(world, world.getChunkManager().getChunkGenerator(), random, pos, null); + public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) { + getFeature().generate(world, world.getChunkManager().getChunkGenerator(), random, pos, null); } @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { super.scheduledTick(state, world, pos, random); if (canGrow(world, random, pos, state)) { grow(world, random, pos, state); } } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override public String getStatesPattern(Reader data) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); return Patterns.createJson(data, blockId.getPath(), blockId.getPath()); } - + @Override public String getModelPattern(String block) { if (block.contains("item")) { @@ -111,9 +103,9 @@ public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Fe } return Patterns.createJson(Patterns.BLOCK_CROSS, block); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_SAPLING; } } diff --git a/src/main/java/ru/betterend/blocks/basis/FurBlock.java b/src/main/java/ru/betterend/blocks/basis/FurBlock.java index 986d8b05..920717a5 100644 --- a/src/main/java/ru/betterend/blocks/basis/FurBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/FurBlock.java @@ -8,21 +8,21 @@ import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.ItemConvertible; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.ItemConvertible; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.BlockGetter; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.util.MHelper; @@ -31,52 +31,44 @@ public class FurBlock extends AttachedBlock implements IRenderTypeable { private static final EnumMap BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); private final ItemConvertible drop; private final int dropChance; - + public FurBlock(ItemConvertible drop, int light, int dropChance, boolean wet) { - super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(wet ? BlockSoundGroup.WET_GRASS : BlockSoundGroup.GRASS) - .luminance(light) - .breakByHand(true) - .noCollision()); + super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT).breakByTool(FabricToolTags.SHEARS) + .sounds(wet ? SoundType.WET_GRASS : SoundType.GRASS).luminance(light).breakByHand(true).noCollision()); this.drop = drop; this.dropChance = dropChance; } - + public FurBlock(ItemConvertible drop, int dropChance) { - super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.GRASS) - .breakByHand(true) - .noCollision()); + super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT).breakByTool(FabricToolTags.SHEARS) + .sounds(SoundType.GRASS).breakByHand(true).noCollision()); this.drop = drop; this.dropChance = dropChance; } @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return BOUNDING_SHAPES.get(state.get(FACING)); + return BOUNDING_SHAPES.get(state.getValue(FACING)); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) + || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Lists.newArrayList(new ItemStack(this)); - } - else if (dropChance < 1 || MHelper.RANDOM.nextInt(dropChance) == 0) { + } else if (dropChance < 1 || MHelper.RANDOM.nextInt(dropChance) == 0) { return Lists.newArrayList(new ItemStack(drop)); - } - else { + } else { return Lists.newArrayList(); } } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + static { BOUNDING_SHAPES.put(Direction.UP, VoxelShapes.cuboid(0.0, 0.0, 0.0, 1.0, 0.5, 1.0)); BOUNDING_SHAPES.put(Direction.DOWN, VoxelShapes.cuboid(0.0, 0.5, 0.0, 1.0, 1.0, 1.0)); diff --git a/src/main/java/ru/betterend/blocks/basis/PedestalBlock.java b/src/main/java/ru/betterend/blocks/basis/PedestalBlock.java index a97f947f..abee8419 100644 --- a/src/main/java/ru/betterend/blocks/basis/PedestalBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/PedestalBlock.java @@ -11,33 +11,33 @@ import org.jetbrains.annotations.Nullable; import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockEntityProvider; -import net.minecraft.block.BlockState; -import net.minecraft.block.ShapeContext; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.BlockEntityProvider; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.EnumProperty; -import net.minecraft.tag.BlockTags; +import net.minecraft.tags.BlockTags; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Registry; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import ru.betterend.blocks.BlockProperties; import ru.betterend.blocks.BlockProperties.PedestalState; import ru.betterend.blocks.InfusionPedestal; @@ -50,14 +50,14 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid public final static EnumProperty STATE = BlockProperties.PEDESTAL_STATE; public static final BooleanProperty HAS_ITEM = BlockProperties.HAS_ITEM; public static final BooleanProperty HAS_LIGHT = BlockProperties.HAS_LIGHT; - + private static final VoxelShape SHAPE_DEFAULT; private static final VoxelShape SHAPE_COLUMN; private static final VoxelShape SHAPE_PILLAR; private static final VoxelShape SHAPE_PEDESTAL_TOP; private static final VoxelShape SHAPE_COLUMN_TOP; private static final VoxelShape SHAPE_BOTTOM; - + /** * * Register new Pedestal block with Better End mod id. @@ -69,7 +69,7 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid public static Block registerPedestal(String name, Block source) { return EndBlocks.registerBlock(name, new PedestalBlock(source)); } - + /** * * Register new Pedestal block with specified mod id. @@ -78,29 +78,32 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid * @param source * @return new Pedestal block with specified id. */ - public static Block registerPedestal(Identifier id, Block source) { + public static Block registerPedestal(ResourceLocation id, Block source) { return EndBlocks.registerBlock(id, new PedestalBlock(source)); } - + protected final Block parent; protected float height = 1.0F; - + public PedestalBlock(Block parent) { - super(FabricBlockSettings.copyOf(parent).luminance(state -> state.get(HAS_LIGHT) ? 12 : 0)); - this.setDefaultState(stateManager.getDefaultState().with(STATE, PedestalState.DEFAULT).with(HAS_ITEM, false).with(HAS_LIGHT, false)); + super(FabricBlockSettings.copyOf(parent).luminance(state -> state.getValue(HAS_LIGHT) ? 12 : 0)); + this.setDefaultState(stateManager.defaultBlockState().with(STATE, PedestalState.DEFAULT).with(HAS_ITEM, false) + .with(HAS_LIGHT, false)); this.parent = parent; } - + public float getHeight(BlockState state) { - if (state.getBlock() instanceof PedestalBlock && state.get(STATE) == PedestalState.PEDESTAL_TOP) { + if (state.getBlock() instanceof PedestalBlock && state.getValue(STATE) == PedestalState.PEDESTAL_TOP) { return this.height - 0.2F; } return this.height; } - + @Override - public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - if (world.isClient || !state.isOf(this)) return ActionResult.CONSUME; + public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand, + BlockHitResult hit) { + if (world.isClientSide || !state.is(this)) + return ActionResult.CONSUME; if (!isPlaceable(state)) { return ActionResult.PASS; } @@ -109,7 +112,8 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity; if (pedestal.isEmpty()) { ItemStack itemStack = player.getStackInHand(hand); - if (itemStack.isEmpty()) return ActionResult.CONSUME; + if (itemStack.isEmpty()) + return ActionResult.CONSUME; pedestal.setStack(0, itemStack.split(1)); checkRitual(world, pos); return ActionResult.SUCCESS; @@ -125,10 +129,10 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid } return ActionResult.PASS; } - - public void checkRitual(World world, BlockPos pos) { - Mutable posMutable = new Mutable(); - for (Point point: InfusionRitual.getMap()) { + + public void checkRitual(Level world, BlockPos pos) { + MutableBlockPos posMutable = new MutableBlockPos(); + for (Point point : InfusionRitual.getMap()) { posMutable.set(pos).move(point.x, 0, point.y); BlockState state = world.getBlockState(posMutable); if (state.getBlock() instanceof InfusionPedestal) { @@ -137,15 +141,16 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid } } } - + @Override @Nullable public BlockState getPlacementState(ItemPlacementContext context) { - World world = context.getWorld(); + Level world = context.getLevel(); BlockPos pos = context.getBlockPos(); BlockState upState = world.getBlockState(pos.up()); - BlockState downState = world.getBlockState(pos.down()); - boolean upSideSolid = upState.isSideSolidFullSquare(world, pos.up(), Direction.DOWN) || upState.isIn(BlockTags.WALLS); + BlockState downState = world.getBlockState(pos.below()); + boolean upSideSolid = upState.isSideSolidFullSquare(world, pos.up(), Direction.DOWN) + || upState.isIn(BlockTags.WALLS); boolean hasPedestalOver = upState.getBlock() instanceof PedestalBlock; boolean hasPedestalUnder = downState.getBlock() instanceof PedestalBlock; if (!hasPedestalOver && hasPedestalUnder && upSideSolid) { @@ -161,27 +166,34 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid } return getDefaultState(); } - + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) { + public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, + BlockPos pos, BlockPos posFrom) { BlockState updated = getUpdatedState(state, direction, newState, world, pos, posFrom); - if (!updated.isOf(this)) return updated; + if (!updated.is(this)) + return updated; if (!isPlaceable(updated)) { moveStoredStack(world, updated, pos); } return updated; } - - private BlockState getUpdatedState(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) { - if (!state.isOf(this)) return state.getStateForNeighborUpdate(direction, newState, world, pos, posFrom); - if (direction != Direction.UP && direction != Direction.DOWN) return state; + + private BlockState getUpdatedState(BlockState state, Direction direction, BlockState newState, LevelAccessor world, + BlockPos pos, BlockPos posFrom) { + if (!state.is(this)) + return state.updateShape(direction, newState, world, pos, posFrom); + if (direction != Direction.UP && direction != Direction.DOWN) + return state; BlockState upState = world.getBlockState(pos.up()); - BlockState downState = world.getBlockState(pos.down()); - boolean upSideSolid = upState.isSideSolidFullSquare(world, pos.up(), Direction.DOWN) || upState.isIn(BlockTags.WALLS); + BlockState downState = world.getBlockState(pos.below()); + boolean upSideSolid = upState.isSideSolidFullSquare(world, pos.up(), Direction.DOWN) + || upState.isIn(BlockTags.WALLS); boolean hasPedestalOver = upState.getBlock() instanceof PedestalBlock; boolean hasPedestalUnder = downState.getBlock() instanceof PedestalBlock; if (direction == Direction.UP) { - upSideSolid = newState.isSideSolidFullSquare(world, posFrom, Direction.DOWN) || newState.isIn(BlockTags.WALLS); + upSideSolid = newState.isSideSolidFullSquare(world, posFrom, Direction.DOWN) + || newState.isIn(BlockTags.WALLS); hasPedestalOver = newState.getBlock() instanceof PedestalBlock; } else { hasPedestalUnder = newState.getBlock() instanceof PedestalBlock; @@ -205,13 +217,13 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid } return updatedState; } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - List drop = Lists.newArrayList(super.getDroppedStacks(state, builder)); - if (state.isOf(this)) { + public List getDrops(BlockState state, LootContext.Builder builder) { + List drop = Lists.newArrayList(super.getDrops(state, builder)); + if (state.is(this)) { if (isPlaceable(state)) { - BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY); + BlockEntity blockEntity = builder.getNullable(LootContextParams.BLOCK_ENTITY); if (blockEntity instanceof PedestalBlockEntity) { PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity; if (!pedestal.isEmpty()) { @@ -224,10 +236,10 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid } return drop; } - - private void moveStoredStack(WorldAccess world, BlockState state, BlockPos pos) { + + private void moveStoredStack(LevelAccessor world, BlockState state, BlockPos pos) { BlockEntity blockEntity = world.getBlockEntity(pos); - if (blockEntity instanceof PedestalBlockEntity && state.isOf(this)) { + if (blockEntity instanceof PedestalBlockEntity && state.is(this)) { PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity; ItemStack stack = pedestal.removeStack(0); if (!stack.isEmpty()) { @@ -235,12 +247,12 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid } } } - - private void moveStoredStack(BlockEntity blockEntity, WorldAccess world, ItemStack stack, BlockPos pos) { + + private void moveStoredStack(BlockEntity blockEntity, LevelAccessor world, ItemStack stack, BlockPos pos) { BlockState state = world.getBlockState(pos); - if (!state.isOf(this)) { + if (!state.is(this)) { dropStoredStack(blockEntity, stack, pos); - } else if (state.get(STATE).equals(PedestalState.PILLAR)) { + } else if (state.getValue(STATE).equals(PedestalState.PILLAR)) { moveStoredStack(blockEntity, world, stack, pos.up()); } else if (!isPlaceable(state)) { dropStoredStack(blockEntity, stack, pos); @@ -255,15 +267,15 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid dropStoredStack(blockEntity, stack, pos); } } - + private void dropStoredStack(BlockEntity blockEntity, ItemStack stack, BlockPos pos) { - if (blockEntity != null && blockEntity.getWorld() != null) { - World world = blockEntity.getWorld(); + if (blockEntity != null && blockEntity.getLevel() != null) { + Level world = blockEntity.getLevel(); Block.dropStack(world, getDropPos(world, pos), stack); } } - - private BlockPos getDropPos(WorldAccess world, BlockPos pos) { + + private BlockPos getDropPos(LevelAccessor world, BlockPos pos) { BlockPos dropPos; if (world.getBlockState(pos).isAir()) { return pos; @@ -271,51 +283,51 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid if (world.getBlockState(pos.up()).isAir()) { return pos.up(); } - for(int i = 2; i < Direction.values().length; i++) { - dropPos = pos.offset(Direction.byId(i)); + for (int i = 2; i < Direction.values().length; i++) { + dropPos = pos.relative(Direction.byId(i)); if (world.getBlockState(dropPos).isAir()) { return dropPos.toImmutable(); } } return getDropPos(world, pos.up()); } - + public boolean isPlaceable(BlockState state) { - if (!state.isOf(this)) return false; - PedestalState currentState = state.get(STATE); - return currentState == PedestalState.DEFAULT || - currentState == PedestalState.PEDESTAL_TOP; + if (!state.is(this)) + return false; + PedestalState currentState = state.getValue(STATE); + return currentState == PedestalState.DEFAULT || currentState == PedestalState.PEDESTAL_TOP; } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { - if (state.isOf(this)) { - switch(state.get(STATE)) { - case BOTTOM: { - return SHAPE_BOTTOM; - } - case PEDESTAL_TOP: { - return SHAPE_PEDESTAL_TOP; - } - case COLUMN_TOP: { - return SHAPE_COLUMN_TOP; - } - case PILLAR: { - return SHAPE_PILLAR; - } - case COLUMN: { - return SHAPE_COLUMN; - } - default: { - return SHAPE_DEFAULT; - } + if (state.is(this)) { + switch (state.getValue(STATE)) { + case BOTTOM: { + return SHAPE_BOTTOM; + } + case PEDESTAL_TOP: { + return SHAPE_PEDESTAL_TOP; + } + case COLUMN_TOP: { + return SHAPE_COLUMN_TOP; + } + case PILLAR: { + return SHAPE_PILLAR; + } + case COLUMN: { + return SHAPE_COLUMN; + } + default: { + return SHAPE_DEFAULT; + } } } return super.getOutlineShape(state, world, pos, context); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(STATE, HAS_ITEM, HAS_LIGHT); } @@ -323,31 +335,31 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid public BlockEntity createBlockEntity(BlockView world) { return new PedestalBlockEntity(); } - + @Override public boolean hasComparatorOutput(BlockState state) { return state.getBlock() instanceof PedestalBlock; } - + @Override - public int getComparatorOutput(BlockState state, World world, BlockPos pos) { - return state.get(HAS_ITEM) ? 15 : 0; + public int getComparatorOutput(BlockState state, Level world, BlockPos pos) { + return state.getValue(HAS_ITEM) ? 15 : 0; } - + @Override public String getStatesPattern(Reader data) { - String texture = Registry.BLOCK.getId(this).getPath(); + String texture = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, texture, texture); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(parent); + ResourceLocation blockId = Registry.BLOCK.getKey(parent); String name = blockId.getPath(); Map textures = new HashMap() { private static final long serialVersionUID = 1L; { - put("%mod%", blockId.getNamespace() ); + put("%mod%", blockId.getNamespace()); put("%top%", name + "_top"); put("%base%", name + "_base"); put("%pillar%", name + "_pillar"); @@ -367,12 +379,12 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid } return Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_PEDESTAL; } - + static { VoxelShape basinUp = Block.createCuboidShape(2, 3, 2, 14, 4, 14); VoxelShape basinDown = Block.createCuboidShape(0, 0, 0, 16, 3, 16); diff --git a/src/main/java/ru/betterend/blocks/basis/SimpleLeavesBlock.java b/src/main/java/ru/betterend/blocks/basis/SimpleLeavesBlock.java index dff29707..145242a3 100644 --- a/src/main/java/ru/betterend/blocks/basis/SimpleLeavesBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/SimpleLeavesBlock.java @@ -3,53 +3,52 @@ package ru.betterend.blocks.basis; import java.io.Reader; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.patterns.Patterns; public class SimpleLeavesBlock extends BlockBaseNotFull implements IRenderTypeable { public SimpleLeavesBlock(MaterialColor color) { - super(FabricBlockSettings.of(Material.LEAVES) - .strength(0.2F) - .sounds(BlockSoundGroup.GRASS) - .nonOpaque() - .allowsSpawning((state, world, pos, type) -> { return false; }) - .suffocates((state, world, pos) -> { return false; }) - .blockVision((state, world, pos) -> { return false; }) - .materialColor(color)); + super(FabricBlockSettings.of(Material.LEAVES).strength(0.2F).sounds(SoundType.GRASS).nonOpaque() + .allowsSpawning((state, world, pos, type) -> { + return false; + }).suffocates((state, world, pos) -> { + return false; + }).blockVision((state, world, pos) -> { + return false; + }).materialColor(color)); } - + public SimpleLeavesBlock(MaterialColor color, int light) { - super(FabricBlockSettings.of(Material.LEAVES) - .strength(0.2F) - .sounds(BlockSoundGroup.GRASS) - .nonOpaque() - .luminance(light) - .allowsSpawning((state, world, pos, type) -> { return false; }) - .suffocates((state, world, pos) -> { return false; }) - .blockVision((state, world, pos) -> { return false; }) - .materialColor(color)); + super(FabricBlockSettings.of(Material.LEAVES).strength(0.2F).sounds(SoundType.GRASS).nonOpaque() + .luminance(light).allowsSpawning((state, world, pos, type) -> { + return false; + }).suffocates((state, world, pos) -> { + return false; + }).blockVision((state, world, pos) -> { + return false; + }).materialColor(color)); } - + @Override public String getStatesPattern(Reader data) { - String texture = Registry.BLOCK.getId(this).getPath(); + String texture = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, texture, texture); } - + @Override public String getModelPattern(String block) { - String texture = Registry.BLOCK.getId(this).getPath(); + String texture = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(Patterns.BLOCK_BASE, texture, texture); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_SIMPLE; } diff --git a/src/main/java/ru/betterend/blocks/basis/StalactiteBlock.java b/src/main/java/ru/betterend/blocks/basis/StalactiteBlock.java index 40f24282..a3a0c88a 100644 --- a/src/main/java/ru/betterend/blocks/basis/StalactiteBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/StalactiteBlock.java @@ -1,32 +1,32 @@ package ru.betterend.blocks.basis; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FluidFillable; -import net.minecraft.block.ShapeContext; -import net.minecraft.block.Waterloggable; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FluidFillable; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.level.block.Waterloggable; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.state.StateManager; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.BooleanProperty; -import net.minecraft.state.property.IntProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; import net.minecraft.state.property.Properties; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.registry.Registry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; +import net.minecraft.core.Registry; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.blocks.BlockProperties; import ru.betterend.client.render.ERenderLayer; @@ -36,86 +36,81 @@ import ru.betterend.patterns.Patterns; public class StalactiteBlock extends BlockBaseNotFull implements Waterloggable, FluidFillable, IRenderTypeable { public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR; - public static final IntProperty SIZE = BlockProperties.SIZE; + public static final IntegerProperty SIZE = BlockProperties.SIZE; private static final VoxelShape[] SHAPES; public StalactiteBlock(Block source) { super(FabricBlockSettings.copy(source).nonOpaque()); - this.setDefaultState(getStateManager().getDefaultState().with(SIZE, 0).with(IS_FLOOR, true).with(WATERLOGGED, false)); + this.setDefaultState( + getStateManager().defaultBlockState().with(SIZE, 0).with(IS_FLOOR, true).with(WATERLOGGED, false)); } @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(WATERLOGGED, IS_FLOOR, SIZE); } @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return SHAPES[state.get(SIZE)]; + return SHAPES[state.getValue(SIZE)]; } - + @Override public BlockState getPlacementState(ItemPlacementContext ctx) { - WorldView world = ctx.getWorld(); + WorldView world = ctx.getLevel(); BlockPos pos = ctx.getBlockPos(); Direction dir = ctx.getSide(); boolean water = world.getFluidState(pos).getFluid() == Fluids.WATER; - + if (dir == Direction.DOWN) { if (isThis(world, pos.up()) || sideCoversSmallSquare(world, pos.up(), Direction.DOWN)) { return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water); - } - else if (isThis(world, pos.down()) || sideCoversSmallSquare(world, pos.down(), Direction.UP)) { + } else if (isThis(world, pos.below()) || sideCoversSmallSquare(world, pos.below(), Direction.UP)) { return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water); - } - else { + } else { return null; } - } - else { - if (isThis(world, pos.down()) || sideCoversSmallSquare(world, pos.down(), Direction.UP)) { + } else { + if (isThis(world, pos.below()) || sideCoversSmallSquare(world, pos.below(), Direction.UP)) { return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water); - } - else if (isThis(world, pos.up()) || sideCoversSmallSquare(world, pos.up(), Direction.DOWN)) { + } else if (isThis(world, pos.up()) || sideCoversSmallSquare(world, pos.up(), Direction.DOWN)) { return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water); - } - else { + } else { return null; } } } @Override - public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) { + public void onPlaced(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) { boolean hasUp = isThis(world, pos.up()); - boolean hasDown = isThis(world, pos.down()); - Mutable mut = new Mutable(); + boolean hasDown = isThis(world, pos.below()); + MutableBlockPos mut = new MutableBlockPos(); if (hasUp && hasDown) { - boolean floor = state.get(IS_FLOOR); - BlockPos second = floor ? pos.up() : pos.down(); + boolean floor = state.getValue(IS_FLOOR); + BlockPos second = floor ? pos.up() : pos.below(); BlockState bState = world.getBlockState(second); - world.setBlockState(pos, state.with(SIZE, 1).with(IS_FLOOR, floor)); - world.setBlockState(second, bState.with(SIZE, 1).with(IS_FLOOR, !floor)); - + world.setBlockAndUpdate(pos, state.with(SIZE, 1).with(IS_FLOOR, floor)); + world.setBlockAndUpdate(second, bState.with(SIZE, 1).with(IS_FLOOR, !floor)); + bState = state; int startSize = floor ? 1 : 2; mut.set(pos.getX(), pos.getY() + 1, pos.getZ()); for (int i = 0; i < 8 && isThis(bState); i++) { - world.setBlockState(mut, bState.with(SIZE, startSize++).with(IS_FLOOR, false)); + world.setBlockAndUpdate(mut, bState.with(SIZE, startSize++).with(IS_FLOOR, false)); mut.setY(mut.getY() + 1); bState = world.getBlockState(mut); } - + bState = state; startSize = floor ? 2 : 1; mut.set(pos.getX(), pos.getY() - 1, pos.getZ()); for (int i = 0; i < 8 && isThis(bState); i++) { - world.setBlockState(mut, bState.with(SIZE, startSize++).with(IS_FLOOR, true)); + world.setBlockAndUpdate(mut, bState.with(SIZE, startSize++).with(IS_FLOOR, true)); mut.setY(mut.getY() - 1); bState = world.getBlockState(mut); } - } - else if (hasDown) { + } else if (hasDown) { mut.setX(pos.getX()); mut.setZ(pos.getZ()); for (int i = 1; i < 8; i++) { @@ -124,18 +119,15 @@ public class StalactiteBlock extends BlockBaseNotFull implements Waterloggable, BlockState state2 = world.getBlockState(mut); int size = state2.get(SIZE); if (size < i) { - world.setBlockState(mut, state2.with(SIZE, i).with(IS_FLOOR, true)); - } - else { + world.setBlockAndUpdate(mut, state2.with(SIZE, i).with(IS_FLOOR, true)); + } else { break; } - } - else { + } else { break; } } - } - else if (hasUp) { + } else if (hasUp) { mut.setX(pos.getX()); mut.setZ(pos.getZ()); for (int i = 1; i < 8; i++) { @@ -144,80 +136,79 @@ public class StalactiteBlock extends BlockBaseNotFull implements Waterloggable, BlockState state2 = world.getBlockState(mut); int size = state2.get(SIZE); if (size < i) { - world.setBlockState(mut, state2.with(SIZE, i).with(IS_FLOOR, false)); - } - else { + world.setBlockAndUpdate(mut, state2.with(SIZE, i).with(IS_FLOOR, false)); + } else { break; } - } - else { + } else { break; } } } } - + private boolean isThis(WorldView world, BlockPos pos) { return isThis(world.getBlockState(pos)); } - + private boolean isThis(BlockState state) { return state.getBlock() instanceof StalactiteBlock; } - + @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (!canPlaceAt(state, world, pos)) { - return Blocks.AIR.getDefaultState(); + return Blocks.AIR.defaultBlockState(); } return state; } @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - int size = state.get(SIZE); + int size = state.getValue(SIZE); return checkUp(world, pos, size) || checkDown(world, pos, size); } - + private boolean checkUp(BlockView world, BlockPos pos, int size) { BlockPos p = pos.up(); BlockState state = world.getBlockState(p); - return (isThis(state) && state.get(SIZE) >= size) || state.isFullCube(world, p); + return (isThis(state) && state.getValue(SIZE) >= size) || state.isFullCube(world, p); } - + private boolean checkDown(BlockView world, BlockPos pos, int size) { - BlockPos p = pos.down(); + BlockPos p = pos.below(); BlockState state = world.getBlockState(p); - return (isThis(state) && state.get(SIZE) >= size) || state.isFullCube(world, p); + return (isThis(state) && state.getValue(SIZE) >= size) || state.isFullCube(world, p); } - + @Override public String getModelPattern(String block) { - Identifier blockId = Registry.BLOCK.getId(this); + ResourceLocation blockId = Registry.BLOCK.getKey(this); if (block.contains("item")) { return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath()); } return Patterns.createJson(Patterns.BLOCK_CROSS_SHADED, block); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_STALACTITE; } - + @Override public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) { return false; } @Override - public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) { + public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) { return false; } - + @Override public FluidState getFluidState(BlockState state) { - return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.getDefaultState(); + return state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.defaultBlockState(); } @Override @@ -230,7 +221,7 @@ public class StalactiteBlock extends BlockBaseNotFull implements Waterloggable, float start = 5F / 8F; SHAPES = new VoxelShape[8]; for (int i = 0; i < 8; i++) { - int side = MathHelper.floor(MathHelper.lerp(i / 7F, start, end) * 8F + 0.5F); + int side = Mth.floor(Mth.lerp(i / 7F, start, end) * 8F + 0.5F); SHAPES[i] = Block.createCuboidShape(side, 0, side, 16 - side, 16, 16 - side); } } diff --git a/src/main/java/ru/betterend/blocks/basis/StoneLanternBlock.java b/src/main/java/ru/betterend/blocks/basis/StoneLanternBlock.java index 4eb82d08..01afe546 100644 --- a/src/main/java/ru/betterend/blocks/basis/StoneLanternBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/StoneLanternBlock.java @@ -3,18 +3,18 @@ package ru.betterend.blocks.basis; import java.io.Reader; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.ShapeContext; -import net.minecraft.client.color.block.BlockColorProvider; -import net.minecraft.client.color.item.ItemColorProvider; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3i; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.client.color.block.BlockColor; +import net.minecraft.client.color.item.ItemColor; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.core.Vec3i; +import net.minecraft.core.Registry; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.BlockGetter; import ru.betterend.blocks.AuroraCrystalBlock; import ru.betterend.interfaces.IColorProvider; import ru.betterend.patterns.Patterns; @@ -24,13 +24,13 @@ public class StoneLanternBlock extends EndLanternBlock implements IColorProvider private static final VoxelShape SHAPE_CEIL = Block.createCuboidShape(3, 1, 3, 13, 16, 13); private static final VoxelShape SHAPE_FLOOR = Block.createCuboidShape(3, 0, 3, 13, 15, 13); private static final Vec3i[] COLORS = AuroraCrystalBlock.COLORS; - + public StoneLanternBlock(Block source) { super(FabricBlockSettings.copyOf(source).luminance(15)); } - + @Override - public BlockColorProvider getProvider() { + public BlockColor getBlockProvider() { return (state, world, pos, tintIndex) -> { long i = (long) pos.getX() + (long) pos.getY() + (long) pos.getZ(); double delta = i * 0.1; @@ -38,47 +38,47 @@ public class StoneLanternBlock extends EndLanternBlock implements IColorProvider int index2 = (index + 1) & 3; delta -= index; index &= 3; - + Vec3i color1 = COLORS[index]; Vec3i color2 = COLORS[index2]; - - int r = MHelper.floor(MathHelper.lerp(delta, color1.getX(), color2.getX())); - int g = MHelper.floor(MathHelper.lerp(delta, color1.getY(), color2.getY())); - int b = MHelper.floor(MathHelper.lerp(delta, color1.getZ(), color2.getZ())); - + + int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX())); + int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY())); + int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ())); + return MHelper.color(r, g, b); }; } @Override - public ItemColorProvider getItemProvider() { + public ItemColor getItemProvider() { return (stack, tintIndex) -> { return MHelper.color(COLORS[3].getX(), COLORS[3].getY(), COLORS[3].getZ()); }; } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return state.get(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL; + return state.getValue(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL; } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_STONE_LANTERN; } - + @Override public String getModelPattern(String block) { - String texture = Registry.BLOCK.getId(this).getPath(); + String texture = Registry.BLOCK.getKey(this).getPath(); if (block.contains("ceil")) { return Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_CEIL, texture, texture); } return Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_FLOOR, texture, texture); } - + @Override public String getStatesPattern(Reader data) { - String block = Registry.BLOCK.getId(this).getPath(); + String block = Registry.BLOCK.getKey(this).getPath(); return Patterns.createJson(data, block, block); } } diff --git a/src/main/java/ru/betterend/blocks/basis/StrippableBarkBlock.java b/src/main/java/ru/betterend/blocks/basis/StrippableBarkBlock.java index 32d651a4..616484ce 100644 --- a/src/main/java/ru/betterend/blocks/basis/StrippableBarkBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/StrippableBarkBlock.java @@ -2,36 +2,38 @@ package ru.betterend.blocks.basis; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.MaterialColor; -import net.minecraft.block.PillarBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public class StrippableBarkBlock extends BarkBlock { private final Block striped; - + public StrippableBarkBlock(MaterialColor color, Block striped) { super(FabricBlockSettings.copyOf(striped).materialColor(color)); this.striped = striped; } - + @Override - public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand, + BlockHitResult hit) { if (player.getMainHandStack().getItem().isIn(FabricToolTags.AXES)) { - world.playSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); - if (!world.isClient) { - world.setBlockState(pos, striped.getDefaultState().with(PillarBlock.AXIS, state.get(PillarBlock.AXIS)), 11); + world.playLocalSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F); + if (!world.isClientSide) { + world.setBlockAndUpdate(pos, striped.defaultBlockState().with(RotatedPillarBlock.AXIS, + state.getValue(RotatedPillarBlock.AXIS)), 11); if (player != null && !player.isCreative()) { - player.getMainHandStack().damage(1, world.random, (ServerPlayerEntity) player); + player.getMainHandStack().damage(1, world.random, (ServerPlayer) player); } } return ActionResult.SUCCESS; diff --git a/src/main/java/ru/betterend/blocks/basis/TripleTerrainBlock.java b/src/main/java/ru/betterend/blocks/basis/TripleTerrainBlock.java index 052f376a..2c585512 100644 --- a/src/main/java/ru/betterend/blocks/basis/TripleTerrainBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/TripleTerrainBlock.java @@ -5,23 +5,23 @@ import java.util.Random; import com.google.common.collect.Maps; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.MaterialColor; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.EnumProperty; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Registry; +import net.minecraft.world.level.Level; import net.minecraft.world.WorldView; import ru.betterend.blocks.BlockProperties; import ru.betterend.blocks.BlockProperties.TripleShape; @@ -30,27 +30,28 @@ import ru.betterend.patterns.Patterns; public class TripleTerrainBlock extends EndTerrainBlock { public static final EnumProperty SHAPE = BlockProperties.TRIPLE_SHAPE; - + public TripleTerrainBlock(MaterialColor color) { super(color); - this.setDefaultState(this.getDefaultState().with(SHAPE, TripleShape.BOTTOM)); + this.setDefaultState(this.defaultBlockState().with(SHAPE, TripleShape.BOTTOM)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(SHAPE); } - + @Override public BlockState getPlacementState(ItemPlacementContext ctx) { Direction dir = ctx.getSide(); - TripleShape shape = dir == Direction.UP ? TripleShape.BOTTOM : dir == Direction.DOWN ? TripleShape.TOP : TripleShape.MIDDLE; - return this.getDefaultState().with(SHAPE, shape); + TripleShape shape = dir == Direction.UP ? TripleShape.BOTTOM + : dir == Direction.DOWN ? TripleShape.TOP : TripleShape.MIDDLE; + return this.defaultBlockState().with(SHAPE, shape); } - + @Override public String getModelPattern(String block) { - String name = Registry.BLOCK.getId(this).getPath(); + String name = Registry.BLOCK.getKey(this).getPath(); if (block.endsWith("_middle")) { return Patterns.createJson(Patterns.BLOCK_BASE, name + "_top", name + "_top"); } @@ -60,65 +61,60 @@ public class TripleTerrainBlock extends EndTerrainBlock { map.put("%bottom%", "minecraft:block/end_stone"); return Patterns.createJson(Patterns.BLOCK_TOP_SIDE_BOTTOM, map); } - + @Override - public Identifier statePatternId() { + public ResourceLocation statePatternId() { return Patterns.STATE_TRIPLE_ROTATED_TOP; } - + @Override - public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - TripleShape shape = state.get(SHAPE); + public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand, + BlockHitResult hit) { + TripleShape shape = state.getValue(SHAPE); if (shape == TripleShape.BOTTOM) { return super.onUse(state, world, pos, player, hand, hit); } return ActionResult.FAIL; } - + @Override - public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - TripleShape shape = state.get(SHAPE); + public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { + TripleShape shape = state.getValue(SHAPE); if (shape == TripleShape.BOTTOM) { super.randomTick(state, world, pos, random); return; - } - else if (random.nextInt(16) == 0) { + } else if (random.nextInt(16) == 0) { boolean bottom = canSurviveBottom(world, pos); if (shape == TripleShape.TOP) { if (!bottom) { - world.setBlockState(pos, Blocks.END_STONE.getDefaultState()); + world.setBlockAndUpdate(pos, Blocks.END_STONE.defaultBlockState()); } - } - else { + } else { boolean top = canSurvive(state, world, pos) || isMiddle(world.getBlockState(pos.up())); if (!top && !bottom) { - world.setBlockState(pos, Blocks.END_STONE.getDefaultState()); - } - else if (top && !bottom) { - world.setBlockState(pos, state.with(SHAPE, TripleShape.BOTTOM)); - } - else if (!top && bottom) { - world.setBlockState(pos, state.with(SHAPE, TripleShape.TOP)); + world.setBlockAndUpdate(pos, Blocks.END_STONE.defaultBlockState()); + } else if (top && !bottom) { + world.setBlockAndUpdate(pos, state.with(SHAPE, TripleShape.BOTTOM)); + } else if (!top && bottom) { + world.setBlockAndUpdate(pos, state.with(SHAPE, TripleShape.TOP)); } } } } - + protected boolean canSurviveBottom(WorldView world, BlockPos pos) { - BlockPos blockPos = pos.down(); + BlockPos blockPos = pos.below(); BlockState blockState = world.getBlockState(blockPos); if (isMiddle(blockState)) { return true; - } - else if (blockState.getFluidState().getLevel() == 8) { + } else if (blockState.getFluidState().getLevel() == 8) { return false; - } - else { + } else { return !blockState.isSideSolidFullSquare(world, blockPos, Direction.UP); } } - + protected boolean isMiddle(BlockState state) { - return state.isOf(this) && state.get(SHAPE) == TripleShape.MIDDLE; + return state.is(this) && state.getValue(SHAPE) == TripleShape.MIDDLE; } } diff --git a/src/main/java/ru/betterend/blocks/basis/UnderwaterPlantBlock.java b/src/main/java/ru/betterend/blocks/basis/UnderwaterPlantBlock.java index 5a16c36e..524aec13 100644 --- a/src/main/java/ru/betterend/blocks/basis/UnderwaterPlantBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/UnderwaterPlantBlock.java @@ -7,32 +7,32 @@ import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Fertilizable; -import net.minecraft.block.FluidFillable; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.entity.ItemEntity; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.Fertilizable; +import net.minecraft.world.level.block.FluidFillable; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.entity.ItemEntity; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; @@ -41,25 +41,18 @@ import ru.betterend.registry.EndTags; public class UnderwaterPlantBlock extends BlockBaseNotFull implements IRenderTypeable, Fertilizable, FluidFillable { private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 14, 12); - + public UnderwaterPlantBlock() { - super(FabricBlockSettings.of(Material.UNDERWATER_PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.WET_GRASS) - .breakByHand(true) - .noCollision()); + super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS) + .sounds(SoundType.WET_GRASS).breakByHand(true).noCollision()); } - + public UnderwaterPlantBlock(int light) { - super(FabricBlockSettings.of(Material.UNDERWATER_PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.WET_GRASS) - .luminance(light) - .breakByHand(true) - .noCollision()); + super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS) + .sounds(SoundType.WET_GRASS).luminance(light).breakByHand(true).noCollision()); } - - public UnderwaterPlantBlock(Settings settings) { + + public UnderwaterPlantBlock(Properties settings) { super(settings); } @@ -76,37 +69,37 @@ public class UnderwaterPlantBlock extends BlockBaseNotFull implements IRenderTyp @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - BlockState down = world.getBlockState(pos.down()); + BlockState down = world.getBlockState(pos.below()); state = world.getBlockState(pos); return isTerrain(down) && state.getFluidState().getFluid().equals(Fluids.WATER.getStill()); } - + protected boolean isTerrain(BlockState state) { return state.isIn(EndTags.END_GROUND) || state.getBlock() == EndBlocks.ENDSTONE_DUST; } @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (!canPlaceAt(state, world, pos)) { world.breakBlock(pos, true); - return Blocks.WATER.getDefaultState(); - } - else { + return Blocks.WATER.defaultBlockState(); + } else { return state; } } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) + || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Lists.newArrayList(new ItemStack(this)); - } - else { + } else { return Lists.newArrayList(); } } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; @@ -118,13 +111,14 @@ public class UnderwaterPlantBlock extends BlockBaseNotFull implements IRenderTyp } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { return true; } @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(this)); + public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) { + ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, + new ItemStack(this)); world.spawnEntity(item); } @@ -134,10 +128,10 @@ public class UnderwaterPlantBlock extends BlockBaseNotFull implements IRenderTyp } @Override - public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) { + public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) { return false; } - + @Override public FluidState getFluidState(BlockState state) { return Fluids.WATER.getStill(false); diff --git a/src/main/java/ru/betterend/blocks/basis/UnderwaterPlantWithAgeBlock.java b/src/main/java/ru/betterend/blocks/basis/UnderwaterPlantWithAgeBlock.java index db52390d..c695fda4 100644 --- a/src/main/java/ru/betterend/blocks/basis/UnderwaterPlantWithAgeBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/UnderwaterPlantWithAgeBlock.java @@ -4,51 +4,46 @@ import java.util.Random; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.BlockProperties; public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock { - public static final IntProperty AGE = BlockProperties.AGE; - + public static final IntegerProperty AGE = BlockProperties.AGE; + public UnderwaterPlantWithAgeBlock() { - super(FabricBlockSettings.of(Material.UNDERWATER_PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.WET_GRASS) - .breakByHand(true) - .ticksRandomly() - .noCollision()); + super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS) + .sounds(SoundType.WET_GRASS).breakByHand(true).ticksRandomly().noCollision()); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(AGE); } - + public abstract void grow(StructureWorldAccess world, Random random, BlockPos pos); - + @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { + public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) { if (random.nextInt(4) == 0) { - int age = state.get(AGE); + int age = state.getValue(AGE); if (age < 3) { - world.setBlockState(pos, state.with(AGE, age + 1)); - } - else { + world.setBlockAndUpdate(pos, state.with(AGE, age + 1)); + } else { grow(world, random, pos); } } } - + @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { super.scheduledTick(state, world, pos, random); if (canGrow(world, random, pos, state)) { grow(world, random, pos, state); diff --git a/src/main/java/ru/betterend/blocks/basis/UpDownPlantBlock.java b/src/main/java/ru/betterend/blocks/basis/UpDownPlantBlock.java index ae9e56a2..37dcaa9f 100644 --- a/src/main/java/ru/betterend/blocks/basis/UpDownPlantBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/UpDownPlantBlock.java @@ -6,25 +6,25 @@ import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; @@ -32,13 +32,10 @@ import ru.betterend.registry.EndTags; public class UpDownPlantBlock extends BlockBaseNotFull implements IRenderTypeable { private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 16, 12); - + public UpDownPlantBlock() { - super(FabricBlockSettings.of(Material.PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.GRASS) - .breakByHand(true) - .noCollision()); + super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS) + .breakByHand(true).noCollision()); } @Override @@ -48,48 +45,49 @@ public class UpDownPlantBlock extends BlockBaseNotFull implements IRenderTypeabl @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - BlockState down = world.getBlockState(pos.down()); + BlockState down = world.getBlockState(pos.below()); BlockState up = world.getBlockState(pos.up()); return (isTerrain(down) || down.getBlock() == this) && (isSupport(up, world, pos) || up.getBlock() == this); } - + protected boolean isTerrain(BlockState state) { return state.isIn(EndTags.END_GROUND); } - + protected boolean isSupport(BlockState state, WorldView world, BlockPos pos) { return sideCoversSmallSquare(world, pos.up(), Direction.UP); } @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (!canPlaceAt(state, world, pos)) { - return Blocks.AIR.getDefaultState(); - } - else { + return Blocks.AIR.defaultBlockState(); + } else { return state; } } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) + || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Lists.newArrayList(new ItemStack(this)); - } - else { + } else { return Lists.newArrayList(); } } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override - public void afterBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, BlockEntity blockEntity, ItemStack stack) { + public void afterBreak(Level world, PlayerEntity player, BlockPos pos, BlockState state, BlockEntity blockEntity, + ItemStack stack) { super.afterBreak(world, player, pos, state, blockEntity, stack); - world.updateNeighbor(pos, Blocks.AIR, pos.down()); + world.updateNeighbor(pos, Blocks.AIR, pos.below()); } } diff --git a/src/main/java/ru/betterend/blocks/basis/VineBlock.java b/src/main/java/ru/betterend/blocks/basis/VineBlock.java index f66fcdf8..2de33f06 100644 --- a/src/main/java/ru/betterend/blocks/basis/VineBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/VineBlock.java @@ -7,30 +7,30 @@ import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Fertilizable; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.Fertilizable; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.EnumProperty; -import net.minecraft.tag.BlockTags; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.tags.BlockTags; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.blocks.BlockProperties; import ru.betterend.blocks.BlockProperties.TripleShape; @@ -41,29 +41,25 @@ import ru.betterend.util.BlocksHelper; public class VineBlock extends BlockBaseNotFull implements IRenderTypeable, Fertilizable { public static final EnumProperty SHAPE = BlockProperties.TRIPLE_SHAPE; private static final VoxelShape VOXEL_SHAPE = Block.createCuboidShape(2, 0, 2, 14, 16, 14); - + public VineBlock() { this(0, false); } - + public VineBlock(int light) { this(light, false); } - + public VineBlock(int light, boolean bottomOnly) { - super(FabricBlockSettings.of(Material.PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.GRASS) + super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS) .luminance((state) -> { - return bottomOnly ? state.get(SHAPE) == TripleShape.BOTTOM ? light : 0 : light; - }) - .breakByHand(true) - .noCollision()); - this.setDefaultState(this.stateManager.getDefaultState().with(SHAPE, TripleShape.BOTTOM)); + return bottomOnly ? state.getValue(SHAPE) == TripleShape.BOTTOM ? light : 0 : light; + }).breakByHand(true).noCollision()); + this.setDefaultState(this.stateManager.defaultBlockState().with(SHAPE, TripleShape.BOTTOM)); } - + @Override - protected void appendProperties(StateManager.Builder stateManager) { + protected void createBlockStateDefinition(StateDefinition.Builder stateManager) { stateManager.add(SHAPE); } @@ -77,7 +73,7 @@ public class VineBlock extends BlockBaseNotFull implements IRenderTypeable, Fert public AbstractBlock.OffsetType getOffsetType() { return AbstractBlock.OffsetType.XZ; } - + public boolean canGenerate(BlockState state, WorldView world, BlockPos pos) { return isSupport(state, world, pos); } @@ -86,37 +82,37 @@ public class VineBlock extends BlockBaseNotFull implements IRenderTypeable, Fert public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { return isSupport(state, world, pos); } - + protected boolean isSupport(BlockState state, WorldView world, BlockPos pos) { BlockState up = world.getBlockState(pos.up()); - return up.isOf(this) || up.isIn(BlockTags.LEAVES) || sideCoversSmallSquare(world, pos.up(), Direction.DOWN); + return up.is(this) || up.isIn(BlockTags.LEAVES) || sideCoversSmallSquare(world, pos.up(), Direction.DOWN); } @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, + BlockPos pos, BlockPos neighborPos) { if (!canPlaceAt(state, world, pos)) { - return Blocks.AIR.getDefaultState(); - } - else { - if (world.getBlockState(pos.down()).getBlock() != this) + return Blocks.AIR.defaultBlockState(); + } else { + if (world.getBlockState(pos.below()).getBlock() != this) return state.with(SHAPE, TripleShape.BOTTOM); else if (world.getBlockState(pos.up()).getBlock() != this) return state.with(SHAPE, TripleShape.TOP); return state.with(SHAPE, TripleShape.MIDDLE); } } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { - ItemStack tool = builder.get(LootContextParameters.TOOL); - if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + public List getDrops(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); + if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) + || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Lists.newArrayList(new ItemStack(this)); - } - else { + } else { return Lists.newArrayList(); } } - + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; @@ -125,25 +121,25 @@ public class VineBlock extends BlockBaseNotFull implements IRenderTypeable, Fert @Override public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { while (world.getBlockState(pos).getBlock() == this) { - pos = pos.down(); + pos = pos.below(); } return world.getBlockState(pos).isAir(); } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { while (world.getBlockState(pos).getBlock() == this) { - pos = pos.down(); + pos = pos.below(); } return world.isAir(pos); } @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { + public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) { while (world.getBlockState(pos).getBlock() == this) { - pos = pos.down(); + pos = pos.below(); } - world.setBlockState(pos, getDefaultState()); + world.setBlockAndUpdate(pos, getDefaultState()); BlocksHelper.setWithoutUpdate(world, pos, getDefaultState()); } } diff --git a/src/main/java/ru/betterend/blocks/basis/WallMushroomBlock.java b/src/main/java/ru/betterend/blocks/basis/WallMushroomBlock.java index 8a3f7c87..55600834 100644 --- a/src/main/java/ru/betterend/blocks/basis/WallMushroomBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/WallMushroomBlock.java @@ -6,32 +6,26 @@ import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.item.ItemStack; -import net.minecraft.loot.context.LootContext; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.WorldView; public class WallMushroomBlock extends EndWallPlantBlock { public WallMushroomBlock(int light) { - super(FabricBlockSettings.of(Material.PLANT) - .breakByTool(FabricToolTags.AXES) - .sounds(BlockSoundGroup.GRASS) - .luminance(light) - .sounds(BlockSoundGroup.WOOD) - .hardness(0.2F) - .breakByHand(true) - .noCollision()); + super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.AXES).sounds(SoundType.GRASS) + .luminance(light).sounds(SoundType.WOOD).hardness(0.2F).breakByHand(true).noCollision()); } - + @Override - public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootContext.Builder builder) { return Lists.newArrayList(new ItemStack(this)); } - + @Override public boolean isSupport(WorldView world, BlockPos pos, BlockState blockState, Direction direction) { return blockState.getMaterial().isSolid() && blockState.isSideSolidFullSquare(world, pos, direction); diff --git a/src/main/java/ru/betterend/blocks/complex/ColoredMaterial.java b/src/main/java/ru/betterend/blocks/complex/ColoredMaterial.java index ab5e9dc9..52bad466 100644 --- a/src/main/java/ru/betterend/blocks/complex/ColoredMaterial.java +++ b/src/main/java/ru/betterend/blocks/complex/ColoredMaterial.java @@ -6,12 +6,12 @@ import java.util.function.Function; import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.MaterialColor; -import net.minecraft.item.DyeItem; -import net.minecraft.item.ItemConvertible; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.item.DyeItem; +import net.minecraft.world.item.ItemConvertible; import net.minecraft.util.DyeColor; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; import ru.betterend.recipe.builders.GridRecipe; import ru.betterend.registry.EndBlocks; import ru.betterend.util.BlocksHelper; @@ -20,38 +20,41 @@ public class ColoredMaterial { private static final Map DYES = Maps.newHashMap(); private static final Map COLORS = Maps.newHashMap(); private final Map colors = Maps.newHashMap(); - + public ColoredMaterial(Function constructor, Block source, boolean craftEight) { this(constructor, source, COLORS, DYES, craftEight); } - - public ColoredMaterial(Function constructor, Block source, Map colors, Map dyes, boolean craftEight) { - String id = Registry.BLOCK.getId(source).getPath(); + + public ColoredMaterial(Function constructor, Block source, Map colors, + Map dyes, boolean craftEight) { + String id = Registry.BLOCK.getKey(source).getPath(); colors.forEach((color, name) -> { String blockName = id + "_" + name; - Block block = constructor.apply(FabricBlockSettings.copyOf(source).materialColor(MaterialColor.BLACK)); + Block block = constructor + .apply(FabricBlockSettings.copyOf(source).materialColor(MaterialColor.COLOR_BLACK)); EndBlocks.registerBlock(blockName, block); if (craftEight) { - GridRecipe.make(blockName, block).setOutputCount(8).setShape("###", "#D#", "###").addMaterial('#', source).addMaterial('D', dyes.get(color)).build(); - } - else { - GridRecipe.make(blockName, block).setList("#D").addMaterial('#', source).addMaterial('D', dyes.get(color)).build(); + GridRecipe.make(blockName, block).setOutputCount(8).setShape("###", "#D#", "###") + .addMaterial('#', source).addMaterial('D', dyes.get(color)).build(); + } else { + GridRecipe.make(blockName, block).setList("#D").addMaterial('#', source) + .addMaterial('D', dyes.get(color)).build(); } this.colors.put(color, block); BlocksHelper.addBlockColor(block, color); }); } - + public Block getByColor(DyeColor color) { return colors.get(color.getMaterialColor().color); } - + public Block getByColor(int color) { return colors.get(color); } - + static { - for (DyeColor color: DyeColor.values()) { + for (DyeColor color : DyeColor.values()) { int colorRGB = color.getMaterialColor().color; COLORS.put(colorRGB, color.getName()); DYES.put(colorRGB, DyeItem.byColor(color)); diff --git a/src/main/java/ru/betterend/blocks/complex/CrystalSubblocksMaterial.java b/src/main/java/ru/betterend/blocks/complex/CrystalSubblocksMaterial.java index 55916dbd..15bf2a3f 100644 --- a/src/main/java/ru/betterend/blocks/complex/CrystalSubblocksMaterial.java +++ b/src/main/java/ru/betterend/blocks/complex/CrystalSubblocksMaterial.java @@ -1,9 +1,9 @@ package ru.betterend.blocks.complex; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.tag.BlockTags; -import net.minecraft.tag.ItemTags; +import net.minecraft.world.level.block.Block; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; import ru.betterend.blocks.EndPedestal; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.blocks.basis.EndPillarBlock; @@ -27,7 +27,7 @@ public class CrystalSubblocksMaterial { public final Block brick_stairs; public final Block brick_slab; public final Block brick_wall; - + public CrystalSubblocksMaterial(String name, Block source) { FabricBlockSettings material = FabricBlockSettings.copyOf(source); polished = EndBlocks.registerBlock(name + "_polished", new BlockBase(material)); @@ -41,29 +41,39 @@ public class CrystalSubblocksMaterial { brick_stairs = EndBlocks.registerBlock(name + "_bricks_stairs", new EndStairsBlock(bricks)); brick_slab = EndBlocks.registerBlock(name + "_bricks_slab", new EndSlabBlock(bricks)); brick_wall = EndBlocks.registerBlock(name + "_bricks_wall", new EndWallBlock(bricks)); - + // Recipes // - GridRecipe.make(name + "_bricks", bricks).setOutputCount(4).setShape("##", "##").addMaterial('#', source).setGroup("end_bricks").build(); - GridRecipe.make(name + "_polished", polished).setOutputCount(4).setShape("##", "##").addMaterial('#', bricks).setGroup("end_tile").build(); - GridRecipe.make(name + "_tiles", tiles).setOutputCount(4).setShape("##", "##").addMaterial('#', polished).setGroup("end_small_tile").build(); - GridRecipe.make(name + "_pillar", pillar).setShape("#", "#").addMaterial('#', slab).setGroup("end_pillar").build(); - - GridRecipe.make(name + "_stairs", stairs).setOutputCount(4).setShape("# ", "## ", "###").addMaterial('#', source).setGroup("end_stone_stairs").build(); - GridRecipe.make(name + "_slab", slab).setOutputCount(6).setShape("###").addMaterial('#', source).setGroup("end_stone_slabs").build(); - GridRecipe.make(name + "_bricks_stairs", brick_stairs).setOutputCount(4).setShape("# ", "## ", "###").addMaterial('#', bricks).setGroup("end_stone_stairs").build(); - GridRecipe.make(name + "_bricks_slab", brick_slab).setOutputCount(6).setShape("###").addMaterial('#', bricks).setGroup("end_stone_slabs").build(); - - GridRecipe.make(name + "_wall", wall).setOutputCount(6).setShape("###", "###").addMaterial('#', source).setGroup("end_wall").build(); - GridRecipe.make(name + "_bricks_wall", brick_wall).setOutputCount(6).setShape("###", "###").addMaterial('#', bricks).setGroup("end_wall").build(); - + GridRecipe.make(name + "_bricks", bricks).setOutputCount(4).setShape("##", "##").addMaterial('#', source) + .setGroup("end_bricks").build(); + GridRecipe.make(name + "_polished", polished).setOutputCount(4).setShape("##", "##").addMaterial('#', bricks) + .setGroup("end_tile").build(); + GridRecipe.make(name + "_tiles", tiles).setOutputCount(4).setShape("##", "##").addMaterial('#', polished) + .setGroup("end_small_tile").build(); + GridRecipe.make(name + "_pillar", pillar).setShape("#", "#").addMaterial('#', slab).setGroup("end_pillar") + .build(); + + GridRecipe.make(name + "_stairs", stairs).setOutputCount(4).setShape("# ", "## ", "###") + .addMaterial('#', source).setGroup("end_stone_stairs").build(); + GridRecipe.make(name + "_slab", slab).setOutputCount(6).setShape("###").addMaterial('#', source) + .setGroup("end_stone_slabs").build(); + GridRecipe.make(name + "_bricks_stairs", brick_stairs).setOutputCount(4).setShape("# ", "## ", "###") + .addMaterial('#', bricks).setGroup("end_stone_stairs").build(); + GridRecipe.make(name + "_bricks_slab", brick_slab).setOutputCount(6).setShape("###").addMaterial('#', bricks) + .setGroup("end_stone_slabs").build(); + + GridRecipe.make(name + "_wall", wall).setOutputCount(6).setShape("###", "###").addMaterial('#', source) + .setGroup("end_wall").build(); + GridRecipe.make(name + "_bricks_wall", brick_wall).setOutputCount(6).setShape("###", "###") + .addMaterial('#', bricks).setGroup("end_wall").build(); + CraftingRecipes.registerPedestal(name + "_pedestal", pedestal, slab, pillar); - + // Item Tags // TagHelper.addTag(ItemTags.SLABS, slab, brick_slab); TagHelper.addTag(ItemTags.STONE_BRICKS, bricks); TagHelper.addTag(ItemTags.STONE_CRAFTING_MATERIALS, source); TagHelper.addTag(ItemTags.STONE_TOOL_MATERIALS, source); - + // Block Tags // TagHelper.addTag(BlockTags.STONE_BRICKS, bricks); TagHelper.addTag(BlockTags.WALLS, wall, brick_wall); diff --git a/src/main/java/ru/betterend/blocks/complex/MetalMaterial.java b/src/main/java/ru/betterend/blocks/complex/MetalMaterial.java index 86acd669..e2ef98dd 100644 --- a/src/main/java/ru/betterend/blocks/complex/MetalMaterial.java +++ b/src/main/java/ru/betterend/blocks/complex/MetalMaterial.java @@ -1,18 +1,17 @@ package ru.betterend.blocks.complex; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.block.MaterialColor; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.item.ArmorMaterial; -import net.minecraft.item.Item; -import net.minecraft.item.Item.Settings; -import net.minecraft.item.Items; -import net.minecraft.item.ToolMaterial; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.tag.BlockTags; -import net.minecraft.tag.ItemTags; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorMaterial; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.Tier; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; import ru.betterend.blocks.BulbVineLanternBlock; import ru.betterend.blocks.BulbVineLanternColoredBlock; import ru.betterend.blocks.ChandelierBlock; @@ -55,116 +54,143 @@ public class MetalMaterial { public final Block chain; public final Block stairs; public final Block slab; - + public final Block chandelier; public final Block bulb_lantern; public final ColoredMaterial bulb_lantern_colored; - + public final Item nugget; public final Item ingot; - + public final Item shovelHead; public final Item pickaxeHead; public final Item axeHead; public final Item hoeHead; public final Item swordBlade; public final Item swordHandle; - + public final Item shovel; public final Item sword; public final Item pickaxe; public final Item axe; public final Item hoe; public final Item hammer; - + public final Item helmet; public final Item chestplate; public final Item leggings; public final Item boots; - - public static MetalMaterial makeNormal(String name, MaterialColor color, ToolMaterial material, ArmorMaterial armor) { - return new MetalMaterial(name, true, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color), EndItems.makeItemSettings(), material, armor); + + public static MetalMaterial makeNormal(String name, MaterialColor color, Tier material, ArmorMaterial armor) { + return new MetalMaterial(name, true, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color), + EndItems.makeItemSettings(), material, armor); } - - public static MetalMaterial makeNormal(String name, MaterialColor color, float hardness, float resistance, ToolMaterial material, ArmorMaterial armor) { - return new MetalMaterial(name, true, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color).hardness(hardness).resistance(resistance), EndItems.makeItemSettings(), material, armor); + + public static MetalMaterial makeNormal(String name, MaterialColor color, float hardness, float resistance, + Tier material, ArmorMaterial armor) { + return new MetalMaterial(name, true, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color) + .hardness(hardness).resistance(resistance), EndItems.makeItemSettings(), material, armor); } - - public static MetalMaterial makeOreless(String name, MaterialColor color, ToolMaterial material, ArmorMaterial armor) { - return new MetalMaterial(name, false, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color), EndItems.makeItemSettings(), material, armor); + + public static MetalMaterial makeOreless(String name, MaterialColor color, Tier material, ArmorMaterial armor) { + return new MetalMaterial(name, false, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color), + EndItems.makeItemSettings(), material, armor); } - - public static MetalMaterial makeOreless(String name, MaterialColor color, float hardness, float resistance, ToolMaterial material, ArmorMaterial armor) { - return new MetalMaterial(name, false, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color).hardness(hardness).resistance(resistance), EndItems.makeItemSettings(), material, armor); + + public static MetalMaterial makeOreless(String name, MaterialColor color, float hardness, float resistance, + Tier material, ArmorMaterial armor) { + return new MetalMaterial(name, false, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color) + .hardness(hardness).resistance(resistance), EndItems.makeItemSettings(), material, armor); } - - private MetalMaterial(String name, boolean hasOre, FabricBlockSettings settings, Settings itemSettings, ToolMaterial material, ArmorMaterial armor) { - FabricBlockSettings lantern = FabricBlockSettings.copyOf(settings).sounds(BlockSoundGroup.LANTERN).hardness(1).resistance(1).luminance(15); - final int level = material.getMiningLevel(); - - ore = hasOre ? EndBlocks.registerBlock(name + "_ore", new BlockBase(FabricBlockSettings.copyOf(Blocks.END_STONE))) : null; + + private MetalMaterial(String name, boolean hasOre, FabricBlockSettings settings, Item.Properties itemSettings, + Tier material, ArmorMaterial armor) { + FabricBlockSettings lantern = FabricBlockSettings.copyOf(settings).sounds(SoundType.LANTERN).hardness(1) + .resistance(1).luminance(15); + final int level = material.getLevel(); + + ore = hasOre + ? EndBlocks.registerBlock(name + "_ore", new BlockBase(FabricBlockSettings.copyOf(Blocks.END_STONE))) + : null; block = EndBlocks.registerBlock(name + "_block", new BlockBase(settings)); tile = EndBlocks.registerBlock(name + "_tile", new BlockBase(settings)); stairs = EndBlocks.registerBlock(name + "_stairs", new EndStairsBlock(tile)); slab = EndBlocks.registerBlock(name + "_slab", new EndSlabBlock(tile)); door = EndBlocks.registerBlock(name + "_door", new EndDoorBlock(block)); trapdoor = EndBlocks.registerBlock(name + "_trapdoor", new EndTrapdoorBlock(block)); - anvil = EndBlocks.registerBlock(name + "_anvil", new EndAnvilBlock(block.getDefaultMaterialColor(), level)); + anvil = EndBlocks.registerBlock(name + "_anvil", new EndAnvilBlock(block.defaultMaterialColor(), level)); bars = EndBlocks.registerBlock(name + "_bars", new EndMetalPaneBlock(block)); - chain = EndBlocks.registerBlock(name + "_chain", new EndChainBlock(block.getDefaultMaterialColor())); + chain = EndBlocks.registerBlock(name + "_chain", new EndChainBlock(block.defaultMaterialColor())); plate = EndBlocks.registerBlock(name + "_plate", new EndWoodenPlateBlock(block)); - + chandelier = EndBlocks.registerBlock(name + "_chandelier", new ChandelierBlock(block)); bulb_lantern = EndBlocks.registerBlock(name + "_bulb_lantern", new BulbVineLanternBlock(lantern)); bulb_lantern_colored = new ColoredMaterial(BulbVineLanternColoredBlock::new, bulb_lantern, false); - + nugget = EndItems.registerItem(name + "_nugget", new PatternedItem(itemSettings)); ingot = EndItems.registerItem(name + "_ingot", new PatternedItem(itemSettings)); - + shovelHead = EndItems.registerItem(name + "_shovel_head"); pickaxeHead = EndItems.registerItem(name + "_pickaxe_head"); axeHead = EndItems.registerItem(name + "_axe_head"); hoeHead = EndItems.registerItem(name + "_hoe_head"); swordBlade = EndItems.registerItem(name + "_sword_blade"); swordHandle = EndItems.registerItem(name + "_sword_handle"); - + shovel = EndItems.registerTool(name + "_shovel", new EndShovelItem(material, 1.5F, -3.0F, itemSettings)); sword = EndItems.registerTool(name + "_sword", new EndSwordItem(material, 3, -2.4F, itemSettings)); pickaxe = EndItems.registerTool(name + "_pickaxe", new EndPickaxeItem(material, 1, -2.8F, itemSettings)); axe = EndItems.registerTool(name + "_axe", new EndAxeItem(material, 6.0F, -3.0F, itemSettings)); hoe = EndItems.registerTool(name + "_hoe", new EndHoeItem(material, -3, 0.0F, itemSettings)); hammer = EndItems.registerTool(name + "_hammer", new EndHammerItem(material, 5.0F, -3.2F, 0.3D, itemSettings)); - + helmet = EndItems.registerItem(name + "_helmet", new EndArmorItem(armor, EquipmentSlot.HEAD, itemSettings)); - chestplate = EndItems.registerItem(name + "_chestplate", new EndArmorItem(armor, EquipmentSlot.CHEST, itemSettings)); + chestplate = EndItems.registerItem(name + "_chestplate", + new EndArmorItem(armor, EquipmentSlot.CHEST, itemSettings)); leggings = EndItems.registerItem(name + "_leggings", new EndArmorItem(armor, EquipmentSlot.LEGS, itemSettings)); boots = EndItems.registerItem(name + "_boots", new EndArmorItem(armor, EquipmentSlot.FEET, itemSettings)); - + if (hasOre) { FurnaceRecipe.make(name + "_ingot_furnace", ore, ingot).setGroup("end_ingot").buildWithBlasting(); - AlloyingRecipe.Builder.create(name + "_ingot_alloy").setInput(ore, ore).setOutput(ingot, 3).setExpiriense(2.1F).build(); + AlloyingRecipe.Builder.create(name + "_ingot_alloy").setInput(ore, ore).setOutput(ingot, 3) + .setExpiriense(2.1F).build(); } - + // Basic recipes - GridRecipe.make(name + "_ingot_from_nuggets", ingot).setShape("###", "###", "###").addMaterial('#', nugget).setGroup("end_metal_ingots_nug").build(); - GridRecipe.make(name + "_block", block).setShape("###", "###", "###").addMaterial('#', ingot).setGroup("end_metal_blocks").build(); - GridRecipe.make(name + "_ingot_from_block", ingot).setOutputCount(9).setList("#").addMaterial('#', block).setGroup("end_metal_ingots").build(); - + GridRecipe.make(name + "_ingot_from_nuggets", ingot).setShape("###", "###", "###").addMaterial('#', nugget) + .setGroup("end_metal_ingots_nug").build(); + GridRecipe.make(name + "_block", block).setShape("###", "###", "###").addMaterial('#', ingot) + .setGroup("end_metal_blocks").build(); + GridRecipe.make(name + "_ingot_from_block", ingot).setOutputCount(9).setList("#").addMaterial('#', block) + .setGroup("end_metal_ingots").build(); + // Block recipes - GridRecipe.make(name + "_tile", tile).setOutputCount(4).setShape("##", "##").addMaterial('#', block).setGroup("end_metal_tiles").build(); - GridRecipe.make(name + "_bars", bars).setOutputCount(16).setShape("###", "###").addMaterial('#', ingot).setGroup("end_metal_bars").build(); - GridRecipe.make(name + "_plate", plate).setShape("##").addMaterial('#', ingot).setGroup("end_metal_plates").build(); - GridRecipe.make(name + "_door", door).setOutputCount(3).setShape("##", "##", "##").addMaterial('#', ingot).setGroup("end_metal_doors").build(); - GridRecipe.make(name + "_trapdoor", trapdoor).setShape("##", "##").addMaterial('#', ingot).setGroup("end_metal_trapdoors").build(); - GridRecipe.make(name + "_stairs", stairs).setOutputCount(4).setShape("# ", "## ", "###").addMaterial('#', block, tile).setGroup("end_metal_stairs").build(); - GridRecipe.make(name + "_slab", slab).setOutputCount(6).setShape("###").addMaterial('#', block, tile).setGroup("end_metal_slabs").build(); - GridRecipe.make(name + "_chain", chain).setShape("N", "#", "N").addMaterial('#', ingot).addMaterial('N', nugget).setGroup("end_metal_chain").build(); - GridRecipe.make(name + "_anvil", anvil).setShape("###", " I ", "III").addMaterial('#', block, tile).addMaterial('I', ingot).setGroup("end_metal_anvil").build(); - GridRecipe.make(name + "bulb_lantern", bulb_lantern).setShape("C", "I", "#").addMaterial('C', chain).addMaterial('I', ingot).addMaterial('#', EndItems.GLOWING_BULB).build(); - - GridRecipe.make(name + "_smith_table", Blocks.SMITHING_TABLE).setShape("II", "##", "##").addMaterial('#', ItemTags.PLANKS).addMaterial('I', ingot).setGroup("smith_table").build(); - GridRecipe.make(name + "_chandelier", chandelier).setShape("I#I", " # ").addMaterial('#', ingot).addMaterial('I', EndItems.LUMECORN_ROD).setGroup("end_metal_chandelier").build(); - + GridRecipe.make(name + "_tile", tile).setOutputCount(4).setShape("##", "##").addMaterial('#', block) + .setGroup("end_metal_tiles").build(); + GridRecipe.make(name + "_bars", bars).setOutputCount(16).setShape("###", "###").addMaterial('#', ingot) + .setGroup("end_metal_bars").build(); + GridRecipe.make(name + "_plate", plate).setShape("##").addMaterial('#', ingot).setGroup("end_metal_plates") + .build(); + GridRecipe.make(name + "_door", door).setOutputCount(3).setShape("##", "##", "##").addMaterial('#', ingot) + .setGroup("end_metal_doors").build(); + GridRecipe.make(name + "_trapdoor", trapdoor).setShape("##", "##").addMaterial('#', ingot) + .setGroup("end_metal_trapdoors").build(); + GridRecipe.make(name + "_stairs", stairs).setOutputCount(4).setShape("# ", "## ", "###") + .addMaterial('#', block, tile).setGroup("end_metal_stairs").build(); + GridRecipe.make(name + "_slab", slab).setOutputCount(6).setShape("###").addMaterial('#', block, tile) + .setGroup("end_metal_slabs").build(); + GridRecipe.make(name + "_chain", chain).setShape("N", "#", "N").addMaterial('#', ingot).addMaterial('N', nugget) + .setGroup("end_metal_chain").build(); + GridRecipe.make(name + "_anvil", anvil).setShape("###", " I ", "III").addMaterial('#', block, tile) + .addMaterial('I', ingot).setGroup("end_metal_anvil").build(); + GridRecipe.make(name + "bulb_lantern", bulb_lantern).setShape("C", "I", "#").addMaterial('C', chain) + .addMaterial('I', ingot).addMaterial('#', EndItems.GLOWING_BULB).build(); + + GridRecipe.make(name + "_smith_table", Blocks.SMITHING_TABLE).setShape("II", "##", "##") + .addMaterial('#', ItemTags.PLANKS).addMaterial('I', ingot).setGroup("smith_table").build(); + GridRecipe.make(name + "_chandelier", chandelier).setShape("I#I", " # ").addMaterial('#', ingot) + .addMaterial('I', EndItems.LUMECORN_ROD).setGroup("end_metal_chandelier").build(); + // Tools & armor into nuggets FurnaceRecipe.make(name + "_axe_nugget", axe, nugget).setGroup("end_nugget").buildWithBlasting(); FurnaceRecipe.make(name + "_hoe_nugget", hoe, nugget).setGroup("end_nugget").buildWithBlasting(); @@ -175,34 +201,47 @@ public class MetalMaterial { FurnaceRecipe.make(name + "_chestplate_nugget", chestplate, nugget).setGroup("end_nugget").buildWithBlasting(); FurnaceRecipe.make(name + "_leggings_nugget", leggings, nugget).setGroup("end_nugget").buildWithBlasting(); FurnaceRecipe.make(name + "_boots_nugget", boots, nugget).setGroup("end_nugget").buildWithBlasting(); - + // Tool parts from ingots - AnvilRecipe.Builder.create(name + "_shovel_head").setInput(ingot).setOutput(shovelHead).setAnvilLevel(level).setToolLevel(level).setDamage(level).build(); - AnvilRecipe.Builder.create(name + "_pickaxe_head").setInput(ingot).setInputCount(3).setOutput(pickaxeHead).setAnvilLevel(level).setToolLevel(level).setDamage(level).build(); - AnvilRecipe.Builder.create(name + "_axe_head").setInput(ingot).setInputCount(3).setOutput(axeHead).setAnvilLevel(level).setToolLevel(level).setDamage(level).build(); - AnvilRecipe.Builder.create(name + "_hoe_head").setInput(ingot).setInputCount(2).setOutput(hoeHead).setAnvilLevel(level).setToolLevel(level).setDamage(level).build(); - AnvilRecipe.Builder.create(name + "_sword_blade").setInput(ingot).setOutput(swordBlade).setAnvilLevel(level).setToolLevel(level).setDamage(level).build(); - + AnvilRecipe.Builder.create(name + "_shovel_head").setInput(ingot).setOutput(shovelHead).setAnvilLevel(level) + .setToolLevel(level).setDamage(level).build(); + AnvilRecipe.Builder.create(name + "_pickaxe_head").setInput(ingot).setInputCount(3).setOutput(pickaxeHead) + .setAnvilLevel(level).setToolLevel(level).setDamage(level).build(); + AnvilRecipe.Builder.create(name + "_axe_head").setInput(ingot).setInputCount(3).setOutput(axeHead) + .setAnvilLevel(level).setToolLevel(level).setDamage(level).build(); + AnvilRecipe.Builder.create(name + "_hoe_head").setInput(ingot).setInputCount(2).setOutput(hoeHead) + .setAnvilLevel(level).setToolLevel(level).setDamage(level).build(); + AnvilRecipe.Builder.create(name + "_sword_blade").setInput(ingot).setOutput(swordBlade).setAnvilLevel(level) + .setToolLevel(level).setDamage(level).build(); + // Tools from parts SmithingTableRecipe.create(name + "_hammer").setResult(hammer).setBase(block).setAddition(Items.STICK).build(); SmithingTableRecipe.create(name + "_axe").setResult(axe).setBase(axeHead).setAddition(Items.STICK).build(); - SmithingTableRecipe.create(name + "_pickaxe").setResult(pickaxe).setBase(pickaxeHead).setAddition(Items.STICK).build(); + SmithingTableRecipe.create(name + "_pickaxe").setResult(pickaxe).setBase(pickaxeHead).setAddition(Items.STICK) + .build(); SmithingTableRecipe.create(name + "_hoe").setResult(hoe).setBase(hoeHead).setAddition(Items.STICK).build(); - SmithingTableRecipe.create(name + "_sword_handle").setResult(swordHandle).setBase(ingot).setAddition(Items.STICK).build(); - SmithingTableRecipe.create(name + "_sword").setResult(sword).setBase(swordBlade).setAddition(swordHandle).build(); - SmithingTableRecipe.create(name + "_shovel").setResult(shovel).setBase(shovelHead).setAddition(Items.STICK).build(); - + SmithingTableRecipe.create(name + "_sword_handle").setResult(swordHandle).setBase(ingot) + .setAddition(Items.STICK).build(); + SmithingTableRecipe.create(name + "_sword").setResult(sword).setBase(swordBlade).setAddition(swordHandle) + .build(); + SmithingTableRecipe.create(name + "_shovel").setResult(shovel).setBase(shovelHead).setAddition(Items.STICK) + .build(); + // Armor crafting - GridRecipe.make(name + "_helmet", helmet).setShape("###", "# #").addMaterial('#', ingot).setGroup("end_metal_helmets").build(); - GridRecipe.make(name + "_chestplate", chestplate).setShape("# #", "###", "###").addMaterial('#', ingot).setGroup("end_metal_chestplates").build(); - GridRecipe.make(name + "_leggings", leggings).setShape("###", "# #", "# #").addMaterial('#', ingot).setGroup("end_metal_leggings").build(); - GridRecipe.make(name + "_boots", boots).setShape("# #", "# #").addMaterial('#', ingot).setGroup("end_metal_boots").build(); - + GridRecipe.make(name + "_helmet", helmet).setShape("###", "# #").addMaterial('#', ingot) + .setGroup("end_metal_helmets").build(); + GridRecipe.make(name + "_chestplate", chestplate).setShape("# #", "###", "###").addMaterial('#', ingot) + .setGroup("end_metal_chestplates").build(); + GridRecipe.make(name + "_leggings", leggings).setShape("###", "# #", "# #").addMaterial('#', ingot) + .setGroup("end_metal_leggings").build(); + GridRecipe.make(name + "_boots", boots).setShape("# #", "# #").addMaterial('#', ingot) + .setGroup("end_metal_boots").build(); + TagHelper.addTag(BlockTags.ANVIL, anvil); TagHelper.addTag(BlockTags.BEACON_BASE_BLOCKS, block); TagHelper.addTag(EndTags.IRON_INGOTS, ingot); TagHelper.addTag(ItemTags.BEACON_PAYMENT_ITEMS, ingot); - + TagHelper.addTag(EndTags.DRAGON_IMMUNE, ore, bars); } } \ No newline at end of file diff --git a/src/main/java/ru/betterend/blocks/complex/StoneMaterial.java b/src/main/java/ru/betterend/blocks/complex/StoneMaterial.java index 782ff4b0..bae66336 100644 --- a/src/main/java/ru/betterend/blocks/complex/StoneMaterial.java +++ b/src/main/java/ru/betterend/blocks/complex/StoneMaterial.java @@ -1,11 +1,11 @@ package ru.betterend.blocks.complex; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.block.MaterialColor; -import net.minecraft.tag.BlockTags; -import net.minecraft.tag.ItemTags; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; import ru.betterend.blocks.EndPedestal; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.blocks.basis.EndFurnaceBlock; @@ -25,7 +25,7 @@ import ru.betterend.util.TagHelper; public class StoneMaterial { public final Block stone; - + public final Block polished; public final Block tiles; public final Block pillar; @@ -36,16 +36,16 @@ public class StoneMaterial { public final Block pressure_plate; public final Block pedestal; public final Block lantern; - + public final Block bricks; public final Block brick_stairs; public final Block brick_slab; public final Block brick_wall; public final Block furnace; - + public StoneMaterial(String name, MaterialColor color) { FabricBlockSettings material = FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color); - + stone = EndBlocks.registerBlock(name, new BlockBase(material)); polished = EndBlocks.registerBlock(name + "_polished", new BlockBase(material)); tiles = EndBlocks.registerBlock(name + "_tiles", new BlockBase(material)); @@ -57,48 +57,62 @@ public class StoneMaterial { pressure_plate = EndBlocks.registerBlock(name + "_plate", new EndStonelateBlock(stone)); pedestal = EndBlocks.registerBlock(name + "_pedestal", new EndPedestal(stone)); lantern = EndBlocks.registerBlock(name + "_lantern", new StoneLanternBlock(stone)); - + bricks = EndBlocks.registerBlock(name + "_bricks", new BlockBase(material)); brick_stairs = EndBlocks.registerBlock(name + "_bricks_stairs", new EndStairsBlock(bricks)); brick_slab = EndBlocks.registerBlock(name + "_bricks_slab", new EndSlabBlock(bricks)); brick_wall = EndBlocks.registerBlock(name + "_bricks_wall", new EndWallBlock(bricks)); furnace = EndBlocks.registerBlock(name + "_furnace", new EndFurnaceBlock(bricks)); - + // Recipes // - GridRecipe.make(name + "_bricks", bricks).setOutputCount(4).setShape("##", "##").addMaterial('#', stone).setGroup("end_bricks").build(); - GridRecipe.make(name + "_polished", polished).setOutputCount(4).setShape("##", "##").addMaterial('#', bricks).setGroup("end_tile").build(); - GridRecipe.make(name + "_tiles", tiles).setOutputCount(4).setShape("##", "##").addMaterial('#', polished).setGroup("end_small_tile").build(); - GridRecipe.make(name + "_pillar", pillar).setShape("#", "#").addMaterial('#', slab).setGroup("end_pillar").build(); - - GridRecipe.make(name + "_stairs", stairs).setOutputCount(4).setShape("# ", "## ", "###").addMaterial('#', stone).setGroup("end_stone_stairs").build(); - GridRecipe.make(name + "_slab", slab).setOutputCount(6).setShape("###").addMaterial('#', stone).setGroup("end_stone_slabs").build(); - GridRecipe.make(name + "_bricks_stairs", brick_stairs).setOutputCount(4).setShape("# ", "## ", "###").addMaterial('#', bricks).setGroup("end_stone_stairs").build(); - GridRecipe.make(name + "_bricks_slab", brick_slab).setOutputCount(6).setShape("###").addMaterial('#', bricks).setGroup("end_stone_slabs").build(); - - GridRecipe.make(name + "_wall", wall).setOutputCount(6).setShape("###", "###").addMaterial('#', stone).setGroup("end_wall").build(); - GridRecipe.make(name + "_bricks_wall", brick_wall).setOutputCount(6).setShape("###", "###").addMaterial('#', bricks).setGroup("end_wall").build(); - - GridRecipe.make(name + "_button", button).setList("#").addMaterial('#', stone).setGroup("end_stone_buttons").build(); - GridRecipe.make(name + "_pressure_plate", pressure_plate).setShape("##").addMaterial('#', stone).setGroup("end_stone_plates").build(); - GridRecipe.make(name + "_lantern", lantern).setShape("S", "#", "S").addMaterial('#', EndItems.CRYSTAL_SHARDS).addMaterial('S', slab, brick_slab).setGroup("end_stone_lanterns").build(); - GridRecipe.make(name + "_furnace", furnace).setShape("###", "# #", "###").addMaterial('#', stone).setGroup("end_stone_furnaces").build(); - + GridRecipe.make(name + "_bricks", bricks).setOutputCount(4).setShape("##", "##").addMaterial('#', stone) + .setGroup("end_bricks").build(); + GridRecipe.make(name + "_polished", polished).setOutputCount(4).setShape("##", "##").addMaterial('#', bricks) + .setGroup("end_tile").build(); + GridRecipe.make(name + "_tiles", tiles).setOutputCount(4).setShape("##", "##").addMaterial('#', polished) + .setGroup("end_small_tile").build(); + GridRecipe.make(name + "_pillar", pillar).setShape("#", "#").addMaterial('#', slab).setGroup("end_pillar") + .build(); + + GridRecipe.make(name + "_stairs", stairs).setOutputCount(4).setShape("# ", "## ", "###") + .addMaterial('#', stone).setGroup("end_stone_stairs").build(); + GridRecipe.make(name + "_slab", slab).setOutputCount(6).setShape("###").addMaterial('#', stone) + .setGroup("end_stone_slabs").build(); + GridRecipe.make(name + "_bricks_stairs", brick_stairs).setOutputCount(4).setShape("# ", "## ", "###") + .addMaterial('#', bricks).setGroup("end_stone_stairs").build(); + GridRecipe.make(name + "_bricks_slab", brick_slab).setOutputCount(6).setShape("###").addMaterial('#', bricks) + .setGroup("end_stone_slabs").build(); + + GridRecipe.make(name + "_wall", wall).setOutputCount(6).setShape("###", "###").addMaterial('#', stone) + .setGroup("end_wall").build(); + GridRecipe.make(name + "_bricks_wall", brick_wall).setOutputCount(6).setShape("###", "###") + .addMaterial('#', bricks).setGroup("end_wall").build(); + + GridRecipe.make(name + "_button", button).setList("#").addMaterial('#', stone).setGroup("end_stone_buttons") + .build(); + GridRecipe.make(name + "_pressure_plate", pressure_plate).setShape("##").addMaterial('#', stone) + .setGroup("end_stone_plates").build(); + GridRecipe.make(name + "_lantern", lantern).setShape("S", "#", "S").addMaterial('#', EndItems.CRYSTAL_SHARDS) + .addMaterial('S', slab, brick_slab).setGroup("end_stone_lanterns").build(); + GridRecipe.make(name + "_furnace", furnace).setShape("###", "# #", "###").addMaterial('#', stone) + .setGroup("end_stone_furnaces").build(); + CraftingRecipes.registerPedestal(name + "_pedestal", pedestal, slab, pillar); - + // Item Tags // TagHelper.addTag(ItemTags.SLABS, slab, brick_slab); TagHelper.addTag(ItemTags.STONE_BRICKS, bricks); TagHelper.addTag(ItemTags.STONE_CRAFTING_MATERIALS, stone); TagHelper.addTag(ItemTags.STONE_TOOL_MATERIALS, stone); TagHelper.addTag(EndTags.FURNACES, furnace); - + // Block Tags // TagHelper.addTag(BlockTags.STONE_BRICKS, bricks); TagHelper.addTag(BlockTags.WALLS, wall, brick_wall); TagHelper.addTag(BlockTags.SLABS, slab, brick_slab); TagHelper.addTags(pressure_plate, BlockTags.PRESSURE_PLATES, BlockTags.STONE_PRESSURE_PLATES); TagHelper.addTag(EndTags.END_STONES, stone); - + TagHelper.addTag(EndTags.DRAGON_IMMUNE, stone, stairs, slab, wall); } } \ No newline at end of file diff --git a/src/main/java/ru/betterend/blocks/complex/WoodenMaterial.java b/src/main/java/ru/betterend/blocks/complex/WoodenMaterial.java index fd4f4c17..b9d8b514 100644 --- a/src/main/java/ru/betterend/blocks/complex/WoodenMaterial.java +++ b/src/main/java/ru/betterend/blocks/complex/WoodenMaterial.java @@ -1,15 +1,15 @@ package ru.betterend.blocks.complex; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.MaterialColor; -import net.minecraft.item.Item; -import net.minecraft.item.Items; -import net.minecraft.tag.BlockTags; -import net.minecraft.tag.ItemTags; -import net.minecraft.tag.Tag; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.tags.Tag; import ru.betterend.blocks.basis.BarkBlock; import ru.betterend.blocks.basis.BlockBase; import ru.betterend.blocks.basis.EndBarrelBlock; @@ -52,28 +52,28 @@ public class WoodenMaterial { public final Block pressurePlate; public final Block trapdoor; public final Block door; - + public final Block craftingTable; public final Block ladder; public final Block sign; - + public final Block chest; public final Block barrel; public final Block shelf; public final Block composter; - + public final Tag.Identified logBlockTag; public final Tag.Identified logItemTag; - + public WoodenMaterial(String name, MaterialColor woodColor, MaterialColor planksColor) { FabricBlockSettings materialPlanks = FabricBlockSettings.copyOf(Blocks.OAK_PLANKS).materialColor(planksColor); - + log_stripped = EndBlocks.registerBlock(name + "_stripped_log", new EndPillarBlock(materialPlanks)); bark_stripped = EndBlocks.registerBlock(name + "_stripped_bark", new BarkBlock(materialPlanks)); - + log = EndBlocks.registerBlock(name + "_log", new EndBlockStripableLogLog(woodColor, log_stripped)); bark = EndBlocks.registerBlock(name + "_bark", new StrippableBarkBlock(woodColor, bark_stripped)); - + planks = EndBlocks.registerBlock(name + "_planks", new BlockBase(materialPlanks)); stairs = EndBlocks.registerBlock(name + "_stairs", new EndStairsBlock(planks)); slab = EndBlocks.registerBlock(name + "_slab", new EndSlabBlock(planks)); @@ -83,43 +83,59 @@ public class WoodenMaterial { pressurePlate = EndBlocks.registerBlock(name + "_plate", new EndWoodenPlateBlock(planks)); trapdoor = EndBlocks.registerBlock(name + "_trapdoor", new EndTrapdoorBlock(planks)); door = EndBlocks.registerBlock(name + "_door", new EndDoorBlock(planks)); - + craftingTable = EndBlocks.registerBlock(name + "_crafting_table", new EndCraftingTableBlock(planks)); ladder = EndBlocks.registerBlock(name + "_ladder", new EndLadderBlock(planks)); sign = EndBlocks.registerBlock(name + "_sign", new EndSignBlock(planks)); - + chest = EndBlocks.registerBlock(name + "_chest", new EndChestBlock(planks)); barrel = EndBlocks.registerBlock(name + "_barrel", new EndBarrelBlock(planks)); shelf = EndBlocks.registerBlock(name + "_bookshelf", new EndBookshelfBlock(planks)); composter = EndBlocks.registerBlock(name + "_composter", new EndComposterBlock(planks)); - + // Recipes // - GridRecipe.make(name + "_planks", planks).setOutputCount(4).setList("#").addMaterial('#', log, bark, log_stripped, bark_stripped).setGroup("end_planks").build(); - GridRecipe.make(name + "_stairs", stairs).setOutputCount(4).setShape("# ", "## ", "###").addMaterial('#', planks).setGroup("end_planks_stairs").build(); - GridRecipe.make(name + "_slab", slab).setOutputCount(6).setShape("###").addMaterial('#', planks).setGroup("end_planks_slabs").build(); - GridRecipe.make(name + "_fence", fence).setOutputCount(3).setShape("#I#", "#I#").addMaterial('#', planks).addMaterial('I', Items.STICK).setGroup("end_planks_fences").build(); - GridRecipe.make(name + "_gate", gate).setShape("I#I", "I#I").addMaterial('#', planks).addMaterial('I', Items.STICK).setGroup("end_planks_gates").build(); - GridRecipe.make(name + "_button", button).setList("#").addMaterial('#', planks).setGroup("end_planks_buttons").build(); - GridRecipe.make(name + "_pressure_plate", pressurePlate).setShape("##").addMaterial('#', planks).setGroup("end_planks_plates").build(); - GridRecipe.make(name + "_trapdoor", trapdoor).setOutputCount(2).setShape("###", "###").addMaterial('#', planks).setGroup("end_trapdoors").build(); - GridRecipe.make(name + "_door", door).setOutputCount(3).setShape("##", "##", "##").addMaterial('#', planks).setGroup("end_doors").build(); - GridRecipe.make(name + "_crafting_table", craftingTable).setShape("##", "##").addMaterial('#', planks).setGroup("end_tables").build(); - GridRecipe.make(name + "_ladder", ladder).setOutputCount(3).setShape("I I", "I#I", "I I").addMaterial('#', planks).addMaterial('I', Items.STICK).setGroup("end_ladders").build(); - GridRecipe.make(name + "_sign", sign).setOutputCount(3).setShape("###", "###", " I ").addMaterial('#', planks).addMaterial('I', Items.STICK).setGroup("end_signs").build(); - GridRecipe.make(name + "_chest", chest).setShape("###", "# #", "###").addMaterial('#', planks).setGroup("end_chests").build(); - GridRecipe.make(name + "_barrel", barrel).setShape("#S#", "# #", "#S#").addMaterial('#', planks).addMaterial('S', slab).setGroup("end_barrels").build(); - GridRecipe.make(name + "_bookshelf", shelf).setShape("###", "PPP", "###").addMaterial('#', planks).addMaterial('P', Items.BOOK).setGroup("end_bookshelves").build(); + GridRecipe.make(name + "_planks", planks).setOutputCount(4).setList("#") + .addMaterial('#', log, bark, log_stripped, bark_stripped).setGroup("end_planks").build(); + GridRecipe.make(name + "_stairs", stairs).setOutputCount(4).setShape("# ", "## ", "###") + .addMaterial('#', planks).setGroup("end_planks_stairs").build(); + GridRecipe.make(name + "_slab", slab).setOutputCount(6).setShape("###").addMaterial('#', planks) + .setGroup("end_planks_slabs").build(); + GridRecipe.make(name + "_fence", fence).setOutputCount(3).setShape("#I#", "#I#").addMaterial('#', planks) + .addMaterial('I', Items.STICK).setGroup("end_planks_fences").build(); + GridRecipe.make(name + "_gate", gate).setShape("I#I", "I#I").addMaterial('#', planks) + .addMaterial('I', Items.STICK).setGroup("end_planks_gates").build(); + GridRecipe.make(name + "_button", button).setList("#").addMaterial('#', planks).setGroup("end_planks_buttons") + .build(); + GridRecipe.make(name + "_pressure_plate", pressurePlate).setShape("##").addMaterial('#', planks) + .setGroup("end_planks_plates").build(); + GridRecipe.make(name + "_trapdoor", trapdoor).setOutputCount(2).setShape("###", "###").addMaterial('#', planks) + .setGroup("end_trapdoors").build(); + GridRecipe.make(name + "_door", door).setOutputCount(3).setShape("##", "##", "##").addMaterial('#', planks) + .setGroup("end_doors").build(); + GridRecipe.make(name + "_crafting_table", craftingTable).setShape("##", "##").addMaterial('#', planks) + .setGroup("end_tables").build(); + GridRecipe.make(name + "_ladder", ladder).setOutputCount(3).setShape("I I", "I#I", "I I") + .addMaterial('#', planks).addMaterial('I', Items.STICK).setGroup("end_ladders").build(); + GridRecipe.make(name + "_sign", sign).setOutputCount(3).setShape("###", "###", " I ").addMaterial('#', planks) + .addMaterial('I', Items.STICK).setGroup("end_signs").build(); + GridRecipe.make(name + "_chest", chest).setShape("###", "# #", "###").addMaterial('#', planks) + .setGroup("end_chests").build(); + GridRecipe.make(name + "_barrel", barrel).setShape("#S#", "# #", "#S#").addMaterial('#', planks) + .addMaterial('S', slab).setGroup("end_barrels").build(); + GridRecipe.make(name + "_bookshelf", shelf).setShape("###", "PPP", "###").addMaterial('#', planks) + .addMaterial('P', Items.BOOK).setGroup("end_bookshelves").build(); GridRecipe.make(name + "_bark", bark).setShape("##", "##").addMaterial('#', log).setOutputCount(3).build(); GridRecipe.make(name + "_log", log).setShape("##", "##").addMaterial('#', bark).setOutputCount(3).build(); GridRecipe.make(name + "_composter", composter).setShape("# #", "# #", "###").addMaterial('#', slab).build(); - GridRecipe.make(name + "_shulker", Items.SHULKER_BOX).setShape("S", "#", "S").addMaterial('S', Items.SHULKER_SHELL).addMaterial('#', chest).build(); - + GridRecipe.make(name + "_shulker", Items.SHULKER_BOX).setShape("S", "#", "S") + .addMaterial('S', Items.SHULKER_SHELL).addMaterial('#', chest).build(); + // Item Tags // TagHelper.addTag(ItemTags.PLANKS, planks); TagHelper.addTag(ItemTags.WOODEN_PRESSURE_PLATES, pressurePlate); TagHelper.addTag(ItemTags.LOGS, log, bark, log_stripped, bark_stripped); TagHelper.addTag(ItemTags.LOGS_THAT_BURN, log, bark, log_stripped, bark_stripped); - + TagHelper.addTags(button, ItemTags.WOODEN_BUTTONS, ItemTags.BUTTONS); TagHelper.addTags(door, ItemTags.WOODEN_DOORS, ItemTags.DOORS); TagHelper.addTags(fence, ItemTags.WOODEN_FENCES, ItemTags.FENCES); @@ -127,13 +143,13 @@ public class WoodenMaterial { TagHelper.addTags(stairs, ItemTags.WOODEN_STAIRS, ItemTags.STAIRS); TagHelper.addTags(trapdoor, ItemTags.WOODEN_TRAPDOORS, ItemTags.TRAPDOORS); TagHelper.addTag(EndTags.ITEM_CHEST, chest); - + // Block Tags // TagHelper.addTag(BlockTags.PLANKS, planks); TagHelper.addTag(BlockTags.CLIMBABLE, ladder); TagHelper.addTag(BlockTags.LOGS, log, bark, log_stripped, bark_stripped); TagHelper.addTag(BlockTags.LOGS_THAT_BURN, log, bark, log_stripped, bark_stripped); - + TagHelper.addTags(button, BlockTags.WOODEN_BUTTONS, BlockTags.BUTTONS); TagHelper.addTags(door, BlockTags.WOODEN_DOORS, BlockTags.DOORS); TagHelper.addTags(fence, BlockTags.WOODEN_FENCES, BlockTags.FENCES); @@ -142,17 +158,17 @@ public class WoodenMaterial { TagHelper.addTags(trapdoor, BlockTags.WOODEN_TRAPDOORS, BlockTags.TRAPDOORS); TagHelper.addTag(EndTags.BOOKSHELVES, shelf); TagHelper.addTag(EndTags.BLOCK_CHEST, chest); - + logBlockTag = EndTags.makeBlockTag(name + "_logs"); logItemTag = EndTags.makeItemTag(name + "_logs"); TagHelper.addTag(logBlockTag, log_stripped, bark_stripped, log, bark); TagHelper.addTag(logItemTag, log_stripped, bark_stripped, log, bark); } - + public boolean isTreeLog(Block block) { return block == log || block == bark; } - + public boolean isTreeLog(BlockState state) { return isTreeLog(state.getBlock()); } diff --git a/src/main/java/ru/betterend/blocks/entities/BlockEntityHydrothermalVent.java b/src/main/java/ru/betterend/blocks/entities/BlockEntityHydrothermalVent.java index f8a2eb68..19306898 100644 --- a/src/main/java/ru/betterend/blocks/entities/BlockEntityHydrothermalVent.java +++ b/src/main/java/ru/betterend/blocks/entities/BlockEntityHydrothermalVent.java @@ -1,8 +1,8 @@ package ru.betterend.blocks.entities; -import net.minecraft.block.BlockState; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.particle.ParticleTypes; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.util.Tickable; import ru.betterend.blocks.HydrothermalVentBlock; import ru.betterend.registry.EndBlockEntities; @@ -21,11 +21,10 @@ public class BlockEntityHydrothermalVent extends BlockEntity implements Tickable double y = pos.getY() + 0.9 + world.random.nextDouble() * 0.3; double z = pos.getZ() + world.random.nextDouble(); BlockState state = getCachedState(); - if (state.isOf(EndBlocks.HYDROTHERMAL_VENT) && state.get(HydrothermalVentBlock.ACTIVATED)) { - if (state.get(HydrothermalVentBlock.WATERLOGGED)) { + if (state.is(EndBlocks.HYDROTHERMAL_VENT) && state.getValue(HydrothermalVentBlock.ACTIVATED)) { + if (state.getValue(HydrothermalVentBlock.WATERLOGGED)) { world.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0); - } - else { + } else { world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0, 0, 0); } } diff --git a/src/main/java/ru/betterend/blocks/entities/EBarrelBlockEntity.java b/src/main/java/ru/betterend/blocks/entities/EBarrelBlockEntity.java index ac9a35c2..077ce206 100644 --- a/src/main/java/ru/betterend/blocks/entities/EBarrelBlockEntity.java +++ b/src/main/java/ru/betterend/blocks/entities/EBarrelBlockEntity.java @@ -1,25 +1,25 @@ package ru.betterend.blocks.entities; -import net.minecraft.block.BarrelBlock; -import net.minecraft.block.BlockState; -import net.minecraft.block.entity.BlockEntityType; -import net.minecraft.block.entity.ChestBlockEntity; -import net.minecraft.block.entity.LootableContainerBlockEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.world.level.block.BarrelBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.entity.ChestBlockEntity; +import net.minecraft.world.level.block.entity.LootableContainerBlockEntity; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.entity.player.PlayerInventory; import net.minecraft.inventory.Inventories; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraft.nbt.CompoundTag; import net.minecraft.screen.GenericContainerScreenHandler; import net.minecraft.screen.ScreenHandler; -import net.minecraft.sound.SoundCategory; +import net.minecraft.sounds.SoundSource; import net.minecraft.sound.SoundEvent; -import net.minecraft.sound.SoundEvents; +import net.minecraft.sounds.SoundEvents; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; import net.minecraft.util.collection.DefaultedList; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3i; +import net.minecraft.core.Direction; +import net.minecraft.core.Vec3i; import ru.betterend.blocks.basis.EndBarrelBlock; import ru.betterend.registry.EndBlockEntities; @@ -124,7 +124,7 @@ public class EBarrelBlockEntity extends LootableContainerBlockEntity { } private void setOpen(BlockState state, boolean open) { - this.world.setBlockState(this.getPos(), (BlockState) state.with(BarrelBlock.OPEN, open), 3); + this.world.setBlockAndUpdate(this.getPos(), (BlockState) state.with(BarrelBlock.OPEN, open), 3); } private void playSound(BlockState blockState, SoundEvent soundEvent) { @@ -132,7 +132,7 @@ public class EBarrelBlockEntity extends LootableContainerBlockEntity { double d = (double) this.pos.getX() + 0.5D + (double) vec3i.getX() / 2.0D; double e = (double) this.pos.getY() + 0.5D + (double) vec3i.getY() / 2.0D; double f = (double) this.pos.getZ() + 0.5D + (double) vec3i.getZ() / 2.0D; - this.world.playSound((PlayerEntity) null, d, e, f, soundEvent, SoundCategory.BLOCKS, 0.5F, + this.world.playLocalSound((PlayerEntity) null, d, e, f, soundEvent, SoundSource.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F); } } \ No newline at end of file diff --git a/src/main/java/ru/betterend/blocks/entities/EChestBlockEntity.java b/src/main/java/ru/betterend/blocks/entities/EChestBlockEntity.java index 25c5bdc8..48e906d1 100644 --- a/src/main/java/ru/betterend/blocks/entities/EChestBlockEntity.java +++ b/src/main/java/ru/betterend/blocks/entities/EChestBlockEntity.java @@ -1,6 +1,6 @@ package ru.betterend.blocks.entities; -import net.minecraft.block.entity.ChestBlockEntity; +import net.minecraft.world.level.block.entity.ChestBlockEntity; import ru.betterend.registry.EndBlockEntities; public class EChestBlockEntity extends ChestBlockEntity { diff --git a/src/main/java/ru/betterend/blocks/entities/EFurnaceBlockEntity.java b/src/main/java/ru/betterend/blocks/entities/EFurnaceBlockEntity.java index 8537ae9d..067113b4 100644 --- a/src/main/java/ru/betterend/blocks/entities/EFurnaceBlockEntity.java +++ b/src/main/java/ru/betterend/blocks/entities/EFurnaceBlockEntity.java @@ -1,8 +1,8 @@ package ru.betterend.blocks.entities; -import net.minecraft.block.entity.AbstractFurnaceBlockEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.recipe.RecipeType; +import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; +import net.minecraft.world.entity.player.PlayerInventory; +import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.screen.FurnaceScreenHandler; import net.minecraft.screen.ScreenHandler; import net.minecraft.text.Text; diff --git a/src/main/java/ru/betterend/blocks/entities/ESignBlockEntity.java b/src/main/java/ru/betterend/blocks/entities/ESignBlockEntity.java index 51e25415..0c2af7cc 100644 --- a/src/main/java/ru/betterend/blocks/entities/ESignBlockEntity.java +++ b/src/main/java/ru/betterend/blocks/entities/ESignBlockEntity.java @@ -1,7 +1,7 @@ package ru.betterend.blocks.entities; -import net.minecraft.block.entity.BlockEntityType; -import net.minecraft.block.entity.SignBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.entity.SignBlockEntity; import ru.betterend.registry.EndBlockEntities; public class ESignBlockEntity extends SignBlockEntity { diff --git a/src/main/java/ru/betterend/blocks/entities/EndStoneSmelterBlockEntity.java b/src/main/java/ru/betterend/blocks/entities/EndStoneSmelterBlockEntity.java index 67280b59..282bfd2c 100644 --- a/src/main/java/ru/betterend/blocks/entities/EndStoneSmelterBlockEntity.java +++ b/src/main/java/ru/betterend/blocks/entities/EndStoneSmelterBlockEntity.java @@ -10,50 +10,51 @@ import com.google.common.collect.Maps; import it.unimi.dsi.fastutil.objects.Object2IntMap.Entry; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import net.fabricmc.fabric.api.registry.FuelRegistry; -import net.minecraft.block.BlockState; -import net.minecraft.block.entity.AbstractFurnaceBlockEntity; -import net.minecraft.block.entity.LockableContainerBlockEntity; -import net.minecraft.entity.ExperienceOrbEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; +import net.minecraft.world.level.block.entity.LockableContainerBlockEntity; +import net.minecraft.world.entity.ExperienceOrbEntity; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.entity.player.PlayerInventory; import net.minecraft.inventory.Inventories; import net.minecraft.inventory.SidedInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemConvertible; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemConvertible; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraft.nbt.CompoundTag; -import net.minecraft.recipe.BlastingRecipe; -import net.minecraft.recipe.Recipe; -import net.minecraft.recipe.RecipeFinder; -import net.minecraft.recipe.RecipeInputProvider; -import net.minecraft.recipe.RecipeType; -import net.minecraft.recipe.RecipeUnlocker; +import net.minecraft.world.item.crafting.BlastingRecipe; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeFinder; +import net.minecraft.world.item.crafting.RecipeInputProvider; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.RecipeUnlocker; import net.minecraft.screen.PropertyDelegate; import net.minecraft.screen.ScreenHandler; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tickable; import net.minecraft.util.collection.DefaultedList; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.MathHelper; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.BetterEnd; import ru.betterend.blocks.EndStoneSmelter; import ru.betterend.client.gui.EndStoneSmelterScreenHandler; import ru.betterend.recipe.builders.AlloyingRecipe; import ru.betterend.registry.EndBlockEntities; -public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity implements SidedInventory, RecipeUnlocker, RecipeInputProvider, Tickable { +public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity + implements SidedInventory, RecipeUnlocker, RecipeInputProvider, Tickable { private static final int[] TOP_SLOTS = new int[] { 0, 1 }; private static final int[] BOTTOM_SLOTS = new int[] { 2, 3 }; private static final int[] SIDE_SLOTS = new int[] { 1, 2 }; private static final Map AVAILABLE_FUELS = Maps.newHashMap(); - - private final Object2IntOpenHashMap recipesUsed; + + private final Object2IntOpenHashMap recipesUsed; protected DefaultedList inventory; protected final PropertyDelegate propertyDelegate; private Recipe lastRecipe; @@ -61,47 +62,47 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp private int smeltTime; private int burnTime; private int fuelTime; - + public EndStoneSmelterBlockEntity() { super(EndBlockEntities.END_STONE_SMELTER); this.inventory = DefaultedList.ofSize(4, ItemStack.EMPTY); this.recipesUsed = new Object2IntOpenHashMap<>(); - this.propertyDelegate = new PropertyDelegate() { - public int get(int index) { - switch(index) { - case 0: - return EndStoneSmelterBlockEntity.this.burnTime; - case 1: - return EndStoneSmelterBlockEntity.this.fuelTime; - case 2: - return EndStoneSmelterBlockEntity.this.smeltTime; - case 3: - return EndStoneSmelterBlockEntity.this.smeltTimeTotal; - default: - return 0; - } - } + this.propertyDelegate = new PropertyDelegate() { + public int get(int index) { + switch (index) { + case 0: + return EndStoneSmelterBlockEntity.this.burnTime; + case 1: + return EndStoneSmelterBlockEntity.this.fuelTime; + case 2: + return EndStoneSmelterBlockEntity.this.smeltTime; + case 3: + return EndStoneSmelterBlockEntity.this.smeltTimeTotal; + default: + return 0; + } + } - public void set(int index, int value) { - switch(index) { - case 0: - EndStoneSmelterBlockEntity.this.burnTime = value; - break; - case 1: - EndStoneSmelterBlockEntity.this.fuelTime = value; - break; - case 2: - EndStoneSmelterBlockEntity.this.smeltTime = value; - break; - case 3: - EndStoneSmelterBlockEntity.this.smeltTimeTotal = value; - } - } + public void set(int index, int value) { + switch (index) { + case 0: + EndStoneSmelterBlockEntity.this.burnTime = value; + break; + case 1: + EndStoneSmelterBlockEntity.this.fuelTime = value; + break; + case 2: + EndStoneSmelterBlockEntity.this.smeltTime = value; + break; + case 3: + EndStoneSmelterBlockEntity.this.smeltTimeTotal = value; + } + } - public int size() { - return 4; - } - }; + public int size() { + return 4; + } + }; } private boolean isBurning() { @@ -145,7 +146,8 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp @Override public void setStack(int slot, ItemStack stack) { ItemStack itemStack = this.inventory.get(slot); - boolean stackValid = !stack.isEmpty() && stack.isItemEqualIgnoreDamage(itemStack) && ItemStack.areTagsEqual(stack, itemStack); + boolean stackValid = !stack.isEmpty() && stack.isItemEqualIgnoreDamage(itemStack) + && ItemStack.areTagsEqual(stack, itemStack); this.inventory.set(slot, stack); if (stack.getCount() > getMaxCountPerStack()) { stack.setCount(getMaxCountPerStack()); @@ -156,23 +158,23 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp this.markDirty(); } } - + protected int getSmeltTime() { assert this.world != null; int smeltTime = this.world.getRecipeManager().getFirstMatch(AlloyingRecipe.TYPE, this, world) .map(AlloyingRecipe::getSmeltTime).orElse(0); if (smeltTime == 0) { smeltTime = this.world.getRecipeManager().getFirstMatch(RecipeType.BLASTING, this, world) - .map(BlastingRecipe::getCookTime).orElse(200); + .map(BlastingRecipe::getCookTime).orElse(200); smeltTime /= 1.5; } return smeltTime; } - + public void dropExperience(PlayerEntity player) { assert world != null; List> list = Lists.newArrayList(); - for (Entry entry : this.recipesUsed.object2IntEntrySet()) { + for (Entry entry : this.recipesUsed.object2IntEntrySet()) { world.getRecipeManager().get(entry.getKey()).ifPresent((recipe) -> { list.add(recipe); if (recipe instanceof AlloyingRecipe) { @@ -187,15 +189,15 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp player.unlockRecipes(list); this.recipesUsed.clear(); } - - private void dropExperience(World world, Vec3d vec3d, int i, float f) { - int j = MathHelper.floor(i * f); - float g = MathHelper.fractionalPart(i * f); + + private void dropExperience(Level world, Vec3d vec3d, int i, float f) { + int j = Mth.floor(i * f); + float g = Mth.fractionalPart(i * f); if (g != 0.0F && Math.random() < g) { j++; } - while(j > 0) { + while (j > 0) { int k = ExperienceOrbEntity.roundToOrbSize(j); j -= k; world.spawnEntity(new ExperienceOrbEntity(world, vec3d.x, vec3d.y, vec3d.z, k)); @@ -208,7 +210,8 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp if (this.world.getBlockEntity(this.pos) != this) { return false; } - return player.squaredDistanceTo(this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D) <= 64.0D; + return player.squaredDistanceTo(this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, + this.pos.getZ() + 0.5D) <= 64.0D; } @Override @@ -235,14 +238,15 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp boolean burning = this.isBurning(); assert this.world != null; - if (!this.world.isClient) { + if (!this.world.isClientSide) { ItemStack fuel = this.inventory.get(2); if (!burning && (fuel.isEmpty() || inventory.get(0).isEmpty() && inventory.get(1).isEmpty())) { if (smeltTime > 0) { - this.smeltTime = MathHelper.clamp(smeltTime - 2, 0, smeltTimeTotal); + this.smeltTime = Mth.clamp(smeltTime - 2, 0, smeltTimeTotal); } } else { - Recipe recipe = this.world.getRecipeManager().getFirstMatch(AlloyingRecipe.TYPE, this, world).orElse(null); + Recipe recipe = this.world.getRecipeManager().getFirstMatch(AlloyingRecipe.TYPE, this, world) + .orElse(null); if (recipe == null) { recipe = this.world.getRecipeManager().getFirstMatch(RecipeType.BLASTING, this, world).orElse(null); } @@ -278,21 +282,20 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp } if (initialBurning != burning) { - this.world.setBlockState(pos, world.getBlockState(pos).with(EndStoneSmelter.LIT, burning), 3); + this.world.setBlockAndUpdate(pos, world.getBlockState(pos).with(EndStoneSmelter.LIT, burning), 3); this.markDirty(); } } } - + protected boolean canAcceptRecipeOutput(Recipe recipe) { - if (recipe == null) return false; + if (recipe == null) + return false; boolean validInput; if (recipe instanceof AlloyingRecipe) { - validInput = !inventory.get(0).isEmpty() && - !inventory.get(1).isEmpty(); + validInput = !inventory.get(0).isEmpty() && !inventory.get(1).isEmpty(); } else { - validInput = !inventory.get(0).isEmpty() || - !inventory.get(1).isEmpty(); + validInput = !inventory.get(0).isEmpty() || !inventory.get(1).isEmpty(); } if (validInput) { ItemStack result = recipe.getOutput(); @@ -317,8 +320,9 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp } private void craftRecipe(Recipe recipe) { - if (recipe == null || !canAcceptRecipeOutput(recipe)) return; - + if (recipe == null || !canAcceptRecipeOutput(recipe)) + return; + ItemStack result = recipe.getOutput(); ItemStack output = this.inventory.get(3); if (output.isEmpty()) { @@ -328,10 +332,10 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp } assert this.world != null; - if (!this.world.isClient) { + if (!this.world.isClientSide) { this.setLastRecipe(recipe); } - + if (recipe instanceof AlloyingRecipe) { this.inventory.get(0).decrement(1); this.inventory.get(1).decrement(1); @@ -354,7 +358,7 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp @Override public void setLastRecipe(Recipe recipe) { if (recipe != null) { - Identifier recipeId = recipe.getId(); + ResourceLocation recipeId = recipe.getId(); this.recipesUsed.addTo(recipeId, 1); this.lastRecipe = recipe; } @@ -393,7 +397,7 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp Item item = fuel.getItem(); return AVAILABLE_FUELS.getOrDefault(item, getFabricFuel(fuel)); } - + @Override public void fromTag(BlockState state, CompoundTag tag) { super.fromTag(state, tag); @@ -405,10 +409,10 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp this.smeltTimeTotal = tag.getShort("SmeltTimeTotal"); CompoundTag compoundTag = tag.getCompound("RecipesUsed"); for (String id : compoundTag.getKeys()) { - this.recipesUsed.put(new Identifier(id), compoundTag.getInt(id)); + this.recipesUsed.put(new ResourceLocation(id), compoundTag.getInt(id)); } } - + @Override public CompoundTag toTag(CompoundTag tag) { super.toTag(tag); @@ -420,10 +424,10 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp CompoundTag usedRecipes = new CompoundTag(); this.recipesUsed.forEach((identifier, integer) -> usedRecipes.putInt(identifier.toString(), integer)); tag.put("RecipesUsed", usedRecipes); - + return tag; } - + public boolean isValid(int slot, ItemStack stack) { if (slot == 3) { return false; @@ -445,7 +449,7 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp public static Map availableFuels() { return AVAILABLE_FUELS; } - + private static int getFabricFuel(ItemStack stack) { Integer ticks = FuelRegistry.INSTANCE.get(stack.getItem()); return ticks == null ? 0 : ticks; diff --git a/src/main/java/ru/betterend/blocks/entities/EternalPedestalEntity.java b/src/main/java/ru/betterend/blocks/entities/EternalPedestalEntity.java index 30039b14..f6ab8e2b 100644 --- a/src/main/java/ru/betterend/blocks/entities/EternalPedestalEntity.java +++ b/src/main/java/ru/betterend/blocks/entities/EternalPedestalEntity.java @@ -1,32 +1,32 @@ package ru.betterend.blocks.entities; import net.minecraft.nbt.CompoundTag; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import ru.betterend.registry.EndBlockEntities; import ru.betterend.rituals.EternalRitual; public class EternalPedestalEntity extends PedestalBlockEntity { private EternalRitual linkedRitual; - + public EternalPedestalEntity() { super(EndBlockEntities.ETERNAL_PEDESTAL); } - + public boolean hasRitual() { return linkedRitual != null; } - + public void linkRitual(EternalRitual ritual) { this.linkedRitual = ritual; } - + public EternalRitual getRitual() { return linkedRitual; } - + @Override - public void setLocation(World world, BlockPos pos) { + public void setLocation(Level world, BlockPos pos) { super.setLocation(world, pos); if (hasRitual()) { linkedRitual.setWorld(world); diff --git a/src/main/java/ru/betterend/blocks/entities/InfusionPedestalEntity.java b/src/main/java/ru/betterend/blocks/entities/InfusionPedestalEntity.java index 66e40fa4..f0151b12 100644 --- a/src/main/java/ru/betterend/blocks/entities/InfusionPedestalEntity.java +++ b/src/main/java/ru/betterend/blocks/entities/InfusionPedestalEntity.java @@ -1,39 +1,39 @@ package ru.betterend.blocks.entities; import net.minecraft.nbt.CompoundTag; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import ru.betterend.registry.EndBlockEntities; import ru.betterend.rituals.InfusionRitual; public class InfusionPedestalEntity extends PedestalBlockEntity { private InfusionRitual linkedRitual; - + public InfusionPedestalEntity() { super(EndBlockEntities.INFUSION_PEDESTAL); } - + @Override - public void setLocation(World world, BlockPos pos) { + public void setLocation(Level world, BlockPos pos) { super.setLocation(world, pos); if (hasRitual()) { linkedRitual.setLocation(world, pos); } } - + public void linkRitual(InfusionRitual ritual) { linkedRitual = ritual; } - + public InfusionRitual getRitual() { return linkedRitual; } - + public boolean hasRitual() { return linkedRitual != null; } - + @Override public void tick() { if (hasRitual()) { diff --git a/src/main/java/ru/betterend/blocks/entities/PedestalBlockEntity.java b/src/main/java/ru/betterend/blocks/entities/PedestalBlockEntity.java index 7bea10ec..01ffeab2 100644 --- a/src/main/java/ru/betterend/blocks/entities/PedestalBlockEntity.java +++ b/src/main/java/ru/betterend/blocks/entities/PedestalBlockEntity.java @@ -1,12 +1,12 @@ package ru.betterend.blocks.entities; import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable; -import net.minecraft.block.BlockState; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.BlockEntityType; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.entity.player.PlayerEntity; import net.minecraft.inventory.Inventory; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.Tickable; import ru.betterend.blocks.basis.PedestalBlock; @@ -15,22 +15,22 @@ import ru.betterend.registry.EndItems; public class PedestalBlockEntity extends BlockEntity implements Inventory, Tickable, BlockEntityClientSerializable { private ItemStack activeItem = ItemStack.EMPTY; - + private final int maxAge = 314; private int age; - + public PedestalBlockEntity() { super(EndBlockEntities.PEDESTAL); } - + public PedestalBlockEntity(BlockEntityType type) { super(type); } - + public int getAge() { return age; } - + public int getMaxAge() { return maxAge; } @@ -54,7 +54,7 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka public ItemStack removeStack(int slot, int amount) { return removeStack(slot); } - + @Override public boolean isValid(int slot, ItemStack stack) { return isEmpty(); @@ -78,10 +78,10 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka activeItem = stack; markDirty(); } - + @Override public void markDirty() { - if (world != null && !world.isClient) { + if (world != null && !world.isClientSide) { BlockState state = world.getBlockState(pos); if (state.getBlock() instanceof PedestalBlock) { BlockState trueState = state.with(PedestalBlock.HAS_ITEM, !isEmpty()); @@ -90,18 +90,17 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka } else { trueState = trueState.with(PedestalBlock.HAS_LIGHT, false); } - world.setBlockState(pos, trueState); + world.setBlockAndUpdate(pos, trueState); } } super.markDirty(); } - @Override public boolean canPlayerUse(PlayerEntity player) { return true; } - + @Override public void fromTag(BlockState state, CompoundTag tag) { super.fromTag(state, tag); diff --git a/src/main/java/ru/betterend/blocks/entities/render/EndChestBlockEntityRenderer.java b/src/main/java/ru/betterend/blocks/entities/render/EndChestBlockEntityRenderer.java index 2fdfed01..f63fba5f 100644 --- a/src/main/java/ru/betterend/blocks/entities/render/EndChestBlockEntityRenderer.java +++ b/src/main/java/ru/betterend/blocks/entities/render/EndChestBlockEntityRenderer.java @@ -6,15 +6,15 @@ import com.google.common.collect.Maps; import it.unimi.dsi.fastutil.floats.Float2FloatFunction; import it.unimi.dsi.fastutil.ints.Int2IntFunction; -import net.minecraft.block.AbstractChestBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.DoubleBlockProperties; -import net.minecraft.block.DoubleBlockProperties.PropertySource; -import net.minecraft.block.entity.ChestBlockEntity; -import net.minecraft.block.enums.ChestType; +import net.minecraft.world.level.block.AbstractChestBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ChestBlock; +import net.minecraft.world.level.block.DoubleBlockProperties; +import net.minecraft.world.level.block.DoubleBlockProperties.PropertySource; +import net.minecraft.world.level.block.entity.ChestBlockEntity; +import net.minecraft.world.level.block.enums.ChestType; import net.minecraft.client.block.ChestAnimationProgress; import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.RenderLayer; @@ -25,11 +25,11 @@ import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.client.render.block.entity.LightmapCoordinatesRetriever; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.item.BlockItem; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.World; +import net.minecraft.world.item.BlockItem; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Direction; +import net.minecraft.core.Registry; +import net.minecraft.world.level.Level; import ru.betterend.BetterEnd; import ru.betterend.blocks.basis.EndChestBlock; import ru.betterend.blocks.entities.EChestBlockEntity; @@ -85,11 +85,15 @@ public class EndChestBlockEntityRenderer extends BlockEntityRenderer abstractChestBlock = (AbstractChestBlock) block; @@ -108,19 +112,23 @@ public class EndChestBlockEntityRenderer extends BlockEntityRenderer { if (item instanceof BlockItem) { Block block = ((BlockItem) item).getBlock(); if (block instanceof EndChestBlock) { - String name = Registry.BLOCK.getId(block).getPath(); + String name = Registry.BLOCK.getKey(block).getPath(); LAYERS.put(block, new RenderLayer[] { - RenderLayer.getEntityCutout(BetterEnd.makeID("textures/entity/chest/" + name + ".png")), - RenderLayer.getEntityCutout(BetterEnd.makeID("textures/entity/chest/" + name + "_left.png")), - RenderLayer.getEntityCutout(BetterEnd.makeID("textures/entity/chest/" + name + "_right.png")) - }); + RenderLayer.getEntityCutout(BetterEnd.makeID("textures/entity/chest/" + name + ".png")), + RenderLayer + .getEntityCutout(BetterEnd.makeID("textures/entity/chest/" + name + "_left.png")), + RenderLayer.getEntityCutout( + BetterEnd.makeID("textures/entity/chest/" + name + "_right.png")) }); } } }); diff --git a/src/main/java/ru/betterend/blocks/entities/render/EndSignBlockEntityRenderer.java b/src/main/java/ru/betterend/blocks/entities/render/EndSignBlockEntityRenderer.java index 10507336..39d3e087 100644 --- a/src/main/java/ru/betterend/blocks/entities/render/EndSignBlockEntityRenderer.java +++ b/src/main/java/ru/betterend/blocks/entities/render/EndSignBlockEntityRenderer.java @@ -5,10 +5,10 @@ import java.util.List; import com.google.common.collect.Maps; -import net.minecraft.block.AbstractSignBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.SignBlock; +import net.minecraft.world.level.block.AbstractSignBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.SignBlock; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.TexturedRenderLayers; @@ -22,11 +22,11 @@ import net.minecraft.client.texture.NativeImage; import net.minecraft.client.util.SpriteIdentifier; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.item.BlockItem; +import net.minecraft.world.item.BlockItem; import net.minecraft.text.OrderedText; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.SignType; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; import ru.betterend.blocks.basis.EndSignBlock; import ru.betterend.blocks.entities.ESignBlockEntity; @@ -47,7 +47,7 @@ public class EndSignBlockEntityRenderer extends BlockEntityRenderer { if (item instanceof BlockItem) { Block block = ((BlockItem) item).getBlock(); if (block instanceof EndSignBlock) { - String name = Registry.BLOCK.getId(block).getPath(); - RenderLayer layer = RenderLayer.getEntitySolid(BetterEnd.makeID("textures/entity/sign/" + name + ".png")); + String name = Registry.BLOCK.getKey(block).getPath(); + RenderLayer layer = RenderLayer + .getEntitySolid(BetterEnd.makeID("textures/entity/sign/" + name + ".png")); LAYERS.put(block, layer); } } }); } - } diff --git a/src/main/java/ru/betterend/blocks/entities/render/PedestalItemRenderer.java b/src/main/java/ru/betterend/blocks/entities/render/PedestalItemRenderer.java index 5d390e4e..16168716 100644 --- a/src/main/java/ru/betterend/blocks/entities/render/PedestalItemRenderer.java +++ b/src/main/java/ru/betterend/blocks/entities/render/PedestalItemRenderer.java @@ -2,7 +2,7 @@ package ru.betterend.blocks.entities.render; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; @@ -11,11 +11,11 @@ import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.json.ModelTransformation; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.util.Mth; +import net.minecraft.world.level.Level; import ru.betterend.blocks.EternalPedestal; import ru.betterend.blocks.basis.PedestalBlock; import ru.betterend.blocks.entities.PedestalBlockEntity; @@ -27,21 +27,23 @@ import ru.betterend.registry.EndItems; @Environment(EnvType.CLIENT) public class PedestalItemRenderer extends BlockEntityRenderer { - + public PedestalItemRenderer(BlockEntityRenderDispatcher dispatcher) { super(dispatcher); } @Override - public void render(T blockEntity, float tickDelta, MatrixStack matrices, - VertexConsumerProvider vertexConsumers, int light, int overlay) { + public void render(T blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, + int light, int overlay) { - World world = blockEntity.getWorld(); - if (world == null || blockEntity.isEmpty()) return; + Level world = blockEntity.getLevel(); + if (world == null || blockEntity.isEmpty()) + return; BlockState state = world.getBlockState(blockEntity.getPos()); - if (!(state.getBlock() instanceof PedestalBlock)) return; - + if (!(state.getBlock() instanceof PedestalBlock)) + return; + ItemStack activeItem = blockEntity.getStack(0); matrices.push(); @@ -57,12 +59,13 @@ public class PedestalItemRenderer extends BlockEn matrices.scale(1.25F, 1.25F, 1.25F); } int age = blockEntity.getAge(); - if (state.isOf(EndBlocks.ETERNAL_PEDESTAL) && state.get(EternalPedestal.ACTIVATED)) { + if (state.is(EndBlocks.ETERNAL_PEDESTAL) && state.getValue(EternalPedestal.ACTIVATED)) { float[] colors = EternalCrystalRenderer.colors(age); int y = blockEntity.getPos().getY(); - - BeamRenderer.renderLightBeam(matrices, vertexConsumers, age, tickDelta, -y, 1024 - y, colors, 0.25F, 0.13F, 0.16F); - float altitude = MathHelper.sin((blockEntity.getAge() + tickDelta) / 10.0F) * 0.1F + 0.1F; + + BeamRenderer.renderLightBeam(matrices, vertexConsumers, age, tickDelta, -y, 1024 - y, colors, 0.25F, 0.13F, + 0.16F); + float altitude = Mth.sin((blockEntity.getAge() + tickDelta) / 10.0F) * 0.1F + 0.1F; matrices.translate(0.0D, altitude, 0.0D); } if (activeItem.getItem() == Items.END_CRYSTAL) { @@ -72,7 +75,8 @@ public class PedestalItemRenderer extends BlockEn } else { float rotation = (age + tickDelta) / 25.0F + 6.0F; matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(rotation)); - minecraft.getItemRenderer().renderItem(activeItem, ModelTransformation.Mode.GROUND, false, matrices, vertexConsumers, light, overlay, model); + minecraft.getItemRenderer().renderItem(activeItem, ModelTransformation.Mode.GROUND, false, matrices, + vertexConsumers, light, overlay, model); } matrices.pop(); } diff --git a/src/main/java/ru/betterend/client/BetterEndClient.java b/src/main/java/ru/betterend/client/BetterEndClient.java index e9e2881f..bdf5c88c 100644 --- a/src/main/java/ru/betterend/client/BetterEndClient.java +++ b/src/main/java/ru/betterend/client/BetterEndClient.java @@ -3,7 +3,7 @@ package ru.betterend.client; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.minecraft.client.render.RenderLayer; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; @@ -24,7 +24,7 @@ public class BetterEndClient implements ClientModInitializer { EndEntitiesRenders.register(); EndModelProviders.register(); ClientOptions.init(); - + if (BetterEnd.isDevEnvironment()) { TranslationHelper.printMissingNames(); } diff --git a/src/main/java/ru/betterend/client/gui/BlockSignEditScreen.java b/src/main/java/ru/betterend/client/gui/BlockSignEditScreen.java index bc394dba..8351c782 100644 --- a/src/main/java/ru/betterend/client/gui/BlockSignEditScreen.java +++ b/src/main/java/ru/betterend/client/gui/BlockSignEditScreen.java @@ -7,7 +7,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ScreenTexts; diff --git a/src/main/java/ru/betterend/client/gui/EndStoneSmelterRecipeBookScreen.java b/src/main/java/ru/betterend/client/gui/EndStoneSmelterRecipeBookScreen.java index 3339920f..5786893f 100644 --- a/src/main/java/ru/betterend/client/gui/EndStoneSmelterRecipeBookScreen.java +++ b/src/main/java/ru/betterend/client/gui/EndStoneSmelterRecipeBookScreen.java @@ -12,10 +12,10 @@ import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.recipebook.BlastFurnaceRecipeBookScreen; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.recipe.Ingredient; -import net.minecraft.recipe.Recipe; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.Recipe; import net.minecraft.screen.slot.Slot; import net.minecraft.util.collection.DefaultedList; import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity; @@ -27,12 +27,12 @@ public class EndStoneSmelterRecipeBookScreen extends BlastFurnaceRecipeBookScree private Slot fuelSlot; private Item currentItem; private float frameTime; - + @Override protected Set getAllowedFuels() { return EndStoneSmelterBlockEntity.availableFuels().keySet(); } - + @Override public void slotClicked(Slot slot) { super.slotClicked(slot); @@ -40,7 +40,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastFurnaceRecipeBookScree this.fuelSlot = null; } } - + @Override public void showGhostRecipe(Recipe recipe, List slots) { this.ghostSlots.reset(); @@ -49,7 +49,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastFurnaceRecipeBookScree this.ghostSlots.addSlot(Ingredient.ofStacks(result), (slots.get(3)).x, (slots.get(3)).y); DefaultedList inputs = recipe.getPreviewInputs(); Iterator iterator = inputs.iterator(); - for(int i = 0; i < 2; i++) { + for (int i = 0; i < 2; i++) { if (!iterator.hasNext()) { return; } @@ -67,7 +67,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastFurnaceRecipeBookScree this.fuelIterator = this.fuels.iterator(); this.currentItem = null; } - + @Override public void drawGhostSlots(MatrixStack matrices, int x, int y, boolean bl, float f) { this.ghostSlots.draw(matrices, client, x, y, bl, f); @@ -79,7 +79,8 @@ public class EndStoneSmelterRecipeBookScreen extends BlastFurnaceRecipeBookScree int slotX = this.fuelSlot.x + x; int slotY = this.fuelSlot.y + y; DrawableHelper.fill(matrices, slotX, slotY, slotX + 16, slotY + 16, 822018048); - this.client.getItemRenderer().renderInGuiWithOverrides(client.player, this.getItem().getDefaultStack(), slotX, slotY); + this.client.getItemRenderer().renderInGuiWithOverrides(client.player, this.getItem().getDefaultStack(), + slotX, slotY); RenderSystem.depthFunc(516); DrawableHelper.fill(matrices, slotX, slotY, slotX + 16, slotY + 16, 822083583); RenderSystem.depthFunc(515); diff --git a/src/main/java/ru/betterend/client/gui/EndStoneSmelterScreen.java b/src/main/java/ru/betterend/client/gui/EndStoneSmelterScreen.java index 8c81c7ff..8831c3ef 100644 --- a/src/main/java/ru/betterend/client/gui/EndStoneSmelterScreen.java +++ b/src/main/java/ru/betterend/client/gui/EndStoneSmelterScreen.java @@ -9,40 +9,42 @@ import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider; import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget; import net.minecraft.client.gui.widget.TexturedButtonWidget; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.world.entity.player.PlayerInventory; import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.SlotActionType; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import ru.betterend.BetterEnd; @Environment(EnvType.CLIENT) public class EndStoneSmelterScreen extends HandledScreen implements RecipeBookProvider { - private final static Identifier RECIPE_BUTTON_TEXTURE = new Identifier("textures/gui/recipe_button.png"); - private final static Identifier BACKGROUND_TEXTURE = BetterEnd.makeID("textures/gui/smelter_gui.png"); - + private final static ResourceLocation RECIPE_BUTTON_TEXTURE = new ResourceLocation( + "textures/gui/recipe_button.png"); + private final static ResourceLocation BACKGROUND_TEXTURE = BetterEnd.makeID("textures/gui/smelter_gui.png"); + public final EndStoneSmelterRecipeBookScreen recipeBook; private boolean narrow; - + public EndStoneSmelterScreen(EndStoneSmelterScreenHandler handler, PlayerInventory inventory, Text title) { super(handler, inventory, title); this.recipeBook = new EndStoneSmelterRecipeBookScreen(); } - + public void init() { super.init(); this.narrow = this.width < 379; this.recipeBook.initialize(width, height, client, narrow, handler); this.x = this.recipeBook.findLeftEdge(narrow, width, backgroundWidth); - this.addButton(new TexturedButtonWidget(x + 20, height / 2 - 49, 20, 18, 0, 0, 19, RECIPE_BUTTON_TEXTURE, (buttonWidget) -> { - this.recipeBook.reset(narrow); - this.recipeBook.toggleOpen(); - this.x = this.recipeBook.findLeftEdge(narrow, width, backgroundWidth); - ((TexturedButtonWidget) buttonWidget).setPos(this.x + 20, height / 2 - 49); - })); - this.titleX = (this.backgroundWidth - this.textRenderer.getWidth((StringVisitable)this.title)) / 2; + this.addButton(new TexturedButtonWidget(x + 20, height / 2 - 49, 20, 18, 0, 0, 19, RECIPE_BUTTON_TEXTURE, + (buttonWidget) -> { + this.recipeBook.reset(narrow); + this.recipeBook.toggleOpen(); + this.x = this.recipeBook.findLeftEdge(narrow, width, backgroundWidth); + ((TexturedButtonWidget) buttonWidget).setPos(this.x + 20, height / 2 - 49); + })); + this.titleX = (this.backgroundWidth - this.textRenderer.getWidth((StringVisitable) this.title)) / 2; } @Override @@ -84,13 +86,16 @@ public class EndStoneSmelterScreen extends HandledScreen= (left + backgroundWidth) || mouseY >= (top + backgroundHeight); - return this.recipeBook.isClickOutsideBounds(mouseX, mouseY, x, y, backgroundWidth, backgroundHeight, button) && isMouseOut; + boolean isMouseOut = mouseX < left || mouseY < top || mouseX >= (left + backgroundWidth) + || mouseY >= (top + backgroundHeight); + return this.recipeBook.isClickOutsideBounds(mouseX, mouseY, x, y, backgroundWidth, backgroundHeight, button) + && isMouseOut; } @Override diff --git a/src/main/java/ru/betterend/client/gui/EndStoneSmelterScreenHandler.java b/src/main/java/ru/betterend/client/gui/EndStoneSmelterScreenHandler.java index f8a00502..d9e084f8 100644 --- a/src/main/java/ru/betterend/client/gui/EndStoneSmelterScreenHandler.java +++ b/src/main/java/ru/betterend/client/gui/EndStoneSmelterScreenHandler.java @@ -3,21 +3,21 @@ package ru.betterend.client.gui; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.entity.player.PlayerInventory; import net.minecraft.inventory.Inventory; import net.minecraft.inventory.SimpleInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.recipe.Recipe; -import net.minecraft.recipe.RecipeFinder; -import net.minecraft.recipe.RecipeInputProvider; -import net.minecraft.recipe.book.RecipeBookCategory; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeFinder; +import net.minecraft.world.item.crafting.RecipeInputProvider; +import net.minecraft.world.item.crafting.book.RecipeBookCategory; import net.minecraft.screen.AbstractRecipeScreenHandler; import net.minecraft.screen.ArrayPropertyDelegate; import net.minecraft.screen.PropertyDelegate; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.screen.slot.Slot; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.BetterEnd; import ru.betterend.blocks.EndStoneSmelter; import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity; @@ -27,39 +27,40 @@ import ru.betterend.recipe.builders.AlloyingRecipe; public class EndStoneSmelterScreenHandler extends AbstractRecipeScreenHandler { - public final static ScreenHandlerType HANDLER_TYPE = ScreenHandlerRegistry.registerSimple( - BetterEnd.makeID(EndStoneSmelter.ID), EndStoneSmelterScreenHandler::new); - + public final static ScreenHandlerType HANDLER_TYPE = ScreenHandlerRegistry + .registerSimple(BetterEnd.makeID(EndStoneSmelter.ID), EndStoneSmelterScreenHandler::new); + private final Inventory inventory; private final PropertyDelegate propertyDelegate; - protected final World world; - + protected final Level world; + public EndStoneSmelterScreenHandler(int syncId, PlayerInventory playerInventory) { this(syncId, playerInventory, new SimpleInventory(4), new ArrayPropertyDelegate(4)); } - - public EndStoneSmelterScreenHandler(int syncId, PlayerInventory playerInventory, Inventory inventory, PropertyDelegate propertyDelegate) { + + public EndStoneSmelterScreenHandler(int syncId, PlayerInventory playerInventory, Inventory inventory, + PropertyDelegate propertyDelegate) { super(HANDLER_TYPE, syncId); this.inventory = inventory; this.propertyDelegate = propertyDelegate; this.world = playerInventory.player.world; - + this.addProperties(propertyDelegate); this.addSlot(new Slot(inventory, 0, 45, 17)); this.addSlot(new Slot(inventory, 1, 67, 17)); this.addSlot(new SmelterFuelSlot(this, inventory, 2, 56, 53)); this.addSlot(new SmelterOutputSlot(playerInventory.player, inventory, 3, 129, 35)); - for(int i = 0; i < 3; ++i) { - for(int j = 0; j < 9; ++j) { + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 9; ++j) { this.addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } - for(int i = 0; i < 9; ++i) { + for (int i = 0; i < 9; ++i) { this.addSlot(new Slot(playerInventory, i, 8 + i * 18, 142)); } } - + @Override public ScreenHandlerType getType() { return HANDLER_TYPE; @@ -113,13 +114,14 @@ public class EndStoneSmelterScreenHandler extends AbstractRecipeScreenHandler keyFactory; - - public IdConfig(String group, BiFunction keyFactory) { + + protected final BiFunction keyFactory; + + public IdConfig(String group, BiFunction keyFactory) { super(group); this.keyFactory = keyFactory; } @Override - protected void registerEntries() {} + protected void registerEntries() { + } - protected ConfigKey createKey(Identifier id, String key) { + protected ConfigKey createKey(ResourceLocation id, String key) { return this.keyFactory.apply(id, key); } @Nullable - public > E getEntry(Identifier id, String key, Class type) { + public > E getEntry(ResourceLocation id, String key, Class type) { return this.getEntry(createKey(id, key), type); } @Nullable - public > T getDefault(Identifier id, String key, Class type) { + public > T getDefault(ResourceLocation id, String key, Class type) { return this.getDefault(createKey(id, key), type); } - public String getString(Identifier id, String key, String defaultValue) { + public String getString(ResourceLocation id, String key, String defaultValue) { return this.getString(createKey(id, key), defaultValue); } - public String getString(Identifier id, String key) { + public String getString(ResourceLocation id, String key) { return this.getString(createKey(id, key)); } - public boolean setString(Identifier id, String key, String value) { + public boolean setString(ResourceLocation id, String key, String value) { return this.setString(createKey(id, key), value); } - public int getInt(Identifier id, String key, int defaultValue) { + public int getInt(ResourceLocation id, String key, int defaultValue) { return this.getInt(createKey(id, key), defaultValue); } - public int getInt(Identifier id, String key) { + public int getInt(ResourceLocation id, String key) { return this.getInt(createKey(id, key)); } - public boolean setInt(Identifier id, String key, int value) { + public boolean setInt(ResourceLocation id, String key, int value) { return this.setInt(createKey(id, key), value); } - public boolean setRangedInt(Identifier id, String key, int value) { + public boolean setRangedInt(ResourceLocation id, String key, int value) { return this.setRanged(createKey(id, key), value, IntegerRange.class); } - - public boolean setRangedFloat(Identifier id, String key, float value) { + + public boolean setRangedFloat(ResourceLocation id, String key, float value) { return this.setRanged(createKey(id, key), value, FloatRange.class); } - public float getFloat(Identifier id, String key, float defaultValue) { + public float getFloat(ResourceLocation id, String key, float defaultValue) { return this.getFloat(createKey(id, key), defaultValue); } - public float getFloat(Identifier id, String key) { + public float getFloat(ResourceLocation id, String key) { return this.getFloat(createKey(id, key)); } - public boolean setFloat(Identifier id, String key, float value) { + public boolean setFloat(ResourceLocation id, String key, float value) { return this.setFloat(createKey(id, key), value); } - public boolean getBoolean(Identifier id, String key, boolean defaultValue) { + public boolean getBoolean(ResourceLocation id, String key, boolean defaultValue) { return this.getBoolean(createKey(id, key), defaultValue); } - public boolean getBoolean(Identifier id, String key) { + public boolean getBoolean(ResourceLocation id, String key) { return this.getBoolean(createKey(id, key)); } - public boolean setBoolean(Identifier id, String key, boolean value) { + public boolean setBoolean(ResourceLocation id, String key, boolean value) { return this.setBoolean(createKey(id, key), value); } } diff --git a/src/main/java/ru/betterend/effects/EndEnchantments.java b/src/main/java/ru/betterend/effects/EndEnchantments.java index 08474c88..dd801a02 100644 --- a/src/main/java/ru/betterend/effects/EndEnchantments.java +++ b/src/main/java/ru/betterend/effects/EndEnchantments.java @@ -1,16 +1,17 @@ package ru.betterend.effects; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; import ru.betterend.effects.enchantment.EndVeilEnchantment; public class EndEnchantments { public final static Enchantment END_VEIL = registerEnchantment("end_veil", new EndVeilEnchantment()); - + public static Enchantment registerEnchantment(String name, Enchantment enchantment) { return Registry.register(Registry.ENCHANTMENT, BetterEnd.makeID(name), enchantment); } - - public static void register() {} + + public static void register() { + } } diff --git a/src/main/java/ru/betterend/effects/EndPotions.java b/src/main/java/ru/betterend/effects/EndPotions.java index 521ff92a..2f2d683b 100644 --- a/src/main/java/ru/betterend/effects/EndPotions.java +++ b/src/main/java/ru/betterend/effects/EndPotions.java @@ -1,11 +1,11 @@ package ru.betterend.effects; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.item.Items; +import net.minecraft.world.entity.effect.StatusEffect; +import net.minecraft.world.entity.effect.StatusEffectInstance; +import net.minecraft.world.item.Items; import net.minecraft.potion.Potion; import net.minecraft.potion.Potions; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; import ru.betterend.mixin.common.BrewingAccessor; import ru.betterend.registry.EndBlocks; @@ -14,15 +14,16 @@ import ru.betterend.registry.EndItems; public class EndPotions { public final static Potion END_VEIL = registerPotion("end_veil", EndStatusEffects.END_VEIL, 3600); public final static Potion LONG_END_VEIL = registerPotion("long_end_veil", EndStatusEffects.END_VEIL, 9600); - + public static Potion registerPotion(String name, StatusEffect effect, int duration) { - return registerPotion(name, new Potion(name, new StatusEffectInstance[]{ new StatusEffectInstance(effect, duration) })); + return registerPotion(name, + new Potion(name, new StatusEffectInstance[] { new StatusEffectInstance(effect, duration) })); } - + public static Potion registerPotion(String name, Potion potion) { return Registry.register(Registry.POTION, BetterEnd.makeID(name), potion); } - + public static void register() { BrewingAccessor.callRegisterPotionRecipe(Potions.AWKWARD, EndItems.ENDER_DUST, END_VEIL); BrewingAccessor.callRegisterPotionRecipe(END_VEIL, Items.REDSTONE, LONG_END_VEIL); diff --git a/src/main/java/ru/betterend/effects/EndStatusEffects.java b/src/main/java/ru/betterend/effects/EndStatusEffects.java index 50e049ff..a485814b 100644 --- a/src/main/java/ru/betterend/effects/EndStatusEffects.java +++ b/src/main/java/ru/betterend/effects/EndStatusEffects.java @@ -1,14 +1,14 @@ package ru.betterend.effects; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.entity.effect.StatusEffect; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; import ru.betterend.effects.status.EndVeilEffect; public class EndStatusEffects { - + public final static StatusEffect END_VEIL = registerEffect("end_veil", new EndVeilEffect()); - + public static StatusEffect registerEffect(String name, E effect) { return Registry.register(Registry.STATUS_EFFECT, BetterEnd.makeID(name), effect); } diff --git a/src/main/java/ru/betterend/effects/enchantment/EndVeilEnchantment.java b/src/main/java/ru/betterend/effects/enchantment/EndVeilEnchantment.java index bdf29bb4..991cdd38 100644 --- a/src/main/java/ru/betterend/effects/enchantment/EndVeilEnchantment.java +++ b/src/main/java/ru/betterend/effects/enchantment/EndVeilEnchantment.java @@ -1,15 +1,15 @@ package ru.betterend.effects.enchantment; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentTarget; -import net.minecraft.entity.EquipmentSlot; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentTarget; +import net.minecraft.world.entity.EquipmentSlot; public class EndVeilEnchantment extends Enchantment { public EndVeilEnchantment() { super(Enchantment.Rarity.VERY_RARE, EnchantmentTarget.ARMOR_HEAD, new EquipmentSlot[] { EquipmentSlot.HEAD }); } - + @Override public boolean isAvailableForRandomSelection() { return false; diff --git a/src/main/java/ru/betterend/effects/status/EndVeilEffect.java b/src/main/java/ru/betterend/effects/status/EndVeilEffect.java index 98e2d8ee..f0cc5079 100644 --- a/src/main/java/ru/betterend/effects/status/EndVeilEffect.java +++ b/src/main/java/ru/betterend/effects/status/EndVeilEffect.java @@ -1,14 +1,14 @@ package ru.betterend.effects.status; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.entity.effect.StatusEffectType; +import net.minecraft.world.entity.effect.StatusEffect; +import net.minecraft.world.entity.effect.StatusEffectType; public class EndVeilEffect extends StatusEffect { public EndVeilEffect() { super(StatusEffectType.BENEFICIAL, 0x0D554A); } - + @Override public boolean canApplyUpdateEffect(int duration, int amplifier) { return false; diff --git a/src/main/java/ru/betterend/entity/CubozoaEntity.java b/src/main/java/ru/betterend/entity/CubozoaEntity.java index 65a20bb9..d13c8919 100644 --- a/src/main/java/ru/betterend/entity/CubozoaEntity.java +++ b/src/main/java/ru/betterend/entity/CubozoaEntity.java @@ -3,52 +3,55 @@ package ru.betterend.entity; import java.util.List; import java.util.Random; -import net.minecraft.entity.EntityData; -import net.minecraft.entity.EntityDimensions; -import net.minecraft.entity.EntityPose; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.ai.control.MoveControl; -import net.minecraft.entity.attribute.DefaultAttributeContainer; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.entity.data.DataTracker; -import net.minecraft.entity.data.TrackedData; -import net.minecraft.entity.data.TrackedDataHandlerRegistry; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.entity.passive.SchoolingFishEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; +import net.minecraft.world.entity.EntityData; +import net.minecraft.world.entity.EntityDimensions; +import net.minecraft.world.entity.EntityPose; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.ItemEntity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.SpawnReason; +import net.minecraft.world.entity.ai.control.MoveControl; +import net.minecraft.world.entity.attribute.DefaultAttributeContainer; +import net.minecraft.world.entity.attribute.EntityAttributes; +import net.minecraft.world.entity.damage.DamageSource; +import net.minecraft.world.entity.data.DataTracker; +import net.minecraft.world.entity.data.TrackedData; +import net.minecraft.world.entity.data.TrackedDataHandlerRegistry; +import net.minecraft.world.entity.effect.StatusEffectInstance; +import net.minecraft.world.entity.effect.StatusEffects; +import net.minecraft.world.entity.passive.SchoolingFishEntity; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.sound.SoundEvent; -import net.minecraft.sound.SoundEvents; -import net.minecraft.tag.FluidTags; -import net.minecraft.util.math.BlockPos; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.tags.FluidTags; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.Box; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import net.minecraft.world.LocalDifficulty; import net.minecraft.world.ServerWorldAccess; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.registry.EndBiomes; import ru.betterend.registry.EndItems; public class CubozoaEntity extends SchoolingFishEntity { public static final int VARIANTS = 2; - private static final TrackedData VARIANT = DataTracker.registerData(CubozoaEntity.class, TrackedDataHandlerRegistry.BYTE); - private static final TrackedData SCALE = DataTracker.registerData(CubozoaEntity.class, TrackedDataHandlerRegistry.BYTE); + private static final TrackedData VARIANT = DataTracker.registerData(CubozoaEntity.class, + TrackedDataHandlerRegistry.BYTE); + private static final TrackedData SCALE = DataTracker.registerData(CubozoaEntity.class, + TrackedDataHandlerRegistry.BYTE); - public CubozoaEntity(EntityType entityType, World world) { + public CubozoaEntity(EntityType entityType, Level world) { super(entityType, world); } @Override - public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, CompoundTag entityTag) { + public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, + EntityData entityData, CompoundTag entityTag) { EntityData data = super.initialize(world, difficulty, spawnReason, entityData, entityTag); if (EndBiomes.getFromBiome(world.getBiome(getBlockPos())) == EndBiomes.SULPHUR_SPRINGS) { this.dataTracker.set(VARIANT, (byte) 1); @@ -83,10 +86,8 @@ public class CubozoaEntity extends SchoolingFishEntity { } public static DefaultAttributeContainer.Builder createMobAttributes() { - return LivingEntity.createLivingAttributes() - .add(EntityAttributes.GENERIC_MAX_HEALTH, 2.0) - .add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0) - .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.5); + return LivingEntity.createLivingAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 2.0) + .add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0).add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.5); } public int getVariant() { @@ -97,7 +98,8 @@ public class CubozoaEntity extends SchoolingFishEntity { return this.dataTracker.get(SCALE) / 32F + 0.75F; } - public static boolean canSpawn(EntityType type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) { + public static boolean canSpawn(EntityType type, ServerWorldAccess world, SpawnReason spawnReason, + BlockPos pos, Random random) { Box box = new Box(pos).expand(16); List list = world.getEntitiesByClass(CubozoaEntity.class, box, (entity) -> { return true; @@ -108,7 +110,7 @@ public class CubozoaEntity extends SchoolingFishEntity { protected float getActiveEyeHeight(EntityPose pose, EntityDimensions dimensions) { return dimensions.height * 0.5F; } - + @Override protected void dropLoot(DamageSource source, boolean causedByPlayer) { int count = random.nextInt(3); @@ -127,12 +129,13 @@ public class CubozoaEntity extends SchoolingFishEntity { protected SoundEvent getFlopSound() { return SoundEvents.ENTITY_SALMON_FLOP; } - + @Override public void onPlayerCollision(PlayerEntity player) { - if (player instanceof ServerPlayerEntity && player.damage(DamageSource.mob(this), 0.5F)) { + if (player instanceof ServerPlayer && player.damage(DamageSource.mob(this), 0.5F)) { if (!this.isSilent()) { - ((ServerPlayerEntity) player).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PUFFERFISH_STING, 0.0F)); + ((ServerPlayer) player).networkHandler + .sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PUFFERFISH_STING, 0.0F)); } if (random.nextBoolean()) { player.addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, 20, 0)); @@ -152,23 +155,23 @@ public class CubozoaEntity extends SchoolingFishEntity { if (this.state == MoveControl.State.MOVE_TO && !this.entity.getNavigation().isIdle()) { float f = (float) (this.speed * this.entity.getAttributeValue(EntityAttributes.GENERIC_MOVEMENT_SPEED)); - this.entity.setMovementSpeed(MathHelper.lerp(0.125F, this.entity.getMovementSpeed(), f)); + this.entity.setMovementSpeed(Mth.lerp(0.125F, this.entity.getMovementSpeed(), f)); double d = this.targetX - this.entity.getX(); double e = this.targetY - this.entity.getY(); double g = this.targetZ - this.entity.getZ(); if (e != 0.0D) { - double h = (double) MathHelper.sqrt(d * d + e * e + g * g); - this.entity.setVelocity(this.entity.getVelocity().add(0.0D, (double) this.entity.getMovementSpeed() * (e / h) * 0.1D, 0.0D)); + double h = (double) Mth.sqrt(d * d + e * e + g * g); + this.entity.setVelocity(this.entity.getVelocity().add(0.0D, + (double) this.entity.getMovementSpeed() * (e / h) * 0.1D, 0.0D)); } if (d != 0.0D || g != 0.0D) { - float i = (float) (MathHelper.atan2(g, d) * 57.2957763671875D) - 90.0F; + float i = (float) (Mth.atan2(g, d) * 57.2957763671875D) - 90.0F; this.entity.yaw = this.changeAngle(this.entity.yaw, i, 90.0F); this.entity.bodyYaw = this.entity.yaw; } - } - else { + } else { this.entity.setMovementSpeed(0.0F); } } diff --git a/src/main/java/ru/betterend/entity/DragonflyEntity.java b/src/main/java/ru/betterend/entity/DragonflyEntity.java index 2cafb340..9394834b 100644 --- a/src/main/java/ru/betterend/entity/DragonflyEntity.java +++ b/src/main/java/ru/betterend/entity/DragonflyEntity.java @@ -3,34 +3,34 @@ package ru.betterend.entity; import java.util.EnumSet; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.Flutterer; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.ai.TargetFinder; -import net.minecraft.entity.ai.control.FlightMoveControl; -import net.minecraft.entity.ai.control.LookControl; -import net.minecraft.entity.ai.goal.AnimalMateGoal; -import net.minecraft.entity.ai.goal.FollowParentGoal; -import net.minecraft.entity.ai.goal.Goal; -import net.minecraft.entity.ai.goal.SwimGoal; -import net.minecraft.entity.ai.pathing.BirdNavigation; -import net.minecraft.entity.ai.pathing.EntityNavigation; -import net.minecraft.entity.ai.pathing.Path; -import net.minecraft.entity.ai.pathing.PathNodeType; -import net.minecraft.entity.attribute.DefaultAttributeContainer; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.mob.MobEntity; -import net.minecraft.entity.passive.AnimalEntity; -import net.minecraft.entity.passive.PassiveEntity; -import net.minecraft.server.world.ServerWorld; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Flutterer; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.SpawnReason; +import net.minecraft.world.entity.ai.TargetFinder; +import net.minecraft.world.entity.ai.control.FlightMoveControl; +import net.minecraft.world.entity.ai.control.LookControl; +import net.minecraft.world.entity.ai.goal.AnimalMateGoal; +import net.minecraft.world.entity.ai.goal.FollowParentGoal; +import net.minecraft.world.entity.ai.goal.Goal; +import net.minecraft.world.entity.ai.goal.SwimGoal; +import net.minecraft.world.entity.ai.pathing.BirdNavigation; +import net.minecraft.world.entity.ai.pathing.EntityNavigation; +import net.minecraft.world.entity.ai.pathing.Path; +import net.minecraft.world.entity.ai.pathing.PathNodeType; +import net.minecraft.world.entity.attribute.DefaultAttributeContainer; +import net.minecraft.world.entity.attribute.EntityAttributes; +import net.minecraft.world.entity.mob.MobEntity; +import net.minecraft.world.entity.passive.AnimalEntity; +import net.minecraft.world.entity.passive.PassiveEntity; +import net.minecraft.server.level.ServerLevel; import net.minecraft.sound.SoundEvent; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.Heightmap.Type; import net.minecraft.world.ServerWorldAccess; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import net.minecraft.world.WorldView; import ru.betterend.registry.EndEntities; import ru.betterend.registry.EndSounds; @@ -38,7 +38,7 @@ import ru.betterend.util.BlocksHelper; import ru.betterend.util.MHelper; public class DragonflyEntity extends AnimalEntity implements Flutterer { - public DragonflyEntity(EntityType entityType, World world) { + public DragonflyEntity(EntityType entityType, Level world) { super(entityType, world); this.moveControl = new FlightMoveControl(this, 20, true); this.lookControl = new DragonflyLookControl(this); @@ -48,15 +48,13 @@ public class DragonflyEntity extends AnimalEntity implements Flutterer { } public static DefaultAttributeContainer.Builder createMobAttributes() { - return LivingEntity.createLivingAttributes() - .add(EntityAttributes.GENERIC_MAX_HEALTH, 8.0D) - .add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0D) - .add(EntityAttributes.GENERIC_FLYING_SPEED, 1.0D) + return LivingEntity.createLivingAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 8.0D) + .add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0D).add(EntityAttributes.GENERIC_FLYING_SPEED, 1.0D) .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.1D); } @Override - protected EntityNavigation createNavigation(World world) { + protected EntityNavigation createNavigation(Level world) { BirdNavigation birdNavigation = new BirdNavigation(this, world) { public boolean isValidPosition(BlockPos pos) { BlockState state = this.world.getBlockState(pos); @@ -153,8 +151,8 @@ public class DragonflyEntity extends AnimalEntity implements Flutterer { if (path != null) { DragonflyEntity.this.navigation.startMovingAlong(path, 1.0D); } + } catch (Exception e) { } - catch (Exception e) {} } super.start(); } @@ -188,11 +186,12 @@ public class DragonflyEntity extends AnimalEntity implements Flutterer { } @Override - public PassiveEntity createChild(ServerWorld world, PassiveEntity entity) { + public PassiveEntity createChild(ServerLevel world, PassiveEntity entity) { return EndEntities.DRAGONFLY.create(world); } - - public static boolean canSpawn(EntityType type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) { + + public static boolean canSpawn(EntityType type, ServerWorldAccess world, SpawnReason spawnReason, + BlockPos pos, Random random) { int y = world.getChunk(pos).sampleHeightmap(Type.WORLD_SURFACE, pos.getX() & 15, pos.getY() & 15); return y > 0 && pos.getY() >= y; } diff --git a/src/main/java/ru/betterend/entity/EndFishEntity.java b/src/main/java/ru/betterend/entity/EndFishEntity.java index 4b633a4d..5292ac81 100644 --- a/src/main/java/ru/betterend/entity/EndFishEntity.java +++ b/src/main/java/ru/betterend/entity/EndFishEntity.java @@ -3,29 +3,29 @@ package ru.betterend.entity; import java.util.List; import java.util.Random; -import net.minecraft.block.Blocks; -import net.minecraft.entity.EntityData; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.attribute.DefaultAttributeContainer; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.entity.data.DataTracker; -import net.minecraft.entity.data.TrackedData; -import net.minecraft.entity.data.TrackedDataHandlerRegistry; -import net.minecraft.entity.passive.SchoolingFishEntity; -import net.minecraft.item.ItemStack; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.EntityData; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.ItemEntity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.SpawnReason; +import net.minecraft.world.entity.attribute.DefaultAttributeContainer; +import net.minecraft.world.entity.attribute.EntityAttributes; +import net.minecraft.world.entity.damage.DamageSource; +import net.minecraft.world.entity.data.DataTracker; +import net.minecraft.world.entity.data.TrackedData; +import net.minecraft.world.entity.data.TrackedDataHandlerRegistry; +import net.minecraft.world.entity.passive.SchoolingFishEntity; +import net.minecraft.world.item.ItemStack; import net.minecraft.nbt.CompoundTag; -import net.minecraft.particle.ParticleTypes; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.sound.SoundEvent; -import net.minecraft.sound.SoundEvents; -import net.minecraft.util.math.BlockPos; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.world.LocalDifficulty; import net.minecraft.world.ServerWorldAccess; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.registry.EndBiomes; import ru.betterend.registry.EndItems; @@ -33,15 +33,18 @@ public class EndFishEntity extends SchoolingFishEntity { public static final int VARIANTS_NORMAL = 5; public static final int VARIANTS_SULPHUR = 3; public static final int VARIANTS = VARIANTS_NORMAL + VARIANTS_SULPHUR; - private static final TrackedData VARIANT = DataTracker.registerData(EndFishEntity.class, TrackedDataHandlerRegistry.BYTE); - private static final TrackedData SCALE = DataTracker.registerData(EndFishEntity.class, TrackedDataHandlerRegistry.BYTE); - - public EndFishEntity(EntityType entityType, World world) { + private static final TrackedData VARIANT = DataTracker.registerData(EndFishEntity.class, + TrackedDataHandlerRegistry.BYTE); + private static final TrackedData SCALE = DataTracker.registerData(EndFishEntity.class, + TrackedDataHandlerRegistry.BYTE); + + public EndFishEntity(EntityType entityType, Level world) { super(entityType, world); } - + @Override - public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, CompoundTag entityTag) { + public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, + EntityData entityData, CompoundTag entityTag) { EntityData data = super.initialize(world, difficulty, spawnReason, entityData, entityTag); if (EndBiomes.getFromBiome(world.getBiome(getBlockPos())) == EndBiomes.SULPHUR_SPRINGS) { this.dataTracker.set(VARIANT, (byte) (random.nextInt(VARIANTS_SULPHUR) + VARIANTS_NORMAL)); @@ -49,14 +52,14 @@ public class EndFishEntity extends SchoolingFishEntity { this.calculateDimensions(); return data; } - + @Override protected void initDataTracker() { super.initDataTracker(); this.dataTracker.startTracking(VARIANT, (byte) this.getRandom().nextInt(VARIANTS_NORMAL)); this.dataTracker.startTracking(SCALE, (byte) this.getRandom().nextInt(16)); } - + @Override public void writeCustomDataToTag(CompoundTag tag) { super.writeCustomDataToTag(tag); @@ -99,39 +102,40 @@ public class EndFishEntity extends SchoolingFishEntity { protected SoundEvent getHurtSound(DamageSource source) { return SoundEvents.ENTITY_SALMON_HURT; } - + @Override public void tick() { super.tick(); - if (random.nextInt(8) == 0 && getBlockState().isOf(Blocks.WATER)) { + if (random.nextInt(8) == 0 && getBlockState().is(Blocks.WATER)) { double x = getX() + random.nextGaussian() * 0.2; double y = getY() + random.nextGaussian() * 0.2; double z = getZ() + random.nextGaussian() * 0.2; world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0, 0, 0); } } - + public static DefaultAttributeContainer.Builder createMobAttributes() { - return LivingEntity.createLivingAttributes() - .add(EntityAttributes.GENERIC_MAX_HEALTH, 2.0) - .add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0) - .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.75); + return LivingEntity.createLivingAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 2.0) + .add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0).add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.75); } - + public int getVariant() { return (int) this.dataTracker.get(VARIANT); } - + public float getScale() { return this.dataTracker.get(SCALE) / 32F + 0.75F; } - - public static boolean canSpawn(EntityType type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) { + + public static boolean canSpawn(EntityType type, ServerWorldAccess world, SpawnReason spawnReason, + BlockPos pos, Random random) { Box box = new Box(pos).expand(16); - List list = world.getEntitiesByClass(EndFishEntity.class, box, (entity) -> { return true; }); + List list = world.getEntitiesByClass(EndFishEntity.class, box, (entity) -> { + return true; + }); return list.size() < 9; } - + @Override protected void dropLoot(DamageSource source, boolean causedByPlayer) { ItemEntity drop = new ItemEntity(world, getX(), getY(), getZ(), new ItemStack(EndItems.END_FISH_RAW)); diff --git a/src/main/java/ru/betterend/entity/EndSlimeEntity.java b/src/main/java/ru/betterend/entity/EndSlimeEntity.java index b9b6118c..03264629 100644 --- a/src/main/java/ru/betterend/entity/EndSlimeEntity.java +++ b/src/main/java/ru/betterend/entity/EndSlimeEntity.java @@ -4,39 +4,39 @@ import java.util.EnumSet; import java.util.List; import java.util.Random; -import net.minecraft.block.Blocks; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.EntityData; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.ai.control.MoveControl; -import net.minecraft.entity.ai.goal.FollowTargetGoal; -import net.minecraft.entity.ai.goal.Goal; -import net.minecraft.entity.attribute.DefaultAttributeContainer; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.entity.data.DataTracker; -import net.minecraft.entity.data.TrackedData; -import net.minecraft.entity.data.TrackedDataHandlerRegistry; -import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.entity.mob.SlimeEntity; -import net.minecraft.entity.passive.IronGolemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.entity.EntityData; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.ItemEntity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.SpawnReason; +import net.minecraft.world.entity.ai.control.MoveControl; +import net.minecraft.world.entity.ai.goal.FollowTargetGoal; +import net.minecraft.world.entity.ai.goal.Goal; +import net.minecraft.world.entity.attribute.DefaultAttributeContainer; +import net.minecraft.world.entity.attribute.EntityAttributes; +import net.minecraft.world.entity.damage.DamageSource; +import net.minecraft.world.entity.data.DataTracker; +import net.minecraft.world.entity.data.TrackedData; +import net.minecraft.world.entity.data.TrackedDataHandlerRegistry; +import net.minecraft.world.entity.effect.StatusEffects; +import net.minecraft.world.entity.mob.SlimeEntity; +import net.minecraft.world.entity.passive.IronGolemEntity; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraft.nbt.CompoundTag; -import net.minecraft.particle.ParticleEffect; -import net.minecraft.particle.ParticleTypes; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.text.Text; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.util.math.Box; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import net.minecraft.world.LocalDifficulty; import net.minecraft.world.ServerWorldAccess; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import net.minecraft.world.biome.Biome; import ru.betterend.interfaces.ISlime; import ru.betterend.registry.EndBiomes; @@ -45,44 +45,43 @@ import ru.betterend.util.MHelper; import ru.betterend.world.biome.EndBiome; public class EndSlimeEntity extends SlimeEntity { - private static final TrackedData VARIANT = DataTracker.registerData(EndSlimeEntity.class, TrackedDataHandlerRegistry.BYTE); - private static final Mutable POS = new Mutable(); - - public EndSlimeEntity(EntityType entityType, World world) { + private static final TrackedData VARIANT = DataTracker.registerData(EndSlimeEntity.class, + TrackedDataHandlerRegistry.BYTE); + private static final MutableBlockPos POS = new MutableBlockPos(); + + public EndSlimeEntity(EntityType entityType, Level world) { super(entityType, world); this.moveControl = new EndSlimeMoveControl(this); } - + protected void initGoals() { this.goalSelector.add(1, new SwimmingGoal()); this.goalSelector.add(2, new FaceTowardTargetGoal()); this.goalSelector.add(3, new RandomLookGoal()); this.goalSelector.add(5, new MoveGoal()); - this.targetSelector.add(1, new FollowTargetGoal(this, PlayerEntity.class, 10, true, false, (livingEntity) -> { - return Math.abs(livingEntity.getY() - this.getY()) <= 4.0D; - })); + this.targetSelector.add(1, + new FollowTargetGoal(this, PlayerEntity.class, 10, true, false, (livingEntity) -> { + return Math.abs(livingEntity.getY() - this.getY()) <= 4.0D; + })); this.targetSelector.add(3, new FollowTargetGoal(this, IronGolemEntity.class, true)); } - + public static DefaultAttributeContainer.Builder createMobAttributes() { - return LivingEntity.createLivingAttributes() - .add(EntityAttributes.GENERIC_MAX_HEALTH, 1.0D) - .add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 1.0D) - .add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0D) + return LivingEntity.createLivingAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 1.0D) + .add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 1.0D).add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0D) .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.15D); } - + @Override - public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, CompoundTag entityTag) { + public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, + EntityData entityData, CompoundTag entityTag) { EntityData data = super.initialize(world, difficulty, spawnReason, entityData, entityTag); EndBiome biome = EndBiomes.getFromBiome(world.getBiome(getBlockPos())); if (biome == EndBiomes.FOGGY_MUSHROOMLAND) { this.setMossy(); - } - else if (biome == EndBiomes.MEGALAKE || biome == EndBiomes.MEGALAKE_GROVE) { + } else if (biome == EndBiomes.MEGALAKE || biome == EndBiomes.MEGALAKE_GROVE) { this.setLake(); - } - else if (biome == EndBiomes.AMBER_LAND) { + } else if (biome == EndBiomes.AMBER_LAND) { this.setAmber(true); } this.calculateDimensions(); @@ -94,7 +93,7 @@ public class EndSlimeEntity extends SlimeEntity { super.initDataTracker(); this.dataTracker.startTracking(VARIANT, (byte) 0); } - + @Override public void writeCustomDataToTag(CompoundTag tag) { super.writeCustomDataToTag(tag); @@ -110,21 +109,21 @@ public class EndSlimeEntity extends SlimeEntity { } @Override - protected ParticleEffect getParticles() { + protected ParticleOptions getParticles() { return ParticleTypes.PORTAL; } - + @Override public void remove() { int i = this.getSize(); - if (!this.world.isClient && i > 1 && this.isDead()) { + if (!this.world.isClientSide && i > 1 && this.isDead()) { Text text = this.getCustomName(); boolean bl = this.isAiDisabled(); float f = (float) i / 4.0F; int j = i / 2; int k = 2 + this.random.nextInt(3); int type = this.getSlimeType(); - + for (int l = 0; l < k; ++l) { float g = ((float) (l % 2) - 0.5F) * f; float h = ((float) (l / 2) - 0.5F) * f; @@ -139,13 +138,14 @@ public class EndSlimeEntity extends SlimeEntity { slimeEntity.setInvulnerable(this.isInvulnerable()); ((ISlime) slimeEntity).beSetSlimeSize(j, true); slimeEntity.calculateDimensions(); - slimeEntity.refreshPositionAndAngles(this.getX() + (double) g, this.getY() + 0.5D, this.getZ() + (double) h, this.random.nextFloat() * 360.0F, 0.0F); + slimeEntity.refreshPositionAndAngles(this.getX() + (double) g, this.getY() + 0.5D, + this.getZ() + (double) h, this.random.nextFloat() * 360.0F, 0.0F); this.world.spawnEntity(slimeEntity); } } this.removed = true; } - + @Override protected void dropLoot(DamageSource source, boolean causedByPlayer) { int maxCount = this.getSize(); @@ -161,15 +161,15 @@ public class EndSlimeEntity extends SlimeEntity { ItemEntity drop = new ItemEntity(world, getX(), getY(), getZ(), new ItemStack(Items.SLIME_BALL, count)); this.world.spawnEntity(drop); } - + public int getSlimeType() { return this.dataTracker.get(VARIANT).intValue(); } - + public void setSlimeType(int value) { this.dataTracker.set(VARIANT, (byte) value); } - + protected void setMossy() { setSlimeType(1); } @@ -177,7 +177,7 @@ public class EndSlimeEntity extends SlimeEntity { public boolean isMossy() { return getSlimeType() == 1; } - + protected void setLake() { setSlimeType(2); } @@ -185,7 +185,7 @@ public class EndSlimeEntity extends SlimeEntity { public boolean isLake() { return getSlimeType() == 2; } - + protected void setAmber(boolean mossy) { this.dataTracker.set(VARIANT, (byte) 3); } @@ -193,26 +193,30 @@ public class EndSlimeEntity extends SlimeEntity { public boolean isAmber() { return this.dataTracker.get(VARIANT) == 3; } - + public boolean isChorus() { return this.dataTracker.get(VARIANT) == 0; } - - public static boolean canSpawn(EntityType type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) { - return random.nextInt(16) == 0 || isPermanentBiome(world, pos) || (notManyEntities(world, pos, 32, 3) && isWaterNear(world, pos, 32, 8)); + + public static boolean canSpawn(EntityType type, ServerWorldAccess world, SpawnReason spawnReason, + BlockPos pos, Random random) { + return random.nextInt(16) == 0 || isPermanentBiome(world, pos) + || (notManyEntities(world, pos, 32, 3) && isWaterNear(world, pos, 32, 8)); } - + private static boolean isPermanentBiome(ServerWorldAccess world, BlockPos pos) { Biome biome = world.getBiome(pos); return EndBiomes.getFromBiome(biome) == EndBiomes.CHORUS_FOREST; } - + private static boolean notManyEntities(ServerWorldAccess world, BlockPos pos, int radius, int maxCount) { Box box = new Box(pos).expand(radius); - List list = world.getEntitiesByClass(EndSlimeEntity.class, box, (entity) -> { return true; }); + List list = world.getEntitiesByClass(EndSlimeEntity.class, box, (entity) -> { + return true; + }); return list.size() <= maxCount; } - + private static boolean isWaterNear(ServerWorldAccess world, BlockPos pos, int radius, int radius2) { for (int x = pos.getX() - radius; x <= pos.getX() + radius; x++) { POS.setX(x); @@ -228,7 +232,7 @@ public class EndSlimeEntity extends SlimeEntity { } return false; } - + class MoveGoal extends Goal { public MoveGoal() { this.setControls(EnumSet.of(Goal.Control.JUMP, Goal.Control.MOVE)); @@ -238,17 +242,17 @@ public class EndSlimeEntity extends SlimeEntity { if (EndSlimeEntity.this.hasVehicle()) { return false; } - + float yaw = EndSlimeEntity.this.getHeadYaw(); float speed = EndSlimeEntity.this.getMovementSpeed(); if (speed > 0.1) { - float dx = MathHelper.sin(-yaw * 0.017453292F); - float dz = MathHelper.cos(-yaw * 0.017453292F); + float dx = Mth.sin(-yaw * 0.017453292F); + float dz = Mth.cos(-yaw * 0.017453292F); BlockPos pos = EndSlimeEntity.this.getBlockPos().add(dx * speed * 4, 0, dz * speed * 4); int down = BlocksHelper.downRay(EndSlimeEntity.this.world, pos, 16); return down < 5; } - + return true; } @@ -264,8 +268,7 @@ public class EndSlimeEntity extends SlimeEntity { } public boolean canStart() { - return (EndSlimeEntity.this.isTouchingWater() - || EndSlimeEntity.this.isInLava()) + return (EndSlimeEntity.this.isTouchingWater() || EndSlimeEntity.this.isInLava()) && EndSlimeEntity.this.getMoveControl() instanceof EndSlimeMoveControl; } @@ -288,8 +291,7 @@ public class EndSlimeEntity extends SlimeEntity { public boolean canStart() { return EndSlimeEntity.this.getTarget() == null - && (EndSlimeEntity.this.onGround - || EndSlimeEntity.this.isTouchingWater() + && (EndSlimeEntity.this.onGround || EndSlimeEntity.this.isTouchingWater() || EndSlimeEntity.this.isInLava() || EndSlimeEntity.this.hasStatusEffect(StatusEffects.LEVITATION)) && EndSlimeEntity.this.getMoveControl() instanceof EndSlimeMoveControl; @@ -316,12 +318,12 @@ public class EndSlimeEntity extends SlimeEntity { LivingEntity livingEntity = EndSlimeEntity.this.getTarget(); if (livingEntity == null) { return false; - } - else if (!livingEntity.isAlive()) { + } else if (!livingEntity.isAlive()) { return false; - } - else { - return livingEntity instanceof PlayerEntity && ((PlayerEntity) livingEntity).abilities.invulnerable ? false : EndSlimeEntity.this.getMoveControl() instanceof EndSlimeMoveControl; + } else { + return livingEntity instanceof PlayerEntity && ((PlayerEntity) livingEntity).abilities.invulnerable + ? false + : EndSlimeEntity.this.getMoveControl() instanceof EndSlimeMoveControl; } } @@ -334,21 +336,19 @@ public class EndSlimeEntity extends SlimeEntity { LivingEntity livingEntity = EndSlimeEntity.this.getTarget(); if (livingEntity == null) { return false; - } - else if (!livingEntity.isAlive()) { + } else if (!livingEntity.isAlive()) { return false; - } - else if (livingEntity instanceof PlayerEntity && ((PlayerEntity) livingEntity).abilities.invulnerable) { + } else if (livingEntity instanceof PlayerEntity && ((PlayerEntity) livingEntity).abilities.invulnerable) { return false; - } - else { + } else { return --this.ticksLeft > 0; } } public void tick() { EndSlimeEntity.this.lookAtEntity(EndSlimeEntity.this.getTarget(), 10.0F, 10.0F); - ((EndSlimeMoveControl) EndSlimeEntity.this.getMoveControl()).look(EndSlimeEntity.this.yaw, EndSlimeEntity.this.canAttack()); + ((EndSlimeMoveControl) EndSlimeEntity.this.getMoveControl()).look(EndSlimeEntity.this.yaw, + EndSlimeEntity.this.canAttack()); } } @@ -378,11 +378,11 @@ public class EndSlimeEntity extends SlimeEntity { this.entity.bodyYaw = this.entity.yaw; if (this.state != MoveControl.State.MOVE_TO) { this.entity.setForwardSpeed(0.0F); - } - else { + } else { this.state = MoveControl.State.WAIT; if (this.entity.isOnGround()) { - this.entity.setMovementSpeed((float) (this.speed * this.entity.getAttributeValue(EntityAttributes.GENERIC_MOVEMENT_SPEED))); + this.entity.setMovementSpeed((float) (this.speed + * this.entity.getAttributeValue(EntityAttributes.GENERIC_MOVEMENT_SPEED))); if (this.ticksUntilJump-- <= 0) { this.ticksUntilJump = EndSlimeEntity.this.getTicksUntilNextJump(); if (this.jumpOften) { @@ -391,17 +391,17 @@ public class EndSlimeEntity extends SlimeEntity { EndSlimeEntity.this.getJumpControl().setActive(); if (EndSlimeEntity.this.makesJumpSound()) { - EndSlimeEntity.this.playSound(EndSlimeEntity.this.getJumpSound(), EndSlimeEntity.this.getSoundVolume(), getJumpSoundPitch()); + EndSlimeEntity.this.playSound(EndSlimeEntity.this.getJumpSound(), + EndSlimeEntity.this.getSoundVolume(), getJumpSoundPitch()); } - } - else { + } else { EndSlimeEntity.this.sidewaysSpeed = 0.0F; EndSlimeEntity.this.forwardSpeed = 0.0F; this.entity.setMovementSpeed(0.0F); } - } - else { - this.entity.setMovementSpeed((float) (this.speed * this.entity.getAttributeValue(EntityAttributes.GENERIC_MOVEMENT_SPEED))); + } else { + this.entity.setMovementSpeed((float) (this.speed + * this.entity.getAttributeValue(EntityAttributes.GENERIC_MOVEMENT_SPEED))); } } @@ -409,7 +409,8 @@ public class EndSlimeEntity extends SlimeEntity { private float getJumpSoundPitch() { float f = EndSlimeEntity.this.isSmall() ? 1.4F : 0.8F; - return ((EndSlimeEntity.this.random.nextFloat() - EndSlimeEntity.this.random.nextFloat()) * 0.2F + 1.0F) * f; + return ((EndSlimeEntity.this.random.nextFloat() - EndSlimeEntity.this.random.nextFloat()) * 0.2F + 1.0F) + * f; } } } diff --git a/src/main/java/ru/betterend/entity/ShadowWalkerEntity.java b/src/main/java/ru/betterend/entity/ShadowWalkerEntity.java index d4108e07..20b2c335 100644 --- a/src/main/java/ru/betterend/entity/ShadowWalkerEntity.java +++ b/src/main/java/ru/betterend/entity/ShadowWalkerEntity.java @@ -3,37 +3,37 @@ package ru.betterend.entity; import java.util.List; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.ai.goal.FollowTargetGoal; -import net.minecraft.entity.ai.goal.LookAroundGoal; -import net.minecraft.entity.ai.goal.LookAtEntityGoal; -import net.minecraft.entity.ai.goal.MeleeAttackGoal; -import net.minecraft.entity.ai.goal.WanderAroundFarGoal; -import net.minecraft.entity.attribute.DefaultAttributeContainer; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.entity.mob.HostileEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.particle.ParticleTypes; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.SpawnReason; +import net.minecraft.world.entity.ai.goal.FollowTargetGoal; +import net.minecraft.world.entity.ai.goal.LookAroundGoal; +import net.minecraft.world.entity.ai.goal.LookAtEntityGoal; +import net.minecraft.world.entity.ai.goal.MeleeAttackGoal; +import net.minecraft.world.entity.ai.goal.WanderAroundFarGoal; +import net.minecraft.world.entity.attribute.DefaultAttributeContainer; +import net.minecraft.world.entity.attribute.EntityAttributes; +import net.minecraft.world.entity.damage.DamageSource; +import net.minecraft.world.entity.effect.StatusEffectInstance; +import net.minecraft.world.entity.effect.StatusEffects; +import net.minecraft.world.entity.mob.HostileEntity; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.sound.SoundEvent; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.world.ServerWorldAccess; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.registry.EndSounds; import ru.betterend.util.MHelper; public class ShadowWalkerEntity extends HostileEntity { - public ShadowWalkerEntity(EntityType entityType, World world) { + public ShadowWalkerEntity(EntityType entityType, Level world) { super(entityType, world); } - + @Override protected void initGoals() { this.goalSelector.add(2, new AttackGoal(this, 1.0D, false)); @@ -44,34 +44,22 @@ public class ShadowWalkerEntity extends HostileEntity { } public static DefaultAttributeContainer.Builder createMobAttributes() { - return HostileEntity.createHostileAttributes() - .add(EntityAttributes.GENERIC_FOLLOW_RANGE, 35.0) - .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.15) - .add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 4.5) - .add(EntityAttributes.GENERIC_ARMOR, 2.0) - .add(EntityAttributes.ZOMBIE_SPAWN_REINFORCEMENTS); + return HostileEntity.createHostileAttributes().add(EntityAttributes.GENERIC_FOLLOW_RANGE, 35.0) + .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.15).add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 4.5) + .add(EntityAttributes.GENERIC_ARMOR, 2.0).add(EntityAttributes.ZOMBIE_SPAWN_REINFORCEMENTS); } - + @Override public void tick() { super.tick(); - world.addParticle(ParticleTypes.ASH, - getX() + random.nextGaussian() * 0.2, - getY() + random.nextGaussian() * 0.5 + 1, - getZ() + random.nextGaussian() * 0.2, - 0, 0, 0); - world.addParticle(ParticleTypes.SMOKE, - getX() + random.nextGaussian() * 0.2, - getY() + random.nextGaussian() * 0.5 + 1, - getZ() + random.nextGaussian() * 0.2, - 0, 0, 0); - world.addParticle(ParticleTypes.ENTITY_EFFECT, - getX() + random.nextGaussian() * 0.2, - getY() + random.nextGaussian() * 0.5 + 1, - getZ() + random.nextGaussian() * 0.2, - 0, 0, 0); + world.addParticle(ParticleTypes.ASH, getX() + random.nextGaussian() * 0.2, + getY() + random.nextGaussian() * 0.5 + 1, getZ() + random.nextGaussian() * 0.2, 0, 0, 0); + world.addParticle(ParticleTypes.SMOKE, getX() + random.nextGaussian() * 0.2, + getY() + random.nextGaussian() * 0.5 + 1, getZ() + random.nextGaussian() * 0.2, 0, 0, 0); + world.addParticle(ParticleTypes.ENTITY_EFFECT, getX() + random.nextGaussian() * 0.2, + getY() + random.nextGaussian() * 0.5 + 1, getZ() + random.nextGaussian() * 0.2, 0, 0, 0); } - + @Override protected SoundEvent getAmbientSound() { return EndSounds.ENTITY_SHADOW_WALKER; @@ -88,18 +76,19 @@ public class ShadowWalkerEntity extends HostileEntity { } @Override - protected void playStepSound(BlockPos pos, BlockState state) {} - + protected void playStepSound(BlockPos pos, BlockState state) { + } + @Override protected float getSoundVolume() { return MHelper.randRange(0.25F, 0.5F, random); } - + @Override protected float getSoundPitch() { return MHelper.randRange(0.75F, 1.25F, random); } - + @Override public boolean tryAttack(Entity target) { boolean attack = super.tryAttack(target); @@ -111,24 +100,27 @@ public class ShadowWalkerEntity extends HostileEntity { } return attack; } - - public static boolean canSpawn(EntityType type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) { + + public static boolean canSpawn(EntityType type, ServerWorldAccess world, + SpawnReason spawnReason, BlockPos pos, Random random) { if (HostileEntity.canSpawnInDark(type, world, spawnReason, pos, random)) { Box box = new Box(pos).expand(16); - List entities = world.getEntitiesByClass(ShadowWalkerEntity.class, box, (entity) -> { return true; }); + List entities = world.getEntitiesByClass(ShadowWalkerEntity.class, box, (entity) -> { + return true; + }); return entities.size() < 6; } return false; } - + private final class AttackGoal extends MeleeAttackGoal { private final ShadowWalkerEntity walker; private int ticks; public AttackGoal(ShadowWalkerEntity walker, double speed, boolean pauseWhenMobIdle) { - super(walker, speed, pauseWhenMobIdle); - this.walker = walker; - } + super(walker, speed, pauseWhenMobIdle); + this.walker = walker; + } public void start() { super.start(); @@ -145,8 +137,7 @@ public class ShadowWalkerEntity extends HostileEntity { ++this.ticks; if (this.ticks >= 5 && this.method_28348() < this.method_28349() / 2) { this.walker.setAttacking(true); - } - else { + } else { this.walker.setAttacking(false); } } diff --git a/src/main/java/ru/betterend/entity/SilkMothEntity.java b/src/main/java/ru/betterend/entity/SilkMothEntity.java index 8329821e..e5494757 100644 --- a/src/main/java/ru/betterend/entity/SilkMothEntity.java +++ b/src/main/java/ru/betterend/entity/SilkMothEntity.java @@ -6,45 +6,45 @@ import java.util.Random; import org.jetbrains.annotations.Nullable; -import net.minecraft.block.BlockState; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.Flutterer; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.ai.TargetFinder; -import net.minecraft.entity.ai.control.FlightMoveControl; -import net.minecraft.entity.ai.control.LookControl; -import net.minecraft.entity.ai.goal.AnimalMateGoal; -import net.minecraft.entity.ai.goal.FollowParentGoal; -import net.minecraft.entity.ai.goal.Goal; -import net.minecraft.entity.ai.goal.SwimGoal; -import net.minecraft.entity.ai.pathing.BirdNavigation; -import net.minecraft.entity.ai.pathing.EntityNavigation; -import net.minecraft.entity.ai.pathing.PathNodeType; -import net.minecraft.entity.attribute.DefaultAttributeContainer; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.entity.mob.MobEntity; -import net.minecraft.entity.passive.AnimalEntity; -import net.minecraft.entity.passive.PassiveEntity; -import net.minecraft.item.ItemStack; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Flutterer; +import net.minecraft.world.entity.ItemEntity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.SpawnReason; +import net.minecraft.world.entity.ai.TargetFinder; +import net.minecraft.world.entity.ai.control.FlightMoveControl; +import net.minecraft.world.entity.ai.control.LookControl; +import net.minecraft.world.entity.ai.goal.AnimalMateGoal; +import net.minecraft.world.entity.ai.goal.FollowParentGoal; +import net.minecraft.world.entity.ai.goal.Goal; +import net.minecraft.world.entity.ai.goal.SwimGoal; +import net.minecraft.world.entity.ai.pathing.BirdNavigation; +import net.minecraft.world.entity.ai.pathing.EntityNavigation; +import net.minecraft.world.entity.ai.pathing.PathNodeType; +import net.minecraft.world.entity.attribute.DefaultAttributeContainer; +import net.minecraft.world.entity.attribute.EntityAttributes; +import net.minecraft.world.entity.damage.DamageSource; +import net.minecraft.world.entity.mob.MobEntity; +import net.minecraft.world.entity.passive.AnimalEntity; +import net.minecraft.world.entity.passive.PassiveEntity; +import net.minecraft.world.item.ItemStack; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtHelper; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; import net.minecraft.state.property.Properties; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.Heightmap.Type; import net.minecraft.world.ServerWorldAccess; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.BetterEnd; import ru.betterend.blocks.BlockProperties; import ru.betterend.registry.EndBlocks; @@ -56,9 +56,9 @@ import ru.betterend.util.MHelper; public class SilkMothEntity extends AnimalEntity implements Flutterer { private BlockPos hivePos; private BlockPos entrance; - private World hiveWorld; - - public SilkMothEntity(EntityType entityType, World world) { + private Level hiveWorld; + + public SilkMothEntity(EntityType entityType, Level world) { super(entityType, world); this.moveControl = new FlightMoveControl(this, 20, true); this.lookControl = new MothLookControl(this); @@ -66,38 +66,35 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer { this.setPathfindingPenalty(PathNodeType.DANGER_FIRE, -1.0F); this.experiencePoints = 1; } - + public static DefaultAttributeContainer.Builder createMobAttributes() { - return LivingEntity.createLivingAttributes() - .add(EntityAttributes.GENERIC_MAX_HEALTH, 2.0D) - .add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0D) - .add(EntityAttributes.GENERIC_FLYING_SPEED, 0.4D) + return LivingEntity.createLivingAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 2.0D) + .add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0D).add(EntityAttributes.GENERIC_FLYING_SPEED, 0.4D) .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.1D); } - - public void setHive(World world, BlockPos hive) { + + public void setHive(Level world, BlockPos hive) { this.hivePos = hive; this.hiveWorld = world; } - + @Override public void writeCustomDataToTag(CompoundTag tag) { if (hivePos != null) { tag.put("HivePos", NbtHelper.fromBlockPos(hivePos)); - tag.putString("HiveWorld", hiveWorld.getRegistryKey().getValue().toString()); + tag.putString("HiveWorld", hiveWorld.dimension().location().toString()); } } - + @Override public void readCustomDataFromTag(CompoundTag tag) { if (tag.contains("HivePos")) { hivePos = NbtHelper.toBlockPos(tag.getCompound("HivePos")); - Identifier worldID = new Identifier(tag.getString("HiveWorld")); + ResourceLocation worldID = new ResourceLocation(tag.getString("HiveWorld")); try { - hiveWorld = world.getServer().getWorld(RegistryKey.of(Registry.DIMENSION, worldID)); - } - catch (Exception e) { - BetterEnd.LOGGER.warning("Silk Moth Hive World {} is missing!", worldID); + hiveWorld = world.getServer().getLevel(RegistryKey.of(Registry.DIMENSION, worldID)); + } catch (Exception e) { + BetterEnd.LOGGER.warning("Silk Moth Hive Level {} is missing!", worldID); hivePos = null; } } @@ -111,9 +108,9 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer { this.goalSelector.add(8, new WanderAroundGoal()); this.goalSelector.add(9, new SwimGoal(this)); } - + @Override - protected EntityNavigation createNavigation(World world) { + protected EntityNavigation createNavigation(Level world) { BirdNavigation birdNavigation = new BirdNavigation(this, world) { public boolean isValidPosition(BlockPos pos) { BlockState state = this.world.getBlockState(pos); @@ -156,10 +153,10 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer { } @Override - public PassiveEntity createChild(ServerWorld world, PassiveEntity entity) { + public PassiveEntity createChild(ServerLevel world, PassiveEntity entity) { return EndEntities.SILK_MOTH.create(world); } - + @Override protected void dropLoot(DamageSource source, boolean causedByPlayer) { int minCount = 0; @@ -176,18 +173,19 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer { ItemEntity drop = new ItemEntity(world, getX(), getY(), getZ(), new ItemStack(EndItems.SILK_FIBER, count)); this.world.spawnEntity(drop); } - - public static boolean canSpawn(EntityType type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) { + + public static boolean canSpawn(EntityType type, ServerWorldAccess world, SpawnReason spawnReason, + BlockPos pos, Random random) { int y = world.getChunk(pos).sampleHeightmap(Type.WORLD_SURFACE, pos.getX() & 15, pos.getY() & 15); return y > 0 && pos.getY() >= y && notManyEntities(world, pos, 32, 1); } - + private static boolean notManyEntities(ServerWorldAccess world, BlockPos pos, int radius, int maxCount) { Box box = new Box(pos).expand(radius); List list = world.getEntitiesByClass(SilkMothEntity.class, box, (entity) -> true); return list.size() <= maxCount; } - + class MothLookControl extends LookControl { MothLookControl(MobEntity entity) { super(entity); @@ -217,16 +215,18 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer { public void start() { Vec3d vec3d = null; if (SilkMothEntity.this.hivePos != null && SilkMothEntity.this.hiveWorld == SilkMothEntity.this.world) { - if (SilkMothEntity.this.getPos().squaredDistanceTo(SilkMothEntity.this.hivePos.getX(), SilkMothEntity.this.hivePos.getY(), SilkMothEntity.this.hivePos.getZ()) > 16) { + if (SilkMothEntity.this.getPos().squaredDistanceTo(SilkMothEntity.this.hivePos.getX(), + SilkMothEntity.this.hivePos.getY(), SilkMothEntity.this.hivePos.getZ()) > 16) { vec3d = SilkMothEntity.this.getPos().add(random.nextGaussian() * 2, 0, random.nextGaussian() * 2); } } vec3d = vec3d == null ? this.getRandomLocation() : vec3d; if (vec3d != null) { try { - SilkMothEntity.this.navigation.startMovingAlong(SilkMothEntity.this.navigation.findPathTo(new BlockPos(vec3d), 1), 1.0D); + SilkMothEntity.this.navigation + .startMovingAlong(SilkMothEntity.this.navigation.findPathTo(new BlockPos(vec3d), 1), 1.0D); + } catch (Exception e) { } - catch (Exception e) {} } } @@ -234,43 +234,47 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer { private Vec3d getRandomLocation() { Vec3d vec3d3 = SilkMothEntity.this.getRotationVec(0.0F); Vec3d vec3d4 = TargetFinder.findAirTarget(SilkMothEntity.this, 8, 7, vec3d3, 1.5707964F, 2, 1); - return vec3d4 != null ? vec3d4 : TargetFinder.findGroundTarget(SilkMothEntity.this, 8, 4, -2, vec3d3, 1.5707963705062866D); + return vec3d4 != null ? vec3d4 + : TargetFinder.findGroundTarget(SilkMothEntity.this, 8, 4, -2, vec3d3, 1.5707963705062866D); } } - + class ReturnToHiveGoal extends Goal { ReturnToHiveGoal() { this.setControls(EnumSet.of(Goal.Control.MOVE)); } - + @Override public boolean canStart() { - return SilkMothEntity.this.hivePos != null - && SilkMothEntity.this.hiveWorld == SilkMothEntity.this.world - && SilkMothEntity.this.navigation.isIdle() - && SilkMothEntity.this.random.nextInt(16) == 0 - && SilkMothEntity.this.getPos().squaredDistanceTo(SilkMothEntity.this.hivePos.getX(), SilkMothEntity.this.hivePos.getY(), SilkMothEntity.this.hivePos.getZ()) < 64; + return SilkMothEntity.this.hivePos != null && SilkMothEntity.this.hiveWorld == SilkMothEntity.this.world + && SilkMothEntity.this.navigation.isIdle() && SilkMothEntity.this.random.nextInt(16) == 0 + && SilkMothEntity.this.getPos().squaredDistanceTo(SilkMothEntity.this.hivePos.getX(), + SilkMothEntity.this.hivePos.getY(), SilkMothEntity.this.hivePos.getZ()) < 64; } - + @Override public boolean shouldContinue() { - return SilkMothEntity.this.navigation.isFollowingPath() && world.getBlockState(entrance).isAir() && (world.getBlockState(hivePos).isOf(EndBlocks.SILK_MOTH_NEST) || world.getBlockState(hivePos).isOf(EndBlocks.SILK_MOTH_HIVE)); + return SilkMothEntity.this.navigation.isFollowingPath() && world.getBlockState(entrance).isAir() + && (world.getBlockState(hivePos).is(EndBlocks.SILK_MOTH_NEST) + || world.getBlockState(hivePos).is(EndBlocks.SILK_MOTH_HIVE)); } - + @Override public void start() { BlockState state = SilkMothEntity.this.world.getBlockState(SilkMothEntity.this.hivePos); - if (!state.isOf(EndBlocks.SILK_MOTH_NEST) && !state.isOf(EndBlocks.SILK_MOTH_HIVE)) { + if (!state.is(EndBlocks.SILK_MOTH_NEST) && !state.is(EndBlocks.SILK_MOTH_HIVE)) { SilkMothEntity.this.hivePos = null; return; } try { - SilkMothEntity.this.entrance = SilkMothEntity.this.hivePos.offset(state.get(Properties.HORIZONTAL_FACING)); - SilkMothEntity.this.navigation.startMovingAlong(SilkMothEntity.this.navigation.findPathTo(entrance, 1), 1.0D); + SilkMothEntity.this.entrance = SilkMothEntity.this.hivePos + .offset(state.getValue(Properties.HORIZONTAL_FACING)); + SilkMothEntity.this.navigation.startMovingAlong(SilkMothEntity.this.navigation.findPathTo(entrance, 1), + 1.0D); + } catch (Exception e) { } - catch (Exception e) {} } - + @Override public void tick() { super.tick(); @@ -282,20 +286,21 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer { double dz = Math.abs(SilkMothEntity.this.entrance.getZ() - SilkMothEntity.this.getZ()); if (dx + dy + dz < 1) { BlockState state = SilkMothEntity.this.world.getBlockState(hivePos); - if (state.isOf(EndBlocks.SILK_MOTH_NEST) || state.isOf(EndBlocks.SILK_MOTH_HIVE)) { - int fullness = state.get(BlockProperties.FULLNESS); - boolean isHive = state.isOf(EndBlocks.SILK_MOTH_HIVE); + if (state.is(EndBlocks.SILK_MOTH_NEST) || state.is(EndBlocks.SILK_MOTH_HIVE)) { + int fullness = state.getValue(BlockProperties.FULLNESS); + boolean isHive = state.is(EndBlocks.SILK_MOTH_HIVE); if (fullness < 3 && (isHive || SilkMothEntity.this.random.nextBoolean())) { fullness += isHive ? MHelper.randRange(1, 2, random) : 1; if (fullness > 3) { fullness = 3; } - BlocksHelper.setWithUpdate(SilkMothEntity.this.hiveWorld, SilkMothEntity.this.hivePos, state.with(BlockProperties.FULLNESS, fullness)); + BlocksHelper.setWithUpdate(SilkMothEntity.this.hiveWorld, SilkMothEntity.this.hivePos, + state.with(BlockProperties.FULLNESS, fullness)); } - SilkMothEntity.this.world.playSound(null, SilkMothEntity.this.entrance, SoundEvents.BLOCK_BEEHIVE_ENTER, SoundCategory.BLOCKS, 1, 1); + SilkMothEntity.this.world.playLocalSound(null, SilkMothEntity.this.entrance, + SoundEvents.BLOCK_BEEHIVE_ENTER, SoundSource.BLOCKS, 1, 1); SilkMothEntity.this.remove(); - } - else { + } else { SilkMothEntity.this.hivePos = null; } } diff --git a/src/main/java/ru/betterend/entity/model/BlockBenchModel.java b/src/main/java/ru/betterend/entity/model/BlockBenchModel.java index f53dc212..052ade1b 100644 --- a/src/main/java/ru/betterend/entity/model/BlockBenchModel.java +++ b/src/main/java/ru/betterend/entity/model/BlockBenchModel.java @@ -5,18 +5,18 @@ import java.util.function.Function; import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.entity.model.EntityModel; -import net.minecraft.entity.Entity; -import net.minecraft.util.Identifier; +import net.minecraft.world.entity.Entity; +import net.minecraft.resources.ResourceLocation; public abstract class BlockBenchModel extends EntityModel { public BlockBenchModel() { super(); } - - public BlockBenchModel(Function function) { + + public BlockBenchModel(Function function) { super(function); } - + protected void setRotationAngle(ModelPart modelRenderer, float x, float y, float z) { modelRenderer.pitch = x; modelRenderer.yaw = y; diff --git a/src/main/java/ru/betterend/entity/model/CubozoaEntityModel.java b/src/main/java/ru/betterend/entity/model/CubozoaEntityModel.java index f9b7d5cd..97187ee1 100644 --- a/src/main/java/ru/betterend/entity/model/CubozoaEntityModel.java +++ b/src/main/java/ru/betterend/entity/model/CubozoaEntityModel.java @@ -4,7 +4,7 @@ import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import ru.betterend.entity.CubozoaEntity; public class CubozoaEntityModel extends BlockBenchModel { @@ -23,10 +23,10 @@ public class CubozoaEntityModel extends BlockBenchModel { public CubozoaEntityModel() { super(RenderLayer::getEntityTranslucent); - + textureWidth = 48; textureHeight = 48; - + model = new ModelPart(this); model.setPivot(0.0F, 24.0F, 0.0F); model.setTextureOffset(0, 17).addCuboid(-2.0F, -12.5F, -2.0F, 4.0F, 4.0F, 4.0F, 0.0F); @@ -40,7 +40,6 @@ public class CubozoaEntityModel extends BlockBenchModel { tentacle_center_1 = new ModelPart(this); tentacle_center_1.setPivot(0.0F, 0.0F, 0.0F); model.addChild(tentacle_center_1); - tentacle_1 = new ModelPart(this); tentacle_1.setPivot(0.0F, -7.0F, 4.5F); @@ -51,7 +50,6 @@ public class CubozoaEntityModel extends BlockBenchModel { tentacle_center_2.setPivot(0.0F, 0.0F, 0.0F); model.addChild(tentacle_center_2); setRotationAngle(tentacle_center_2, 0.0F, -1.5708F, 0.0F); - tentacle_2 = new ModelPart(this); tentacle_2.setPivot(0.0F, -7.0F, 4.5F); @@ -62,7 +60,6 @@ public class CubozoaEntityModel extends BlockBenchModel { tentacle_center_3.setPivot(0.0F, 0.0F, 0.0F); model.addChild(tentacle_center_3); setRotationAngle(tentacle_center_3, 0.0F, 3.1416F, 0.0F); - tentacle_3 = new ModelPart(this); tentacle_3.setPivot(0.0F, -7.0F, 4.5F); @@ -73,20 +70,20 @@ public class CubozoaEntityModel extends BlockBenchModel { tentacle_center_4.setPivot(0.0F, 0.0F, 0.0F); model.addChild(tentacle_center_4); setRotationAngle(tentacle_center_4, 0.0F, 1.5708F, 0.0F); - tentacle_4 = new ModelPart(this); tentacle_4.setPivot(0.0F, -7.0F, 4.5F); tentacle_center_4.addChild(tentacle_4); tentacle_4.setTextureOffset(16, 17).addCuboid(-4.0F, 0.0F, 0.0F, 8.0F, 7.0F, 0.0F, 0.0F); } - + @Override - public void setAngles(CubozoaEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) { - float sin = MathHelper.sin(animationProgress * 0.13F); + public void setAngles(CubozoaEntity entity, float limbAngle, float limbDistance, float animationProgress, + float headYaw, float headPitch) { + float sin = Mth.sin(animationProgress * 0.13F); scaleY = sin * 0.1F + 0.9F; - scaleXZ = MathHelper.sin(animationProgress * 0.13F + 3.14F) * 0.1F + 0.9F; - + scaleXZ = Mth.sin(animationProgress * 0.13F + 3.14F) * 0.1F + 0.9F; + tentacle_1.pitch = sin * 0.15F; tentacle_2.pitch = sin * 0.15F; tentacle_3.pitch = sin * 0.15F; @@ -94,7 +91,8 @@ public class CubozoaEntityModel extends BlockBenchModel { } @Override - public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) { + public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, + float blue, float alpha) { matrices.push(); matrices.scale(scaleXZ, scaleY, scaleXZ); model.render(matrices, vertices, light, overlay); diff --git a/src/main/java/ru/betterend/entity/model/SilkMothEntityModel.java b/src/main/java/ru/betterend/entity/model/SilkMothEntityModel.java index c9751121..21579703 100644 --- a/src/main/java/ru/betterend/entity/model/SilkMothEntityModel.java +++ b/src/main/java/ru/betterend/entity/model/SilkMothEntityModel.java @@ -4,7 +4,7 @@ import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import ru.betterend.entity.SilkMothEntity; public class SilkMothEntityModel extends BlockBenchModel { @@ -26,7 +26,7 @@ public class SilkMothEntityModel extends BlockBenchModel { public SilkMothEntityModel() { super(RenderLayer::getEntityCutout); - + textureWidth = 64; textureHeight = 64; @@ -113,22 +113,22 @@ public class SilkMothEntityModel extends BlockBenchModel { abdomen_r1.setTextureOffset(0, 10).addCuboid(-3.0F, -4.0F, -1.0F, 4.0F, 4.0F, 7.0F, 0.0F); } - @Override - public void setAngles(SilkMothEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) { - wingR_r1.roll = MathHelper.sin(animationProgress * 2F) * 0.4F + 0.3927F; + public void setAngles(SilkMothEntity entity, float limbAngle, float limbDistance, float animationProgress, + float headYaw, float headPitch) { + wingR_r1.roll = Mth.sin(animationProgress * 2F) * 0.4F + 0.3927F; wingL_r1.roll = -wingR_r1.roll; - head_pivot.pitch = MathHelper.sin(animationProgress * 0.03F) * 0.1F; - tendril_r_r1.roll = MathHelper.sin(animationProgress * 0.07F) * 0.2F + 0.3927F; + head_pivot.pitch = Mth.sin(animationProgress * 0.03F) * 0.1F; + tendril_r_r1.roll = Mth.sin(animationProgress * 0.07F) * 0.2F + 0.3927F; tendril_r_r2.roll = -tendril_r_r1.roll; - abdomen_r1.pitch = MathHelper.sin(animationProgress * 0.05F) * 0.1F - 0.3927F; - legsR.roll = MathHelper.sin(animationProgress * 0.07F) * 0.1F - 0.6545F; + abdomen_r1.pitch = Mth.sin(animationProgress * 0.05F) * 0.1F - 0.3927F; + legsR.roll = Mth.sin(animationProgress * 0.07F) * 0.1F - 0.6545F; legsL.roll = -legsR.roll; } - @Override - public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) { + public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, + float blue, float alpha) { bb_main.render(matrices, vertices, light, overlay); head_pivot.render(matrices, vertices, light, overlay); legsL.render(matrices, vertices, light, overlay); diff --git a/src/main/java/ru/betterend/entity/render/RendererEntityCubozoa.java b/src/main/java/ru/betterend/entity/render/RendererEntityCubozoa.java index cf36a3be..0bb0b984 100644 --- a/src/main/java/ru/betterend/entity/render/RendererEntityCubozoa.java +++ b/src/main/java/ru/betterend/entity/render/RendererEntityCubozoa.java @@ -8,13 +8,13 @@ import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.MobEntityRenderer; import net.minecraft.client.render.entity.feature.EyesFeatureRenderer; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import ru.betterend.BetterEnd; import ru.betterend.entity.CubozoaEntity; import ru.betterend.entity.model.CubozoaEntityModel; public class RendererEntityCubozoa extends MobEntityRenderer { - private static final Identifier[] TEXTURE = new Identifier[2]; + private static final ResourceLocation[] TEXTURE = new ResourceLocation[2]; private static final RenderLayer[] GLOW = new RenderLayer[2]; public RendererEntityCubozoa(EntityRenderDispatcher entityRenderDispatcher) { @@ -26,11 +26,14 @@ public class RendererEntityCubozoa extends MobEntityRenderer { - private static final Identifier TEXTURE = BetterEnd.makeID("textures/entity/dragonfly.png"); - private static final RenderLayer GLOW = RenderLayer.getEyes(BetterEnd.makeID("textures/entity/dragonfly_glow.png")); - + private static final ResourceLocation TEXTURE = BetterEnd.makeID("textures/entity/dragonfly.png"); + private static final RenderLayer GLOW = RenderLayer.getEyes(BetterEnd.makeID("textures/entity/dragonfly_glow.png")); + public RendererEntityDragonfly(EntityRenderDispatcher entityRenderDispatcher) { super(entityRenderDispatcher, new DragonflyEntityModel(), 0.5f); this.addFeature(new EyesFeatureRenderer(this) { - @Override - public RenderLayer getEyesTexture() { - return GLOW; - } + @Override + public RenderLayer getEyesTexture() { + return GLOW; + } }); } - + @Override - public Identifier getTexture(DragonflyEntity entity) { + public ResourceLocation getTexture(DragonflyEntity entity) { return TEXTURE; } } \ No newline at end of file diff --git a/src/main/java/ru/betterend/entity/render/RendererEntityEndFish.java b/src/main/java/ru/betterend/entity/render/RendererEntityEndFish.java index f5b6ff64..c96ae77d 100644 --- a/src/main/java/ru/betterend/entity/render/RendererEntityEndFish.java +++ b/src/main/java/ru/betterend/entity/render/RendererEntityEndFish.java @@ -8,46 +8,49 @@ import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.MobEntityRenderer; import net.minecraft.client.render.entity.feature.EyesFeatureRenderer; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import ru.betterend.BetterEnd; import ru.betterend.entity.EndFishEntity; import ru.betterend.entity.model.EndFishEntityModel; public class RendererEntityEndFish extends MobEntityRenderer { - private static final Identifier[] TEXTURE = new Identifier[EndFishEntity.VARIANTS]; + private static final ResourceLocation[] TEXTURE = new ResourceLocation[EndFishEntity.VARIANTS]; private static final RenderLayer[] GLOW = new RenderLayer[EndFishEntity.VARIANTS]; - - public RendererEntityEndFish(EntityRenderDispatcher entityRenderDispatcher) { - super(entityRenderDispatcher, new EndFishEntityModel(), 0.5f); - this.addFeature(new EyesFeatureRenderer(this) { + + public RendererEntityEndFish(EntityRenderDispatcher entityRenderDispatcher) { + super(entityRenderDispatcher, new EndFishEntityModel(), 0.5f); + this.addFeature(new EyesFeatureRenderer(this) { @Override public RenderLayer getEyesTexture() { return GLOW[0]; } @Override - public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, EndFishEntity entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) { + public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, + EndFishEntity entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, + float headYaw, float headPitch) { VertexConsumer vertexConsumer = vertexConsumers.getBuffer(GLOW[entity.getVariant()]); - this.getContextModel().render(matrices, vertexConsumer, 15728640, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F); + this.getContextModel().render(matrices, vertexConsumer, 15728640, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, + 1.0F, 1.0F); } - }); - } - - @Override + }); + } + + @Override protected void scale(EndFishEntity entity, MatrixStack matrixStack, float f) { float scale = entity.getScale(); matrixStack.scale(scale, scale, scale); } - - @Override - public Identifier getTexture(EndFishEntity entity) { - return TEXTURE[entity.getVariant()]; - } - - static { - for (int i = 0; i < EndFishEntity.VARIANTS; i++) { - TEXTURE[i] = BetterEnd.makeID("textures/entity/end_fish/end_fish_" + i + ".png"); - GLOW[i] = RenderLayer.getEyes(BetterEnd.makeID("textures/entity/end_fish/end_fish_" + i + "_glow.png")); - } - } + + @Override + public ResourceLocation getTexture(EndFishEntity entity) { + return TEXTURE[entity.getVariant()]; + } + + static { + for (int i = 0; i < EndFishEntity.VARIANTS; i++) { + TEXTURE[i] = BetterEnd.makeID("textures/entity/end_fish/end_fish_" + i + ".png"); + GLOW[i] = RenderLayer.getEyes(BetterEnd.makeID("textures/entity/end_fish/end_fish_" + i + "_glow.png")); + } + } } \ No newline at end of file diff --git a/src/main/java/ru/betterend/entity/render/RendererEntityEndSlime.java b/src/main/java/ru/betterend/entity/render/RendererEntityEndSlime.java index 403e22b0..6075d9eb 100644 --- a/src/main/java/ru/betterend/entity/render/RendererEntityEndSlime.java +++ b/src/main/java/ru/betterend/entity/render/RendererEntityEndSlime.java @@ -11,43 +11,47 @@ import net.minecraft.client.render.entity.feature.EyesFeatureRenderer; import net.minecraft.client.render.entity.feature.FeatureRenderer; import net.minecraft.client.render.entity.feature.FeatureRendererContext; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.MathHelper; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; import ru.betterend.BetterEnd; import ru.betterend.entity.EndSlimeEntity; import ru.betterend.entity.model.EndSlimeEntityModel; public class RendererEntityEndSlime extends MobEntityRenderer> { - private static final Identifier TEXTURE[] = new Identifier[4]; + private static final ResourceLocation TEXTURE[] = new ResourceLocation[4]; private static final RenderLayer GLOW[] = new RenderLayer[4]; - - public RendererEntityEndSlime(EntityRenderDispatcher entityRenderDispatcher) { - super(entityRenderDispatcher, new EndSlimeEntityModel(false), 0.25F); - this.addFeature(new OverlayFeatureRenderer(this)); - this.addFeature(new EyesFeatureRenderer>(this) { + + public RendererEntityEndSlime(EntityRenderDispatcher entityRenderDispatcher) { + super(entityRenderDispatcher, new EndSlimeEntityModel(false), 0.25F); + this.addFeature(new OverlayFeatureRenderer(this)); + this.addFeature(new EyesFeatureRenderer>(this) { @Override public RenderLayer getEyesTexture() { return GLOW[0]; } - + @Override - public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, EndSlimeEntity entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) { + public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, + EndSlimeEntity entity, float limbAngle, float limbDistance, float tickDelta, + float animationProgress, float headYaw, float headPitch) { VertexConsumer vertexConsumer = vertexConsumers.getBuffer(GLOW[entity.getSlimeType()]); - this.getContextModel().render(matrices, vertexConsumer, 15728640, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F); + this.getContextModel().render(matrices, vertexConsumer, 15728640, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, + 1.0F, 1.0F); if (entity.isLake()) { this.getContextModel().renderFlower(matrices, vertexConsumer, 15728640, OverlayTexture.DEFAULT_UV); } } - }); - } + }); + } @Override - public Identifier getTexture(EndSlimeEntity entity) { + public ResourceLocation getTexture(EndSlimeEntity entity) { return TEXTURE[entity.getSlimeType()]; } @Override - public void render(EndSlimeEntity slimeEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) { + public void render(EndSlimeEntity slimeEntity, float f, float g, MatrixStack matrixStack, + VertexConsumerProvider vertexConsumerProvider, int i) { this.shadowRadius = 0.25F * (float) slimeEntity.getSize(); super.render(slimeEntity, f, g, matrixStack, vertexConsumerProvider, i); } @@ -57,12 +61,13 @@ public class RendererEntityEndSlime extends MobEntityRenderer extends FeatureRenderer> { + private final class OverlayFeatureRenderer + extends FeatureRenderer> { private final EndSlimeEntityModel modelOrdinal = new EndSlimeEntityModel(true); private final EndSlimeEntityModel modelLake = new EndSlimeEntityModel(true); @@ -70,27 +75,33 @@ public class RendererEntityEndSlime extends MobEntityRenderer model = livingEntity.getSlimeType() == 1 ? modelLake : modelOrdinal; this.getContextModel().copyStateTo(model); model.animateModel(livingEntity, f, g, h); model.setAngles(livingEntity, f, g, j, k, l); - VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getEntityTranslucent(this.getTexture(livingEntity))); - model.render(matrixStack, vertexConsumer, i, LivingEntityRenderer.getOverlay(livingEntity, 0.0F), 1.0F, 1.0F, 1.0F, 1.0F); + VertexConsumer vertexConsumer = vertexConsumerProvider + .getBuffer(RenderLayer.getEntityTranslucent(this.getTexture(livingEntity))); + model.render(matrixStack, vertexConsumer, i, LivingEntityRenderer.getOverlay(livingEntity, 0.0F), 1.0F, + 1.0F, 1.0F, 1.0F); } } } - + static { TEXTURE[0] = BetterEnd.makeID("textures/entity/end_slime/end_slime.png"); TEXTURE[1] = BetterEnd.makeID("textures/entity/end_slime/end_slime_mossy.png"); diff --git a/src/main/java/ru/betterend/entity/render/RendererEntityShadowWalker.java b/src/main/java/ru/betterend/entity/render/RendererEntityShadowWalker.java index 42ce3685..ca11514a 100644 --- a/src/main/java/ru/betterend/entity/render/RendererEntityShadowWalker.java +++ b/src/main/java/ru/betterend/entity/render/RendererEntityShadowWalker.java @@ -3,19 +3,20 @@ package ru.betterend.entity.render; import net.minecraft.client.render.entity.BipedEntityRenderer; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.model.PlayerEntityModel; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import ru.betterend.BetterEnd; import ru.betterend.entity.ShadowWalkerEntity; -public class RendererEntityShadowWalker extends BipedEntityRenderer> { - private static final Identifier TEXTURE = BetterEnd.makeID("textures/entity/shadow_walker.png"); - +public class RendererEntityShadowWalker + extends BipedEntityRenderer> { + private static final ResourceLocation TEXTURE = BetterEnd.makeID("textures/entity/shadow_walker.png"); + public RendererEntityShadowWalker(EntityRenderDispatcher entityRenderDispatcher) { super(entityRenderDispatcher, new PlayerEntityModel(0.0F, false), 0.5F); } @Override - public Identifier getTexture(ShadowWalkerEntity zombieEntity) { + public ResourceLocation getTexture(ShadowWalkerEntity zombieEntity) { return TEXTURE; } } diff --git a/src/main/java/ru/betterend/entity/render/SilkMothEntityRenderer.java b/src/main/java/ru/betterend/entity/render/SilkMothEntityRenderer.java index 818520d6..f6514e5d 100644 --- a/src/main/java/ru/betterend/entity/render/SilkMothEntityRenderer.java +++ b/src/main/java/ru/betterend/entity/render/SilkMothEntityRenderer.java @@ -2,20 +2,20 @@ package ru.betterend.entity.render; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.MobEntityRenderer; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import ru.betterend.BetterEnd; import ru.betterend.entity.SilkMothEntity; import ru.betterend.entity.model.SilkMothEntityModel; public class SilkMothEntityRenderer extends MobEntityRenderer { - private static final Identifier TEXTURE = BetterEnd.makeID("textures/entity/silk_moth.png"); - + private static final ResourceLocation TEXTURE = BetterEnd.makeID("textures/entity/silk_moth.png"); + public SilkMothEntityRenderer(EntityRenderDispatcher entityRenderDispatcher) { super(entityRenderDispatcher, new SilkMothEntityModel(), 0.5f); } - + @Override - public Identifier getTexture(SilkMothEntity entity) { + public ResourceLocation getTexture(SilkMothEntity entity) { return TEXTURE; } } \ No newline at end of file diff --git a/src/main/java/ru/betterend/events/PlayerAdvancementsEvents.java b/src/main/java/ru/betterend/events/PlayerAdvancementsEvents.java index 7a90891e..bfb6fcbe 100644 --- a/src/main/java/ru/betterend/events/PlayerAdvancementsEvents.java +++ b/src/main/java/ru/betterend/events/PlayerAdvancementsEvents.java @@ -2,18 +2,19 @@ package ru.betterend.events; import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.advancement.Advancement; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.advancements.Advancement; +import net.minecraft.server.level.ServerPlayer; public final class PlayerAdvancementsEvents { - - public static Event PLAYER_ADVENCEMENT_COMPLETE = EventFactory.createArrayBacked(AdvancementComplete.class, callbacks -> (player, advancement, criterionName) -> { - for (AdvancementComplete event : callbacks) { - event.onAdvancementComplete(player, advancement, criterionName); - } - }); - + + public static Event PLAYER_ADVANCEMENT_COMPLETE = EventFactory + .createArrayBacked(AdvancementComplete.class, callbacks -> (player, advancement, criterionName) -> { + for (AdvancementComplete event : callbacks) { + event.onAdvancementComplete(player, advancement, criterionName); + } + }); + public interface AdvancementComplete { - void onAdvancementComplete(ServerPlayerEntity player, Advancement advancement, String criterionName); + void onAdvancementComplete(ServerPlayer player, Advancement advancement, String criterionName); } } diff --git a/src/main/java/ru/betterend/integration/FlamboyantRefabricatedIntegration.java b/src/main/java/ru/betterend/integration/FlamboyantRefabricatedIntegration.java index 09255141..158151ca 100644 --- a/src/main/java/ru/betterend/integration/FlamboyantRefabricatedIntegration.java +++ b/src/main/java/ru/betterend/integration/FlamboyantRefabricatedIntegration.java @@ -5,7 +5,7 @@ import java.util.Map; import com.google.common.collect.Maps; -import net.minecraft.item.ItemConvertible; +import net.minecraft.world.item.ItemConvertible; import ru.betterend.blocks.HydraluxPetalColoredBlock; import ru.betterend.blocks.complex.ColoredMaterial; import ru.betterend.registry.EndBlocks; @@ -18,25 +18,24 @@ public class FlamboyantRefabricatedIntegration extends ModIntegration { @Override public void register() { - /*Class fDyeColor = getClass("com.github.EltrutCo.flamboyant.items.FDyeColor"); - Object[] values = getStaticFieldValue(fDyeColor, "VALUES"); - - if (values == null) { - return; - }*/ - + /* + * Class fDyeColor = + * getClass("com.github.EltrutCo.flamboyant.items.FDyeColor"); Object[] values = + * getStaticFieldValue(fDyeColor, "VALUES"); + * + * if (values == null) { return; } + */ + Map colors = Maps.newHashMap(); Map dyes = Maps.newHashMap(); - /*for (Object val: values) { - Integer color = (Integer) getFieldValue(fDyeColor, "signColor", val); - String name = (String) getFieldValue(fDyeColor, "name", val); - if (color != null && name != null) { - colors.put(color, name); - System.out.println(name + " " + color + " " + new Color(color)); - dyes.put(color, getItem(name + "_dye")); - } - }*/ - + /* + * for (Object val: values) { Integer color = (Integer) getFieldValue(fDyeColor, + * "signColor", val); String name = (String) getFieldValue(fDyeColor, "name", + * val); if (color != null && name != null) { colors.put(color, name); + * System.out.println(name + " " + color + " " + new Color(color)); + * dyes.put(color, getItem(name + "_dye")); } } + */ + addColor("fead1d", "amber", colors, dyes); addColor("bd9a5f", "beige", colors, dyes); addColor("edeada", "cream", colors, dyes); @@ -53,15 +52,15 @@ public class FlamboyantRefabricatedIntegration extends ModIntegration { addColor("6bb1cf", "sky_blue", colors, dyes); addColor("6e8c9c", "slate_gray", colors, dyes); addColor("b02454", "violet", colors, dyes); - + new ColoredMaterial(HydraluxPetalColoredBlock::new, EndBlocks.HYDRALUX_PETAL_BLOCK, colors, dyes, true); } - + private void addColor(String hex, String name, Map colors, Map dyes) { int color = MHelper.color(hex); colors.put(color, name); dyes.put(color, getItem(name + "_dye")); - + System.out.println(name + " " + color + " " + new Color(color)); } } diff --git a/src/main/java/ru/betterend/integration/ModIntegration.java b/src/main/java/ru/betterend/integration/ModIntegration.java index 60d8f80b..0ee53e25 100644 --- a/src/main/java/ru/betterend/integration/ModIntegration.java +++ b/src/main/java/ru/betterend/integration/ModIntegration.java @@ -7,16 +7,16 @@ import java.lang.reflect.Method; import net.fabricmc.fabric.api.tag.TagRegistry; import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.Item; -import net.minecraft.tag.BlockTags; -import net.minecraft.tag.ItemTags; -import net.minecraft.tag.Tag; -import net.minecraft.tag.Tag.Identified; -import net.minecraft.util.Identifier; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.item.Item; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.tags.Tag; +import net.minecraft.tags.Tag.Identified; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.registry.BuiltinRegistries; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.GenerationStep; @@ -27,63 +27,65 @@ import ru.betterend.world.features.EndFeature; public abstract class ModIntegration { private final String modID; - - public void register() {} - - public void addBiomes() {} - + + public void register() { + } + + public void addBiomes() { + } + public ModIntegration(String modID) { this.modID = modID; } - - public Identifier getID(String name) { - return new Identifier(modID, name); + + public ResourceLocation getID(String name) { + return new ResourceLocation(modID, name); } - + public Block getBlock(String name) { return Registry.BLOCK.get(getID(name)); } - + public Item getItem(String name) { return Registry.ITEM.get(getID(name)); } public BlockState getDefaultState(String name) { - return getBlock(name).getDefaultState(); + return getBlock(name).defaultBlockState(); } - + public RegistryKey getKey(String name) { return RegistryKey.of(Registry.BIOME_KEY, getID(name)); } - + public boolean modIsInstalled() { return FabricLoader.getInstance().isModLoaded(modID); } - + public EndFeature getFeature(String featureID, String configuredFeatureID, GenerationStep.Feature featureStep) { Feature feature = Registry.FEATURE.get(getID(featureID)); - ConfiguredFeature featureConfigured = BuiltinRegistries.CONFIGURED_FEATURE.get(getID(configuredFeatureID)); + ConfiguredFeature featureConfigured = BuiltinRegistries.CONFIGURED_FEATURE + .get(getID(configuredFeatureID)); return new EndFeature(feature, featureConfigured, featureStep); } - + public EndFeature getFeature(String name, GenerationStep.Feature featureStep) { return getFeature(name, name, featureStep); } - + public ConfiguredFeature getConfiguredFeature(String name) { return BuiltinRegistries.CONFIGURED_FEATURE.get(getID(name)); } - + public Biome getBiome(String name) { return BuiltinRegistries.BIOME.get(getID(name)); } - + public Class getClass(String path) { Class cl = null; try { cl = Class.forName(path); - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { BetterEnd.LOGGER.error(e.getMessage()); if (BetterEnd.isDevEnvironment()) { e.printStackTrace(); @@ -91,7 +93,7 @@ public abstract class ModIntegration { } return cl; } - + @SuppressWarnings("unchecked") public T getStaticFieldValue(Class cl, String name) { if (cl != null) { @@ -100,14 +102,13 @@ public abstract class ModIntegration { if (field != null) { return (T) field.get(null); } - } - catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { + } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); } } return null; } - + public Object getFieldValue(Class cl, String name, Object classInstance) { if (cl != null) { try { @@ -115,20 +116,18 @@ public abstract class ModIntegration { if (field != null) { return field.get(classInstance); } - } - catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { + } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); } } return null; } - + public Method getMethod(Class cl, String functionName, Class... args) { if (cl != null) { try { return cl.getMethod(functionName, args); - } - catch (NoSuchMethodException | SecurityException e) { + } catch (NoSuchMethodException | SecurityException e) { BetterEnd.LOGGER.error(e.getMessage()); if (BetterEnd.isDevEnvironment()) { e.printStackTrace(); @@ -137,13 +136,12 @@ public abstract class ModIntegration { } return null; } - + public Object executeMethod(Object instance, Method method, Object... args) { if (method != null) { try { return method.invoke(instance, args); - } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { BetterEnd.LOGGER.error(e.getMessage()); if (BetterEnd.isDevEnvironment()) { e.printStackTrace(); @@ -152,7 +150,7 @@ public abstract class ModIntegration { } return null; } - + public Object getAndExecuteStatic(Class cl, String functionName, Object... args) { if (cl != null) { Class[] classes = new Class[args.length]; @@ -164,9 +162,10 @@ public abstract class ModIntegration { } return null; } - + @SuppressWarnings("unchecked") - public T getAndExecuteRuntime(Class cl, Object instance, String functionName, Object... args) { + public T getAndExecuteRuntime(Class cl, Object instance, String functionName, + Object... args) { if (instance != null) { Class[] classes = new Class[args.length]; for (int i = 0; i < args.length; i++) { @@ -177,15 +176,15 @@ public abstract class ModIntegration { } return null; } - + public Object newInstance(Class cl, Object... args) { if (cl != null) { - for (Constructor constructor: cl.getConstructors()) { + for (Constructor constructor : cl.getConstructors()) { if (constructor.getParameterCount() == args.length) { try { return constructor.newInstance(args); - } - catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { BetterEnd.LOGGER.error(e.getMessage()); if (BetterEnd.isDevEnvironment()) { e.printStackTrace(); @@ -196,15 +195,15 @@ public abstract class ModIntegration { } return null; } - + public Tag.Identified getItemTag(String name) { - Identifier id = getID(name); + ResourceLocation id = getID(name); Tag tag = ItemTags.getTagGroup().getTag(id); return tag == null ? (Identified) TagRegistry.item(id) : (Identified) tag; } - + public Tag.Identified getBlockTag(String name) { - Identifier id = getID(name); + ResourceLocation id = getID(name); Tag tag = BlockTags.getTagGroup().getTag(id); return tag == null ? (Identified) TagRegistry.block(id) : (Identified) tag; } diff --git a/src/main/java/ru/betterend/integration/NourishIntegration.java b/src/main/java/ru/betterend/integration/NourishIntegration.java index de54e081..1c4e8778 100644 --- a/src/main/java/ru/betterend/integration/NourishIntegration.java +++ b/src/main/java/ru/betterend/integration/NourishIntegration.java @@ -1,7 +1,7 @@ package ru.betterend.integration; -import net.minecraft.item.Item; -import net.minecraft.tag.Tag; +import net.minecraft.world.item.Item; +import net.minecraft.tags.Tag; import ru.betterend.registry.EndItems; import ru.betterend.util.TagHelper; @@ -16,9 +16,10 @@ public class NourishIntegration extends ModIntegration { Tag.Identified fruit = getItemTag("fruit"); Tag.Identified protein = getItemTag("protein"); Tag.Identified sweets = getItemTag("sweets"); - + TagHelper.addTag(fats, EndItems.END_FISH_RAW, EndItems.END_FISH_COOKED); - TagHelper.addTag(fruit, EndItems.SHADOW_BERRY_RAW, EndItems.SHADOW_BERRY_COOKED, EndItems.BLOSSOM_BERRY, EndItems.SHADOW_BERRY_JELLY, EndItems.SWEET_BERRY_JELLY); + TagHelper.addTag(fruit, EndItems.SHADOW_BERRY_RAW, EndItems.SHADOW_BERRY_COOKED, EndItems.BLOSSOM_BERRY, + EndItems.SHADOW_BERRY_JELLY, EndItems.SWEET_BERRY_JELLY); TagHelper.addTag(protein, EndItems.END_FISH_RAW, EndItems.END_FISH_COOKED); TagHelper.addTag(sweets, EndItems.SHADOW_BERRY_JELLY, EndItems.SWEET_BERRY_JELLY); } diff --git a/src/main/java/ru/betterend/integration/byg/BYGBlocks.java b/src/main/java/ru/betterend/integration/byg/BYGBlocks.java index 55844e08..3dd5635f 100644 --- a/src/main/java/ru/betterend/integration/byg/BYGBlocks.java +++ b/src/main/java/ru/betterend/integration/byg/BYGBlocks.java @@ -1,6 +1,6 @@ package ru.betterend.integration.byg; -import net.minecraft.block.Block; +import net.minecraft.world.level.block.Block; import ru.betterend.blocks.basis.EndWallPlantBlock; import ru.betterend.blocks.basis.VineBlock; import ru.betterend.registry.EndBlocks; @@ -8,8 +8,9 @@ import ru.betterend.registry.EndBlocks; public class BYGBlocks { public static final Block IVIS_MOSS = EndBlocks.registerBlock("ivis_moss", new EndWallPlantBlock()); public static final Block NIGHTSHADE_MOSS = EndBlocks.registerBlock("nightshade_moss", new EndWallPlantBlock()); - + public static final Block IVIS_VINE = EndBlocks.registerBlock("ivis_vine", new VineBlock()); - - public static void register() {} + + public static void register() { + } } diff --git a/src/main/java/ru/betterend/integration/byg/BYGIntegration.java b/src/main/java/ru/betterend/integration/byg/BYGIntegration.java index ffa7d743..37dffd01 100644 --- a/src/main/java/ru/betterend/integration/byg/BYGIntegration.java +++ b/src/main/java/ru/betterend/integration/byg/BYGIntegration.java @@ -3,7 +3,7 @@ package ru.betterend.integration.byg; import java.util.List; import java.util.stream.Collectors; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.collection.WeightedList; import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.world.biome.Biome; @@ -32,31 +32,31 @@ public class BYGIntegration extends ModIntegration { @Override public void addBiomes() { BYGBiomes.addBiomes(); - + Class biomeClass = this.getClass("corgiaoc.byg.common.world.biome.BYGEndBiome"); List biomes = this.getStaticFieldValue(biomeClass, "BYG_END_BIOMES"); - + if (biomes != null && biomeClass != null) { biomes.forEach((obj) -> { Biome biome = this.getAndExecuteRuntime(biomeClass, obj, "getBiome"); if (biome != null) { - Identifier biomeID = BuiltinRegistries.BIOME.getId(biome); + ResourceLocation biomeID = BuiltinRegistries.BIOME.getId(biome); EndBiome endBiome = EndBiomes.getBiome(biomeID); Biome edge = this.getAndExecuteRuntime(biomeClass, obj, "getEdge"); if (edge != null) { - Identifier edgeID = BuiltinRegistries.BIOME.getId(edge); + ResourceLocation edgeID = BuiltinRegistries.BIOME.getId(edge); EndBiomes.LAND_BIOMES.removeMutableBiome(edgeID); EndBiomes.VOID_BIOMES.removeMutableBiome(edgeID); EndBiome edgeBiome = EndBiomes.getBiome(edgeID); endBiome.setEdge(edgeBiome); - } - else { + } else { Boolean isVoid = this.getAndExecuteRuntime(biomeClass, obj, "isVoid"); if (isVoid != null && isVoid.booleanValue()) { EndBiomes.LAND_BIOMES.removeMutableBiome(biomeID); EndBiomes.VOID_BIOMES.addBiomeMutable(endBiome); } - WeightedList subBiomes = this.getAndExecuteRuntime(biomeClass, obj, "getHills"); + WeightedList subBiomes = this.getAndExecuteRuntime(biomeClass, obj, + "getHills"); if (subBiomes != null) { subBiomes.stream().collect(Collectors.toList()).forEach((id) -> { EndBiome subBiome = EndBiomes.getBiome(id); diff --git a/src/main/java/ru/betterend/integration/byg/biomes/EterialGrove.java b/src/main/java/ru/betterend/integration/byg/biomes/EterialGrove.java index cec4f4c5..7ba8407d 100644 --- a/src/main/java/ru/betterend/integration/byg/biomes/EterialGrove.java +++ b/src/main/java/ru/betterend/integration/byg/biomes/EterialGrove.java @@ -2,7 +2,7 @@ package ru.betterend.integration.byg.biomes; import java.util.List; -import net.minecraft.entity.SpawnGroup; +import net.minecraft.world.entity.SpawnGroup; import net.minecraft.sound.SoundEvent; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeEffects; @@ -17,15 +17,15 @@ public class EterialGrove extends EndBiome { public EterialGrove() { super(makeDef()); } - + private static BiomeDefinition makeDef() { Biome biome = Integrations.BYG.getBiome("ethereal_islands"); BiomeEffects effects = biome.getEffects(); - + BiomeDefinition def = new BiomeDefinition("eterial_grove") .setSurface(biome.getGenerationSettings().getSurfaceBuilder().get()) .addFeature(BYGFeatures.BIG_ETHER_TREE); - + if (BetterEnd.isClient()) { SoundEvent loop = effects.getLoopSound().get(); SoundEvent music = effects.getMusic().get().getSound(); @@ -33,14 +33,14 @@ public class EterialGrove extends EndBiome { SoundEvent mood = effects.getMoodSound().get().getSound(); def.setLoop(loop).setMusic(music).setAdditions(additions).setMood(mood); } - - for (SpawnGroup group: SpawnGroup.values()) { + + for (SpawnGroup group : SpawnGroup.values()) { List list = biome.getSpawnSettings().getSpawnEntry(group); list.forEach((entry) -> { def.addMobSpawn(entry); }); } - + return def; } } diff --git a/src/main/java/ru/betterend/integration/byg/biomes/NightshadeRedwoods.java b/src/main/java/ru/betterend/integration/byg/biomes/NightshadeRedwoods.java index 525b433a..85094e37 100644 --- a/src/main/java/ru/betterend/integration/byg/biomes/NightshadeRedwoods.java +++ b/src/main/java/ru/betterend/integration/byg/biomes/NightshadeRedwoods.java @@ -2,8 +2,8 @@ package ru.betterend.integration.byg.biomes; import java.util.List; -import net.minecraft.entity.SpawnGroup; -import net.minecraft.particle.ParticleTypes; +import net.minecraft.world.entity.SpawnGroup; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.sound.SoundEvent; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeEffects; @@ -20,25 +20,19 @@ public class NightshadeRedwoods extends EndBiome { public NightshadeRedwoods() { super(makeDef()); } - + private static BiomeDefinition makeDef() { Biome biome = Integrations.BYG.getBiome("nightshade_forest"); BiomeEffects effects = biome.getEffects(); - - BiomeDefinition def = new BiomeDefinition("nightshade_redwoods") - .setFogColor(140, 108, 47) - .setFogDensity(1.5F) - .setWaterAndFogColor(55, 70, 186) - .setFoliageColor(122, 17, 155) + + BiomeDefinition def = new BiomeDefinition("nightshade_redwoods").setFogColor(140, 108, 47).setFogDensity(1.5F) + .setWaterAndFogColor(55, 70, 186).setFoliageColor(122, 17, 155) .setParticles(ParticleTypes.REVERSE_PORTAL, 0.002F) - .setSurface(biome.getGenerationSettings().getSurfaceBuilder().get()) - .setGrassColor(48, 13, 89) - .setPlantsColor(200, 125, 9) - .addFeature(EndFeatures.END_LAKE_RARE) - .addFeature(BYGFeatures.NIGHTSHADE_REDWOOD_TREE) - .addFeature(BYGFeatures.NIGHTSHADE_MOSS_WOOD) + .setSurface(biome.getGenerationSettings().getSurfaceBuilder().get()).setGrassColor(48, 13, 89) + .setPlantsColor(200, 125, 9).addFeature(EndFeatures.END_LAKE_RARE) + .addFeature(BYGFeatures.NIGHTSHADE_REDWOOD_TREE).addFeature(BYGFeatures.NIGHTSHADE_MOSS_WOOD) .addFeature(BYGFeatures.NIGHTSHADE_MOSS); - + if (BetterEnd.isClient()) { SoundEvent loop = effects.getLoopSound().get(); SoundEvent music = effects.getMusic().get().getSound(); @@ -51,14 +45,14 @@ public class NightshadeRedwoods extends EndBiome { def.addFeature(Feature.VEGETAL_DECORATION, feature.get()); }); }); - - for (SpawnGroup group: SpawnGroup.values()) { + + for (SpawnGroup group : SpawnGroup.values()) { List list = biome.getSpawnSettings().getSpawnEntry(group); list.forEach((entry) -> { def.addMobSpawn(entry); }); } - + return def; } } diff --git a/src/main/java/ru/betterend/integration/byg/biomes/OldBulbisGardens.java b/src/main/java/ru/betterend/integration/byg/biomes/OldBulbisGardens.java index ec711c80..a59f15ed 100644 --- a/src/main/java/ru/betterend/integration/byg/biomes/OldBulbisGardens.java +++ b/src/main/java/ru/betterend/integration/byg/biomes/OldBulbisGardens.java @@ -3,13 +3,13 @@ package ru.betterend.integration.byg.biomes; import java.util.List; import java.util.function.Supplier; -import net.minecraft.block.Block; -import net.minecraft.entity.SpawnGroup; -import net.minecraft.particle.ParticleTypes; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.entity.SpawnGroup; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.sound.SoundEvent; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.registry.BuiltinRegistries; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeEffects; import net.minecraft.world.biome.SpawnSettings.SpawnEntry; @@ -27,23 +27,18 @@ public class OldBulbisGardens extends EndBiome { public OldBulbisGardens() { super(makeDef()); } - + private static BiomeDefinition makeDef() { Biome biome = Integrations.BYG.getBiome("bulbis_gardens"); BiomeEffects effects = biome.getEffects(); - + Block ivis = Integrations.BYG.getBlock("ivis_phylium"); Block origin = biome.getGenerationSettings().getSurfaceConfig().getTopMaterial().getBlock(); - BiomeDefinition def = new BiomeDefinition("old_bulbis_gardens") - .setFogColor(215, 132, 207) - .setFogDensity(1.8F) - .setWaterAndFogColor(40, 0, 56) - .setFoliageColor(122, 17, 155) - .setParticles(ParticleTypes.REVERSE_PORTAL, 0.002F) - .setSurface(ivis, origin) - .addFeature(EndFeatures.END_LAKE_RARE) - .addFeature(BYGFeatures.OLD_BULBIS_TREE); - + BiomeDefinition def = new BiomeDefinition("old_bulbis_gardens").setFogColor(215, 132, 207).setFogDensity(1.8F) + .setWaterAndFogColor(40, 0, 56).setFoliageColor(122, 17, 155) + .setParticles(ParticleTypes.REVERSE_PORTAL, 0.002F).setSurface(ivis, origin) + .addFeature(EndFeatures.END_LAKE_RARE).addFeature(BYGFeatures.OLD_BULBIS_TREE); + if (BetterEnd.isClient()) { SoundEvent loop = effects.getLoopSound().get(); SoundEvent music = effects.getMusic().get().getSound(); @@ -51,25 +46,27 @@ public class OldBulbisGardens extends EndBiome { SoundEvent mood = effects.getMoodSound().get().getSound(); def.setLoop(loop).setMusic(music).setAdditions(additions).setMood(mood); } - - for (SpawnGroup group: SpawnGroup.values()) { + + for (SpawnGroup group : SpawnGroup.values()) { List list = biome.getSpawnSettings().getSpawnEntry(group); list.forEach((entry) -> { def.addMobSpawn(entry); }); } - + List>>> features = biome.getGenerationSettings().getFeatures(); List>> vegetal = features.get(Feature.VEGETAL_DECORATION.ordinal()); if (vegetal.size() > 2) { Supplier> getter; // Trees (first two features) - // I couldn't process them with conditions, so that's why they are hardcoded (paulevs) + // I couldn't process them with conditions, so that's why they are hardcoded + // (paulevs) for (int i = 0; i < 2; i++) { getter = vegetal.get(i); ConfiguredFeature feature = getter.get(); - Identifier id = BetterEnd.makeID("obg_feature_" + i); - feature = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, feature.decorate(ConfiguredFeatures.Decorators.SQUARE_HEIGHTMAP).repeatRandomly(1)); + ResourceLocation id = BetterEnd.makeID("obg_feature_" + i); + feature = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, + feature.decorate(ConfiguredFeatures.Decorators.SQUARE_HEIGHTMAP).repeatRandomly(1)); def.addFeature(Feature.VEGETAL_DECORATION, feature); } // Grasses and other features @@ -79,13 +76,11 @@ public class OldBulbisGardens extends EndBiome { def.addFeature(Feature.VEGETAL_DECORATION, feature); } } - - def.addFeature(EndFeatures.PURPLE_POLYPORE) - .addFeature(BYGFeatures.IVIS_MOSS_WOOD) - .addFeature(BYGFeatures.IVIS_MOSS) - .addFeature(BYGFeatures.IVIS_VINE) - .addFeature(BYGFeatures.IVIS_SPROUT); - + + def.addFeature(EndFeatures.PURPLE_POLYPORE).addFeature(BYGFeatures.IVIS_MOSS_WOOD) + .addFeature(BYGFeatures.IVIS_MOSS).addFeature(BYGFeatures.IVIS_VINE) + .addFeature(BYGFeatures.IVIS_SPROUT); + return def; } } diff --git a/src/main/java/ru/betterend/integration/byg/features/BigEtherTreeFeature.java b/src/main/java/ru/betterend/integration/byg/features/BigEtherTreeFeature.java index 08c87af3..4e4da866 100644 --- a/src/main/java/ru/betterend/integration/byg/features/BigEtherTreeFeature.java +++ b/src/main/java/ru/betterend/integration/byg/features/BigEtherTreeFeature.java @@ -5,10 +5,10 @@ import java.util.Random; import com.google.common.base.Function; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -21,22 +21,27 @@ import ru.betterend.world.features.DefaultFeature; public class BigEtherTreeFeature extends DefaultFeature { @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false; - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)) + return false; + BlockState log = Integrations.BYG.getDefaultState("ether_log"); BlockState wood = Integrations.BYG.getDefaultState("ether_wood"); - //BlockState leaves = Integrations.BYG.getDefaultState("ether_leaves"); - Function splinePlacer = (bpos) -> { return log; }; - Function replace = (state) -> { - return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().isReplaceable(); + // BlockState leaves = Integrations.BYG.getDefaultState("ether_leaves"); + Function splinePlacer = (bpos) -> { + return log; }; - + Function replace = (state) -> { + return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) + || state.getMaterial().isReplaceable(); + }; + int height = MHelper.randRange(40, 60, random); List trunk = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, height / 4); SplineHelper.offsetParts(trunk, random, 2F, 0, 2F); SDF sdf = SplineHelper.buildSDF(trunk, 2.3F, 0.8F, splinePlacer); - + int count = height / 15; for (int i = 1; i < count; i++) { float splinePos = (float) i / (float) count; @@ -46,21 +51,22 @@ public class BigEtherTreeFeature extends DefaultFeature { List branch = SplineHelper.makeSpline(0, 0, 0, length, 0, 0, points < 2 ? 2 : points); SplineHelper.powerOffset(branch, length, 2F); int rotCount = MHelper.randRange(5, 7, random); - //float startRad = MathHelper.lerp(splinePos, 2.3F, 0.8F) * 0.8F; + // float startRad = Mth.lerp(splinePos, 2.3F, 0.8F) * 0.8F; Vector3f start = SplineHelper.getPos(trunk, splinePos * (trunk.size() - 1)); for (int j = 0; j < rotCount; j++) { float angle = startAngle + (float) j / rotCount * MHelper.PI2; List br = SplineHelper.copySpline(branch); SplineHelper.offsetParts(br, random, 0, 1, 1); SplineHelper.rotateSpline(br, angle); - + SplineHelper.offset(br, start); SplineHelper.fillSpline(br, world, wood, pos, replace); } } - + sdf.setReplaceFunction((state) -> { - return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().isReplaceable(); + return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) + || state.getMaterial().isReplaceable(); }).addPostProcess((info) -> { if (info.getState().equals(log) && (!info.getStateUp().equals(log) || !info.getStateDown().equals(log))) { return wood; @@ -70,8 +76,9 @@ public class BigEtherTreeFeature extends DefaultFeature { return true; } - - //private void makeLeavesSphere(StructureWorldAccess world, BlockPos pos, BlockState leaves, Function ignore) { - // - //} + + // private void makeLeavesSphere(StructureWorldAccess world, BlockPos pos, + // BlockState leaves, Function ignore) { + // + // } } diff --git a/src/main/java/ru/betterend/integration/byg/features/GreatNightshadeTreeFeature.java b/src/main/java/ru/betterend/integration/byg/features/GreatNightshadeTreeFeature.java index b9005f20..bf5e89c0 100644 --- a/src/main/java/ru/betterend/integration/byg/features/GreatNightshadeTreeFeature.java +++ b/src/main/java/ru/betterend/integration/byg/features/GreatNightshadeTreeFeature.java @@ -6,14 +6,14 @@ import java.util.Random; import com.google.common.base.Function; import com.google.common.collect.Lists; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -33,19 +33,25 @@ import ru.betterend.world.features.DefaultFeature; public class GreatNightshadeTreeFeature extends DefaultFeature { private static final List BRANCH; - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false; - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)) + return false; + BlockState log = Integrations.BYG.getDefaultState("nightshade_log"); BlockState wood = Integrations.BYG.getDefaultState("nightshade_wood"); BlockState leaves = Integrations.BYG.getDefaultState("nightshade_leaves").with(LeavesBlock.DISTANCE, 1); - BlockState leaves_flower = Integrations.BYG.getDefaultState("flowering_nightshade_leaves").with(LeavesBlock.DISTANCE, 1); - - Function splinePlacer = (bpos) -> { return log; }; + BlockState leaves_flower = Integrations.BYG.getDefaultState("flowering_nightshade_leaves") + .with(LeavesBlock.DISTANCE, 1); + + Function splinePlacer = (bpos) -> { + return log; + }; Function replace = (state) -> { - return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().isReplaceable(); + return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) + || state.getMaterial().isReplaceable(); }; Function post = (info) -> { if (info.getState().equals(log) && (!info.getStateUp().equals(log) || !info.getStateDown().equals(log))) { @@ -56,15 +62,15 @@ public class GreatNightshadeTreeFeature extends DefaultFeature { Function ignore = (state) -> { return state.equals(log) || state.equals(wood); }; - + int height = MHelper.randRange(40, 60, random); List trunk = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, height / 4); SplineHelper.offsetParts(trunk, random, 0.8F, 0, 0.8F); - + if (!SplineHelper.canGenerate(trunk, pos, world, replace)) { return false; } - + int count = height >> 2; float start = trunk.size() / 3F; float delta = trunk.size() * 0.6F; @@ -83,20 +89,21 @@ public class GreatNightshadeTreeFeature extends DefaultFeature { SplineHelper.fillSpline(branch, world, wood, pos, replace); } SplineHelper.fillSpline(trunk, world, log, pos, ignore); - + SDF sdf = SplineHelper.buildSDF(trunk, 2.3F, 0.8F, splinePlacer); SDF roots = new SDFSphere().setRadius(2F).setBlock(log); - roots = new SDFFlatWave().setIntensity(2F).setRaysCount(MHelper.randRange(5, 7, random)).setAngle(random.nextFloat() * MHelper.PI2).setSource(roots); + roots = new SDFFlatWave().setIntensity(2F).setRaysCount(MHelper.randRange(5, 7, random)) + .setAngle(random.nextFloat() * MHelper.PI2).setSource(roots); sdf = new SDFSmoothUnion().setRadius(2F).setSourceA(sdf).setSourceB(roots); sdf.setReplaceFunction(replace).addPostProcess(post).fillRecursive(world, pos); Vector3f last = SplineHelper.getPos(trunk, trunk.size() - 1.75F); for (int y = 0; y < 8; y++) { - BlockPos p = pos.add(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5); + BlockPos p = pos.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5); BlocksHelper.setWithoutUpdate(world, p, y == 4 ? wood : log); } - + for (int y = 0; y < 16; y++) { - BlockPos p = pos.add(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5); + BlockPos p = pos.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5); if (world.isAir(p)) { BlocksHelper.setWithoutUpdate(world, p, leaves); } @@ -116,8 +123,8 @@ public class GreatNightshadeTreeFeature extends DefaultFeature { } } } - - Mutable mut = new Mutable(); + + MutableBlockPos mut = new MutableBlockPos(); Function leavesPost1 = (info) -> { if (info.getState().equals(log) || info.getState().equals(wood)) { for (int x = -6; x < 7; x++) { @@ -133,7 +140,7 @@ public class GreatNightshadeTreeFeature extends DefaultFeature { mut.setY(y + info.getPos().getY()); BlockState state = info.getState(mut); if (state.getBlock() instanceof LeavesBlock) { - int distance = state.get(LeavesBlock.DISTANCE); + int distance = state.getValue(LeavesBlock.DISTANCE); if (d < distance) { info.setState(mut, state.with(LeavesBlock.DISTANCE, d)); } @@ -149,15 +156,15 @@ public class GreatNightshadeTreeFeature extends DefaultFeature { if (info.getState().getBlock() instanceof LeavesBlock) { int distance = info.getState().get(LeavesBlock.DISTANCE); if (distance > MHelper.randRange(2, 4, random)) { - return Blocks.AIR.getDefaultState(); + return Blocks.AIR.defaultBlockState(); } - for (Direction d: BlocksHelper.DIRECTIONS) { + for (Direction d : BlocksHelper.DIRECTIONS) { int airCount = 0; if (info.getState(d).isAir()) { - airCount ++; + airCount++; } if (airCount > 5) { - return Blocks.AIR.getDefaultState(); + return Blocks.AIR.defaultBlockState(); } } if (random.nextInt(8) == 0) { @@ -166,19 +173,19 @@ public class GreatNightshadeTreeFeature extends DefaultFeature { } return info.getState(); }; - + SDF canopy = new SDFCappedCone().setRadius1(12F).setRadius2(1f).setHeight(height * 0.3F).setBlock(leaves); - canopy = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-3F, 3F, random); }).setSource(canopy); - canopy.addPostProcess(leavesPost1).addPostProcess(leavesPost2).fillRecursiveIgnore(world, pos.add(0, height * 0.75, 0), ignore); - + canopy = new SDFDisplacement().setFunction((vec) -> { + return MHelper.randRange(-3F, 3F, random); + }).setSource(canopy); + canopy.addPostProcess(leavesPost1).addPostProcess(leavesPost2).fillRecursiveIgnore(world, + pos.offset(0, height * 0.75, 0), ignore); + return true; } - + static { - BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0), - new Vector3f(0.25F, 0.1F, 0), - new Vector3f(0.40F, 0.2F, 0), - new Vector3f(0.50F, 0.4F, 0), - new Vector3f(0.55F, 0.6F, 0)); + BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0), new Vector3f(0.25F, 0.1F, 0), new Vector3f(0.40F, 0.2F, 0), + new Vector3f(0.50F, 0.4F, 0), new Vector3f(0.55F, 0.6F, 0)); } } diff --git a/src/main/java/ru/betterend/integration/byg/features/NightshadeRedwoodTreeFeature.java b/src/main/java/ru/betterend/integration/byg/features/NightshadeRedwoodTreeFeature.java index e58089d2..e18fdaab 100644 --- a/src/main/java/ru/betterend/integration/byg/features/NightshadeRedwoodTreeFeature.java +++ b/src/main/java/ru/betterend/integration/byg/features/NightshadeRedwoodTreeFeature.java @@ -6,14 +6,14 @@ import java.util.Random; import com.google.common.base.Function; import com.google.common.collect.Lists; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -33,19 +33,24 @@ import ru.betterend.world.features.DefaultFeature; public class NightshadeRedwoodTreeFeature extends DefaultFeature { private static final List BRANCH; - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false; - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)) + return false; + BlockState log = Integrations.BYG.getDefaultState("nightshade_log"); BlockState wood = Integrations.BYG.getDefaultState("nightshade_wood"); BlockState leaves = Integrations.BYG.getDefaultState("nightshade_leaves"); BlockState leaves_flower = Integrations.BYG.getDefaultState("flowering_nightshade_leaves"); - - Function splinePlacer = (bpos) -> { return log; }; + + Function splinePlacer = (bpos) -> { + return log; + }; Function replace = (state) -> { - return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().isReplaceable(); + return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) + || state.getMaterial().isReplaceable(); }; Function post = (info) -> { if (info.getState().equals(log) && (!info.getStateUp().equals(log) || !info.getStateDown().equals(log))) { @@ -56,15 +61,15 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature { Function ignore = (state) -> { return state.equals(log) || state.equals(wood); }; - + int height = MHelper.randRange(40, 60, random); List trunk = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, height / 4); SplineHelper.offsetParts(trunk, random, 0.8F, 0, 0.8F); - + if (!SplineHelper.canGenerate(trunk, pos, world, replace)) { return false; } - + int count = height >> 2; float start = trunk.size() / 3F; float delta = trunk.size() * 0.6F; @@ -83,20 +88,21 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature { SplineHelper.offset(branch, offset); SplineHelper.fillSpline(branch, world, wood, pos, replace); } - + SDF sdf = SplineHelper.buildSDF(trunk, 2.3F, 0.8F, splinePlacer); SDF roots = new SDFSphere().setRadius(2F).setBlock(log); - roots = new SDFFlatWave().setIntensity(2F).setRaysCount(MHelper.randRange(5, 7, random)).setAngle(random.nextFloat() * MHelper.PI2).setSource(roots); + roots = new SDFFlatWave().setIntensity(2F).setRaysCount(MHelper.randRange(5, 7, random)) + .setAngle(random.nextFloat() * MHelper.PI2).setSource(roots); sdf = new SDFSmoothUnion().setRadius(2F).setSourceA(sdf).setSourceB(roots); sdf.setReplaceFunction(replace).addPostProcess(post).fillRecursive(world, pos); Vector3f last = SplineHelper.getPos(trunk, trunk.size() - 1.35F); for (int y = 0; y < 8; y++) { - BlockPos p = pos.add(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5); + BlockPos p = pos.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5); BlocksHelper.setWithoutUpdate(world, p, y == 4 ? wood : log); } - + for (int y = 0; y < 16; y++) { - BlockPos p = pos.add(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5); + BlockPos p = pos.offset(last.getX() + 0.5, last.getY() + y, last.getZ() + 0.5); if (world.isAir(p)) { BlocksHelper.setWithoutUpdate(world, p, leaves); } @@ -116,8 +122,8 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature { } } } - - Mutable mut = new Mutable(); + + MutableBlockPos mut = new MutableBlockPos(); Function leavesPost1 = (info) -> { if (info.getState().equals(log) || info.getState().equals(wood)) { for (int x = -6; x < 7; x++) { @@ -133,7 +139,7 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature { mut.setY(y + info.getPos().getY()); BlockState state = info.getState(mut); if (state.getBlock() instanceof LeavesBlock) { - int distance = state.get(LeavesBlock.DISTANCE); + int distance = state.getValue(LeavesBlock.DISTANCE); if (d < distance) { info.setState(mut, state.with(LeavesBlock.DISTANCE, d)); } @@ -149,15 +155,15 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature { if (info.getState().getBlock() instanceof LeavesBlock) { int distance = info.getState().get(LeavesBlock.DISTANCE); if (distance > MHelper.randRange(2, 4, random)) { - return Blocks.AIR.getDefaultState(); + return Blocks.AIR.defaultBlockState(); } - for (Direction d: BlocksHelper.DIRECTIONS) { + for (Direction d : BlocksHelper.DIRECTIONS) { int airCount = 0; if (info.getState(d).isAir()) { - airCount ++; + airCount++; } if (airCount > 5) { - return Blocks.AIR.getDefaultState(); + return Blocks.AIR.defaultBlockState(); } } if (random.nextInt(8) == 0) { @@ -166,19 +172,19 @@ public class NightshadeRedwoodTreeFeature extends DefaultFeature { } return info.getState(); }; - + SDF canopy = new SDFCappedCone().setRadius1(12F).setRadius2(1f).setHeight(height * 0.3F).setBlock(leaves); - canopy = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-3F, 3F, random); }).setSource(canopy); - canopy.addPostProcess(leavesPost1).addPostProcess(leavesPost2).fillRecursiveIgnore(world, pos.add(0, height * 0.75, 0), ignore); - + canopy = new SDFDisplacement().setFunction((vec) -> { + return MHelper.randRange(-3F, 3F, random); + }).setSource(canopy); + canopy.addPostProcess(leavesPost1).addPostProcess(leavesPost2).fillRecursiveIgnore(world, + pos.offset(0, height * 0.75, 0), ignore); + return true; } - + static { - BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0), - new Vector3f(0.25F, 0.1F, 0), - new Vector3f(0.40F, 0.2F, 0), - new Vector3f(0.50F, 0.4F, 0), - new Vector3f(0.55F, 0.6F, 0)); + BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0), new Vector3f(0.25F, 0.1F, 0), new Vector3f(0.40F, 0.2F, 0), + new Vector3f(0.50F, 0.4F, 0), new Vector3f(0.55F, 0.6F, 0)); } } diff --git a/src/main/java/ru/betterend/integration/byg/features/OldBulbisTreeFeature.java b/src/main/java/ru/betterend/integration/byg/features/OldBulbisTreeFeature.java index a7d93ef7..a0a3b41c 100644 --- a/src/main/java/ru/betterend/integration/byg/features/OldBulbisTreeFeature.java +++ b/src/main/java/ru/betterend/integration/byg/features/OldBulbisTreeFeature.java @@ -6,13 +6,13 @@ import java.util.function.Function; import com.google.common.collect.Lists; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.Box; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -34,30 +34,35 @@ public class OldBulbisTreeFeature extends DefaultFeature { private static final List ROOT; private static final List LEAF; private static final List SIDE; - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false; - if (!world.getBlockState(pos.down(4)).getBlock().isIn(EndTags.GEN_TERRAIN)) return false; - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)) + return false; + if (!world.getBlockState(pos.down(4)).getBlock().isIn(EndTags.GEN_TERRAIN)) + return false; + BlockState stem = Integrations.BYG.getDefaultState("bulbis_stem"); BlockState wood = Integrations.BYG.getDefaultState("bulbis_wood"); - BlockState cap = Integrations.BYG.getDefaultState(random.nextBoolean() ? "bulbis_shell" : "purple_bulbis_shell"); + BlockState cap = Integrations.BYG + .getDefaultState(random.nextBoolean() ? "bulbis_shell" : "purple_bulbis_shell"); BlockState glow = Integrations.BYG.getDefaultState("purple_shroomlight"); - + Function replacement = (state) -> { - if (state.equals(stem) || state.equals(wood) || state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) { + if (state.equals(stem) || state.equals(wood) || state.isIn(EndTags.END_GROUND) + || state.getMaterial().equals(Material.PLANT)) { return true; } return state.getMaterial().isReplaceable(); }; - + float size = MHelper.randRange(10, 20, random); float addSize = MHelper.randRange(1, 1.7F, random); float addRad = addSize * 0.5F + 0.5F; int count = (int) (size * 0.15F); size *= addSize; - float var = MHelper.PI2 / (float) (count * 3); + float var = MHelper.PI2 / (float) (count * 3); float start = MHelper.randRange(0, MHelper.PI2, random); SDF sdf = null; int x1 = ((pos.getX() >> 4) << 4) - 16; @@ -70,53 +75,56 @@ public class OldBulbisTreeFeature extends DefaultFeature { SplineHelper.scale(spline, sizeXZ, sizeXZ * 1.5F + MHelper.randRange(0, size * 0.5F, random), sizeXZ); SplineHelper.offset(spline, new Vector3f(size * random.nextFloat() * 0.3F, 0, 0)); SplineHelper.rotateSpline(spline, angle); - SplineHelper.offsetParts(spline, random, 1F, 0, 1F);//1.3F 0.8F + SplineHelper.offsetParts(spline, random, 1F, 0, 1F);// 1.3F 0.8F SDF branch = SplineHelper.buildSDF(spline, 2.3F * addRad, 1.3F * addRad, (bpos) -> { return stem; }); Vector3f vec = spline.get(spline.size() - 1); float radius = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.35F; - bigSphere(world, pos.add(vec.getX(), vec.getY(), vec.getZ()), radius, cap, glow, wood, replacement, random); + bigSphere(world, pos.offset(vec.getX(), vec.getY(), vec.getZ()), radius, cap, glow, wood, replacement, + random); vec = SplineHelper.getPos(spline, 0.3F); - makeRoots(world, pos.add(vec.getX(), vec.getY(), vec.getZ()), size * 0.4F + 5, random, wood, replacement); + makeRoots(world, pos.offset(vec.getX(), vec.getY(), vec.getZ()), size * 0.4F + 5, random, wood, + replacement); sdf = (sdf == null) ? branch : new SDFUnion().setSourceA(sdf).setSourceB(branch); } - + sdf.setReplaceFunction(replacement).addPostProcess((info) -> { - if (info.getState().equals(stem) && (!info.getStateUp().equals(stem) || !info.getStateDown().equals(stem))) { + if (info.getState().equals(stem) + && (!info.getStateUp().equals(stem) || !info.getStateDown().equals(stem))) { return wood; } return info.getState(); }).fillArea(world, pos, limits); - return true; } - - private void bigSphere(StructureWorldAccess world, BlockPos pos, float radius, BlockState cap, BlockState glow, BlockState wood, Function replacement, Random random) { + + private void bigSphere(StructureWorldAccess world, BlockPos pos, float radius, BlockState cap, BlockState glow, + BlockState wood, Function replacement, Random random) { OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong()); SDF sphere = new SDFSphere().setRadius(radius).setBlock(cap); - + SDF sphereInner = new SDFSphere().setRadius(radius * 0.53F).setBlock(Blocks.AIR); sphereInner = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1); }).setSource(sphereInner); - + SDF sphereGlow = new SDFSphere().setRadius(radius * 0.6F).setBlock(glow); sphereGlow = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1) * 2F; }).setSource(sphereGlow); sphereGlow = new SDFSubtraction().setSourceA(sphereGlow).setSourceB(sphereInner); - + sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sphereGlow); sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sphereInner); - + float offsetY = radius * 1.7F; sphere = new SDFUnion().setSourceA(sphere).setSourceB(sphereGlow); sphere = new SDFTranslate().setTranslate(0, offsetY, 0).setSource(sphere); - + int leafCount = (int) (radius * 0.5F) + 2; for (int i = 0; i < 4; i++) { float angle = (float) i / 4 * MHelper.PI2; @@ -124,72 +132,54 @@ public class OldBulbisTreeFeature extends DefaultFeature { SplineHelper.rotateSpline(spline, angle); SplineHelper.scale(spline, radius * 1.4F); SplineHelper.fillSplineForce(spline, world, wood, pos, replacement); - + for (int j = 0; j < leafCount; j++) { float delta = ((float) j / (float) (leafCount - 1)); float scale = (float) Math.sin(delta * Math.PI) * 0.8F + 0.2F; - float index = MathHelper.lerp(delta, 1F, 3.9F); + float index = Mth.lerp(delta, 1F, 3.9F); Vector3f point = SplineHelper.getPos(spline, index); - + List side = SplineHelper.copySpline(SIDE); SplineHelper.rotateSpline(side, angle); SplineHelper.scale(side, scale * radius); - BlockPos p = pos.add(point.getX() + 0.5F, point.getY() + 0.5F, point.getZ() + 0.5F); + BlockPos p = pos.offset(point.getX() + 0.5F, point.getY() + 0.5F, point.getZ() + 0.5F); SplineHelper.fillSplineForce(side, world, wood, p, replacement); } } - + sphere.fillArea(world, pos, new Box(pos.up((int) offsetY)).expand(radius * 1.3F)); } - - private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random, BlockState wood, Function replacement) { + + private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random, BlockState wood, + Function replacement) { int count = (int) (radius * 1.5F); for (int i = 0; i < count; i++) { float angle = (float) i / (float) count * MHelper.PI2; float scale = radius * MHelper.randRange(0.85F, 1.15F, random); - + List branch = SplineHelper.copySpline(ROOT); SplineHelper.rotateSpline(branch, angle); SplineHelper.scale(branch, scale); Vector3f last = branch.get(branch.size() - 1); - if (world.getBlockState(pos.add(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) { + if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) { SplineHelper.fillSpline(branch, world, wood, pos, replacement); } } } - + static { - SPLINE = Lists.newArrayList( - new Vector3f(0.00F, 0.00F, 0.00F), - new Vector3f(0.10F, 0.35F, 0.00F), - new Vector3f(0.20F, 0.50F, 0.00F), - new Vector3f(0.30F, 0.55F, 0.00F), - new Vector3f(0.42F, 0.70F, 0.00F), - new Vector3f(0.50F, 1.00F, 0.00F) - ); - - ROOT = Lists.newArrayList(new Vector3f(0F, 1F, 0), - new Vector3f(0.1F, 0.70F, 0), - new Vector3f(0.3F, 0.30F, 0), - new Vector3f(0.7F, 0.05F, 0), - new Vector3f(0.8F, -0.20F, 0) - ); + SPLINE = Lists.newArrayList(new Vector3f(0.00F, 0.00F, 0.00F), new Vector3f(0.10F, 0.35F, 0.00F), + new Vector3f(0.20F, 0.50F, 0.00F), new Vector3f(0.30F, 0.55F, 0.00F), new Vector3f(0.42F, 0.70F, 0.00F), + new Vector3f(0.50F, 1.00F, 0.00F)); + + ROOT = Lists.newArrayList(new Vector3f(0F, 1F, 0), new Vector3f(0.1F, 0.70F, 0), new Vector3f(0.3F, 0.30F, 0), + new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.20F, 0)); SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0)); - - LEAF = Lists.newArrayList( - new Vector3f(0.00F, 0.0F, 0), - new Vector3f(0.10F, 0.4F, 0), - new Vector3f(0.40F, 0.8F, 0), - new Vector3f(0.75F, 0.9F, 0), - new Vector3f(1.00F, 0.8F, 0) - ); - - SIDE = Lists.newArrayList( - new Vector3f(0, -0.3F, -0.5F), - new Vector3f(0, -0.1F, -0.3F), - new Vector3f(0, 0.0F, 0.0F), - new Vector3f(0, -0.1F, 0.3F), - new Vector3f(0, -0.3F, 0.5F) - ); + + LEAF = Lists.newArrayList(new Vector3f(0.00F, 0.0F, 0), new Vector3f(0.10F, 0.4F, 0), + new Vector3f(0.40F, 0.8F, 0), new Vector3f(0.75F, 0.9F, 0), new Vector3f(1.00F, 0.8F, 0)); + + SIDE = Lists.newArrayList(new Vector3f(0, -0.3F, -0.5F), new Vector3f(0, -0.1F, -0.3F), + new Vector3f(0, 0.0F, 0.0F), new Vector3f(0, -0.1F, 0.3F), new Vector3f(0, -0.3F, 0.5F)); } } diff --git a/src/main/java/ru/betterend/integration/rei/REIAlloyingCategory.java b/src/main/java/ru/betterend/integration/rei/REIAlloyingCategory.java index 67ddf9ba..fa83d526 100644 --- a/src/main/java/ru/betterend/integration/rei/REIAlloyingCategory.java +++ b/src/main/java/ru/betterend/integration/rei/REIAlloyingCategory.java @@ -19,7 +19,7 @@ import me.shedaniel.rei.gui.widget.Widget; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.TranslatableText; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import ru.betterend.recipe.builders.AlloyingRecipe; import ru.betterend.registry.EndBlocks; import ru.betterend.util.LangUtil; @@ -27,7 +27,7 @@ import ru.betterend.util.LangUtil; public class REIAlloyingCategory implements TransferRecipeCategory { @Override - public @NotNull Identifier getIdentifier() { + public @NotNull ResourceLocation getIdentifier() { return AlloyingRecipe.ID; } @@ -35,12 +35,12 @@ public class REIAlloyingCategory implements TransferRecipeCategory setupDisplay(REIAlloyingDisplay display, Rectangle bounds) { Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10); @@ -49,18 +49,26 @@ public class REIAlloyingCategory implements TransferRecipeCategory widgets = Lists.newArrayList(); widgets.add(Widgets.createRecipeBase(bounds)); widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 9))); - widgets.add(Widgets.createBurningFire(new Point(startPoint.x - 9, startPoint.y + 20)).animationDurationMS(10000)); - widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + 5), - new TranslatableText("category.rei.cooking.time&xp", df.format(display.getXp()), df.format(smeltTime / 20D))).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB)); - widgets.add(Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 8)).animationDurationTicks(smeltTime)); + widgets.add( + Widgets.createBurningFire(new Point(startPoint.x - 9, startPoint.y + 20)).animationDurationMS(10000)); + widgets.add(Widgets + .createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + 5), new TranslatableText( + "category.rei.cooking.time&xp", df.format(display.getXp()), df.format(smeltTime / 20D))) + .noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB)); + widgets.add( + Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 8)).animationDurationTicks(smeltTime)); List> inputEntries = display.getInputEntries(); - widgets.add(Widgets.createSlot(new Point(startPoint.x - 20, startPoint.y + 1)).entries(inputEntries.get(0)).markInput()); + widgets.add(Widgets.createSlot(new Point(startPoint.x - 20, startPoint.y + 1)).entries(inputEntries.get(0)) + .markInput()); if (inputEntries.size() > 1) { - widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(inputEntries.get(1)).markInput()); + widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(inputEntries.get(1)) + .markInput()); } else { - widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(Lists.newArrayList()).markInput()); + widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(Lists.newArrayList()) + .markInput()); } - widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 9)).entries(display.getResultingEntries().get(0)).disableBackground().markOutput()); + widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 9)) + .entries(display.getResultingEntries().get(0)).disableBackground().markOutput()); return widgets; } @@ -71,17 +79,19 @@ public class REIAlloyingCategory implements TransferRecipeCategory fuel; - + private Recipe recipe; private List> input; private List output; private float xp; private double smeltTime; - + public REIAlloyingDisplay(AlloyingRecipe recipe) { this.recipe = recipe; this.input = EntryStack.ofIngredients(recipe.getPreviewInputs()); @@ -37,7 +37,7 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay { this.xp = recipe.getExperience(); this.smeltTime = recipe.getSmeltTime(); } - + public REIAlloyingDisplay(BlastingRecipe recipe) { this.recipe = recipe; this.input = EntryStack.ofIngredients(recipe.getPreviewInputs()); @@ -45,44 +45,44 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay { this.xp = recipe.getExperience(); this.smeltTime = recipe.getCookTime(); } - + public static List getFuel() { return fuel; } - + @Override - public @NotNull Optional getRecipeLocation() { + public @NotNull Optional getRecipeLocation() { return Optional.ofNullable(recipe).map(Recipe::getId); } - + @Override public @NotNull List> getInputEntries() { return this.input; } - + @Override public @NotNull List> getResultingEntries() { return Collections.singletonList(output); } @Override - public @NotNull Identifier getRecipeCategory() { + public @NotNull ResourceLocation getRecipeCategory() { return AlloyingRecipe.ID; } - + @Override public @NotNull List> getRequiredEntries() { return this.input; } - + public float getXp() { return this.xp; } - + public double getSmeltTime() { return this.smeltTime; } - + public Optional> getOptionalRecipe() { return Optional.ofNullable(recipe); } @@ -98,14 +98,17 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay { } @Override - public List> getOrganisedInputEntries(ContainerInfo containerInfo, ScreenHandler container) { + public List> getOrganisedInputEntries(ContainerInfo containerInfo, + ScreenHandler container) { return this.input; } - + static { - fuel = EndStoneSmelterBlockEntity.availableFuels().keySet().stream() - .map(Item::getDefaultStack).map(EntryStack::create) - .map(e -> e.setting(EntryStack.Settings.TOOLTIP_APPEND_EXTRA, stack -> Collections.singletonList(new TranslatableText("category.rei.smelting.fuel") - .formatted(Formatting.YELLOW)))).collect(Collectors.toList()); + fuel = EndStoneSmelterBlockEntity.availableFuels().keySet().stream().map(Item::getDefaultStack) + .map(EntryStack::create) + .map(e -> e.setting(EntryStack.Properties.TOOLTIP_APPEND_EXTRA, + stack -> Collections.singletonList( + new TranslatableText("category.rei.smelting.fuel").formatted(Formatting.YELLOW)))) + .collect(Collectors.toList()); } } diff --git a/src/main/java/ru/betterend/integration/rei/REIAlloyingFuelCategory.java b/src/main/java/ru/betterend/integration/rei/REIAlloyingFuelCategory.java index 1d1856f7..6869324d 100644 --- a/src/main/java/ru/betterend/integration/rei/REIAlloyingFuelCategory.java +++ b/src/main/java/ru/betterend/integration/rei/REIAlloyingFuelCategory.java @@ -20,15 +20,15 @@ import me.shedaniel.rei.gui.widget.Widget; import net.minecraft.client.MinecraftClient; import net.minecraft.client.resource.language.I18n; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.item.Items; +import net.minecraft.world.item.Items; import net.minecraft.text.TranslatableText; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; public class REIAlloyingFuelCategory implements RecipeCategory { private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##"); @Override - public @NotNull Identifier getIdentifier() { + public @NotNull ResourceLocation getIdentifier() { return REIPlugin.ALLOYING_FUEL; } @@ -53,16 +53,21 @@ public class REIAlloyingFuelCategory implements RecipeCategory widgets = Lists.newArrayList(); widgets.add(Widgets.createRecipeBase(bounds)); - widgets.add(Widgets.createLabel(new Point(bounds.x + 26, bounds.getMaxY() - 15), new TranslatableText("category.rei.fuel.time", burnTime)) + widgets.add(Widgets + .createLabel(new Point(bounds.x + 26, bounds.getMaxY() - 15), + new TranslatableText("category.rei.fuel.time", burnTime)) .color(0xFF404040, 0xFFBBBBBB).noShadow().leftAligned()); - widgets.add(Widgets.createBurningFire(new Point(bounds.x + 6, startPoint.y + 1)).animationDurationTicks(recipeDisplay.getFuelTime())); - widgets.add(Widgets.createSlot(new Point(bounds.x + 6, startPoint.y + 18)).entries(recipeDisplay.getInputEntries().get(0)).markInput()); + widgets.add(Widgets.createBurningFire(new Point(bounds.x + 6, startPoint.y + 1)) + .animationDurationTicks(recipeDisplay.getFuelTime())); + widgets.add(Widgets.createSlot(new Point(bounds.x + 6, startPoint.y + 18)) + .entries(recipeDisplay.getInputEntries().get(0)).markInput()); return widgets; } @Override public @NotNull RecipeEntry getSimpleRenderer(REIAlloyingFuelDisplay recipe) { - Slot slot = Widgets.createSlot(new Point(0, 0)).entries(recipe.getInputEntries().get(0)).disableBackground().disableHighlight(); + Slot slot = Widgets.createSlot(new Point(0, 0)).entries(recipe.getInputEntries().get(0)).disableBackground() + .disableHighlight(); String burnItems = DECIMAL_FORMAT.format(recipe.getFuelTime() / 200d); return new RecipeEntry() { private TranslatableText text = new TranslatableText("category.rei.fuel.time_short.items", burnItems); @@ -85,7 +90,8 @@ public class REIAlloyingFuelCategory implements RecipeCategory { @Override - public @NotNull Identifier getIdentifier() { + public @NotNull ResourceLocation getIdentifier() { return REIPlugin.SMITHING; } @@ -39,12 +39,12 @@ public class REIAnvilCategory implements TransferRecipeCategory public @NotNull String getCategoryName() { return LangUtil.translate(Blocks.ANVIL.getTranslationKey()); } - + @Override public @NotNull EntryStack getLogo() { return REIPlugin.ANVILS[0]; } - + @Override public @NotNull List setupDisplay(REIAnvilDisplay display, Rectangle bounds) { Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10); @@ -65,11 +65,14 @@ public class REIAnvilCategory implements TransferRecipeCategory }).collect(Collectors.toList()); materials.forEach(entryStack -> entryStack.setAmount(display.getInputCount())); widgets.add(Widgets.createArrow(new Point(x + 24, y + 4))); - widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 7, bounds.y + bounds.height - 15), - new TranslatableText("category.rei.damage.amount&dmg", display.getDamage())).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB)); + widgets.add(Widgets + .createLabel(new Point(bounds.x + bounds.width - 7, bounds.y + bounds.height - 15), + new TranslatableText("category.rei.damage.amount&dmg", display.getDamage())) + .noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB)); widgets.add(Widgets.createSlot(new Point(x - 20, y + 4)).entries(materials).markInput()); widgets.add(Widgets.createSlot(new Point(x + 1, y + 4)).entries(inputEntries.get(0)).markInput()); - widgets.add(Widgets.createSlot(new Point(x + 61, y + 5)).entries(display.getResultingEntries().get(0)).disableBackground().markOutput()); + widgets.add(Widgets.createSlot(new Point(x + 61, y + 5)).entries(display.getResultingEntries().get(0)) + .disableBackground().markOutput()); widgets.add(Widgets.createSlot(new Point(x - 9, y + 25)).entries(anvils)); return widgets; @@ -82,17 +85,20 @@ public class REIAnvilCategory implements TransferRecipeCategory matrices.push(); matrices.translate(0, 0, 400); if (redSlots.contains(0)) { - DrawableHelper.fill(matrices, startPoint.x - 20, startPoint.y + 3, startPoint.x - 20 + 16, startPoint.y + 3 + 16, 1090453504); - DrawableHelper.fill(matrices, startPoint.x + 1, startPoint.y + 3, startPoint.x + 1 + 16, startPoint.y + 3 + 16, 1090453504); + DrawableHelper.fill(matrices, startPoint.x - 20, startPoint.y + 3, startPoint.x - 20 + 16, + startPoint.y + 3 + 16, 1090453504); + DrawableHelper.fill(matrices, startPoint.x + 1, startPoint.y + 3, startPoint.x + 1 + 16, + startPoint.y + 3 + 16, 1090453504); } matrices.pop(); } - + @Override public @NotNull RecipeEntry getSimpleRenderer(REIAnvilDisplay recipe) { - return SimpleRecipeEntry.from(Collections.singletonList(recipe.getInputEntries().get(0)), recipe.getResultingEntries()); + return SimpleRecipeEntry.from(Collections.singletonList(recipe.getInputEntries().get(0)), + recipe.getResultingEntries()); } - + @Override public int getDisplayHeight() { return 60; diff --git a/src/main/java/ru/betterend/integration/rei/REIAnvilDisplay.java b/src/main/java/ru/betterend/integration/rei/REIAnvilDisplay.java index 3381f2fb..2da35b4d 100644 --- a/src/main/java/ru/betterend/integration/rei/REIAnvilDisplay.java +++ b/src/main/java/ru/betterend/integration/rei/REIAnvilDisplay.java @@ -9,23 +9,23 @@ import org.jetbrains.annotations.NotNull; import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.TransferRecipeDisplay; import me.shedaniel.rei.server.ContainerInfo; -import net.minecraft.recipe.Recipe; +import net.minecraft.world.item.crafting.Recipe; import net.minecraft.screen.ScreenHandler; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import ru.betterend.recipe.builders.AnvilRecipe; public class REIAnvilDisplay implements TransferRecipeDisplay { - + private final AnvilRecipe recipe; private final List> input; private final List output; - + public REIAnvilDisplay(AnvilRecipe recipe) { this.recipe = recipe; this.input = EntryStack.ofIngredients(recipe.getPreviewInputs()); this.output = Collections.singletonList(EntryStack.create(recipe.getOutput())); } - + public int getDamage() { return recipe.getDamage(); } @@ -37,9 +37,9 @@ public class REIAnvilDisplay implements TransferRecipeDisplay { public int getAnvilLevel() { return recipe.getAnvilLevel(); } - + @Override - public @NotNull Optional getRecipeLocation() { + public @NotNull Optional getRecipeLocation() { return Optional.ofNullable(recipe).map(Recipe::getId); } @@ -47,17 +47,17 @@ public class REIAnvilDisplay implements TransferRecipeDisplay { public @NotNull List> getInputEntries() { return this.input; } - + @Override public @NotNull List> getResultingEntries() { return Collections.singletonList(output); } @Override - public @NotNull Identifier getRecipeCategory() { + public @NotNull ResourceLocation getRecipeCategory() { return REIPlugin.SMITHING; } - + @Override public @NotNull List> getRequiredEntries() { return input; diff --git a/src/main/java/ru/betterend/integration/rei/REIInfusionCategory.java b/src/main/java/ru/betterend/integration/rei/REIInfusionCategory.java index 6821a790..d7ea7884 100644 --- a/src/main/java/ru/betterend/integration/rei/REIInfusionCategory.java +++ b/src/main/java/ru/betterend/integration/rei/REIInfusionCategory.java @@ -17,18 +17,18 @@ import me.shedaniel.rei.gui.entries.SimpleRecipeEntry; import me.shedaniel.rei.gui.widget.Widget; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.TranslatableText; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import ru.betterend.BetterEnd; import ru.betterend.recipe.builders.InfusionRecipe; import ru.betterend.registry.EndBlocks; import ru.betterend.util.LangUtil; public class REIInfusionCategory implements TransferRecipeCategory { - - private final static Identifier BACKGROUND = BetterEnd.makeID("textures/gui/rei_infusion.png"); + + private final static ResourceLocation BACKGROUND = BetterEnd.makeID("textures/gui/rei_infusion.png"); @Override - public @NotNull Identifier getIdentifier() { + public @NotNull ResourceLocation getIdentifier() { return InfusionRecipe.ID; } @@ -36,17 +36,17 @@ public class REIInfusionCategory implements TransferRecipeCategory setupDisplay(REIInfusionDisplay display, Rectangle bounds) { Point centerPoint = new Point(bounds.getCenterX() - 34, bounds.getCenterY() - 2); @@ -56,24 +56,36 @@ public class REIInfusionCategory implements TransferRecipeCategory> outputEntries = display.getResultingEntries(); widgets.add(Widgets.createTexturedWidget(BACKGROUND, bounds.x, bounds.y, 0, 0, 150, 104, 150, 104)); widgets.add(Widgets.createSlot(centerPoint).entries(inputEntries.get(0)).disableBackground().markInput()); - widgets.add(Widgets.createSlot(new Point(centerPoint.x, centerPoint.y - 28)).entries(inputEntries.get(1)).disableBackground().markInput()); - widgets.add(Widgets.createSlot(new Point(centerPoint.x + 28, centerPoint.y)).entries(inputEntries.get(3)).disableBackground().markInput()); - widgets.add(Widgets.createSlot(new Point(centerPoint.x, centerPoint.y + 28)).entries(inputEntries.get(5)).disableBackground().markInput()); - widgets.add(Widgets.createSlot(new Point(centerPoint.x - 28, centerPoint.y)).entries(inputEntries.get(7)).disableBackground().markInput()); - widgets.add(Widgets.createSlot(new Point(centerPoint.x + 24, centerPoint.y - 24)).entries(inputEntries.get(2)).disableBackground().markInput()); - widgets.add(Widgets.createSlot(new Point(centerPoint.x + 24, centerPoint.y + 24)).entries(inputEntries.get(4)).disableBackground().markInput()); - widgets.add(Widgets.createSlot(new Point(centerPoint.x - 24, centerPoint.y + 24)).entries(inputEntries.get(6)).disableBackground().markInput()); - widgets.add(Widgets.createSlot(new Point(centerPoint.x - 24, centerPoint.y - 24)).entries(inputEntries.get(8)).disableBackground().markInput()); - widgets.add(Widgets.createSlot(new Point(centerPoint.x + 80, centerPoint.y)).entries(outputEntries.get(0)).disableBackground().markOutput()); - widgets.add(Widgets.createLabel(new Point(bounds.getMaxX() - 5, bounds.y + 6), new TranslatableText("category.rei.infusion.time&val", display.getInfusionTime())) + widgets.add(Widgets.createSlot(new Point(centerPoint.x, centerPoint.y - 28)).entries(inputEntries.get(1)) + .disableBackground().markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x + 28, centerPoint.y)).entries(inputEntries.get(3)) + .disableBackground().markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x, centerPoint.y + 28)).entries(inputEntries.get(5)) + .disableBackground().markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x - 28, centerPoint.y)).entries(inputEntries.get(7)) + .disableBackground().markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x + 24, centerPoint.y - 24)).entries(inputEntries.get(2)) + .disableBackground().markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x + 24, centerPoint.y + 24)).entries(inputEntries.get(4)) + .disableBackground().markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x - 24, centerPoint.y + 24)).entries(inputEntries.get(6)) + .disableBackground().markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x - 24, centerPoint.y - 24)).entries(inputEntries.get(8)) + .disableBackground().markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x + 80, centerPoint.y)).entries(outputEntries.get(0)) + .disableBackground().markOutput()); + widgets.add(Widgets + .createLabel(new Point(bounds.getMaxX() - 5, bounds.y + 6), + new TranslatableText("category.rei.infusion.time&val", display.getInfusionTime())) .noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB)); return widgets; } @Override - public void renderRedSlots(MatrixStack matrices, List widgets, Rectangle bounds, - REIInfusionDisplay display, IntList redSlots) {} - + public void renderRedSlots(MatrixStack matrices, List widgets, Rectangle bounds, REIInfusionDisplay display, + IntList redSlots) { + } + @Override public int getDisplayHeight() { return 104; diff --git a/src/main/java/ru/betterend/integration/rei/REIInfusionDisplay.java b/src/main/java/ru/betterend/integration/rei/REIInfusionDisplay.java index 9e77e114..86313c99 100644 --- a/src/main/java/ru/betterend/integration/rei/REIInfusionDisplay.java +++ b/src/main/java/ru/betterend/integration/rei/REIInfusionDisplay.java @@ -11,36 +11,36 @@ import com.google.common.collect.Lists; import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.TransferRecipeDisplay; import me.shedaniel.rei.server.ContainerInfo; -import net.minecraft.recipe.Recipe; +import net.minecraft.world.item.crafting.Recipe; import net.minecraft.screen.ScreenHandler; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import ru.betterend.recipe.builders.AlloyingRecipe; import ru.betterend.recipe.builders.InfusionRecipe; public class REIInfusionDisplay implements TransferRecipeDisplay { - + private final InfusionRecipe recipe; private final List> input; private final List output; private final int time; - + public REIInfusionDisplay(InfusionRecipe recipe) { this.recipe = recipe; this.input = Lists.newArrayList(); this.output = Collections.singletonList(EntryStack.create(recipe.getOutput())); this.time = recipe.getInfusionTime(); - + recipe.getPreviewInputs().forEach(ingredient -> { input.add(EntryStack.ofIngredient(ingredient)); }); } - + public int getInfusionTime() { return this.time; } - + @Override - public @NotNull Optional getRecipeLocation() { + public @NotNull Optional getRecipeLocation() { return Optional.ofNullable(recipe).map(Recipe::getId); } @@ -48,17 +48,17 @@ public class REIInfusionDisplay implements TransferRecipeDisplay { public @NotNull List> getInputEntries() { return this.input; } - + @Override public @NotNull List> getResultingEntries() { return Collections.singletonList(output); } @Override - public @NotNull Identifier getRecipeCategory() { + public @NotNull ResourceLocation getRecipeCategory() { return AlloyingRecipe.ID; } - + @Override public @NotNull List> getRequiredEntries() { return this.input; @@ -75,7 +75,8 @@ public class REIInfusionDisplay implements TransferRecipeDisplay { } @Override - public List> getOrganisedInputEntries(ContainerInfo containerInfo, ScreenHandler container) { + public List> getOrganisedInputEntries(ContainerInfo containerInfo, + ScreenHandler container) { return this.input; } } diff --git a/src/main/java/ru/betterend/integration/rei/REIPlugin.java b/src/main/java/ru/betterend/integration/rei/REIPlugin.java index 1a83a037..3232fd8e 100644 --- a/src/main/java/ru/betterend/integration/rei/REIPlugin.java +++ b/src/main/java/ru/betterend/integration/rei/REIPlugin.java @@ -12,10 +12,10 @@ import me.shedaniel.rei.plugin.DefaultPlugin; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.impl.content.registry.FuelRegistryImpl; -import net.minecraft.block.Blocks; -import net.minecraft.item.BlockItem; -import net.minecraft.recipe.BlastingRecipe; -import net.minecraft.util.Identifier; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.crafting.BlastingRecipe; +import net.minecraft.resources.ResourceLocation; import ru.betterend.BetterEnd; import ru.betterend.blocks.basis.EndAnvilBlock; import ru.betterend.blocks.basis.EndFurnaceBlock; @@ -28,11 +28,11 @@ import ru.betterend.registry.EndItems; @Environment(EnvType.CLIENT) public class REIPlugin implements REIPluginV0 { - public final static Identifier PLUGIN_ID = BetterEnd.makeID("rei_plugin"); - public final static Identifier ALLOYING_FUEL = BetterEnd.makeID("alloying_fuel"); - public final static Identifier ALLOYING = AlloyingRecipe.ID; - public final static Identifier SMITHING = AnvilRecipe.ID; - public final static Identifier INFUSION = InfusionRecipe.ID; + public final static ResourceLocation PLUGIN_ID = BetterEnd.makeID("rei_plugin"); + public final static ResourceLocation ALLOYING_FUEL = BetterEnd.makeID("alloying_fuel"); + public final static ResourceLocation ALLOYING = AlloyingRecipe.ID; + public final static ResourceLocation SMITHING = AnvilRecipe.ID; + public final static ResourceLocation INFUSION = InfusionRecipe.ID; public final static EntryStack END_STONE_SMELTER = EntryStack.create(EndBlocks.END_STONE_SMELTER); public final static EntryStack INFUSION_RITUAL = EntryStack.create(EndBlocks.INFUSION_PEDESTAL); @@ -40,12 +40,12 @@ public class REIPlugin implements REIPluginV0 { public final static EntryStack[] ANVILS; @Override - public Identifier getPluginIdentifier() { + public ResourceLocation getPluginIdentifier() { return PLUGIN_ID; } - + @Override - public void registerRecipeDisplays(RecipeHelper recipeHelper) { + public void registerRecipeDisplays(RecipeHelper recipeHelper) { recipeHelper.registerRecipes(ALLOYING, AlloyingRecipe.class, REIAlloyingDisplay::new); recipeHelper.registerRecipes(ALLOYING, BlastingRecipe.class, REIAlloyingDisplay::new); recipeHelper.registerRecipes(SMITHING, AnvilRecipe.class, REIAnvilDisplay::new); @@ -56,7 +56,7 @@ public class REIPlugin implements REIPluginV0 { } }); } - + @Override public void registerOthers(RecipeHelper recipeHelper) { recipeHelper.registerWorkingStations(ALLOYING_FUEL, END_STONE_SMELTER); @@ -68,15 +68,12 @@ public class REIPlugin implements REIPluginV0 { recipeHelper.registerWorkingStations(DefaultPlugin.SMELTING, FURNACES); recipeHelper.registerWorkingStations(DefaultPlugin.FUEL, FURNACES); - } - + } + @Override public void registerPluginCategories(RecipeHelper recipeHelper) { - recipeHelper.registerCategories( - new REIAlloyingFuelCategory(), - new REIAlloyingCategory(), - new REIInfusionCategory(), - new REIAnvilCategory()); + recipeHelper.registerCategories(new REIAlloyingFuelCategory(), new REIAlloyingCategory(), + new REIInfusionCategory(), new REIAnvilCategory()); } static { diff --git a/src/main/java/ru/betterend/interfaces/IBiomeArray.java b/src/main/java/ru/betterend/interfaces/IBiomeArray.java index 8916cd5c..264a1eba 100644 --- a/src/main/java/ru/betterend/interfaces/IBiomeArray.java +++ b/src/main/java/ru/betterend/interfaces/IBiomeArray.java @@ -1,6 +1,6 @@ package ru.betterend.interfaces; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.biome.Biome; public interface IBiomeArray { diff --git a/src/main/java/ru/betterend/interfaces/IColorProvider.java b/src/main/java/ru/betterend/interfaces/IColorProvider.java index ae6d0db5..2c0100da 100644 --- a/src/main/java/ru/betterend/interfaces/IColorProvider.java +++ b/src/main/java/ru/betterend/interfaces/IColorProvider.java @@ -1,10 +1,9 @@ package ru.betterend.interfaces; -import net.minecraft.client.color.block.BlockColorProvider; -import net.minecraft.client.color.item.ItemColorProvider; +import net.minecraft.client.color.block.BlockColor; +import net.minecraft.client.color.item.ItemColor; public interface IColorProvider { - BlockColorProvider getProvider(); - - ItemColorProvider getItemProvider(); + BlockColor getBlockProvider(); + ItemColor getItemProvider(); } diff --git a/src/main/java/ru/betterend/interfaces/IRenderTypeable.java b/src/main/java/ru/betterend/interfaces/IRenderTypeable.java index 1a5c029c..96f961ba 100644 --- a/src/main/java/ru/betterend/interfaces/IRenderTypeable.java +++ b/src/main/java/ru/betterend/interfaces/IRenderTypeable.java @@ -4,5 +4,5 @@ import ru.betterend.client.render.ERenderLayer; public interface IRenderTypeable { - public ERenderLayer getRenderLayer(); + ERenderLayer getRenderLayer(); } diff --git a/src/main/java/ru/betterend/interfaces/TeleportingEntity.java b/src/main/java/ru/betterend/interfaces/TeleportingEntity.java index 76cf8c24..f339e736 100644 --- a/src/main/java/ru/betterend/interfaces/TeleportingEntity.java +++ b/src/main/java/ru/betterend/interfaces/TeleportingEntity.java @@ -1,9 +1,11 @@ package ru.betterend.interfaces; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; public interface TeleportingEntity { void beSetExitPos(BlockPos pos); + void beResetExitPos(); + boolean beCanTeleport(); } diff --git a/src/main/java/ru/betterend/item/DrinkItem.java b/src/main/java/ru/betterend/item/DrinkItem.java index 2dd617c8..78c78eaf 100644 --- a/src/main/java/ru/betterend/item/DrinkItem.java +++ b/src/main/java/ru/betterend/item/DrinkItem.java @@ -1,20 +1,20 @@ package ru.betterend.item; import net.minecraft.advancement.criterion.Criteria; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUsage; -import net.minecraft.item.Items; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemUsage; +import net.minecraft.world.item.Items; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.stat.Stats; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; import net.minecraft.util.UseAction; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; public class DrinkItem extends PatternedItem { - public DrinkItem(Settings settings) { + public DrinkItem(Properties settings) { super(settings); } @@ -29,14 +29,14 @@ public class DrinkItem extends PatternedItem { } @Override - public TypedActionResult use(World world, PlayerEntity user, Hand hand) { + public TypedActionResult use(Level world, PlayerEntity user, Hand hand) { return ItemUsage.consumeHeldItem(world, user, hand); } @Override - public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) { - if (user instanceof ServerPlayerEntity) { - ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) user; + public ItemStack finishUsing(ItemStack stack, Level world, LivingEntity user) { + if (user instanceof ServerPlayer) { + ServerPlayer serverPlayerEntity = (ServerPlayer) user; Criteria.CONSUME_ITEM.trigger(serverPlayerEntity, stack); serverPlayerEntity.incrementStat(Stats.USED.getOrCreateStat(this)); } @@ -45,7 +45,7 @@ public class DrinkItem extends PatternedItem { stack.decrement(1); } - if (!world.isClient) { + if (!world.isClientSide) { user.clearStatusEffects(); } diff --git a/src/main/java/ru/betterend/item/EnchantedPetalItem.java b/src/main/java/ru/betterend/item/EnchantedPetalItem.java index 93e75b96..9ede5983 100644 --- a/src/main/java/ru/betterend/item/EnchantedPetalItem.java +++ b/src/main/java/ru/betterend/item/EnchantedPetalItem.java @@ -1,7 +1,7 @@ package ru.betterend.item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Rarity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Rarity; import ru.betterend.patterns.Patterns; import ru.betterend.registry.EndItems; @@ -14,7 +14,7 @@ public class EnchantedPetalItem extends PatternedItem { public boolean hasGlint(ItemStack stack) { return true; } - + @Override public String getModelPattern(String name) { return Patterns.createJson(Patterns.ITEM_GENERATED, "item/hydralux_petal"); diff --git a/src/main/java/ru/betterend/item/EndArmorItem.java b/src/main/java/ru/betterend/item/EndArmorItem.java index dc298f2f..0d9bfe05 100644 --- a/src/main/java/ru/betterend/item/EndArmorItem.java +++ b/src/main/java/ru/betterend/item/EndArmorItem.java @@ -5,26 +5,27 @@ import java.util.UUID; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Multimap; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.item.ArmorItem; -import net.minecraft.item.ArmorMaterial; -import net.minecraft.item.Item; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.attribute.EntityAttribute; +import net.minecraft.world.entity.attribute.EntityAttributeModifier; +import net.minecraft.world.entity.attribute.EntityAttributes; +import net.minecraft.world.item.ArmorItem; +import net.minecraft.world.item.ArmorMaterial; +import net.minecraft.world.item.Item; import ru.betterend.mixin.common.ArmorItemAccessor; import ru.betterend.patterns.Patterned; import ru.betterend.patterns.Patterns; public class EndArmorItem extends ArmorItem implements Patterned { - public EndArmorItem(ArmorMaterial material, EquipmentSlot slot, Item.Settings settings) { + public EndArmorItem(ArmorMaterial material, EquipmentSlot slot, Item.Properties settings) { super(material, slot, settings); addKnockbackResistance((ArmorItemAccessor) this, slot, this.knockbackResistance); } /** Ensures knockback resistance is actually applied */ - private static void addKnockbackResistance(ArmorItemAccessor accessor, EquipmentSlot slot, double knockbackResistance) { + private static void addKnockbackResistance(ArmorItemAccessor accessor, EquipmentSlot slot, + double knockbackResistance) { if (knockbackResistance == 0) { return; } @@ -41,7 +42,8 @@ public class EndArmorItem extends ArmorItem implements Patterned { // Rebuild attributeModifiers to include knockback resistance ImmutableMultimap.Builder builder = ImmutableMultimap.builder(); builder.putAll(attributeModifiers); - builder.put(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(uuid, "Armor knockback resistance", knockbackResistance, EntityAttributeModifier.Operation.ADDITION)); + builder.put(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(uuid, + "Armor knockback resistance", knockbackResistance, EntityAttributeModifier.Operation.ADDITION)); accessor.be_setAttributeModifiers(builder.build()); } diff --git a/src/main/java/ru/betterend/item/EndSpawnEggItem.java b/src/main/java/ru/betterend/item/EndSpawnEggItem.java index 0987e685..419136ec 100644 --- a/src/main/java/ru/betterend/item/EndSpawnEggItem.java +++ b/src/main/java/ru/betterend/item/EndSpawnEggItem.java @@ -1,15 +1,15 @@ package ru.betterend.item; -import net.minecraft.entity.EntityType; -import net.minecraft.item.SpawnEggItem; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.SpawnEggItem; import ru.betterend.patterns.Patterned; import ru.betterend.patterns.Patterns; public class EndSpawnEggItem extends SpawnEggItem implements Patterned { - public EndSpawnEggItem(EntityType type, int primaryColor, int secondaryColor, Settings settings) { + public EndSpawnEggItem(EntityType type, int primaryColor, int secondaryColor, Properties settings) { super(type, primaryColor, secondaryColor, settings); } - + @Override public String getModelPattern(String name) { return Patterns.createJson(Patterns.ITEM_SPAWN_EGG, name); diff --git a/src/main/java/ru/betterend/item/EternalCrystalItem.java b/src/main/java/ru/betterend/item/EternalCrystalItem.java index 1ad6bb40..3466577e 100644 --- a/src/main/java/ru/betterend/item/EternalCrystalItem.java +++ b/src/main/java/ru/betterend/item/EternalCrystalItem.java @@ -1,6 +1,6 @@ package ru.betterend.item; -import net.minecraft.util.Rarity; +import net.minecraft.world.item.Rarity; import ru.betterend.registry.EndItems; public class EternalCrystalItem extends PatternedItem { diff --git a/src/main/java/ru/betterend/item/GuideBookItem.java b/src/main/java/ru/betterend/item/GuideBookItem.java index 17309d80..ad652d22 100644 --- a/src/main/java/ru/betterend/item/GuideBookItem.java +++ b/src/main/java/ru/betterend/item/GuideBookItem.java @@ -3,42 +3,44 @@ package ru.betterend.item; import java.util.List; import net.minecraft.client.item.TooltipContext; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.Hand; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.TypedActionResult; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.BetterEnd; import ru.betterend.registry.EndItems; import ru.betterend.util.LangUtil; import vazkii.patchouli.api.PatchouliAPI; public class GuideBookItem extends PatternedItem { - public final static Identifier BOOK_ID = BetterEnd.makeID("guidebook"); - public static final Item GUIDE_BOOK = EndItems.registerItem(BOOK_ID, new GuideBookItem()); - - public static void register() {} - - public GuideBookItem() { - super(EndItems.makeItemSettings().maxCount(1)); - } - + public final static ResourceLocation BOOK_ID = BetterEnd.makeID("guidebook"); + public static final Item GUIDE_BOOK = EndItems.registerItem(BOOK_ID, new GuideBookItem()); + + public static void register() { + } + + public GuideBookItem() { + super(EndItems.makeItemSettings().maxCount(1)); + } + @Override - public TypedActionResult use(World world, PlayerEntity user, Hand hand) { - if (!world.isClient && user instanceof ServerPlayerEntity) { - PatchouliAPI.get().openBookGUI((ServerPlayerEntity) user, BOOK_ID); + public TypedActionResult use(Level world, PlayerEntity user, Hand hand) { + if (!world.isClientSide && user instanceof ServerPlayer) { + PatchouliAPI.get().openBookGUI((ServerPlayer) user, BOOK_ID); return TypedActionResult.success(user.getStackInHand(hand)); } return TypedActionResult.consume(user.getStackInHand(hand)); } @Override - public void appendTooltip(ItemStack stack, World world, List tooltip, TooltipContext context) { - tooltip.add(LangUtil.getText("book.betterend", "subtitle").formatted(Formatting.DARK_PURPLE, Formatting.ITALIC)); + public void appendTooltip(ItemStack stack, Level world, List tooltip, TooltipContext context) { + tooltip.add( + LangUtil.getText("book.betterend", "subtitle").formatted(Formatting.DARK_PURPLE, Formatting.ITALIC)); } } diff --git a/src/main/java/ru/betterend/item/PatternedDiscItem.java b/src/main/java/ru/betterend/item/PatternedDiscItem.java index 6f8b9d54..dca0c763 100644 --- a/src/main/java/ru/betterend/item/PatternedDiscItem.java +++ b/src/main/java/ru/betterend/item/PatternedDiscItem.java @@ -1,12 +1,12 @@ package ru.betterend.item; -import net.minecraft.item.MusicDiscItem; +import net.minecraft.world.item.MusicDiscItem; import net.minecraft.sound.SoundEvent; import ru.betterend.patterns.Patterned; import ru.betterend.patterns.Patterns; public class PatternedDiscItem extends MusicDiscItem implements Patterned { - public PatternedDiscItem(int comparatorOutput, SoundEvent sound, Settings settings) { + public PatternedDiscItem(int comparatorOutput, SoundEvent sound, Properties settings) { super(comparatorOutput, sound, settings); } diff --git a/src/main/java/ru/betterend/item/PatternedItem.java b/src/main/java/ru/betterend/item/PatternedItem.java index c2b8eeff..de970bb6 100644 --- a/src/main/java/ru/betterend/item/PatternedItem.java +++ b/src/main/java/ru/betterend/item/PatternedItem.java @@ -1,14 +1,14 @@ package ru.betterend.item; -import net.minecraft.item.Item; +import net.minecraft.world.item.Item; import ru.betterend.patterns.Patterned; import ru.betterend.patterns.Patterns; public class PatternedItem extends Item implements Patterned { - public PatternedItem(Settings settings) { + public PatternedItem(Properties settings) { super(settings); } - + @Override public String getModelPattern(String name) { return Patterns.createJson(Patterns.ITEM_GENERATED, name); diff --git a/src/main/java/ru/betterend/item/material/EndArmorMaterial.java b/src/main/java/ru/betterend/item/material/EndArmorMaterial.java index 9916cb8d..c80e094c 100644 --- a/src/main/java/ru/betterend/item/material/EndArmorMaterial.java +++ b/src/main/java/ru/betterend/item/material/EndArmorMaterial.java @@ -4,27 +4,26 @@ import java.util.function.Supplier; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.item.ArmorMaterial; -import net.minecraft.recipe.Ingredient; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorMaterial; +import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.sound.SoundEvent; -import net.minecraft.sound.SoundEvents; -import net.minecraft.util.Lazy; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.util.LazyLoadedValue; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndItems; public enum EndArmorMaterial implements ArmorMaterial { THALLASIUM("thallasium", 17, new int[] { 1, 4, 5, 2 }, 12, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 0.0F, 0.0F, () -> { - return Ingredient.ofItems(EndBlocks.THALLASIUM.ingot); - }), - TERMINITE("terminite", 26, new int[] { 3, 6, 7, 3 }, 14, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 1.0F, 0.05F, () -> { - return Ingredient.ofItems(EndBlocks.TERMINITE.ingot); + return Ingredient.of(EndBlocks.THALLASIUM.ingot); + }), TERMINITE("terminite", 26, new int[] { 3, 6, 7, 3 }, 14, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 1.0F, 0.05F, () -> { + return Ingredient.of(EndBlocks.TERMINITE.ingot); }), AETERNIUM("aeternium", 40, new int[] { 4, 7, 9, 4 }, 18, SoundEvents.ITEM_ARMOR_EQUIP_NETHERITE, 3.5F, 0.2F, () -> { - return Ingredient.ofItems(EndItems.AETERNIUM_INGOT); + return Ingredient.of(EndItems.AETERNIUM_INGOT); }), CRYSTALITE("crystalite", 30, new int[] { 3, 6, 8, 3 }, 24, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 1.2F, 0.1F, () -> { - return Ingredient.ofItems(EndBlocks.TERMINITE.ingot); + return Ingredient.of(EndBlocks.TERMINITE.ingot); }); private static final int[] BASE_DURABILITY = new int[] { 13, 15, 16, 11 }; @@ -35,12 +34,11 @@ public enum EndArmorMaterial implements ArmorMaterial { private final SoundEvent equipSound; private final float toughness; private final float knockbackResistance; - private final Lazy repairIngredient; - + private final LazyLoadedValue repairIngredient; + private EndArmorMaterial(String name, int durabilityMultiplier, int[] protectionAmounts, int enchantability, - SoundEvent equipSound, float toughness, float knockbackResistance, - Supplier repairIngredient) { - + SoundEvent equipSound, float toughness, float knockbackResistance, Supplier repairIngredient) { + this.name = name; this.durabilityMultiplier = durabilityMultiplier; this.protectionAmounts = protectionAmounts; @@ -48,7 +46,7 @@ public enum EndArmorMaterial implements ArmorMaterial { this.equipSound = equipSound; this.toughness = toughness; this.knockbackResistance = knockbackResistance; - this.repairIngredient = new Lazy<>(repairIngredient); + this.repairIngredient = new LazyLoadedValue<>(repairIngredient); } @Override diff --git a/src/main/java/ru/betterend/item/material/EndToolMaterial.java b/src/main/java/ru/betterend/item/material/EndToolMaterial.java index de508032..151e683e 100644 --- a/src/main/java/ru/betterend/item/material/EndToolMaterial.java +++ b/src/main/java/ru/betterend/item/material/EndToolMaterial.java @@ -2,21 +2,19 @@ package ru.betterend.item.material; import java.util.function.Supplier; -import net.minecraft.item.ToolMaterial; -import net.minecraft.recipe.Ingredient; -import net.minecraft.util.Lazy; +import net.minecraft.util.LazyLoadedValue; +import net.minecraft.world.item.Tier; +import net.minecraft.world.item.crafting.Ingredient; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndItems; -public enum EndToolMaterial implements ToolMaterial { +public enum EndToolMaterial implements Tier { THALLASIUM(2, 320, 7.0F, 1.5F, 12, () -> { - return Ingredient.ofItems(EndBlocks.THALLASIUM.ingot); - }), - TERMINITE(3, 1230, 8.5F, 3.0F, 14, () -> { - return Ingredient.ofItems(EndBlocks.TERMINITE.ingot); - }), - AETERNIUM(5, 2196, 10.0F, 4.5F, 18, () -> { - return Ingredient.ofItems(EndItems.AETERNIUM_INGOT); + return Ingredient.of(EndBlocks.THALLASIUM.ingot); + }), TERMINITE(3, 1230, 8.5F, 3.0F, 14, () -> { + return Ingredient.of(EndBlocks.TERMINITE.ingot); + }), AETERNIUM(5, 2196, 10.0F, 4.5F, 18, () -> { + return Ingredient.of(EndItems.AETERNIUM_INGOT); }); private final int durability; @@ -24,8 +22,8 @@ public enum EndToolMaterial implements ToolMaterial { private final float attackDamage; private final int miningLevel; private final int enchantability; - private final Lazy repairIngredient; - + private final LazyLoadedValue repairIngredient; + private EndToolMaterial(int miningLevel, int durability, float miningSpeed, float attackDamage, int enchantability, Supplier repairIngredient) { @@ -34,32 +32,32 @@ public enum EndToolMaterial implements ToolMaterial { this.attackDamage = attackDamage; this.miningLevel = miningLevel; this.enchantability = enchantability; - this.repairIngredient = new Lazy<>(repairIngredient); + this.repairIngredient = new LazyLoadedValue<>(repairIngredient); } @Override - public int getDurability() { - return this.durability; + public int getUses() { + return durability; } @Override - public float getMiningSpeedMultiplier() { - return this.miningSpeed; + public float getSpeed() { + return miningSpeed; } @Override - public float getAttackDamage() { - return this.attackDamage; + public float getAttackDamageBonus() { + return attackDamage; } @Override - public int getMiningLevel() { - return this.miningLevel; + public int getLevel() { + return miningLevel; } @Override - public int getEnchantability() { - return this.enchantability; + public int getEnchantmentValue() { + return enchantability; } @Override diff --git a/src/main/java/ru/betterend/item/model/CrystaliteArmorProvider.java b/src/main/java/ru/betterend/item/model/CrystaliteArmorProvider.java index c5462c51..4073824f 100644 --- a/src/main/java/ru/betterend/item/model/CrystaliteArmorProvider.java +++ b/src/main/java/ru/betterend/item/model/CrystaliteArmorProvider.java @@ -11,69 +11,73 @@ import net.fabricmc.fabric.api.client.rendering.v1.ArmorRenderingRegistry.ModelP import net.fabricmc.fabric.api.client.rendering.v1.ArmorRenderingRegistry.TextureProvider; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.render.entity.model.BipedEntityModel; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Identifier; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.resources.ResourceLocation; import ru.betterend.registry.EndItems; @Environment(EnvType.CLIENT) public class CrystaliteArmorProvider implements ModelProvider, TextureProvider { - private final static Identifier FIRST_LAYER = new Identifier("textures/models/armor/crystalite_layer_1.png"); - private final static Identifier SECOND_LAYER = new Identifier("textures/models/armor/crystalite_layer_2.png"); + private final static ResourceLocation FIRST_LAYER = new ResourceLocation( + "textures/models/armor/crystalite_layer_1.png"); + private final static ResourceLocation SECOND_LAYER = new ResourceLocation( + "textures/models/armor/crystalite_layer_2.png"); private final static CrystaliteHelmetModel HELMET_MODEL = new CrystaliteHelmetModel(1.0F); private final static CrystaliteChestplateModel CHEST_MODEL = new CrystaliteChestplateModel(1.0F, false); private final static CrystaliteChestplateModel CHEST_MODEL_SLIM = new CrystaliteChestplateModel(1.0F, true); private final static CrystaliteLeggingsModel LEGGINGS_MODEL = new CrystaliteLeggingsModel(1.0F); private final static CrystaliteBootsModel BOOTS_MODEL = new CrystaliteBootsModel(1.0F); - + @Override - public @NotNull Identifier getArmorTexture(LivingEntity entity, ItemStack stack, EquipmentSlot slot, - boolean secondLayer, @Nullable String suffix, Identifier defaultTexture) { - if (!isStackValid(stack)) return defaultTexture; - if (secondLayer) return SECOND_LAYER; + public @NotNull ResourceLocation getArmorTexture(LivingEntity entity, ItemStack stack, EquipmentSlot slot, + boolean secondLayer, @Nullable String suffix, ResourceLocation defaultTexture) { + if (!isStackValid(stack)) + return defaultTexture; + if (secondLayer) + return SECOND_LAYER; return FIRST_LAYER; } @Override public @NotNull BipedEntityModel getArmorModel(LivingEntity entity, ItemStack stack, EquipmentSlot slot, BipedEntityModel defaultModel) { - if (!isStackValid(stack)) return defaultModel; - switch(slot) { - case HEAD: { - return HELMET_MODEL; - } - case CHEST: { - if (entity instanceof AbstractClientPlayerEntity && - ((AbstractClientPlayerEntity) entity).getModel().equals("slim")) { - CHEST_MODEL_SLIM.setAttributes(defaultModel); - return CHEST_MODEL_SLIM; - } - CHEST_MODEL.setAttributes(defaultModel); - return CHEST_MODEL; - } - case LEGS: { - return LEGGINGS_MODEL; - } - case FEET: { - BOOTS_MODEL.setAttributes(defaultModel); - return BOOTS_MODEL; - } - default: { - return defaultModel; + if (!isStackValid(stack)) + return defaultModel; + switch (slot) { + case HEAD: { + return HELMET_MODEL; + } + case CHEST: { + if (entity instanceof AbstractClientPlayerEntity + && ((AbstractClientPlayerEntity) entity).getModel().equals("slim")) { + CHEST_MODEL_SLIM.setAttributes(defaultModel); + return CHEST_MODEL_SLIM; } + CHEST_MODEL.setAttributes(defaultModel); + return CHEST_MODEL; + } + case LEGS: { + return LEGGINGS_MODEL; + } + case FEET: { + BOOTS_MODEL.setAttributes(defaultModel); + return BOOTS_MODEL; + } + default: { + return defaultModel; + } } } - + public Iterable getRenderedItems() { - return Lists.newArrayList(EndItems.CRYSTALITE_HELMET, EndItems.CRYSTALITE_CHESTPLATE, EndItems.CRYSTALITE_LEGGINGS, EndItems.CRYSTALITE_BOOTS); + return Lists.newArrayList(EndItems.CRYSTALITE_HELMET, EndItems.CRYSTALITE_CHESTPLATE, + EndItems.CRYSTALITE_LEGGINGS, EndItems.CRYSTALITE_BOOTS); } - + private boolean isStackValid(ItemStack stack) { - return stack.getItem() == EndItems.CRYSTALITE_HELMET || - stack.getItem() == EndItems.CRYSTALITE_CHESTPLATE || - stack.getItem() == EndItems.CRYSTALITE_LEGGINGS || - stack.getItem() == EndItems.CRYSTALITE_BOOTS; + return stack.getItem() == EndItems.CRYSTALITE_HELMET || stack.getItem() == EndItems.CRYSTALITE_CHESTPLATE + || stack.getItem() == EndItems.CRYSTALITE_LEGGINGS || stack.getItem() == EndItems.CRYSTALITE_BOOTS; } } diff --git a/src/main/java/ru/betterend/item/model/CrystaliteBootsModel.java b/src/main/java/ru/betterend/item/model/CrystaliteBootsModel.java index c0c05698..7b476aa5 100644 --- a/src/main/java/ru/betterend/item/model/CrystaliteBootsModel.java +++ b/src/main/java/ru/betterend/item/model/CrystaliteBootsModel.java @@ -7,13 +7,13 @@ import com.google.common.collect.Lists; import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.entity.model.BipedEntityModel; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.entity.LivingEntity; public class CrystaliteBootsModel extends BipedEntityModel { public ModelPart leftBoot; public ModelPart rightBoot; - + public CrystaliteBootsModel(float scale) { super(RenderLayer::getEntityTranslucent, scale, 0.0F, 64, 48); this.leftBoot = new ModelPart(this, 0, 32); @@ -23,7 +23,7 @@ public class CrystaliteBootsModel extends BipedEntityModel { this.rightBoot.addCuboid(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, scale + 0.25F); this.rightBoot.setPivot(-1.9F, 12.0F, 0.0F); } - + @Override public void setAttributes(BipedEntityModel bipedEntityModel) { super.setAttributes(bipedEntityModel); @@ -35,7 +35,7 @@ public class CrystaliteBootsModel extends BipedEntityModel { protected Iterable getHeadParts() { return Collections::emptyIterator; } - + @Override protected Iterable getBodyParts() { return Lists.newArrayList(leftBoot, rightBoot); diff --git a/src/main/java/ru/betterend/item/model/CrystaliteChestplateModel.java b/src/main/java/ru/betterend/item/model/CrystaliteChestplateModel.java index 5a08f9d0..51b07d02 100644 --- a/src/main/java/ru/betterend/item/model/CrystaliteChestplateModel.java +++ b/src/main/java/ru/betterend/item/model/CrystaliteChestplateModel.java @@ -8,7 +8,7 @@ import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.entity.model.BipedEntityModel; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.util.Arm; public class CrystaliteChestplateModel extends BipedEntityModel { @@ -16,7 +16,7 @@ public class CrystaliteChestplateModel extends BipedEntityModel { public ModelPart leftShoulder; public ModelPart rightShoulder; private boolean thinArms; - + public CrystaliteChestplateModel(float scale, boolean thinArms) { super(RenderLayer::getEntityTranslucent, scale, 0.0F, 64, 48); this.thinArms = thinArms; @@ -41,29 +41,29 @@ public class CrystaliteChestplateModel extends BipedEntityModel { this.rightShoulder.setPivot(-5.0F, 2.0F, 10.0F); } } - + @Override public void setAttributes(BipedEntityModel bipedEntityModel) { super.setAttributes(bipedEntityModel); this.leftShoulder.copyPositionAndRotation(leftArm); this.rightShoulder.copyPositionAndRotation(rightArm); } - + @Override protected Iterable getHeadParts() { return Collections::emptyIterator; } - + @Override protected Iterable getBodyParts() { return Lists.newArrayList(torso, leftShoulder, rightShoulder); } - + @Override public void setArmAngle(Arm arm, MatrixStack matrices) { ModelPart modelPart = this.getArm(arm); if (this.thinArms) { - float f = 0.5F * (float)(arm == Arm.RIGHT ? 1 : -1); + float f = 0.5F * (float) (arm == Arm.RIGHT ? 1 : -1); modelPart.pivotX += f; modelPart.rotate(matrices); modelPart.pivotX -= f; diff --git a/src/main/java/ru/betterend/item/model/CrystaliteHelmetModel.java b/src/main/java/ru/betterend/item/model/CrystaliteHelmetModel.java index 6d759695..fc82b4e7 100644 --- a/src/main/java/ru/betterend/item/model/CrystaliteHelmetModel.java +++ b/src/main/java/ru/betterend/item/model/CrystaliteHelmetModel.java @@ -9,7 +9,7 @@ import net.fabricmc.api.Environment; import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.entity.model.BipedEntityModel; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.entity.LivingEntity; @Environment(EnvType.CLIENT) public class CrystaliteHelmetModel extends BipedEntityModel { @@ -20,12 +20,12 @@ public class CrystaliteHelmetModel extends BipedEntityModel { this.helmet.addCuboid(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F, scale + 0.5F); this.helmet.setPivot(0.0F, 0.0F, 0.0F); } - + @Override protected Iterable getHeadParts() { return Collections::emptyIterator; } - + @Override protected Iterable getBodyParts() { return Lists.newArrayList(helmet); diff --git a/src/main/java/ru/betterend/item/model/CrystaliteLeggingsModel.java b/src/main/java/ru/betterend/item/model/CrystaliteLeggingsModel.java index ea5d80fe..d4bd17c9 100644 --- a/src/main/java/ru/betterend/item/model/CrystaliteLeggingsModel.java +++ b/src/main/java/ru/betterend/item/model/CrystaliteLeggingsModel.java @@ -7,7 +7,7 @@ import com.google.common.collect.Lists; import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.entity.model.BipedEntityModel; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.entity.LivingEntity; public class CrystaliteLeggingsModel extends BipedEntityModel { @@ -28,7 +28,7 @@ public class CrystaliteLeggingsModel extends BipedEntityModel { protected Iterable getHeadParts() { return Collections::emptyIterator; } - + @Override protected Iterable getBodyParts() { return Lists.newArrayList(torso, rightLeg, leftLeg); diff --git a/src/main/java/ru/betterend/item/tool/EndAxeItem.java b/src/main/java/ru/betterend/item/tool/EndAxeItem.java index 77e1e53a..047683b5 100644 --- a/src/main/java/ru/betterend/item/tool/EndAxeItem.java +++ b/src/main/java/ru/betterend/item/tool/EndAxeItem.java @@ -2,29 +2,29 @@ package ru.betterend.item.tool; import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.BlockState; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.AxeItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ToolMaterial; -import net.minecraft.tag.Tag; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.AxeItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Tier; +import net.minecraft.tags.Tag; import ru.betterend.patterns.Patterned; import ru.betterend.patterns.Patterns; public class EndAxeItem extends AxeItem implements DynamicAttributeTool, Patterned { - public EndAxeItem(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) { + public EndAxeItem(Tier material, float attackDamage, float attackSpeed, Properties settings) { super(material, attackDamage, attackSpeed, settings); } @Override public int getMiningLevel(Tag tag, BlockState state, ItemStack stack, LivingEntity user) { if (tag.equals(FabricToolTags.AXES)) { - return this.getMaterial().getMiningLevel(); + return this.getTier().getLevel(); } return 0; } - + @Override public String getModelPattern(String name) { return Patterns.createJson(Patterns.ITEM_HANDHELD, name); diff --git a/src/main/java/ru/betterend/item/tool/EndHammerItem.java b/src/main/java/ru/betterend/item/tool/EndHammerItem.java index 004e05c4..ca6d5998 100644 --- a/src/main/java/ru/betterend/item/tool/EndHammerItem.java +++ b/src/main/java/ru/betterend/item/tool/EndHammerItem.java @@ -9,50 +9,51 @@ import com.google.common.collect.Sets; import io.netty.util.internal.ThreadLocalRandom; import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.MiningToolItem; -import net.minecraft.item.ToolMaterial; -import net.minecraft.tag.Tag; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.attribute.EntityAttribute; +import net.minecraft.world.entity.attribute.EntityAttributeModifier; +import net.minecraft.world.entity.attribute.EntityAttributes; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.MiningToolItem; +import net.minecraft.world.item.Tier; +import net.minecraft.tags.Tag; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.Level; import ru.betterend.patterns.Patterned; import ru.betterend.patterns.Patterns; import ru.betterend.registry.EndTags; public class EndHammerItem extends MiningToolItem implements DynamicAttributeTool, Patterned { - public final static UUID ATTACK_KNOCKBACK_MODIFIER_ID = MathHelper.randomUuid(ThreadLocalRandom.current()); - + public final static UUID ATTACK_KNOCKBACK_MODIFIER_ID = Mth.randomUuid(ThreadLocalRandom.current()); + private final Multimap attributeModifiers; - public EndHammerItem(ToolMaterial material, float attackDamage, float attackSpeed, double knockback, Settings settings) { + public EndHammerItem(Tier material, float attackDamage, float attackSpeed, double knockback, Properties settings) { super(attackDamage, attackSpeed, material, Sets.newHashSet(), settings); Builder builder = ImmutableMultimap.builder(); - builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID, "Weapon modifier", attackDamage + material.getAttackDamage(), EntityAttributeModifier.Operation.ADDITION)); - builder.put(EntityAttributes.GENERIC_ATTACK_SPEED, new EntityAttributeModifier(ATTACK_SPEED_MODIFIER_ID, "Weapon modifier", attackSpeed, EntityAttributeModifier.Operation.ADDITION)); - builder.put(EntityAttributes.GENERIC_ATTACK_KNOCKBACK, new EntityAttributeModifier(ATTACK_KNOCKBACK_MODIFIER_ID, "Weapon modifier", knockback, EntityAttributeModifier.Operation.ADDITION)); + builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, + new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID, "Weapon modifier", + attackDamage + material.getAttackDamage(), EntityAttributeModifier.Operation.ADDITION)); + builder.put(EntityAttributes.GENERIC_ATTACK_SPEED, new EntityAttributeModifier(ATTACK_SPEED_MODIFIER_ID, + "Weapon modifier", attackSpeed, EntityAttributeModifier.Operation.ADDITION)); + builder.put(EntityAttributes.GENERIC_ATTACK_KNOCKBACK, new EntityAttributeModifier(ATTACK_KNOCKBACK_MODIFIER_ID, + "Weapon modifier", knockback, EntityAttributeModifier.Operation.ADDITION)); this.attributeModifiers = builder.build(); } @Override - public boolean canMine(BlockState state, World world, BlockPos pos, PlayerEntity miner) { - return state.getMaterial().equals(Material.STONE) || - state.getMaterial().equals(Material.GLASS) || - state.isOf(Blocks.DIAMOND_BLOCK) || - state.isOf(Blocks.EMERALD_BLOCK) || - state.isOf(Blocks.LAPIS_BLOCK) || - state.isOf(Blocks.REDSTONE_BLOCK); + public boolean canMine(BlockState state, Level world, BlockPos pos, PlayerEntity miner) { + return state.getMaterial().equals(Material.STONE) || state.getMaterial().equals(Material.GLASS) + || state.is(Blocks.DIAMOND_BLOCK) || state.is(Blocks.EMERALD_BLOCK) || state.is(Blocks.LAPIS_BLOCK) + || state.is(Blocks.REDSTONE_BLOCK); } @Override @@ -60,12 +61,12 @@ public class EndHammerItem extends MiningToolItem implements DynamicAttributeToo stack.damage(1, attacker, ((entity) -> { entity.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND); })); - + return true; } @Override - public boolean postMine(ItemStack stack, World world, BlockState state, BlockPos pos, LivingEntity miner) { + public boolean postMine(ItemStack stack, Level world, BlockState state, BlockPos pos, LivingEntity miner) { if (state.getHardness(world, pos) != 0.0F) { stack.damage(1, miner, ((entity) -> { entity.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND); @@ -76,54 +77,58 @@ public class EndHammerItem extends MiningToolItem implements DynamicAttributeToo } @Override - public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { + public float getDestroySpeed(ItemStack stack, BlockState state) { if (state.getMaterial().equals(Material.GLASS)) { - return this.getMaterial().getMiningSpeedMultiplier() * 2.0F; + return this.getMaterial().getDestroySpeed() * 2.0F; } - if (isEffectiveOn(state)) { + if (isCorrectToolForDrops(state)) { float mult = 1.0F; - if (state.isOf(Blocks.DIAMOND_BLOCK) || state.isOf(Blocks.EMERALD_BLOCK) || state.isOf(Blocks.LAPIS_BLOCK) || state.isOf(Blocks.REDSTONE_BLOCK)) { - mult = this.getMaterial().getMiningSpeedMultiplier(); + if (state.is(Blocks.DIAMOND_BLOCK) || state.is(Blocks.EMERALD_BLOCK) || state.is(Blocks.LAPIS_BLOCK) + || state.is(Blocks.REDSTONE_BLOCK)) { + mult = this.getMaterial().getDestroySpeed(); } else { - mult = this.getMaterial().getMiningSpeedMultiplier() / 2.0F; + mult = this.getMaterial().getDestroySpeed() / 2.0F; } return mult > 1.0F ? mult : 1.0F; } return 1.0F; } - + @Override - public float getMiningSpeedMultiplier(Tag tag, BlockState state, ItemStack stack, LivingEntity user) { + public float getDestroySpeed(Tag tag, BlockState state, ItemStack stack, LivingEntity user) { if (tag.equals(EndTags.HAMMERS)) { - return this.getMiningSpeedMultiplier(stack, state); + return this.getDestroySpeed(stack, state); } return 1.0F; } - + @Override public int getMiningLevel(Tag tag, BlockState state, ItemStack stack, LivingEntity user) { if (tag.equals(EndTags.HAMMERS)) { - return this.getMaterial().getMiningLevel(); + return this.getTier().getLevel(); } return 0; } @Override - public boolean isEffectiveOn(BlockState state) { + public boolean isCorrectToolForDrops(BlockState state) { if (state.getMaterial().equals(Material.GLASS)) { return true; } - if (!state.isOf(Blocks.REDSTONE_BLOCK) && !state.isOf(Blocks.DIAMOND_BLOCK) && !state.isOf(Blocks.EMERALD_BLOCK) && !state.isOf(Blocks.LAPIS_BLOCK) && !state.getMaterial().equals(Material.STONE)) { + if (!state.is(Blocks.REDSTONE_BLOCK) && !state.is(Blocks.DIAMOND_BLOCK) && !state.is(Blocks.EMERALD_BLOCK) + && !state.is(Blocks.LAPIS_BLOCK) && !state.getMaterial().equals(Material.STONE)) { return false; } - int level = this.getMaterial().getMiningLevel(); - if (state.isOf(Blocks.IRON_ORE) || state.isOf(Blocks.LAPIS_BLOCK) || state.isOf(Blocks.LAPIS_ORE)) { + int level = this.getTier().getLevel(); + if (state.is(Blocks.IRON_ORE) || state.is(Blocks.LAPIS_BLOCK) || state.is(Blocks.LAPIS_ORE)) { return level >= 1; } - if (state.isOf(Blocks.DIAMOND_BLOCK) && !state.isOf(Blocks.DIAMOND_ORE) || state.isOf(Blocks.EMERALD_ORE) || state.isOf(Blocks.EMERALD_BLOCK) || state.isOf(Blocks.GOLD_ORE) || state.isOf(Blocks.REDSTONE_ORE)) { + if (state.is(Blocks.DIAMOND_BLOCK) && !state.is(Blocks.DIAMOND_ORE) || state.is(Blocks.EMERALD_ORE) + || state.is(Blocks.EMERALD_BLOCK) || state.is(Blocks.GOLD_ORE) || state.is(Blocks.REDSTONE_ORE)) { return level >= 2; } - if (state.isOf(Blocks.OBSIDIAN) || state.isOf(Blocks.CRYING_OBSIDIAN) || state.isOf(Blocks.RESPAWN_ANCHOR) || state.isOf(Blocks.ANCIENT_DEBRIS)) { + if (state.is(Blocks.OBSIDIAN) || state.is(Blocks.CRYING_OBSIDIAN) || state.is(Blocks.RESPAWN_ANCHOR) + || state.is(Blocks.ANCIENT_DEBRIS)) { return level >= 3; } return true; @@ -133,7 +138,7 @@ public class EndHammerItem extends MiningToolItem implements DynamicAttributeToo public Multimap getAttributeModifiers(EquipmentSlot slot) { return slot == EquipmentSlot.MAINHAND ? this.attributeModifiers : super.getAttributeModifiers(slot); } - + @Override public String getModelPattern(String name) { return Patterns.createJson(Patterns.ITEM_HANDHELD, name); diff --git a/src/main/java/ru/betterend/item/tool/EndHoeItem.java b/src/main/java/ru/betterend/item/tool/EndHoeItem.java index ec635fc7..ca920b52 100644 --- a/src/main/java/ru/betterend/item/tool/EndHoeItem.java +++ b/src/main/java/ru/betterend/item/tool/EndHoeItem.java @@ -1,15 +1,15 @@ package ru.betterend.item.tool; -import net.minecraft.item.HoeItem; -import net.minecraft.item.ToolMaterial; +import net.minecraft.world.item.HoeItem; +import net.minecraft.world.item.Tier; import ru.betterend.patterns.Patterned; import ru.betterend.patterns.Patterns; public class EndHoeItem extends HoeItem implements Patterned { - public EndHoeItem(ToolMaterial material, int attackDamage, float attackSpeed, Settings settings) { + public EndHoeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) { super(material, attackDamage, attackSpeed, settings); } - + @Override public String getModelPattern(String name) { return Patterns.createJson(Patterns.ITEM_HANDHELD, name); diff --git a/src/main/java/ru/betterend/item/tool/EndPickaxeItem.java b/src/main/java/ru/betterend/item/tool/EndPickaxeItem.java index d30eb891..4fa85f5e 100644 --- a/src/main/java/ru/betterend/item/tool/EndPickaxeItem.java +++ b/src/main/java/ru/betterend/item/tool/EndPickaxeItem.java @@ -4,39 +4,41 @@ import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl; import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl.Entry; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.PickaxeItem; -import net.minecraft.item.ToolMaterial; -import net.minecraft.tag.Tag; +import net.minecraft.tags.Tag; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.PickaxeItem; +import net.minecraft.world.item.Tier; import ru.betterend.patterns.Patterned; import ru.betterend.patterns.Patterns; public class EndPickaxeItem extends PickaxeItem implements DynamicAttributeTool, Patterned { - public EndPickaxeItem(ToolMaterial material, int attackDamage, float attackSpeed, Settings settings) { + public EndPickaxeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) { super(material, attackDamage, attackSpeed, settings); } - + @Override public int getMiningLevel(Tag tag, BlockState state, ItemStack stack, LivingEntity user) { if (tag.equals(FabricToolTags.PICKAXES)) { - return this.getMaterial().getMiningLevel(); + return this.getTier().getLevel(); } return 0; } - + @Override - public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { - if (this.getMaterial().getMiningLevel() > 2 && state.getMaterial().equals(Blocks.END_STONE.getDefaultState().getMaterial())) { - return this.miningSpeed * 3; + public float getDestroySpeed(ItemStack stack, BlockState state) { + if (this.getTier().getLevel() > 2 + && state.getMaterial().equals(Blocks.END_STONE.defaultBlockState().getMaterial())) { + return this.speed * 3; } Entry entry = ToolManagerImpl.entryNullable(state.getBlock()); - return (entry != null && entry.getMiningLevel(FabricToolTags.PICKAXES) >= 0) ? this.miningSpeed : super.getMiningSpeedMultiplier(stack, state); + return (entry != null && entry.getMiningLevel(FabricToolTags.PICKAXES) >= 0) ? speed + : super.getDestroySpeed(stack, state); } - + @Override public String getModelPattern(String name) { return Patterns.createJson(Patterns.ITEM_HANDHELD, name); diff --git a/src/main/java/ru/betterend/item/tool/EndShovelItem.java b/src/main/java/ru/betterend/item/tool/EndShovelItem.java index a0b9de67..4d36aa49 100644 --- a/src/main/java/ru/betterend/item/tool/EndShovelItem.java +++ b/src/main/java/ru/betterend/item/tool/EndShovelItem.java @@ -4,35 +4,36 @@ import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl; import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl.Entry; -import net.minecraft.block.BlockState; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ShovelItem; -import net.minecraft.item.ToolMaterial; -import net.minecraft.tag.Tag; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ShovelItem; +import net.minecraft.world.item.Tier; +import net.minecraft.tags.Tag; import ru.betterend.patterns.Patterned; import ru.betterend.patterns.Patterns; public class EndShovelItem extends ShovelItem implements DynamicAttributeTool, Patterned { - public EndShovelItem(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) { + public EndShovelItem(Tier material, float attackDamage, float attackSpeed, Properties settings) { super(material, attackDamage, attackSpeed, settings); } - + @Override public int getMiningLevel(Tag tag, BlockState state, ItemStack stack, LivingEntity user) { if (tag.equals(FabricToolTags.SHOVELS)) { - return this.getMaterial().getMiningLevel(); + return this.getTier().getLevel(); } return 0; } - + @Override - public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { + public float getDestroySpeed(ItemStack stack, BlockState state) { Entry entry = ToolManagerImpl.entryNullable(state.getBlock()); - return (entry != null && entry.getMiningLevel(FabricToolTags.SHOVELS) >= 0) ? this.miningSpeed : super.getMiningSpeedMultiplier(stack, state); + return (entry != null && entry.getMiningLevel(FabricToolTags.SHOVELS) >= 0) ? speed + : super.getDestroySpeed(stack, state); } - + @Override public String getModelPattern(String name) { return Patterns.createJson(Patterns.ITEM_HANDHELD, name); diff --git a/src/main/java/ru/betterend/item/tool/EndSwordItem.java b/src/main/java/ru/betterend/item/tool/EndSwordItem.java index 45f4f8dc..679ae06c 100644 --- a/src/main/java/ru/betterend/item/tool/EndSwordItem.java +++ b/src/main/java/ru/betterend/item/tool/EndSwordItem.java @@ -1,16 +1,16 @@ package ru.betterend.item.tool; import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; -import net.minecraft.item.SwordItem; -import net.minecraft.item.ToolMaterial; +import net.minecraft.world.item.SwordItem; +import net.minecraft.world.item.Tier; import ru.betterend.patterns.Patterned; import ru.betterend.patterns.Patterns; public class EndSwordItem extends SwordItem implements DynamicAttributeTool, Patterned { - public EndSwordItem(ToolMaterial material, int attackDamage, float attackSpeed, Settings settings) { + public EndSwordItem(Tier material, int attackDamage, float attackSpeed, Properties settings) { super(material, attackDamage, attackSpeed, settings); } - + @Override public String getModelPattern(String name) { return Patterns.createJson(Patterns.ITEM_HANDHELD, name); diff --git a/src/main/java/ru/betterend/mixin/client/AnvilScreenMixin.java b/src/main/java/ru/betterend/mixin/client/AnvilScreenMixin.java index a47b4c53..a37d7cee 100644 --- a/src/main/java/ru/betterend/mixin/client/AnvilScreenMixin.java +++ b/src/main/java/ru/betterend/mixin/client/AnvilScreenMixin.java @@ -16,13 +16,13 @@ import net.minecraft.client.gui.widget.AbstractButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.player.PlayerInventory; +import net.minecraft.world.item.ItemStack; import net.minecraft.screen.AnvilScreenHandler; import net.minecraft.screen.ScreenHandler; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import ru.betterend.interfaces.AnvilScreenHandlerExtended; @Mixin(AnvilScreen.class) @@ -30,12 +30,12 @@ public class AnvilScreenMixin extends ForgingScreen { @Shadow private TextFieldWidget nameField; - + private final List be_buttons = Lists.newArrayList(); private AnvilScreenHandlerExtended anvilHandler; - + public AnvilScreenMixin(AnvilScreenHandler handler, PlayerInventory playerInventory, Text title, - Identifier texture) { + ResourceLocation texture) { super(handler, playerInventory, title, texture); } @@ -43,19 +43,19 @@ public class AnvilScreenMixin extends ForgingScreen { protected void be_setup(CallbackInfo info) { this.be_buttons.clear(); int x = (width - backgroundWidth) / 2; - int y = (height - backgroundHeight) / 2; - this.anvilHandler = (AnvilScreenHandlerExtended) this.handler; - this.be_buttons.add(new ButtonWidget(x + 8, y + 45, 15, 20, new LiteralText("<"), (b) -> be_previousRecipe())); + int y = (height - backgroundHeight) / 2; + this.anvilHandler = (AnvilScreenHandlerExtended) this.handler; + this.be_buttons.add(new ButtonWidget(x + 8, y + 45, 15, 20, new LiteralText("<"), (b) -> be_previousRecipe())); this.be_buttons.add(new ButtonWidget(x + 154, y + 45, 15, 20, new LiteralText(">"), (b) -> be_nextRecipe())); } - + @Inject(method = "renderForeground", at = @At("TAIL")) protected void be_renderForeground(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo info) { this.be_buttons.forEach(button -> { button.render(matrices, mouseX, mouseY, delta); }); } - + @Inject(method = "onSlotUpdate", at = @At("HEAD"), cancellable = true) public void be_onSlotUpdate(ScreenHandler handler, int slotId, ItemStack stack, CallbackInfo info) { AnvilScreenHandlerExtended anvilHandler = (AnvilScreenHandlerExtended) handler; @@ -71,15 +71,15 @@ public class AnvilScreenMixin extends ForgingScreen { this.be_buttons.forEach(button -> button.visible = false); } } - + private void be_nextRecipe() { this.anvilHandler.be_nextRecipe(); } - + private void be_previousRecipe() { this.anvilHandler.be_previousRecipe(); } - + @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { if (client != null) { diff --git a/src/main/java/ru/betterend/mixin/client/BackgroundRendererMixin.java b/src/main/java/ru/betterend/mixin/client/BackgroundRendererMixin.java index 26d59d3a..aa74a438 100644 --- a/src/main/java/ru/betterend/mixin/client/BackgroundRendererMixin.java +++ b/src/main/java/ru/betterend/mixin/client/BackgroundRendererMixin.java @@ -11,15 +11,15 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.render.BackgroundRenderer; import net.minecraft.client.render.Camera; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.effect.StatusEffectInstance; +import net.minecraft.world.entity.effect.StatusEffects; import net.minecraft.fluid.FluidState; import net.minecraft.util.Util; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; +import net.minecraft.util.Mth; +import net.minecraft.world.level.Level; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome.Category; import ru.betterend.client.ClientOptions; @@ -33,23 +33,25 @@ public class BackgroundRendererMixin { private static float fogDensity; private static float lerp; private static long time; - + @Shadow private static float red; @Shadow private static float green; @Shadow private static float blue; - + @Inject(method = "render", at = @At("RETURN")) - private static void be_onRender(Camera camera, float tickDelta, ClientWorld world, int i, float f, CallbackInfo info) { + private static void be_onRender(Camera camera, float tickDelta, ClientLevel world, int i, float f, + CallbackInfo info) { long l = Util.getMeasuringTimeMs() - time; time += l; lerp += l * 0.001F; - if (lerp > 1) lerp = 1; - + if (lerp > 1) + lerp = 1; + FluidState fluidState = camera.getSubmergedFluidState(); - if (fluidState.isEmpty() && world.getRegistryKey().equals(World.END)) { + if (fluidState.isEmpty() && world.dimension().equals(Level.END)) { Entity entity = camera.getFocusedEntity(); boolean skip = false; if (entity instanceof LivingEntity) { @@ -62,20 +64,21 @@ public class BackgroundRendererMixin { blue *= 4; } } - + BackgroundInfo.red = red; BackgroundInfo.green = green; BackgroundInfo.blue = blue; } - + @Inject(method = "applyFog", at = @At("HEAD"), cancellable = true) - private static void be_fogDensity(Camera camera, BackgroundRenderer.FogType fogType, float viewDistance, boolean thickFog, CallbackInfo info) { + private static void be_fogDensity(Camera camera, BackgroundRenderer.FogType fogType, float viewDistance, + boolean thickFog, CallbackInfo info) { Entity entity = camera.getFocusedEntity(); Biome biome = entity.world.getBiome(entity.getBlockPos()); FluidState fluidState = camera.getSubmergedFluidState(); if (ClientOptions.useFogDensity() && biome.getCategory() == Category.THEEND && fluidState.isEmpty()) { EndBiome endBiome = EndBiomes.getRenderBiome(biome); - + if (fogDensity == 0) { fogDensity = endBiome.getFogDensity(); lastFogDensity = fogDensity; @@ -85,12 +88,12 @@ public class BackgroundRendererMixin { fogDensity = endBiome.getFogDensity(); lerp = 0; } - - float fog = MathHelper.lerp(lerp, lastFogDensity, fogDensity); + + float fog = Mth.lerp(lerp, lastFogDensity, fogDensity); BackgroundInfo.fog = fog; float start = viewDistance * 0.75F / fog; float end = viewDistance / fog; - + if (entity instanceof LivingEntity) { LivingEntity le = (LivingEntity) entity; StatusEffectInstance effect = le.getStatusEffect(StatusEffects.BLINDNESS); @@ -100,19 +103,17 @@ public class BackgroundRendererMixin { start = 0; end *= 0.03F; BackgroundInfo.blindness = 1; - } - else { + } else { float delta = (float) duration / 20F; BackgroundInfo.blindness = delta; - start = MathHelper.lerp(delta, start, 0); - end = MathHelper.lerp(delta, end, end * 0.03F); + start = Mth.lerp(delta, start, 0); + end = Mth.lerp(delta, end, end * 0.03F); } - } - else { + } else { BackgroundInfo.blindness = 0; } } - + RenderSystem.fogStart(start); RenderSystem.fogEnd(end); RenderSystem.fogMode(GlStateManager.FogMode.LINEAR); diff --git a/src/main/java/ru/betterend/mixin/client/BiomeColorsMixin.java b/src/main/java/ru/betterend/mixin/client/BiomeColorsMixin.java index 33f777be..6e0e074b 100644 --- a/src/main/java/ru/betterend/mixin/client/BiomeColorsMixin.java +++ b/src/main/java/ru/betterend/mixin/client/BiomeColorsMixin.java @@ -10,9 +10,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; import net.minecraft.client.color.world.BiomeColors; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.BlockRenderView; import ru.betterend.client.ClientOptions; import ru.betterend.registry.EndBlocks; @@ -25,17 +25,17 @@ public class BiomeColorsMixin { private static final int STREAM_COLOR = MHelper.color(105, 213, 244); private static final Point[] OFFSETS; private static final boolean HAS_SODIUM; - + @Inject(method = "getWaterColor", at = @At("RETURN"), cancellable = true) private static void be_getWaterColor(BlockRenderView world, BlockPos pos, CallbackInfoReturnable info) { if (ClientOptions.useSulfurWaterColor()) { BlockRenderView view = HAS_SODIUM ? MinecraftClient.getInstance().world : world; - Mutable mut = new Mutable(); + MutableBlockPos mut = new MutableBlockPos(); mut.setY(pos.getY()); for (int i = 0; i < OFFSETS.length; i++) { mut.setX(pos.getX() + OFFSETS[i].x); mut.setZ(pos.getZ() + OFFSETS[i].y); - if ((view.getBlockState(mut).isOf(EndBlocks.BRIMSTONE))) { + if ((view.getBlockState(mut).is(EndBlocks.BRIMSTONE))) { info.setReturnValue(i < 16 ? STREAM_COLOR : POISON_COLOR); info.cancel(); return; @@ -43,10 +43,10 @@ public class BiomeColorsMixin { } } } - + static { HAS_SODIUM = FabricLoader.getInstance().isModLoaded("sodium"); - + OFFSETS = new Point[20]; for (int i = 0; i < 3; i++) { int p = i - 1; @@ -55,7 +55,7 @@ public class BiomeColorsMixin { OFFSETS[i + 6] = new Point(-2, p); OFFSETS[i + 9] = new Point(2, p); } - + for (int i = 0; i < 4; i++) { int inner = i + 16; Direction dir = BlocksHelper.HORIZONTAL[i]; diff --git a/src/main/java/ru/betterend/mixin/client/ClientPlayNetworkHandlerMixin.java b/src/main/java/ru/betterend/mixin/client/ClientPlayNetworkHandlerMixin.java index 8899eb4d..bd858608 100644 --- a/src/main/java/ru/betterend/mixin/client/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/ru/betterend/mixin/client/ClientPlayNetworkHandlerMixin.java @@ -6,23 +6,22 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.client.world.ClientWorld; +import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.network.NetworkThreadUtils; import net.minecraft.network.packet.s2c.play.SignEditorOpenS2CPacket; import ru.betterend.blocks.entities.ESignBlockEntity; import ru.betterend.client.gui.BlockSignEditScreen; @Mixin(ClientPlayNetworkHandler.class) -public class ClientPlayNetworkHandlerMixin -{ +public class ClientPlayNetworkHandlerMixin { @Shadow private MinecraftClient client; @Shadow - private ClientWorld world; + private ClientLevel world; @Inject(method = "onSignEditorOpen", at = @At(value = "HEAD"), cancellable = true) public void be_openSignEditor(SignEditorOpenS2CPacket packet, CallbackInfo info) { diff --git a/src/main/java/ru/betterend/mixin/client/ClientRecipeBookMixin.java b/src/main/java/ru/betterend/mixin/client/ClientRecipeBookMixin.java index d4185133..90797794 100644 --- a/src/main/java/ru/betterend/mixin/client/ClientRecipeBookMixin.java +++ b/src/main/java/ru/betterend/mixin/client/ClientRecipeBookMixin.java @@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import net.minecraft.client.recipebook.ClientRecipeBook; import net.minecraft.client.recipebook.RecipeBookGroup; -import net.minecraft.recipe.Recipe; +import net.minecraft.world.item.crafting.Recipe; import ru.betterend.interfaces.BetterEndRecipe; import ru.betterend.recipe.builders.AlloyingRecipe; diff --git a/src/main/java/ru/betterend/mixin/client/EnchantingTableBlockMixin.java b/src/main/java/ru/betterend/mixin/client/EnchantingTableBlockMixin.java index ee3c03aa..dbc78fec 100644 --- a/src/main/java/ru/betterend/mixin/client/EnchantingTableBlockMixin.java +++ b/src/main/java/ru/betterend/mixin/client/EnchantingTableBlockMixin.java @@ -7,22 +7,22 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.EnchantingTableBlock; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.EnchantingTableBlock; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; import ru.betterend.registry.EndTags; @Mixin(EnchantingTableBlock.class) public abstract class EnchantingTableBlockMixin extends Block { - public EnchantingTableBlockMixin(Settings settings) { + public EnchantingTableBlockMixin(Properties settings) { super(settings); } - @Inject(method = "randomDisplayTick", at = @At(value = "TAIL")) - private void be_onRandomDisplayTick(BlockState state, World world, BlockPos pos, Random random, CallbackInfo info) { + @Inject(method = "animateTick", at = @At(value = "TAIL")) + private void be_onRandomDisplayTick(BlockState state, Level world, BlockPos pos, Random random, CallbackInfo info) { for (int px = -2; px <= 2; ++px) { for (int pz = -2; pz <= 2; ++pz) { if (px > -2 && px < 2 && pz == -1) { @@ -30,12 +30,14 @@ public abstract class EnchantingTableBlockMixin extends Block { } if (random.nextInt(16) == 0) { for (int py = 0; py <= 1; ++py) { - BlockPos blockPos = pos.add(px, py, pz); + BlockPos blockPos = pos.offset(px, py, pz); if (world.getBlockState(blockPos).isIn(EndTags.BOOKSHELVES)) { - if (!world.isAir(pos.add(px / 2, 0, pz / 2))) { + if (!world.isAir(pos.offset(px / 2, 0, pz / 2))) { break; } - world.addParticle(ParticleTypes.ENCHANT, pos.getX() + 0.5, pos.getY() + 2.0, pos.getZ() + 0.5, px + random.nextFloat() - 0.5, py - random.nextFloat() - 1.0, pz + random.nextFloat() - 0.5); + world.addParticle(ParticleTypes.ENCHANT, pos.getX() + 0.5, pos.getY() + 2.0, + pos.getZ() + 0.5, px + random.nextFloat() - 0.5, py - random.nextFloat() - 1.0, + pz + random.nextFloat() - 0.5); } } } diff --git a/src/main/java/ru/betterend/mixin/client/MinecraftClientMixin.java b/src/main/java/ru/betterend/mixin/client/MinecraftClientMixin.java index 48a734f9..97c63bb2 100644 --- a/src/main/java/ru/betterend/mixin/client/MinecraftClientMixin.java +++ b/src/main/java/ru/betterend/mixin/client/MinecraftClientMixin.java @@ -17,10 +17,10 @@ import net.minecraft.client.gui.screen.CreditsScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.sound.MusicType; -import net.minecraft.client.world.ClientWorld; +import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.sound.MusicSound; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.World; +import net.minecraft.core.Registry; +import net.minecraft.world.level.Level; import ru.betterend.interfaces.IColorProvider; import ru.betterend.util.MHelper; @@ -28,17 +28,17 @@ import ru.betterend.util.MHelper; public class MinecraftClientMixin { @Shadow public ClientPlayerEntity player; - + @Shadow public Screen currentScreen; - + @Shadow @Final public InGameHud inGameHud; - + @Shadow - public ClientWorld world; - + public ClientLevel world; + @Shadow @Final private BlockColors blockColors; @@ -46,27 +46,28 @@ public class MinecraftClientMixin { @Shadow @Final private ItemColors itemColors; - + @Inject(method = "*", at = @At("TAIL")) private void be_onInit(RunArgs args, CallbackInfo info) { Registry.BLOCK.forEach(block -> { if (block instanceof IColorProvider) { IColorProvider provider = (IColorProvider) block; - blockColors.registerColorProvider(provider.getProvider(), block); + blockColors.registerColorProvider(provider.getBlockProvider(), block); itemColors.register(provider.getItemProvider(), block.asItem()); } }); } - + @Inject(method = "getMusicType", at = @At("HEAD"), cancellable = true) private void be_getEndMusic(CallbackInfoReturnable info) { if (!(this.currentScreen instanceof CreditsScreen) && this.player != null) { - if (this.player.world.getRegistryKey() == World.END) { - if (this.inGameHud.getBossBarHud().shouldPlayDragonMusic() && MHelper.lengthSqr(this.player.getX(), this.player.getZ()) < 250000) { + if (this.player.world.dimension() == Level.END) { + if (this.inGameHud.getBossBarHud().shouldPlayDragonMusic() + && MHelper.lengthSqr(this.player.getX(), this.player.getZ()) < 250000) { info.setReturnValue(MusicType.DRAGON); - } - else { - MusicSound sound = (MusicSound) this.world.getBiomeAccess().method_27344(this.player.getBlockPos()).getMusic().orElse(MusicType.END); + } else { + MusicSound sound = (MusicSound) this.world.getBiomeAccess().method_27344(this.player.getBlockPos()) + .getMusic().orElse(MusicType.END); info.setReturnValue(sound); } info.cancel(); diff --git a/src/main/java/ru/betterend/mixin/client/ModelLoaderMixin.java b/src/main/java/ru/betterend/mixin/client/ModelLoaderMixin.java index c3f922a4..5e4ed077 100644 --- a/src/main/java/ru/betterend/mixin/client/ModelLoaderMixin.java +++ b/src/main/java/ru/betterend/mixin/client/ModelLoaderMixin.java @@ -13,14 +13,14 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.block.Block; +import net.minecraft.world.level.block.Block; import net.minecraft.client.render.model.ModelLoader; import net.minecraft.client.render.model.json.JsonUnbakedModel; -import net.minecraft.item.Item; +import net.minecraft.world.item.Item; import net.minecraft.resource.Resource; import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; import ru.betterend.patterns.Patterned; import ru.betterend.world.generator.GeneratorOptions; @@ -30,11 +30,11 @@ public class ModelLoaderMixin { @Final @Shadow private ResourceManager resourceManager; - + @Inject(method = "loadModelFromJson", at = @At("HEAD"), cancellable = true) - private void be_loadModelPattern(Identifier id, CallbackInfoReturnable info) { + private void be_loadModelPattern(ResourceLocation id, CallbackInfoReturnable info) { if (id.getNamespace().equals(BetterEnd.MOD_ID)) { - Identifier modelId = new Identifier(id.getNamespace(), "models/" + id.getPath() + ".json"); + ResourceLocation modelId = new ResourceLocation(id.getNamespace(), "models/" + id.getPath() + ".json"); JsonUnbakedModel model; try (Resource resource = this.resourceManager.getResource(modelId)) { Reader reader = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8); @@ -44,7 +44,7 @@ public class ModelLoaderMixin { } catch (Exception ex) { String data[] = id.getPath().split("/"); if (data.length > 1) { - Identifier itemId = new Identifier(id.getNamespace(), data[1]); + ResourceLocation itemId = new ResourceLocation(id.getNamespace(), data[1]); Optional block = Registry.BLOCK.getOrEmpty(itemId); if (block.isPresent()) { if (block.get() instanceof Patterned) { @@ -64,8 +64,8 @@ public class ModelLoaderMixin { } } } - - private JsonUnbakedModel be_getModel(String data[], Identifier id, Patterned patterned) { + + private JsonUnbakedModel be_getModel(String data[], ResourceLocation id, Patterned patterned) { String pattern; if (id.getPath().contains("item")) { pattern = patterned.getModelPattern(id.getPath()); @@ -78,14 +78,16 @@ public class ModelLoaderMixin { } JsonUnbakedModel model = JsonUnbakedModel.deserialize(pattern); model.id = id.toString(); - + return model; } - + @ModifyVariable(method = "loadModel", ordinal = 2, at = @At(value = "INVOKE")) - public Identifier be_SwitchModel(Identifier id) { - if (GeneratorOptions.changeChorusPlant() && id.getNamespace().equals("minecraft") && id.getPath().startsWith("blockstates/") && id.getPath().contains("chorus") && !id.getPath().contains("custom_")) { - id = new Identifier(id.getPath().replace("chorus", "custom_chorus")); + public ResourceLocation be_SwitchModel(ResourceLocation id) { + if (GeneratorOptions.changeChorusPlant() && id.getNamespace().equals("minecraft") + && id.getPath().startsWith("blockstates/") && id.getPath().contains("chorus") + && !id.getPath().contains("custom_")) { + id = new ResourceLocation(id.getPath().replace("chorus", "custom_chorus")); } return id; } diff --git a/src/main/java/ru/betterend/mixin/client/ModelVariantMapMixin.java b/src/main/java/ru/betterend/mixin/client/ModelVariantMapMixin.java index c742bf18..1754ac85 100644 --- a/src/main/java/ru/betterend/mixin/client/ModelVariantMapMixin.java +++ b/src/main/java/ru/betterend/mixin/client/ModelVariantMapMixin.java @@ -10,17 +10,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.google.gson.Gson; -import net.minecraft.block.Block; +import net.minecraft.world.level.block.Block; import net.minecraft.client.render.model.json.ModelVariantMap; import net.minecraft.util.JsonHelper; import ru.betterend.patterns.BlockPatterned; @Mixin(ModelVariantMap.class) public abstract class ModelVariantMapMixin { - + @Inject(method = "deserialize", at = @At("HEAD"), cancellable = true) - private static void be_deserializeBlockState(ModelVariantMap.DeserializationContext context, Reader reader, CallbackInfoReturnable info) { - Block block = context.getStateFactory().getDefaultState().getBlock(); + private static void be_deserializeBlockState(ModelVariantMap.DeserializationContext context, Reader reader, + CallbackInfoReturnable info) { + Block block = context.getStateFactory().defaultBlockState().getBlock(); if (block instanceof BlockPatterned) { String pattern = ((BlockPatterned) block).getStatesPattern(reader); Gson gson = ContextGsonAccessor.class.cast(context).getGson(); diff --git a/src/main/java/ru/betterend/mixin/client/MusicTrackerMixin.java b/src/main/java/ru/betterend/mixin/client/MusicTrackerMixin.java index fdd8b5ec..587da5f2 100644 --- a/src/main/java/ru/betterend/mixin/client/MusicTrackerMixin.java +++ b/src/main/java/ru/betterend/mixin/client/MusicTrackerMixin.java @@ -14,8 +14,8 @@ import net.minecraft.client.sound.AbstractSoundInstance; import net.minecraft.client.sound.MusicTracker; import net.minecraft.client.sound.SoundInstance; import net.minecraft.sound.MusicSound; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; +import net.minecraft.util.Mth; +import net.minecraft.world.level.Level; import ru.betterend.client.ClientOptions; @Mixin(MusicTracker.class) @@ -23,21 +23,21 @@ public class MusicTrackerMixin { @Shadow @Final private MinecraftClient client; - + @Shadow @Final private Random random; - + @Shadow private SoundInstance current; - + @Shadow private int timeUntilNextSong; - + private static float volume = 1; private static float srcVolume = 0; private static long time; - + @Inject(method = "tick", at = @At("HEAD"), cancellable = true) public void be_onTick(CallbackInfo info) { if (ClientOptions.blendBiomeMusic()) { @@ -67,32 +67,33 @@ public class MusicTrackerMixin { time = 0; srcVolume = -1; this.client.getSoundManager().stop(this.current); - this.timeUntilNextSong = MathHelper.nextInt(this.random, 0, musicSound.getMinDelay() / 2); + this.timeUntilNextSong = Mth.nextInt(this.random, 0, musicSound.getMinDelay() / 2); this.current = null; } if (this.current == null && this.timeUntilNextSong-- <= 0) { this.play(musicSound); } info.cancel(); - } - else { + } else { volume = 1; } } } - + private boolean be_isInEnd() { - return client.world != null && client.world.getRegistryKey().equals(World.END); + return client.world != null && client.world.dimension().equals(Level.END); } - + private boolean be_shouldChangeSound(MusicSound musicSound) { - return current != null && !musicSound.getSound().getId().equals(this.current.getId()) && musicSound.shouldReplaceCurrentMusic(); + return current != null && !musicSound.getSound().getId().equals(this.current.getId()) + && musicSound.shouldReplaceCurrentMusic(); } - + private boolean be_checkNullSound(MusicSound musicSound) { return musicSound != null && musicSound.getSound() != null; } - + @Shadow - public void play(MusicSound type) {} + public void play(MusicSound type) { + } } diff --git a/src/main/java/ru/betterend/mixin/client/NamespaceResourceManagerMixin.java b/src/main/java/ru/betterend/mixin/client/NamespaceResourceManagerMixin.java index a1c5ad08..12a23843 100644 --- a/src/main/java/ru/betterend/mixin/client/NamespaceResourceManagerMixin.java +++ b/src/main/java/ru/betterend/mixin/client/NamespaceResourceManagerMixin.java @@ -11,32 +11,29 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.google.common.collect.Lists; -import net.minecraft.block.Block; +import net.minecraft.world.level.block.Block; import net.minecraft.resource.NamespaceResourceManager; import net.minecraft.resource.Resource; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; import ru.betterend.patterns.BlockPatterned; @Mixin(NamespaceResourceManager.class) public abstract class NamespaceResourceManagerMixin { - + @Shadow - public abstract Resource getResource(Identifier id); - - @Inject(method = "getAllResources", cancellable = true, at = @At( - value = "NEW", - target = "java/io/FileNotFoundException", - shift = Shift.BEFORE)) - public void be_getStatesPattern(Identifier id, CallbackInfoReturnable> info) { + public abstract Resource getResource(ResourceLocation id); + + @Inject(method = "getAllResources", cancellable = true, at = @At(value = "NEW", target = "java/io/FileNotFoundException", shift = Shift.BEFORE)) + public void be_getStatesPattern(ResourceLocation id, CallbackInfoReturnable> info) { if (id.getNamespace().equals(BetterEnd.MOD_ID)) { String[] data = id.getPath().split("/"); if (data.length > 1) { - Identifier blockId = BetterEnd.makeID(data[1].replace(".json", "")); + ResourceLocation blockId = BetterEnd.makeID(data[1].replace(".json", "")); Block block = Registry.BLOCK.get(blockId); if (block instanceof BlockPatterned) { - Identifier stateId = ((BlockPatterned) block).statePatternId(); + ResourceLocation stateId = ((BlockPatterned) block).statePatternId(); try { List resources = Lists.newArrayList(); Resource stateRes = this.getResource(stateId); diff --git a/src/main/java/ru/betterend/mixin/client/WorldRendererMixin.java b/src/main/java/ru/betterend/mixin/client/WorldRendererMixin.java index 75f78bca..ebe07df1 100644 --- a/src/main/java/ru/betterend/mixin/client/WorldRendererMixin.java +++ b/src/main/java/ru/betterend/mixin/client/WorldRendererMixin.java @@ -26,8 +26,8 @@ import net.minecraft.client.render.WorldRenderer; import net.minecraft.client.texture.TextureManager; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.util.Identifier; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.math.Quaternion; import ru.betterend.BetterEnd; import ru.betterend.client.ClientOptions; @@ -36,12 +36,12 @@ import ru.betterend.util.MHelper; @Mixin(WorldRenderer.class) public class WorldRendererMixin { - private static final Identifier NEBULA_1 = BetterEnd.makeID("textures/sky/nebula_2.png"); - private static final Identifier NEBULA_2 = BetterEnd.makeID("textures/sky/nebula_3.png"); - private static final Identifier HORIZON = BetterEnd.makeID("textures/sky/nebula_1.png"); - private static final Identifier STARS = BetterEnd.makeID("textures/sky/stars.png"); - private static final Identifier FOG = BetterEnd.makeID("textures/sky/fog.png"); - + private static final ResourceLocation NEBULA_1 = BetterEnd.makeID("textures/sky/nebula_2.png"); + private static final ResourceLocation NEBULA_2 = BetterEnd.makeID("textures/sky/nebula_3.png"); + private static final ResourceLocation HORIZON = BetterEnd.makeID("textures/sky/nebula_1.png"); + private static final ResourceLocation STARS = BetterEnd.makeID("textures/sky/stars.png"); + private static final ResourceLocation FOG = BetterEnd.makeID("textures/sky/fog.png"); + private static VertexBuffer stars1; private static VertexBuffer stars2; private static VertexBuffer stars3; @@ -60,21 +60,21 @@ public class WorldRendererMixin { private static float blind02; private static float blind06; private static boolean directOpenGL = false; - + @Shadow @Final private MinecraftClient client; - + @Shadow @Final private TextureManager textureManager; - + @Shadow - private ClientWorld world; - + private ClientLevel world; + @Shadow private int ticks; - + @Inject(method = "*", at = @At("TAIL")) private void be_onInit(MinecraftClient client, BufferBuilderStorage bufferBuilders, CallbackInfo info) { be_initStars(); @@ -87,103 +87,106 @@ public class WorldRendererMixin { axis2.normalize(); axis3.normalize(); axis4.normalize(); - - directOpenGL = FabricLoader.getInstance().isModLoaded("optifabric") || FabricLoader.getInstance().isModLoaded("immersive_portals"); + + directOpenGL = FabricLoader.getInstance().isModLoaded("optifabric") + || FabricLoader.getInstance().isModLoaded("immersive_portals"); } - + @Inject(method = "renderSky", at = @At("HEAD"), cancellable = true) private void be_renderBetterEndSky(MatrixStack matrices, float tickDelta, CallbackInfo info) { if (ClientOptions.isCustomSky() && client.world.getSkyProperties().getSkyType() == SkyProperties.SkyType.END) { time = (ticks % 360000) * 0.000017453292F; time2 = time * 2; time3 = time * 3; - + BackgroundRenderer.setFogBlack(); RenderSystem.enableTexture(); - + if (directOpenGL) { GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(516, 0.0F); GL11.glEnable(GL11.GL_BLEND); RenderSystem.depthMask(false); - } - else { + } else { RenderSystem.enableAlphaTest(); RenderSystem.alphaFunc(516, 0.0F); RenderSystem.enableBlend(); } - + float blindA = 1F - BackgroundInfo.blindness; blind02 = blindA * 0.2F; blind06 = blindA * 0.6F; - + if (blindA > 0) { matrices.push(); matrices.multiply(new Quaternion(0, time, 0, false)); textureManager.bindTexture(HORIZON); be_renderBuffer(matrices, horizon, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, 0.7F * blindA); matrices.pop(); - + matrices.push(); matrices.multiply(new Quaternion(0, -time, 0, false)); textureManager.bindTexture(NEBULA_1); be_renderBuffer(matrices, nebulas1, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, blind02); matrices.pop(); - + matrices.push(); matrices.multiply(new Quaternion(0, time2, 0, false)); textureManager.bindTexture(NEBULA_2); be_renderBuffer(matrices, nebulas2, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, blind02); matrices.pop(); - + textureManager.bindTexture(STARS); - + matrices.push(); matrices.multiply(axis3.getRadialQuaternion(time)); be_renderBuffer(matrices, stars3, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, blind06); matrices.pop(); - + matrices.push(); matrices.multiply(axis4.getRadialQuaternion(time2)); be_renderBuffer(matrices, stars4, VertexFormats.POSITION_TEXTURE, 1F, 1F, 1F, blind06); matrices.pop(); } - + float a = (BackgroundInfo.fog - 1F); if (a > 0) { - if (a > 1) a = 1; + if (a > 1) + a = 1; textureManager.bindTexture(FOG); - be_renderBuffer(matrices, fog, VertexFormats.POSITION_TEXTURE, BackgroundInfo.red, BackgroundInfo.green, BackgroundInfo.blue, a); + be_renderBuffer(matrices, fog, VertexFormats.POSITION_TEXTURE, BackgroundInfo.red, BackgroundInfo.green, + BackgroundInfo.blue, a); } RenderSystem.disableTexture(); - + if (blindA > 0) { matrices.push(); matrices.multiply(axis1.getRadialQuaternion(time3)); be_renderBuffer(matrices, stars1, VertexFormats.POSITION, 1, 1, 1, blind06); matrices.pop(); - + matrices.push(); matrices.multiply(axis2.getRadialQuaternion(time2)); be_renderBuffer(matrices, stars2, VertexFormats.POSITION, 0.95F, 0.64F, 0.93F, blind06); matrices.pop(); } - + RenderSystem.enableTexture(); RenderSystem.depthMask(true); - + info.cancel(); } } - - private void be_renderBuffer(MatrixStack matrices, VertexBuffer buffer, VertexFormat format, float r, float g, float b, float a) { + + private void be_renderBuffer(MatrixStack matrices, VertexBuffer buffer, VertexFormat format, float r, float g, + float b, float a) { RenderSystem.color4f(r, g, b, a); buffer.bind(); format.startDrawing(0L); - buffer.draw(matrices.peek().getModel(), 7); - VertexBuffer.unbind(); - format.endDrawing(); + buffer.draw(matrices.peek().getModel(), 7); + VertexBuffer.unbind(); + format.endDrawing(); } private void be_initStars() { @@ -197,8 +200,9 @@ public class WorldRendererMixin { horizon = be_buildBufferHorizon(buffer, horizon); fog = be_buildBufferFog(buffer, fog); } - - private VertexBuffer be_buildBufferStars(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, double maxSize, int count, long seed) { + + private VertexBuffer be_buildBufferStars(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, + double maxSize, int count, long seed) { if (buffer != null) { buffer.close(); } @@ -210,8 +214,9 @@ public class WorldRendererMixin { return buffer; } - - private VertexBuffer be_buildBufferUVStars(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, double maxSize, int count, long seed) { + + private VertexBuffer be_buildBufferUVStars(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, + double maxSize, int count, long seed) { if (buffer != null) { buffer.close(); } @@ -223,8 +228,9 @@ public class WorldRendererMixin { return buffer; } - - private VertexBuffer be_buildBufferFarFog(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, double maxSize, int count, long seed) { + + private VertexBuffer be_buildBufferFarFog(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, + double maxSize, int count, long seed) { if (buffer != null) { buffer.close(); } @@ -236,7 +242,7 @@ public class WorldRendererMixin { return buffer; } - + private VertexBuffer be_buildBufferHorizon(BufferBuilder bufferBuilder, VertexBuffer buffer) { if (buffer != null) { buffer.close(); @@ -249,7 +255,7 @@ public class WorldRendererMixin { return buffer; } - + private VertexBuffer be_buildBufferFog(BufferBuilder bufferBuilder, VertexBuffer buffer) { if (buffer != null) { buffer.close(); @@ -262,7 +268,7 @@ public class WorldRendererMixin { return buffer; } - + private void be_makeStars(BufferBuilder buffer, double minSize, double maxSize, int count, long seed) { Random random = new Random(seed); buffer.begin(7, VertexFormats.POSITION); @@ -305,7 +311,7 @@ public class WorldRendererMixin { } } } - + private void be_makeUVStars(BufferBuilder buffer, double minSize, double maxSize, int count, long seed) { Random random = new Random(seed); buffer.begin(7, VertexFormats.POSITION_TEXTURE); @@ -347,13 +353,13 @@ public class WorldRendererMixin { double ah = ab * n + ae * o; float texU = (pos >> 1) & 1; float texV = (((pos + 1) >> 1) & 1) / 4F + minV; - pos ++; + pos++; buffer.vertex(j + af, k + ad, l + ah).texture(texU, texV).next(); } } } } - + private void be_makeFarFog(BufferBuilder buffer, double minSize, double maxSize, int count, long seed) { Random random = new Random(seed); buffer.begin(7, VertexFormats.POSITION_TEXTURE); @@ -398,26 +404,26 @@ public class WorldRendererMixin { double ah = ab * n + ae * o; float texU = (pos >> 1) & 1; float texV = ((pos + 1) >> 1) & 1; - pos ++; + pos++; buffer.vertex(j + af, k + ad, l + ah).texture(texU, texV).next(); } } } } - + private void be_makeCylinder(BufferBuilder buffer, int segments, double height, double radius) { buffer.begin(7, VertexFormats.POSITION_TEXTURE); - for (int i = 0; i < segments; i ++) { + for (int i = 0; i < segments; i++) { double a1 = (double) i * Math.PI * 2.0 / (double) segments; double a2 = (double) (i + 1) * Math.PI * 2.0 / (double) segments; double px1 = Math.sin(a1) * radius; double pz1 = Math.cos(a1) * radius; double px2 = Math.sin(a2) * radius; double pz2 = Math.cos(a2) * radius; - + float u0 = (float) i / (float) segments; float u1 = (float) (i + 1) / (float) segments; - + buffer.vertex(px1, -height, pz1).texture(u0, 0).next(); buffer.vertex(px1, height, pz1).texture(u0, 1).next(); buffer.vertex(px2, height, pz2).texture(u1, 1).next(); diff --git a/src/main/java/ru/betterend/mixin/common/AbstractBlockMixin.java b/src/main/java/ru/betterend/mixin/common/AbstractBlockMixin.java index fd4473ed..6f4f77bb 100644 --- a/src/main/java/ru/betterend/mixin/common/AbstractBlockMixin.java +++ b/src/main/java/ru/betterend/mixin/common/AbstractBlockMixin.java @@ -9,34 +9,35 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.google.common.collect.Lists; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextParameters; -import net.minecraft.util.math.MathHelper; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.util.Mth; import ru.betterend.item.tool.EndHammerItem; import ru.betterend.util.MHelper; @Mixin(AbstractBlock.class) public abstract class AbstractBlockMixin { - - @Inject(method = "getDroppedStacks", at = @At("HEAD"), cancellable = true) - public void be_getDroppedStacks(BlockState state, LootContext.Builder builder, CallbackInfoReturnable> info) { - if (state.isOf(Blocks.GLOWSTONE)) { - ItemStack tool = builder.get(LootContextParameters.TOOL); + + @Inject(method = "getDrops", at = @At("HEAD"), cancellable = true) + public void be_getDroppedStacks(BlockState state, LootContext.Builder builder, + CallbackInfoReturnable> info) { + if (state.is(Blocks.GLOWSTONE)) { + ItemStack tool = builder.getParameter(LootContextParams.TOOL); if (tool != null && tool.getItem() instanceof EndHammerItem) { int min = 3; int max = 4; int count = 0; - int fortune = EnchantmentHelper.getLevel(Enchantments.FORTUNE, tool); + int fortune = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool); if (fortune > 0) { - fortune /= Enchantments.FORTUNE.getMaxLevel(); - min = MathHelper.clamp(min + fortune, min, max); + fortune /= Enchantments.BLOCK_FORTUNE.getMaxLevel(); + min = Mth.clamp(min + fortune, min, max); if (min == max) { info.setReturnValue(Lists.newArrayList(new ItemStack(Items.GLOWSTONE_DUST, max))); } diff --git a/src/main/java/ru/betterend/mixin/common/AnvilBlockMixin.java b/src/main/java/ru/betterend/mixin/common/AnvilBlockMixin.java index 130df457..28c29eb4 100644 --- a/src/main/java/ru/betterend/mixin/common/AnvilBlockMixin.java +++ b/src/main/java/ru/betterend/mixin/common/AnvilBlockMixin.java @@ -5,9 +5,9 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.block.AnvilBlock; -import net.minecraft.block.BlockState; -import net.minecraft.state.property.IntProperty; +import net.minecraft.world.level.block.AnvilBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; import ru.betterend.blocks.basis.EndAnvilBlock; @Mixin(AnvilBlock.class) @@ -15,7 +15,7 @@ public class AnvilBlockMixin { @Inject(method = "getLandingState", at = @At("HEAD"), cancellable = true) private static void be_getLandingState(BlockState fallingState, CallbackInfoReturnable info) { if (fallingState.getBlock() instanceof EndAnvilBlock) { - IntProperty destructionProperty = ((EndAnvilBlock) fallingState.getBlock()).getDestructionProperty(); + IntegerProperty destructionProperty = ((EndAnvilBlock) fallingState.getBlock()).getDESTRUCTION(); int destruction = fallingState.get(destructionProperty); try { BlockState state = fallingState.with(destructionProperty, destruction + 1); diff --git a/src/main/java/ru/betterend/mixin/common/AnvilScreenHandlerMixin.java b/src/main/java/ru/betterend/mixin/common/AnvilScreenHandlerMixin.java index 016a78b3..2b4c380e 100644 --- a/src/main/java/ru/betterend/mixin/common/AnvilScreenHandlerMixin.java +++ b/src/main/java/ru/betterend/mixin/common/AnvilScreenHandlerMixin.java @@ -11,19 +11,19 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.block.AnvilBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.recipe.RecipeManager; +import net.minecraft.world.level.block.AnvilBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.world.entity.player.PlayerInventory; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.screen.AnvilScreenHandler; import net.minecraft.screen.ForgingScreenHandler; import net.minecraft.screen.Property; import net.minecraft.screen.ScreenHandlerContext; import net.minecraft.screen.ScreenHandlerType; -import net.minecraft.tag.BlockTags; +import net.minecraft.tags.BlockTags; import ru.betterend.blocks.basis.EndAnvilBlock; import ru.betterend.interfaces.AnvilScreenHandlerExtended; import ru.betterend.recipe.builders.AnvilRecipe; @@ -39,9 +39,9 @@ public abstract class AnvilScreenHandlerMixin extends ForgingScreenHandler imple super(ScreenHandlerType.ANVIL, syncId, playerInventory, ScreenHandlerContext.EMPTY); } - @Inject(method = "(ILnet/minecraft/entity/player/PlayerInventory;Lnet/minecraft/screen/ScreenHandlerContext;)V", - at = @At("TAIL")) - public void be_initAnvilLevel(int syncId, PlayerInventory inventory, ScreenHandlerContext context, CallbackInfo info) { + @Inject(method = "(ILnet/minecraft/entity/player/PlayerInventory;Lnet/minecraft/screen/ScreenHandlerContext;)V", at = @At("TAIL")) + public void be_initAnvilLevel(int syncId, PlayerInventory inventory, ScreenHandlerContext context, + CallbackInfo info) { if (context != ScreenHandlerContext.EMPTY) { int anvLevel = context.run((world, blockPos) -> { Block anvilBlock = world.getBlockState(blockPos).getBlock(); @@ -55,17 +55,17 @@ public abstract class AnvilScreenHandlerMixin extends ForgingScreenHandler imple this.anvilLevel = addProperty(anvilLevel); } } - + @Shadow public abstract void updateResult(); - + @Inject(method = "canTakeOutput", at = @At("HEAD"), cancellable = true) protected void be_canTakeOutput(PlayerEntity player, boolean present, CallbackInfoReturnable info) { if (be_currentRecipe != null) { info.setReturnValue(be_currentRecipe.checkHammerDurability(input, player)); } } - + @Inject(method = "onTakeOutput", at = @At("HEAD"), cancellable = true) protected void be_onTakeOutput(PlayerEntity player, ItemStack stack, CallbackInfoReturnable info) { if (be_currentRecipe != null) { @@ -74,13 +74,14 @@ public abstract class AnvilScreenHandlerMixin extends ForgingScreenHandler imple this.onContentChanged(input); this.context.run((world, blockPos) -> { BlockState anvilState = world.getBlockState(blockPos); - if (!player.abilities.creativeMode && anvilState.isIn(BlockTags.ANVIL) && player.getRandom().nextFloat() < 0.12F) { + if (!player.abilities.creativeMode && anvilState.isIn(BlockTags.ANVIL) + && player.getRandom().nextFloat() < 0.12F) { BlockState landingState = AnvilBlock.getLandingState(anvilState); if (landingState == null) { world.removeBlock(blockPos, false); world.syncWorldEvent(1029, blockPos, 0); } else { - world.setBlockState(blockPos, landingState, 2); + world.setBlockAndUpdate(blockPos, landingState, 2); world.syncWorldEvent(1030, blockPos, 0); } } else { @@ -90,15 +91,15 @@ public abstract class AnvilScreenHandlerMixin extends ForgingScreenHandler imple info.setReturnValue(stack); } } - + @Inject(method = "updateResult", at = @At("HEAD"), cancellable = true) public void be_updateOutput(CallbackInfo info) { RecipeManager recipeManager = this.player.world.getRecipeManager(); be_recipes = recipeManager.getAllMatches(AnvilRecipe.TYPE, input, player.world); if (be_recipes.size() > 0) { int anvilLevel = this.anvilLevel.get(); - be_recipes = be_recipes.stream().filter(recipe -> - anvilLevel >= recipe.getAnvilLevel()).collect(Collectors.toList()); + be_recipes = be_recipes.stream().filter(recipe -> anvilLevel >= recipe.getAnvilLevel()) + .collect(Collectors.toList()); if (be_recipes.size() > 0) { if (be_currentRecipe == null || !be_recipes.contains(be_currentRecipe)) { be_currentRecipe = be_recipes.get(0); @@ -110,14 +111,14 @@ public abstract class AnvilScreenHandlerMixin extends ForgingScreenHandler imple } } } - + @Inject(method = "setNewItemName", at = @At("HEAD"), cancellable = true) public void be_setNewItemName(String string, CallbackInfo info) { if (be_currentRecipe != null) { info.cancel(); } } - + @Override public boolean onButtonClick(PlayerEntity player, int id) { if (id == 0) { @@ -129,24 +130,25 @@ public abstract class AnvilScreenHandlerMixin extends ForgingScreenHandler imple } return super.onButtonClick(player, id); } - + private void be_updateResult() { - if (be_currentRecipe == null) return; + if (be_currentRecipe == null) + return; this.output.setStack(0, be_currentRecipe.craft(input)); this.sendContentUpdates(); } - + @Override public void be_updateCurrentRecipe(AnvilRecipe recipe) { this.be_currentRecipe = recipe; this.be_updateResult(); } - + @Override public AnvilRecipe be_getCurrentRecipe() { return this.be_currentRecipe; } - + @Override public List be_getRecipes() { return this.be_recipes; diff --git a/src/main/java/ru/betterend/mixin/common/ArmorItemAccessor.java b/src/main/java/ru/betterend/mixin/common/ArmorItemAccessor.java index 8a02ed79..08accbe8 100644 --- a/src/main/java/ru/betterend/mixin/common/ArmorItemAccessor.java +++ b/src/main/java/ru/betterend/mixin/common/ArmorItemAccessor.java @@ -7,9 +7,9 @@ import org.spongepowered.asm.mixin.gen.Accessor; import com.google.common.collect.Multimap; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.item.ArmorItem; +import net.minecraft.world.entity.attribute.EntityAttribute; +import net.minecraft.world.entity.attribute.EntityAttributeModifier; +import net.minecraft.world.item.ArmorItem; @Mixin(ArmorItem.class) public interface ArmorItemAccessor { diff --git a/src/main/java/ru/betterend/mixin/common/BiomeArrayMixin.java b/src/main/java/ru/betterend/mixin/common/BiomeArrayMixin.java index deb834e7..5ac2ad3d 100644 --- a/src/main/java/ru/betterend/mixin/common/BiomeArrayMixin.java +++ b/src/main/java/ru/betterend/mixin/common/BiomeArrayMixin.java @@ -4,8 +4,8 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.source.BiomeArray; import ru.betterend.interfaces.IBiomeArray; @@ -39,7 +39,7 @@ public class BiomeArrayMixin implements IBiomeArray { private int be_getArrayIndex(int biomeX, int biomeY, int biomeZ) { int i = biomeX & HORIZONTAL_BIT_MASK; - int j = MathHelper.clamp(biomeY, 0, VERTICAL_BIT_MASK); + int j = Mth.clamp(biomeY, 0, VERTICAL_BIT_MASK); int k = biomeZ & HORIZONTAL_BIT_MASK; return j << HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT | k << HORIZONTAL_SECTION_COUNT | i; } diff --git a/src/main/java/ru/betterend/mixin/common/BoneMealItemMixin.java b/src/main/java/ru/betterend/mixin/common/BoneMealItemMixin.java index 1eff0099..fa990422 100644 --- a/src/main/java/ru/betterend/mixin/common/BoneMealItemMixin.java +++ b/src/main/java/ru/betterend/mixin/common/BoneMealItemMixin.java @@ -7,16 +7,16 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.item.BoneMealItem; -import net.minecraft.item.ItemUsageContext; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.BoneMealItem; +import net.minecraft.world.item.ItemUsageContext; import net.minecraft.util.ActionResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; import net.minecraft.world.biome.Biome.Category; import ru.betterend.registry.EndBiomes; import ru.betterend.registry.EndBlocks; @@ -28,32 +28,30 @@ import ru.betterend.world.biome.EndBiome; @Mixin(BoneMealItem.class) public class BoneMealItemMixin { private static final Direction[] DIR = BlocksHelper.makeHorizontal(); - private static final Mutable POS = new Mutable(); + private static final MutableBlockPos POS = new MutableBlockPos(); @Inject(method = "useOnBlock", at = @At("HEAD"), cancellable = true) private void be_onUse(ItemUsageContext context, CallbackInfoReturnable info) { - World world = context.getWorld(); + Level world = context.getLevel(); BlockPos blockPos = context.getBlockPos(); - if (!world.isClient) { + if (!world.isClientSide) { BlockPos offseted = blockPos.offset(context.getSide()); boolean endBiome = world.getBiome(offseted).getCategory() == Category.THEEND; - + if (world.getBlockState(blockPos).isIn(EndTags.END_GROUND)) { boolean consume = false; - if (world.getBlockState(blockPos).isOf(Blocks.END_STONE)) { + if (world.getBlockState(blockPos).is(Blocks.END_STONE)) { BlockState nylium = beGetNylium(world, blockPos); if (nylium != null) { BlocksHelper.setWithoutUpdate(world, blockPos, nylium); consume = true; } - } - else { + } else { if (!world.getFluidState(offseted).isEmpty() && endBiome) { if (world.getBlockState(offseted).getBlock().equals(Blocks.WATER)) { consume = beGrowWaterGrass(world, blockPos); } - } - else { + } else { consume = beGrowGrass(world, blockPos); } } @@ -65,8 +63,7 @@ public class BoneMealItemMixin { info.setReturnValue(ActionResult.SUCCESS); info.cancel(); } - } - else if (!world.getFluidState(offseted).isEmpty() && endBiome) { + } else if (!world.getFluidState(offseted).isEmpty() && endBiome) { if (world.getBlockState(offseted).getBlock().equals(Blocks.WATER)) { info.setReturnValue(ActionResult.FAIL); info.cancel(); @@ -74,8 +71,8 @@ public class BoneMealItemMixin { } } } - - private boolean beGrowGrass(World world, BlockPos pos) { + + private boolean beGrowGrass(Level world, BlockPos pos) { int y1 = pos.getY() + 3; int y2 = pos.getY() - 3; boolean result = false; @@ -86,7 +83,7 @@ public class BoneMealItemMixin { POS.setZ(z); for (int y = y1; y >= y2; y--) { POS.setY(y); - BlockPos down = POS.down(); + BlockPos down = POS.below(); if (world.isAir(POS) && !world.isAir(down)) { BlockState grass = beGetGrassState(world, down); if (grass != null) { @@ -99,8 +96,8 @@ public class BoneMealItemMixin { } return result; } - - private boolean beGrowWaterGrass(World world, BlockPos pos) { + + private boolean beGrowWaterGrass(Level world, BlockPos pos) { int y1 = pos.getY() + 3; int y2 = pos.getY() - 3; boolean result = false; @@ -111,8 +108,8 @@ public class BoneMealItemMixin { POS.setZ(z); for (int y = y1; y >= y2; y--) { POS.setY(y); - BlockPos down = POS.down(); - if (world.getBlockState(POS).isOf(Blocks.WATER) && world.getBlockState(down).isIn(EndTags.END_GROUND)) { + BlockPos down = POS.below(); + if (world.getBlockState(POS).is(Blocks.WATER) && world.getBlockState(down).isIn(EndTags.END_GROUND)) { BlockState grass = beGetWaterGrassState(world, down); if (grass != null) { BlocksHelper.setWithoutUpdate(world, POS, grass); @@ -124,27 +121,27 @@ public class BoneMealItemMixin { } return result; } - - private BlockState beGetGrassState(World world, BlockPos pos) { + + private BlockState beGetGrassState(Level world, BlockPos pos) { BlockState state = world.getBlockState(pos); Block block = state.getBlock(); block = BonemealUtil.getGrass(EndBiomes.getBiomeID(world.getBiome(pos)), block, world.getRandom()); - return block == null ? null : block.getDefaultState(); + return block == null ? null : block.defaultBlockState(); } - - private BlockState beGetWaterGrassState(World world, BlockPos pos) { + + private BlockState beGetWaterGrassState(Level world, BlockPos pos) { EndBiome biome = EndBiomes.getFromBiome(world.getBiome(pos)); if (world.random.nextInt(16) == 0) { - return EndBlocks.CHARNIA_RED.getDefaultState(); - } - else if (biome == EndBiomes.FOGGY_MUSHROOMLAND || biome == EndBiomes.MEGALAKE || biome == EndBiomes.MEGALAKE_GROVE) { - return world.random.nextBoolean() ? EndBlocks.CHARNIA_LIGHT_BLUE.getDefaultState() : EndBlocks.CHARNIA_LIGHT_BLUE.getDefaultState(); - } - else if (biome == EndBiomes.AMBER_LAND) { - return world.random.nextBoolean() ? EndBlocks.CHARNIA_ORANGE.getDefaultState() : EndBlocks.CHARNIA_RED.getDefaultState(); - } - else if (biome == EndBiomes.CHORUS_FOREST || biome == EndBiomes.SHADOW_FOREST) { - return EndBlocks.CHARNIA_PURPLE.getDefaultState(); + return EndBlocks.CHARNIA_RED.defaultBlockState(); + } else if (biome == EndBiomes.FOGGY_MUSHROOMLAND || biome == EndBiomes.MEGALAKE + || biome == EndBiomes.MEGALAKE_GROVE) { + return world.random.nextBoolean() ? EndBlocks.CHARNIA_LIGHT_BLUE.defaultBlockState() + : EndBlocks.CHARNIA_LIGHT_BLUE.defaultBlockState(); + } else if (biome == EndBiomes.AMBER_LAND) { + return world.random.nextBoolean() ? EndBlocks.CHARNIA_ORANGE.defaultBlockState() + : EndBlocks.CHARNIA_RED.defaultBlockState(); + } else if (biome == EndBiomes.CHORUS_FOREST || biome == EndBiomes.SHADOW_FOREST) { + return EndBlocks.CHARNIA_PURPLE.defaultBlockState(); } return null; } @@ -158,10 +155,10 @@ public class BoneMealItemMixin { } } - private BlockState beGetNylium(World world, BlockPos pos) { + private BlockState beGetNylium(Level world, BlockPos pos) { beShuffle(world.random); for (Direction dir : DIR) { - BlockState state = world.getBlockState(pos.offset(dir)); + BlockState state = world.getBlockState(pos.relative(dir)); if (BlocksHelper.isEndNylium(state)) return state; } diff --git a/src/main/java/ru/betterend/mixin/common/BrewingAccessor.java b/src/main/java/ru/betterend/mixin/common/BrewingAccessor.java index 17129e52..3c46279d 100644 --- a/src/main/java/ru/betterend/mixin/common/BrewingAccessor.java +++ b/src/main/java/ru/betterend/mixin/common/BrewingAccessor.java @@ -3,9 +3,9 @@ package ru.betterend.mixin.common; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; -import net.minecraft.item.Item; +import net.minecraft.world.item.Item; import net.minecraft.potion.Potion; -import net.minecraft.recipe.BrewingRecipeRegistry; +import net.minecraft.world.item.crafting.BrewingRecipeRegistry; @Mixin(BrewingRecipeRegistry.class) public interface BrewingAccessor { diff --git a/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java b/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java index bc394a99..da3255b4 100644 --- a/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java +++ b/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java @@ -11,20 +11,20 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ChorusFlowerBlock; -import net.minecraft.block.ChorusPlantBlock; -import net.minecraft.block.ShapeContext; -import net.minecraft.server.world.ServerWorld; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ChorusFlowerBlock; +import net.minecraft.world.level.block.ChorusPlantBlock; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.server.level.ServerLevel; import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndTags; @@ -35,75 +35,80 @@ import ru.betterend.world.generator.GeneratorOptions; public abstract class ChorusFlowerBlockMixin extends Block { private static final VoxelShape SHAPE_FULL = Block.createCuboidShape(0, 0, 0, 16, 16, 16); private static final VoxelShape SHAPE_HALF = Block.createCuboidShape(0, 0, 0, 16, 4, 16); - - public ChorusFlowerBlockMixin(Settings settings) { + + public ChorusFlowerBlockMixin(Properties settings) { super(settings); } @Shadow @Final private ChorusPlantBlock plantBlock; - + @Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true) private void beCanPlace(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable info) { - if (world.getBlockState(pos.down()).isOf(EndBlocks.CHORUS_NYLIUM)) { + if (world.getBlockState(pos.below()).is(EndBlocks.CHORUS_NYLIUM)) { info.setReturnValue(true); info.cancel(); } } - + @Inject(method = "randomTick", at = @At("HEAD"), cancellable = true) - private void beOnTick(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo info) { - if (world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) { + private void beOnTick(BlockState state, ServerLevel world, BlockPos pos, Random random, CallbackInfo info) { + if (world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) { BlockPos up = pos.up(); if (world.isAir(up) && up.getY() < 256) { - int i = state.get(ChorusFlowerBlock.AGE); + int i = state.getValue(ChorusFlowerBlock.AGE); if (i < 5) { this.grow(world, up, i + 1); if (GeneratorOptions.changeChorusPlant()) { - BlocksHelper.setWithoutUpdate(world, pos, plantBlock.getDefaultState().with(ChorusPlantBlock.UP, true).with(ChorusPlantBlock.DOWN, true).with(BlocksHelper.ROOTS, true)); - } - else { - BlocksHelper.setWithoutUpdate(world, pos, plantBlock.getDefaultState().with(ChorusPlantBlock.UP, true).with(ChorusPlantBlock.DOWN, true)); + BlocksHelper.setWithoutUpdate(world, pos, + plantBlock.defaultBlockState().with(ChorusPlantBlock.UP, true) + .with(ChorusPlantBlock.DOWN, true).with(BlocksHelper.ROOTS, true)); + } else { + BlocksHelper.setWithoutUpdate(world, pos, plantBlock.defaultBlockState() + .with(ChorusPlantBlock.UP, true).with(ChorusPlantBlock.DOWN, true)); } info.cancel(); } } } } - + @Inject(method = "generate", at = @At("RETURN"), cancellable = true) - private static void beOnGenerate(WorldAccess world, BlockPos pos, Random random, int size, CallbackInfo info) { + private static void beOnGenerate(LevelAccessor world, BlockPos pos, Random random, int size, CallbackInfo info) { BlockState state = world.getBlockState(pos); - if (GeneratorOptions.changeChorusPlant() && state.isOf(Blocks.CHORUS_PLANT)) { + if (GeneratorOptions.changeChorusPlant() && state.is(Blocks.CHORUS_PLANT)) { BlocksHelper.setWithoutUpdate(world, pos, state.with(BlocksHelper.ROOTS, true)); } } - + @Shadow - private static boolean isSurroundedByAir(WorldView world, BlockPos pos, @Nullable Direction exceptDirection) { return false; } - + private static boolean isSurroundedByAir(WorldView world, BlockPos pos, @Nullable Direction exceptDirection) { + return false; + } + @Shadow - private void grow(World world, BlockPos pos, int age) {} - + private void grow(Level world, BlockPos pos, int age) { + } + @Shadow - private void die(World world, BlockPos pos) {} - + private void die(Level world, BlockPos pos) { + } + @Override public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { if (GeneratorOptions.changeChorusPlant()) { - return state.get(ChorusFlowerBlock.AGE) == 5 ? SHAPE_HALF : SHAPE_FULL; - } - else { + return state.getValue(ChorusFlowerBlock.AGE) == 5 ? SHAPE_HALF : SHAPE_FULL; + } else { return super.getOutlineShape(state, world, pos, context); } } @Inject(method = "die", at = @At("HEAD"), cancellable = true) - private void beOnDie(World world, BlockPos pos, CallbackInfo info) { - BlockState down = world.getBlockState(pos.down()); - if (down.isOf(Blocks.CHORUS_PLANT) || down.isIn(EndTags.GEN_TERRAIN)) { - world.setBlockState(pos, this.getDefaultState().with(Properties.AGE_5, 5), 2); + private void beOnDie(Level world, BlockPos pos, CallbackInfo info) { + BlockState down = world.getBlockState(pos.below()); + if (down.is(Blocks.CHORUS_PLANT) || down.isIn(EndTags.GEN_TERRAIN)) { + world.setBlockAndUpdate(pos, this.defaultBlockState().with(Properties.AGE_5, 5), 2); world.syncWorldEvent(1034, pos, 0); } info.cancel(); diff --git a/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java b/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java index 10fcef63..ce3b77ad 100644 --- a/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java +++ b/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java @@ -6,19 +6,19 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ChorusPlantBlock; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.state.StateManager; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ChorusPlantBlock; +import net.minecraft.world.item.ItemPlacementContext; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.WorldView; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndTags; @@ -27,39 +27,37 @@ import ru.betterend.world.generator.GeneratorOptions; @Mixin(value = ChorusPlantBlock.class, priority = 100) public abstract class ChorusPlantBlockMixin extends Block { - public ChorusPlantBlockMixin(Settings settings) { + public ChorusPlantBlockMixin(Properties settings) { super(settings); } @Inject(method = "*", at = @At("TAIL")) - private void beOnInit(AbstractBlock.Settings settings, CallbackInfo info) { + private void beOnInit(AbstractBlock.Properties settings, CallbackInfo info) { if (GeneratorOptions.changeChorusPlant()) { - this.setDefaultState(this.getDefaultState().with(BlocksHelper.ROOTS, false)); + this.setDefaultState(this.defaultBlockState().with(BlocksHelper.ROOTS, false)); } } - - @Inject(method = "appendProperties", at = @At("TAIL")) - private void beAddProperties(StateManager.Builder builder, CallbackInfo info) { + + @Inject(method = "createBlockStateDefinition", at = @At("TAIL")) + private void beAddProperties(StateDefinition.Builder builder, CallbackInfo info) { GeneratorOptions.init(); if (GeneratorOptions.changeChorusPlant()) { builder.add(BlocksHelper.ROOTS); } } - + @Inject(method = "withConnectionProperties", at = @At("RETURN"), cancellable = true) private void beConnectionProperties(BlockView world, BlockPos pos, CallbackInfoReturnable info) { BlockState plant = info.getReturnValue(); - if (plant.isOf(Blocks.CHORUS_PLANT)) { - if (world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) { + if (plant.is(Blocks.CHORUS_PLANT)) { + if (world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) { if (GeneratorOptions.changeChorusPlant()) { info.setReturnValue(plant.with(Properties.DOWN, true).with(BlocksHelper.ROOTS, true)); - } - else { + } else { info.setReturnValue(plant.with(Properties.DOWN, true)); } info.cancel(); - } - else { + } else { if (GeneratorOptions.changeChorusPlant()) { info.setReturnValue(plant.with(BlocksHelper.ROOTS, false)); } @@ -67,30 +65,29 @@ public abstract class ChorusPlantBlockMixin extends Block { } } } - + @Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true) private void beCanPlace(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable info) { - BlockState down = world.getBlockState(pos.down()); - if (down.isOf(EndBlocks.CHORUS_NYLIUM) || down.isOf(Blocks.END_STONE)) { + BlockState down = world.getBlockState(pos.below()); + if (down.is(EndBlocks.CHORUS_NYLIUM) || down.is(Blocks.END_STONE)) { info.setReturnValue(true); info.cancel(); } } - - @Inject(method = "getStateForNeighborUpdate", at = @At("RETURN"), cancellable = true) - private void beStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom, CallbackInfoReturnable info) { + + @Inject(method = "updateShape", at = @At("RETURN"), cancellable = true) + private void beStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, + LevelAccessor world, BlockPos pos, BlockPos posFrom, CallbackInfoReturnable info) { BlockState plant = info.getReturnValue(); - if (plant.isOf(Blocks.CHORUS_PLANT)) { - if (world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) { + if (plant.is(Blocks.CHORUS_PLANT)) { + if (world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) { if (GeneratorOptions.changeChorusPlant()) { plant = plant.with(Properties.DOWN, true).with(BlocksHelper.ROOTS, true); - } - else { + } else { plant = plant.with(Properties.DOWN, true); } info.cancel(); - } - else { + } else { if (GeneratorOptions.changeChorusPlant()) { plant = plant.with(BlocksHelper.ROOTS, false); } @@ -100,17 +97,17 @@ public abstract class ChorusPlantBlockMixin extends Block { info.cancel(); } } - + @Inject(method = "getPlacementState", at = @At("RETURN"), cancellable = true) private void beGetPlacementState(ItemPlacementContext ctx, CallbackInfoReturnable info) { BlockPos pos = ctx.getBlockPos(); - World world = ctx.getWorld(); + Level world = ctx.getLevel(); BlockState plant = info.getReturnValue(); - if (ctx.canPlace() && plant.isOf(Blocks.CHORUS_PLANT) && world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) { + if (ctx.canPlace() && plant.is(Blocks.CHORUS_PLANT) + && world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) { if (GeneratorOptions.changeChorusPlant()) { info.setReturnValue(plant.with(BlocksHelper.ROOTS, true).with(Properties.DOWN, true)); - } - else { + } else { info.setReturnValue(plant.with(Properties.DOWN, true)); } info.cancel(); diff --git a/src/main/java/ru/betterend/mixin/common/ChorusPlantFeatureMixin.java b/src/main/java/ru/betterend/mixin/common/ChorusPlantFeatureMixin.java index 1c11ceca..e55d6160 100644 --- a/src/main/java/ru/betterend/mixin/common/ChorusPlantFeatureMixin.java +++ b/src/main/java/ru/betterend/mixin/common/ChorusPlantFeatureMixin.java @@ -7,11 +7,11 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ChorusFlowerBlock; -import net.minecraft.block.ConnectingBlock; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ChorusFlowerBlock; +import net.minecraft.world.level.block.ConnectingBlock; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.ChorusPlantFeature; @@ -24,16 +24,19 @@ import ru.betterend.world.generator.GeneratorOptions; @Mixin(ChorusPlantFeature.class) public class ChorusPlantFeatureMixin { @Inject(method = "generate", at = @At("HEAD"), cancellable = true) - private void be_onGenerate(StructureWorldAccess structureWorldAccess, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig defaultFeatureConfig, CallbackInfoReturnable info) { - if (structureWorldAccess.isAir(blockPos) && structureWorldAccess.getBlockState(blockPos.down()).isOf(EndBlocks.CHORUS_NYLIUM)) { + private void be_onGenerate(StructureWorldAccess structureWorldAccess, ChunkGenerator chunkGenerator, Random random, + BlockPos blockPos, DefaultFeatureConfig defaultFeatureConfig, CallbackInfoReturnable info) { + if (structureWorldAccess.isAir(blockPos) + && structureWorldAccess.getBlockState(blockPos.below()).is(EndBlocks.CHORUS_NYLIUM)) { ChorusFlowerBlock.generate(structureWorldAccess, blockPos, random, MHelper.randRange(8, 16, random)); BlockState bottom = structureWorldAccess.getBlockState(blockPos); - if (bottom.isOf(Blocks.CHORUS_PLANT)) { + if (bottom.is(Blocks.CHORUS_PLANT)) { if ((GeneratorOptions.changeChorusPlant())) { - BlocksHelper.setWithoutUpdate(structureWorldAccess, blockPos, bottom.with(BlocksHelper.ROOTS, true).with(ConnectingBlock.DOWN, true)); - } - else { - BlocksHelper.setWithoutUpdate(structureWorldAccess, blockPos, bottom.with(ConnectingBlock.DOWN, true)); + BlocksHelper.setWithoutUpdate(structureWorldAccess, blockPos, + bottom.with(BlocksHelper.ROOTS, true).with(ConnectingBlock.DOWN, true)); + } else { + BlocksHelper.setWithoutUpdate(structureWorldAccess, blockPos, + bottom.with(ConnectingBlock.DOWN, true)); } } info.setReturnValue(true); diff --git a/src/main/java/ru/betterend/mixin/common/ComposterBlockAccessor.java b/src/main/java/ru/betterend/mixin/common/ComposterBlockAccessor.java index e5bf69a9..d2931d21 100644 --- a/src/main/java/ru/betterend/mixin/common/ComposterBlockAccessor.java +++ b/src/main/java/ru/betterend/mixin/common/ComposterBlockAccessor.java @@ -3,8 +3,8 @@ package ru.betterend.mixin.common; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; -import net.minecraft.block.ComposterBlock; -import net.minecraft.item.ItemConvertible; +import net.minecraft.world.level.block.ComposterBlock; +import net.minecraft.world.item.ItemConvertible; @Mixin(ComposterBlock.class) public interface ComposterBlockAccessor { diff --git a/src/main/java/ru/betterend/mixin/common/CraftingScreenHandlerMixin.java b/src/main/java/ru/betterend/mixin/common/CraftingScreenHandlerMixin.java index 7e533fa9..ec38ae5e 100644 --- a/src/main/java/ru/betterend/mixin/common/CraftingScreenHandlerMixin.java +++ b/src/main/java/ru/betterend/mixin/common/CraftingScreenHandlerMixin.java @@ -7,14 +7,13 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.block.CraftingTableBlock; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.level.block.CraftingTableBlock; +import net.minecraft.world.entity.player.PlayerEntity; import net.minecraft.screen.CraftingScreenHandler; import net.minecraft.screen.ScreenHandlerContext; @Mixin(CraftingScreenHandler.class) -public abstract class CraftingScreenHandlerMixin -{ +public abstract class CraftingScreenHandlerMixin { @Shadow @Final private ScreenHandlerContext context; diff --git a/src/main/java/ru/betterend/mixin/common/DimensionTypeMixin.java b/src/main/java/ru/betterend/mixin/common/DimensionTypeMixin.java index a851723c..618d38c8 100644 --- a/src/main/java/ru/betterend/mixin/common/DimensionTypeMixin.java +++ b/src/main/java/ru/betterend/mixin/common/DimensionTypeMixin.java @@ -5,9 +5,9 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; import net.minecraft.world.biome.Biome; -import net.minecraft.world.dimension.DimensionType; +import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.ChunkGeneratorSettings; import net.minecraft.world.gen.chunk.NoiseChunkGenerator; @@ -17,13 +17,15 @@ import ru.betterend.world.generator.GeneratorOptions; @Mixin(value = DimensionType.class, priority = 100) public class DimensionTypeMixin { @Inject(method = "createEndGenerator", at = @At("HEAD"), cancellable = true) - private static void be_replaceGenerator(Registry biomeRegistry, Registry chunkGeneratorSettingsRegistry, long seed, CallbackInfoReturnable info) { + private static void be_replaceGenerator(Registry biomeRegistry, + Registry chunkGeneratorSettingsRegistry, long seed, + CallbackInfoReturnable info) { info.setReturnValue(new NoiseChunkGenerator(new BetterEndBiomeSource(biomeRegistry, seed), seed, () -> { return (ChunkGeneratorSettings) chunkGeneratorSettingsRegistry.getOrThrow(ChunkGeneratorSettings.END); })); info.cancel(); } - + @Inject(method = "hasEnderDragonFight", at = @At("HEAD"), cancellable = true) private void be_hasEnderDragonFight(CallbackInfoReturnable info) { if (!GeneratorOptions.hasDragonFights()) { diff --git a/src/main/java/ru/betterend/mixin/common/EnchantmentScreenHandlerMixin.java b/src/main/java/ru/betterend/mixin/common/EnchantmentScreenHandlerMixin.java index 669666ea..faba5e67 100644 --- a/src/main/java/ru/betterend/mixin/common/EnchantmentScreenHandlerMixin.java +++ b/src/main/java/ru/betterend/mixin/common/EnchantmentScreenHandlerMixin.java @@ -10,16 +10,16 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.EnchantmentLevelEntry; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.EnchantmentLevelEntry; import net.minecraft.inventory.Inventory; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraft.screen.EnchantmentScreenHandler; import net.minecraft.screen.Property; import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandlerContext; import net.minecraft.screen.ScreenHandlerType; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; import ru.betterend.registry.EndTags; @Mixin(EnchantmentScreenHandler.class) @@ -67,7 +67,8 @@ public abstract class EnchantmentScreenHandlerMixin extends ScreenHandler { int j; for (j = -1; j <= 1; ++j) { for (int k = -1; k <= 1; ++k) { - if ((j != 0 || k != 0) && world.isAir(blockPos.add(k, 0, j)) && world.isAir(blockPos.add(k, 1, j))) { + if ((j != 0 || k != 0) && world.isAir(blockPos.add(k, 0, j)) + && world.isAir(blockPos.add(k, 1, j))) { if (world.getBlockState(blockPos.add(k * 2, 0, j * 2)).isIn(EndTags.BOOKSHELVES)) { ++i; } @@ -100,7 +101,8 @@ public abstract class EnchantmentScreenHandlerMixin extends ScreenHandler { this.random.setSeed((long) this.seed.get()); for (j = 0; j < 3; ++j) { - this.enchantmentPower[j] = EnchantmentHelper.calculateRequiredExperienceLevel(this.random, j, i, itemStack); + this.enchantmentPower[j] = EnchantmentHelper.calculateRequiredExperienceLevel(this.random, j, i, + itemStack); this.enchantmentId[j] = -1; this.enchantmentLevel[j] = -1; if (this.enchantmentPower[j] < j + 1) { @@ -110,10 +112,13 @@ public abstract class EnchantmentScreenHandlerMixin extends ScreenHandler { for (j = 0; j < 3; ++j) { if (this.enchantmentPower[j] > 0) { - List list = this.generateEnchantments(itemStack, j, this.enchantmentPower[j]); + List list = this.generateEnchantments(itemStack, j, + this.enchantmentPower[j]); if (list != null && !list.isEmpty()) { - EnchantmentLevelEntry enchantmentLevelEntry = (EnchantmentLevelEntry) list.get(this.random.nextInt(list.size())); - this.enchantmentId[j] = Registry.ENCHANTMENT.getRawId(enchantmentLevelEntry.enchantment); + EnchantmentLevelEntry enchantmentLevelEntry = (EnchantmentLevelEntry) list + .get(this.random.nextInt(list.size())); + this.enchantmentId[j] = Registry.ENCHANTMENT + .getRawId(enchantmentLevelEntry.enchantment); this.enchantmentLevel[j] = enchantmentLevelEntry.level; } } @@ -121,8 +126,7 @@ public abstract class EnchantmentScreenHandlerMixin extends ScreenHandler { this.sendContentUpdates(); }); - } - else { + } else { for (int i = 0; i < 3; ++i) { this.enchantmentPower[i] = 0; this.enchantmentId[i] = -1; diff --git a/src/main/java/ru/betterend/mixin/common/EndPortalFeatureMixin.java b/src/main/java/ru/betterend/mixin/common/EndPortalFeatureMixin.java index b874e9b8..3d4b0f51 100644 --- a/src/main/java/ru/betterend/mixin/common/EndPortalFeatureMixin.java +++ b/src/main/java/ru/betterend/mixin/common/EndPortalFeatureMixin.java @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import net.minecraft.nbt.NbtHelper; import net.minecraft.structure.Structure; import net.minecraft.structure.StructurePlacementData; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.Heightmap.Type; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; @@ -29,16 +29,17 @@ public class EndPortalFeatureMixin { @Final @Shadow private boolean open; - + @Inject(method = "generate", at = @At("HEAD"), cancellable = true) - private void bePortalGenerate(StructureWorldAccess world, ChunkGenerator generator, Random random, BlockPos blockPos, DefaultFeatureConfig config, CallbackInfoReturnable info) { + private void bePortalGenerate(StructureWorldAccess world, ChunkGenerator generator, Random random, + BlockPos blockPos, DefaultFeatureConfig config, CallbackInfoReturnable info) { if (!GeneratorOptions.hasPortal()) { info.setReturnValue(false); info.cancel(); - } - else if (GeneratorOptions.replacePortal()) { + } else if (GeneratorOptions.replacePortal()) { blockPos = be_updatePos(blockPos, world); - Structure structure = StructureHelper.readStructure(BetterEnd.makeID(open ? "portal/end_portal_active" : "portal/end_portal_inactive")); + Structure structure = StructureHelper + .readStructure(BetterEnd.makeID(open ? "portal/end_portal_active" : "portal/end_portal_inactive")); BlockPos size = structure.getSize(); blockPos = blockPos.add(-(size.getX() >> 1), -3, -(size.getZ() >> 1)); structure.place(world, blockPos, new StructurePlacementData(), random); @@ -46,12 +47,12 @@ public class EndPortalFeatureMixin { info.cancel(); } } - + @ModifyVariable(method = "generate", ordinal = 0, at = @At("HEAD")) private BlockPos be_setPosOnGround(BlockPos blockPos, StructureWorldAccess world) { return be_updatePos(blockPos, world); } - + private BlockPos be_updatePos(BlockPos blockPos, StructureWorldAccess world) { if (GeneratorOptions.useNewGenerator()) { BlockPos pos = GeneratorOptions.getPortalPos(); diff --git a/src/main/java/ru/betterend/mixin/common/EndSpikeFeatureMixin.java b/src/main/java/ru/betterend/mixin/common/EndSpikeFeatureMixin.java index 44f69e31..579fc164 100644 --- a/src/main/java/ru/betterend/mixin/common/EndSpikeFeatureMixin.java +++ b/src/main/java/ru/betterend/mixin/common/EndSpikeFeatureMixin.java @@ -8,17 +8,17 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.PaneBlock; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.decoration.EndCrystalEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.PaneBlock; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.decoration.EndCrystalEntity; import net.minecraft.nbt.CompoundTag; import net.minecraft.structure.Structure; import net.minecraft.structure.StructurePlacementData; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.MathHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.util.Mth; import net.minecraft.world.Heightmap.Type; import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.StructureWorldAccess; @@ -34,54 +34,58 @@ import ru.betterend.world.generator.GeneratorOptions; @Mixin(EndSpikeFeature.class) public class EndSpikeFeatureMixin { @Inject(method = "generate", at = @At("HEAD"), cancellable = true) - private void beSpikeGenerate(StructureWorldAccess structureWorldAccess, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, EndSpikeFeatureConfig endSpikeFeatureConfig, CallbackInfoReturnable info) { + private void beSpikeGenerate(StructureWorldAccess structureWorldAccess, ChunkGenerator chunkGenerator, + Random random, BlockPos blockPos, EndSpikeFeatureConfig endSpikeFeatureConfig, + CallbackInfoReturnable info) { if (!GeneratorOptions.hasPillars()) { info.setReturnValue(false); } } @Inject(method = "generateSpike", at = @At("HEAD"), cancellable = true) - private void be_generateSpike(ServerWorldAccess world, Random random, EndSpikeFeatureConfig config, EndSpikeFeature.Spike spike, CallbackInfo info) { + private void be_generateSpike(ServerWorldAccess world, Random random, EndSpikeFeatureConfig config, + EndSpikeFeature.Spike spike, CallbackInfo info) { int x = spike.getCenterX(); int z = spike.getCenterZ(); int radius = spike.getRadius(); int minY = 0; - + long lx = (long) x; long lz = (long) z; if (lx * lx + lz * lz < 10000) { String pillarID = String.format("%d_%d", x, z); CompoundTag pillar = WorldDataUtil.getCompoundTag("pillars"); boolean haveValue = pillar.contains(pillarID); - minY = haveValue ? pillar.getInt(pillarID) : world.getChunk(x >> 4, z >> 4).sampleHeightmap(Type.WORLD_SURFACE, x & 15, z); + minY = haveValue ? pillar.getInt(pillarID) + : world.getChunk(x >> 4, z >> 4).sampleHeightmap(Type.WORLD_SURFACE, x & 15, z); if (!haveValue) { pillar.putInt(pillarID, minY); WorldDataUtil.saveFile(); } - } - else { + } else { minY = world.getChunk(x >> 4, z >> 4).sampleHeightmap(Type.WORLD_SURFACE, x & 15, z); } - + int maxY = minY + spike.getHeight() - 64; - + if (GeneratorOptions.replacePillars() && be_radiusInRange(radius)) { radius--; Structure base = StructureHelper.readStructure(BetterEnd.makeID("pillars/pillar_base_" + radius)); - Structure top = StructureHelper.readStructure(BetterEnd.makeID("pillars/pillar_top_" + radius + (spike.isGuarded() ? "_cage" : ""))); + Structure top = StructureHelper.readStructure( + BetterEnd.makeID("pillars/pillar_top_" + radius + (spike.isGuarded() ? "_cage" : ""))); BlockPos side = base.getSize(); BlockPos pos1 = new BlockPos(x - (side.getX() >> 1), minY - 3, z - (side.getZ() >> 1)); minY = pos1.getY() + side.getY(); side = top.getSize(); BlockPos pos2 = new BlockPos(x - (side.getX() >> 1), maxY, z - (side.getZ() >> 1)); maxY = pos2.getY(); - + StructurePlacementData data = new StructurePlacementData(); base.place(world, pos1, data, random); top.place(world, pos2, data, random); - + int r2 = radius * radius + 1; - Mutable mut = new Mutable(); + MutableBlockPos mut = new MutableBlockPos(); for (int px = -radius; px <= radius; px++) { mut.setX(x + px); int x2 = px * px; @@ -92,10 +96,10 @@ public class EndSpikeFeatureMixin { for (int py = minY; py < maxY; py++) { mut.setY(py); if (world.getBlockState(mut).getMaterial().isReplaceable()) { - if ((px == radius || px == -radius || pz == radius || pz == -radius) && random.nextInt(24) == 0) { + if ((px == radius || px == -radius || pz == radius || pz == -radius) + && random.nextInt(24) == 0) { BlocksHelper.setWithoutUpdate(world, mut, Blocks.CRYING_OBSIDIAN); - } - else { + } else { BlocksHelper.setWithoutUpdate(world, mut, Blocks.OBSIDIAN); } } @@ -103,11 +107,10 @@ public class EndSpikeFeatureMixin { } } } - } - else { + } else { minY -= 15; int r2 = radius * radius + 1; - Mutable mut = new Mutable(); + MutableBlockPos mut = new MutableBlockPos(); for (int px = -radius; px <= radius; px++) { mut.setX(x + px); int x2 = px * px; @@ -128,25 +131,30 @@ public class EndSpikeFeatureMixin { mut.setZ(z); mut.setY(maxY); BlocksHelper.setWithoutUpdate(world, mut, Blocks.BEDROCK); - + EndCrystalEntity crystal = EntityType.END_CRYSTAL.create(world.toServerWorld()); crystal.setBeamTarget(config.getPos()); crystal.setInvulnerable(config.isCrystalInvulnerable()); crystal.refreshPositionAndAngles(x + 0.5D, maxY + 1, z + 0.5D, random.nextFloat() * 360.0F, 0.0F); world.spawnEntity(crystal); - + if (spike.isGuarded()) { for (int px = -2; px <= 2; ++px) { - boolean bl = MathHelper.abs(px) == 2; + boolean bl = Mth.abs(px) == 2; for (int pz = -2; pz <= 2; ++pz) { - boolean bl2 = MathHelper.abs(pz) == 2; + boolean bl2 = Mth.abs(pz) == 2; for (int py = 0; py <= 3; ++py) { boolean bl3 = py == 3; if (bl || bl2 || bl3) { boolean bl4 = px == -2 || px == 2 || bl3; boolean bl5 = pz == -2 || pz == 2 || bl3; - BlockState blockState = (BlockState) ((BlockState) ((BlockState) ((BlockState) Blocks.IRON_BARS.getDefaultState().with(PaneBlock.NORTH, bl4 && pz != -2)).with(PaneBlock.SOUTH, bl4 && pz != 2)).with(PaneBlock.WEST, bl5 && px != -2)).with(PaneBlock.EAST, bl5 && px != 2); - BlocksHelper.setWithoutUpdate(world, mut.set(spike.getCenterX() + px, maxY + py, spike.getCenterZ() + pz), blockState); + BlockState blockState = (BlockState) ((BlockState) ((BlockState) ((BlockState) Blocks.IRON_BARS + .defaultBlockState().with(PaneBlock.NORTH, bl4 && pz != -2)) + .with(PaneBlock.SOUTH, bl4 && pz != 2)).with(PaneBlock.WEST, + bl5 && px != -2)).with(PaneBlock.EAST, bl5 && px != 2); + BlocksHelper.setWithoutUpdate(world, + mut.set(spike.getCenterX() + px, maxY + py, spike.getCenterZ() + pz), + blockState); } } } @@ -156,7 +164,7 @@ public class EndSpikeFeatureMixin { info.cancel(); } - + private boolean be_radiusInRange(int radius) { return radius > 1 && radius < 6; } diff --git a/src/main/java/ru/betterend/mixin/common/EndermanEntityMixin.java b/src/main/java/ru/betterend/mixin/common/EndermanEntityMixin.java index 3abbf94d..8cef9161 100644 --- a/src/main/java/ru/betterend/mixin/common/EndermanEntityMixin.java +++ b/src/main/java/ru/betterend/mixin/common/EndermanEntityMixin.java @@ -5,20 +5,20 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.mob.EndermanEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.mob.EndermanEntity; +import net.minecraft.world.entity.player.PlayerEntity; import ru.betterend.effects.EndEnchantments; import ru.betterend.effects.EndStatusEffects; @Mixin(EndermanEntity.class) public abstract class EndermanEntityMixin { - + @Inject(method = "isPlayerStaring", at = @At("HEAD"), cancellable = true) private void be_isPlayerStaring(PlayerEntity player, CallbackInfoReturnable info) { - if (player.isCreative() || player.hasStatusEffect(EndStatusEffects.END_VEIL) || - EnchantmentHelper.getLevel(EndEnchantments.END_VEIL, player.getEquippedStack(EquipmentSlot.HEAD)) > 0) { + if (player.isCreative() || player.hasStatusEffect(EndStatusEffects.END_VEIL) || EnchantmentHelper + .getLevel(EndEnchantments.END_VEIL, player.getEquippedStack(EquipmentSlot.HEAD)) > 0) { info.setReturnValue(false); } } diff --git a/src/main/java/ru/betterend/mixin/common/EntityMixin.java b/src/main/java/ru/betterend/mixin/common/EntityMixin.java index de405742..3a5f1047 100644 --- a/src/main/java/ru/betterend/mixin/common/EntityMixin.java +++ b/src/main/java/ru/betterend/mixin/common/EntityMixin.java @@ -7,13 +7,13 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.TeleportTarget; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.interfaces.TeleportingEntity; @Mixin(Entity.class) @@ -26,26 +26,26 @@ public abstract class EntityMixin implements TeleportingEntity { @Shadow public boolean removed; @Shadow - public World world; - + public Level world; + @Final @Shadow public abstract void detach(); - + @Shadow public abstract Vec3d getVelocity(); - + @Shadow public abstract EntityType getType(); - + @Shadow - protected abstract TeleportTarget getTeleportTarget(ServerWorld destination); + protected abstract TeleportTarget getTeleportTarget(ServerLevel destination); private BlockPos exitPos; @Inject(method = "moveToWorld", at = @At("HEAD"), cancellable = true) - public void be_moveToWorld(ServerWorld destination, CallbackInfoReturnable info) { - if (!removed && beCanTeleport() && world instanceof ServerWorld) { + public void be_moveToWorld(ServerLevel destination, CallbackInfoReturnable info) { + if (!removed && beCanTeleport() && world instanceof ServerLevel) { this.detach(); this.world.getProfiler().push("changeDimension"); this.world.getProfiler().push("reposition"); @@ -55,13 +55,14 @@ public abstract class EntityMixin implements TeleportingEntity { Entity entity = this.getType().create(destination); if (entity != null) { entity.copyFrom(Entity.class.cast(this)); - entity.refreshPositionAndAngles(teleportTarget.position.x, teleportTarget.position.y, teleportTarget.position.z, teleportTarget.yaw, entity.pitch); + entity.refreshPositionAndAngles(teleportTarget.position.x, teleportTarget.position.y, + teleportTarget.position.z, teleportTarget.yaw, entity.pitch); entity.setVelocity(teleportTarget.velocity); destination.onDimensionChanged(entity); } this.removed = true; this.world.getProfiler().pop(); - ((ServerWorld) world).resetIdleTimeout(); + ((ServerLevel) world).resetIdleTimeout(); destination.resetIdleTimeout(); this.world.getProfiler().pop(); this.beResetExitPos(); @@ -69,11 +70,12 @@ public abstract class EntityMixin implements TeleportingEntity { } } } - + @Inject(method = "getTeleportTarget", at = @At("HEAD"), cancellable = true) - protected void be_getTeleportTarget(ServerWorld destination, CallbackInfoReturnable info) { + protected void be_getTeleportTarget(ServerLevel destination, CallbackInfoReturnable info) { if (beCanTeleport()) { - info.setReturnValue(new TeleportTarget(new Vec3d(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5), getVelocity(), yaw, pitch)); + info.setReturnValue(new TeleportTarget( + new Vec3d(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5), getVelocity(), yaw, pitch)); } } diff --git a/src/main/java/ru/betterend/mixin/common/HostileEntityMixin.java b/src/main/java/ru/betterend/mixin/common/HostileEntityMixin.java index 0e2e4bcb..04ab3397 100644 --- a/src/main/java/ru/betterend/mixin/common/HostileEntityMixin.java +++ b/src/main/java/ru/betterend/mixin/common/HostileEntityMixin.java @@ -8,22 +8,26 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.mob.EndermanEntity; -import net.minecraft.entity.mob.HostileEntity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.SpawnReason; +import net.minecraft.world.entity.mob.EndermanEntity; +import net.minecraft.world.entity.mob.HostileEntity; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.world.ServerWorldAccess; @Mixin(HostileEntity.class) public class HostileEntityMixin { @Inject(method = "canSpawnInDark", at = @At(value = "RETURN"), cancellable = true) - private static void be_endermenCheck(EntityType type, ServerWorldAccess serverWorldAccess, SpawnReason spawnReason, BlockPos pos, Random random, CallbackInfoReturnable info) { + private static void be_endermenCheck(EntityType type, ServerWorldAccess serverWorldAccess, + SpawnReason spawnReason, BlockPos pos, Random random, CallbackInfoReturnable info) { boolean canSpawn = info.getReturnValue(); if (canSpawn && spawnReason == SpawnReason.NATURAL && type == EntityType.ENDERMAN) { Box box = new Box(pos).expand(16); - List entities = serverWorldAccess.getEntitiesByClass(EndermanEntity.class, box, (entity) -> { return true; }); + List entities = serverWorldAccess.getEntitiesByClass(EndermanEntity.class, box, + (entity) -> { + return true; + }); info.setReturnValue(entities.size() < 6); } } diff --git a/src/main/java/ru/betterend/mixin/common/LivingEntityMixin.java b/src/main/java/ru/betterend/mixin/common/LivingEntityMixin.java index 442fdeae..58e071f2 100644 --- a/src/main/java/ru/betterend/mixin/common/LivingEntityMixin.java +++ b/src/main/java/ru/betterend/mixin/common/LivingEntityMixin.java @@ -8,24 +8,24 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.item.Item; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.attribute.EntityAttributeModifier; +import net.minecraft.world.entity.attribute.EntityAttributes; +import net.minecraft.world.entity.damage.DamageSource; +import net.minecraft.world.item.Item; @Mixin(LivingEntity.class) public abstract class LivingEntityMixin { private Entity lastAttacker; - + @Inject(method = "damage", at = @At("HEAD")) public void be_damage(DamageSource source, float amount, CallbackInfoReturnable info) { this.lastAttacker = source.getAttacker(); } - + @ModifyArg(method = "damage", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;takeKnockback(FDD)V")) private float be_increaseKnockback(float value, double x, double z) { if (lastAttacker != null && lastAttacker instanceof LivingEntity) { @@ -34,11 +34,12 @@ public abstract class LivingEntityMixin { } return value; } - + private double be_getKnockback(Item tool) { - if (tool == null) return 0.0D; + if (tool == null) + return 0.0D; Collection modifiers = tool.getAttributeModifiers(EquipmentSlot.MAINHAND) - .get(EntityAttributes.GENERIC_ATTACK_KNOCKBACK); + .get(EntityAttributes.GENERIC_ATTACK_KNOCKBACK); if (modifiers.size() > 0) { return modifiers.iterator().next().getValue(); } diff --git a/src/main/java/ru/betterend/mixin/common/MinecraftServerMixin.java b/src/main/java/ru/betterend/mixin/common/MinecraftServerMixin.java index f739527e..3bdf2c65 100644 --- a/src/main/java/ru/betterend/mixin/common/MinecraftServerMixin.java +++ b/src/main/java/ru/betterend/mixin/common/MinecraftServerMixin.java @@ -17,10 +17,10 @@ import net.minecraft.resource.ServerResourceManager; import net.minecraft.server.MinecraftServer; import net.minecraft.server.PlayerManager; import net.minecraft.server.WorldGenerationProgressListener; -import net.minecraft.server.world.ServerWorld; +import net.minecraft.server.level.ServerLevel; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.SaveProperties; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import net.minecraft.world.level.ServerWorldProperties; import ru.betterend.recipe.EndRecipeManager; import ru.betterend.registry.EndBiomes; @@ -30,11 +30,11 @@ import ru.betterend.world.generator.GeneratorOptions; public class MinecraftServerMixin { @Shadow private ServerResourceManager serverResourceManager; - + @Final @Shadow - private Map, ServerWorld> worlds; - + private Map, ServerLevel> worlds; + @Final @Shadow protected SaveProperties saveProperties; @@ -49,25 +49,26 @@ public class MinecraftServerMixin { beInjectRecipes(); EndBiomes.initRegistry((MinecraftServer) (Object) this); } - + @Inject(method = "getOverworld", at = @At(value = "HEAD"), cancellable = true) - private final void beGetOverworld(CallbackInfoReturnable info) { + private final void beGetOverworld(CallbackInfoReturnable info) { if (GeneratorOptions.swapOverworldToEnd()) { - ServerWorld world = worlds.get(World.END); + ServerLevel world = worlds.get(Level.END); if (world == null) { - world = worlds.get(World.OVERWORLD); + world = worlds.get(Level.OVERWORLD); } info.setReturnValue(world); info.cancel(); } } - + @Inject(method = "createWorlds", at = @At(value = "TAIL")) - private final void be_CreateWorlds(WorldGenerationProgressListener worldGenerationProgressListener, CallbackInfo info) { + private final void be_CreateWorlds(WorldGenerationProgressListener worldGenerationProgressListener, + CallbackInfo info) { if (GeneratorOptions.swapOverworldToEnd()) { - ServerWorld world = worlds.get(World.END); + ServerLevel world = worlds.get(Level.END); if (world == null) { - world = worlds.get(World.OVERWORLD); + world = worlds.get(Level.OVERWORLD); } this.getPlayerManager().setMainWorld(world); ServerWorldProperties serverWorldProperties = saveProperties.getMainWorldProperties(); @@ -76,17 +77,20 @@ public class MinecraftServerMixin { setupSpawn(world, serverWorldProperties, generatorOptions.hasBonusChest(), bl, true); } } - + @Inject(method = "setupSpawn", at = @At(value = "HEAD"), cancellable = true) - private static void be_SetupSpawn(ServerWorld world, ServerWorldProperties serverWorldProperties, boolean bonusChest, boolean debugWorld, boolean bl, CallbackInfo info) { - if (GeneratorOptions.swapOverworldToEnd() && world.getRegistryKey() == World.OVERWORLD) { + private static void be_SetupSpawn(ServerLevel world, ServerWorldProperties serverWorldProperties, + boolean bonusChest, boolean debugWorld, boolean bl, CallbackInfo info) { + if (GeneratorOptions.swapOverworldToEnd() && world.dimension() == Level.OVERWORLD) { info.cancel(); } } - + @Shadow - private static void setupSpawn(ServerWorld world, ServerWorldProperties serverWorldProperties, boolean bonusChest, boolean debugWorld, boolean bl) {} - + private static void setupSpawn(ServerLevel world, ServerWorldProperties serverWorldProperties, boolean bonusChest, + boolean debugWorld, boolean bl) { + } + @Shadow public PlayerManager getPlayerManager() { return null; diff --git a/src/main/java/ru/betterend/mixin/common/PlayerAdvancementTrackerMixin.java b/src/main/java/ru/betterend/mixin/common/PlayerAdvancementTrackerMixin.java index 2acef8ea..035398e3 100644 --- a/src/main/java/ru/betterend/mixin/common/PlayerAdvancementTrackerMixin.java +++ b/src/main/java/ru/betterend/mixin/common/PlayerAdvancementTrackerMixin.java @@ -1,5 +1,7 @@ package ru.betterend.mixin.common; +import net.minecraft.advancements.Advancement; +import net.minecraft.server.PlayerAdvancements; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -7,22 +9,19 @@ import org.spongepowered.asm.mixin.injection.At.Shift; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.advancement.Advancement; -import net.minecraft.advancement.PlayerAdvancementTracker; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.level.ServerPlayer; import ru.betterend.events.PlayerAdvancementsEvents; -@Mixin(PlayerAdvancementTracker.class) +@Mixin(PlayerAdvancements.class) public abstract class PlayerAdvancementTrackerMixin { - + @Shadow - private ServerPlayerEntity owner; - - @Inject(method = "grantCriterion", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/advancement/AdvancementRewards;apply(Lnet/minecraft/server/network/ServerPlayerEntity;)V", - shift = Shift.AFTER)) - public void be_onAdvancementComplete(Advancement advancement, String criterionName, CallbackInfoReturnable info) { - PlayerAdvancementsEvents.PLAYER_ADVENCEMENT_COMPLETE.invoker().onAdvancementComplete(owner, advancement, criterionName); + private ServerPlayer owner; + + @Inject(method = "award", at = @At(value = "INVOKE", target = "Lnet/minecraft/advancements/AdvancementRewards;grant(Lnet/minecraft/server/level/ServerPlayer;)V", shift = Shift.AFTER)) + public void be_onAdvancementComplete(Advancement advancement, String criterionName, + CallbackInfoReturnable info) { + PlayerAdvancementsEvents.PLAYER_ADVANCEMENT_COMPLETE.invoker().onAdvancementComplete(owner, advancement, + criterionName); } } diff --git a/src/main/java/ru/betterend/mixin/common/PlayerEntityMixin.java b/src/main/java/ru/betterend/mixin/common/PlayerEntityMixin.java index e85db22e..af378145 100644 --- a/src/main/java/ru/betterend/mixin/common/PlayerEntityMixin.java +++ b/src/main/java/ru/betterend/mixin/common/PlayerEntityMixin.java @@ -7,11 +7,11 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.entity.player.PlayerEntity; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.math.Vec3d; import ru.betterend.blocks.BlockProperties; import ru.betterend.blocks.BlockProperties.TripleShape; @@ -22,29 +22,29 @@ import ru.betterend.util.MHelper; @Mixin(PlayerEntity.class) public abstract class PlayerEntityMixin { private static Direction[] HORIZONTAL; - + @Inject(method = "findRespawnPosition", at = @At(value = "HEAD"), cancellable = true) - private static void be_statueRespawn(ServerWorld world, BlockPos pos, float f, boolean bl, boolean bl2, CallbackInfoReturnable> info) { + private static void be_statueRespawn(ServerLevel world, BlockPos pos, float f, boolean bl, boolean bl2, + CallbackInfoReturnable> info) { BlockState blockState = world.getBlockState(pos); - if (blockState.isOf(EndBlocks.RESPAWN_OBELISK)) { + if (blockState.is(EndBlocks.RESPAWN_OBELISK)) { info.setReturnValue(beObeliskRespawnPosition(world, pos, blockState)); info.cancel(); } } - private static Optional beObeliskRespawnPosition(ServerWorld world, BlockPos pos, BlockState state) { - if (state.get(BlockProperties.TRIPLE_SHAPE) == TripleShape.TOP) { + private static Optional beObeliskRespawnPosition(ServerLevel world, BlockPos pos, BlockState state) { + if (state.getValue(BlockProperties.TRIPLE_SHAPE) == TripleShape.TOP) { pos = pos.down(2); - } - else if (state.get(BlockProperties.TRIPLE_SHAPE) == TripleShape.MIDDLE) { - pos = pos.down(); + } else if (state.getValue(BlockProperties.TRIPLE_SHAPE) == TripleShape.MIDDLE) { + pos = pos.below(); } if (HORIZONTAL == null) { HORIZONTAL = BlocksHelper.makeHorizontal(); } MHelper.shuffle(HORIZONTAL, world.getRandom()); - for (Direction dir: HORIZONTAL) { - BlockPos p = pos.offset(dir); + for (Direction dir : HORIZONTAL) { + BlockPos p = pos.relative(dir); BlockState state2 = world.getBlockState(p); if (!state2.getMaterial().blocksMovement() && state2.getCollisionShape(world, pos).isEmpty()) { return Optional.of(Vec3d.of(p).add(0.5, 0, 0.5)); diff --git a/src/main/java/ru/betterend/mixin/common/PlayerManagerMixin.java b/src/main/java/ru/betterend/mixin/common/PlayerManagerMixin.java index ed4abddb..ed21cf4a 100644 --- a/src/main/java/ru/betterend/mixin/common/PlayerManagerMixin.java +++ b/src/main/java/ru/betterend/mixin/common/PlayerManagerMixin.java @@ -19,9 +19,9 @@ import com.mojang.serialization.DataResult; import com.mojang.serialization.Dynamic; import io.netty.buffer.Unpooled; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.effect.StatusEffectInstance; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.effect.StatusEffectInstance; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.Tag; @@ -42,8 +42,8 @@ import net.minecraft.scoreboard.ServerScoreboard; import net.minecraft.server.MinecraftServer; import net.minecraft.server.PlayerManager; import net.minecraft.server.network.ServerPlayNetworkHandler; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.ServerLevel; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; @@ -52,10 +52,10 @@ import net.minecraft.util.Util; import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.GameRules; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import net.minecraft.world.WorldProperties; import net.minecraft.world.biome.source.BiomeAccess; -import net.minecraft.world.dimension.DimensionType; +import net.minecraft.world.level.dimension.DimensionType; import ru.betterend.world.generator.GeneratorOptions; @Mixin(PlayerManager.class) @@ -77,14 +77,14 @@ public class PlayerManagerMixin { @Final @Shadow - private List players; + private List players; @Final @Shadow - private Map playerMap; + private Map playerMap; @Inject(method = "onPlayerConnect", at = @At(value = "HEAD"), cancellable = true) - public void be_onPlayerConnect(ClientConnection connection, ServerPlayerEntity player, CallbackInfo info) { + public void be_onPlayerConnect(ClientConnection connection, ServerPlayer player, CallbackInfo info) { if (GeneratorOptions.swapOverworldToEnd()) { GameProfile gameProfile = player.getGameProfile(); UserCache userCache = this.server.getUserCache(); @@ -92,50 +92,57 @@ public class PlayerManagerMixin { String string = gameProfile2 == null ? gameProfile.getName() : gameProfile2.getName(); userCache.add(gameProfile); CompoundTag compoundTag = this.loadPlayerData(player); - RegistryKey var23; + RegistryKey var23; if (compoundTag != null) { - DataResult> var10000 = DimensionType.method_28521(new Dynamic(NbtOps.INSTANCE, compoundTag.get("Dimension"))); + DataResult> var10000 = DimensionType + .method_28521(new Dynamic(NbtOps.INSTANCE, compoundTag.get("Dimension"))); Logger var10001 = LOGGER; var10001.getClass(); - var23 = (RegistryKey) var10000.resultOrPartial(var10001::error).orElse(World.END); - } - else { - var23 = World.END; + var23 = (RegistryKey) var10000.resultOrPartial(var10001::error).orElse(Level.END); + } else { + var23 = Level.END; } - RegistryKey registryKey = var23; - ServerWorld serverWorld = this.server.getWorld(registryKey); - ServerWorld serverWorld3; + RegistryKey registryKey = var23; + ServerLevel serverWorld = this.server.getLevel(registryKey); + ServerLevel serverWorld3; if (serverWorld == null) { LOGGER.warn("Unknown respawn dimension {}, defaulting to overworld", registryKey); serverWorld3 = this.server.getOverworld(); - } - else { + } else { serverWorld3 = serverWorld; } player.setWorld(serverWorld3); - player.interactionManager.setWorld((ServerWorld) player.world); + player.interactionManager.setWorld((ServerLevel) player.world); String string2 = "local"; if (connection.getAddress() != null) { string2 = connection.getAddress().toString(); } - LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", player.getName().getString(), string2, player.getEntityId(), player.getX(), player.getY(), player.getZ()); + LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", player.getName().getString(), string2, + player.getEntityId(), player.getX(), player.getY(), player.getZ()); WorldProperties worldProperties = serverWorld3.getLevelProperties(); - this.setGameMode(player, (ServerPlayerEntity) null, serverWorld3); - ServerPlayNetworkHandler serverPlayNetworkHandler = new ServerPlayNetworkHandler(this.server, connection, player); + this.setGameMode(player, (ServerPlayer) null, serverWorld3); + ServerPlayNetworkHandler serverPlayNetworkHandler = new ServerPlayNetworkHandler(this.server, connection, + player); GameRules gameRules = serverWorld3.getGameRules(); boolean bl = gameRules.getBoolean(GameRules.DO_IMMEDIATE_RESPAWN); boolean bl2 = gameRules.getBoolean(GameRules.REDUCED_DEBUG_INFO); - serverPlayNetworkHandler.sendPacket(new GameJoinS2CPacket(player.getEntityId(), player.interactionManager.getGameMode(), player.interactionManager.getPreviousGameMode(), BiomeAccess.hashSeed(serverWorld3.getSeed()), - worldProperties.isHardcore(), this.server.getWorldRegistryKeys(), this.registryManager, serverWorld3.getDimension(), serverWorld3.getRegistryKey(), this.getMaxPlayerCount(), this.viewDistance, bl2, !bl, + serverPlayNetworkHandler.sendPacket(new GameJoinS2CPacket(player.getEntityId(), + player.interactionManager.getGameMode(), player.interactionManager.getPreviousGameMode(), + BiomeAccess.hashSeed(serverWorld3.getSeed()), worldProperties.isHardcore(), + this.server.getWorldRegistryKeys(), this.registryManager, serverWorld3.getDimension(), + serverWorld3.dimension(), this.getMaxPlayerCount(), this.viewDistance, bl2, !bl, serverWorld3.isDebugWorld(), serverWorld3.isFlat())); - serverPlayNetworkHandler.sendPacket(new CustomPayloadS2CPacket(CustomPayloadS2CPacket.BRAND, (new PacketByteBuf(Unpooled.buffer())).writeString(this.getServer().getServerModName()))); - serverPlayNetworkHandler.sendPacket(new DifficultyS2CPacket(worldProperties.getDifficulty(), worldProperties.isDifficultyLocked())); + serverPlayNetworkHandler.sendPacket(new CustomPayloadS2CPacket(CustomPayloadS2CPacket.BRAND, + (new PacketByteBuf(Unpooled.buffer())).writeString(this.getServer().getServerModName()))); + serverPlayNetworkHandler.sendPacket( + new DifficultyS2CPacket(worldProperties.getDifficulty(), worldProperties.isDifficultyLocked())); serverPlayNetworkHandler.sendPacket(new PlayerAbilitiesS2CPacket(player.abilities)); serverPlayNetworkHandler.sendPacket(new HeldItemChangeS2CPacket(player.inventory.selectedSlot)); - serverPlayNetworkHandler.sendPacket(new SynchronizeRecipesS2CPacket(this.server.getRecipeManager().values())); + serverPlayNetworkHandler + .sendPacket(new SynchronizeRecipesS2CPacket(this.server.getRecipeManager().values())); serverPlayNetworkHandler.sendPacket(new SynchronizeTagsS2CPacket(this.server.getTagManager())); this.sendCommandTree(player); player.getStatHandler().updateStatSet(); @@ -144,20 +151,24 @@ public class PlayerManagerMixin { this.server.forcePlayerSampleUpdate(); TranslatableText mutableText2; if (player.getGameProfile().getName().equalsIgnoreCase(string)) { - mutableText2 = new TranslatableText("multiplayer.player.joined", new Object[] { player.getDisplayName() }); - } - else { - mutableText2 = new TranslatableText("multiplayer.player.joined.renamed", new Object[] { player.getDisplayName(), string }); + mutableText2 = new TranslatableText("multiplayer.player.joined", + new Object[] { player.getDisplayName() }); + } else { + mutableText2 = new TranslatableText("multiplayer.player.joined.renamed", + new Object[] { player.getDisplayName(), string }); } this.broadcastChatMessage(mutableText2.formatted(Formatting.YELLOW), MessageType.SYSTEM, Util.NIL_UUID); - serverPlayNetworkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.yaw, player.pitch); + serverPlayNetworkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.yaw, + player.pitch); this.players.add(player); this.playerMap.put(player.getUuid(), player); - this.sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, new ServerPlayerEntity[] { player })); + this.sendToAll( + new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, new ServerPlayer[] { player })); for (int i = 0; i < this.players.size(); ++i) { - player.networkHandler.sendPacket(new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, new ServerPlayerEntity[] { (ServerPlayerEntity) this.players.get(i) })); + player.networkHandler.sendPacket(new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, + new ServerPlayer[] { (ServerPlayer) this.players.get(i) })); } serverWorld3.onPlayerConnected(player); @@ -171,20 +182,21 @@ public class PlayerManagerMixin { while (var24.hasNext()) { StatusEffectInstance statusEffectInstance = (StatusEffectInstance) var24.next(); - serverPlayNetworkHandler.sendPacket(new EntityStatusEffectS2CPacket(player.getEntityId(), statusEffectInstance)); + serverPlayNetworkHandler + .sendPacket(new EntityStatusEffectS2CPacket(player.getEntityId(), statusEffectInstance)); } if (compoundTag != null && compoundTag.contains("RootVehicle", 10)) { CompoundTag compoundTag2 = compoundTag.getCompound("RootVehicle"); - Entity entity = EntityType.loadEntityWithPassengers(compoundTag2.getCompound("Entity"), serverWorld3, (vehicle) -> { - return !serverWorld3.tryLoadEntity(vehicle) ? null : vehicle; - }); + Entity entity = EntityType.loadEntityWithPassengers(compoundTag2.getCompound("Entity"), serverWorld3, + (vehicle) -> { + return !serverWorld3.tryLoadEntity(vehicle) ? null : vehicle; + }); if (entity != null) { UUID uUID2; if (compoundTag2.containsUuid("Attach")) { uUID2 = compoundTag2.getUuid("Attach"); - } - else { + } else { uUID2 = null; } @@ -192,8 +204,7 @@ public class PlayerManagerMixin { Entity entity3; if (entity.getUuid().equals(uUID2)) { player.startRiding(entity, true); - } - else { + } else { var21 = entity.getPassengersDeep().iterator(); while (var21.hasNext()) { @@ -224,15 +235,17 @@ public class PlayerManagerMixin { } @Shadow - public CompoundTag loadPlayerData(ServerPlayerEntity player) { + public CompoundTag loadPlayerData(ServerPlayer player) { return null; } @Shadow - private void setGameMode(ServerPlayerEntity player, @Nullable ServerPlayerEntity oldPlayer, ServerWorld world) {} + private void setGameMode(ServerPlayer player, @Nullable ServerPlayer oldPlayer, ServerLevel world) { + } @Shadow - public void sendCommandTree(ServerPlayerEntity player) {} + public void sendCommandTree(ServerPlayer player) { + } @Shadow public int getMaxPlayerCount() { @@ -245,14 +258,18 @@ public class PlayerManagerMixin { } @Shadow - protected void sendScoreboard(ServerScoreboard scoreboard, ServerPlayerEntity player) {} + protected void sendScoreboard(ServerScoreboard scoreboard, ServerPlayer player) { + } @Shadow - public void broadcastChatMessage(Text message, MessageType type, UUID senderUuid) {} + public void broadcastChatMessage(Text message, MessageType type, UUID senderUuid) { + } @Shadow - public void sendToAll(Packet packet) {} + public void sendToAll(Packet packet) { + } @Shadow - public void sendWorldInfo(ServerPlayerEntity player, ServerWorld world) {} + public void sendWorldInfo(ServerPlayer player, ServerLevel world) { + } } diff --git a/src/main/java/ru/betterend/mixin/common/RecipeManagerAccessor.java b/src/main/java/ru/betterend/mixin/common/RecipeManagerAccessor.java index deaa0d66..759f56f3 100644 --- a/src/main/java/ru/betterend/mixin/common/RecipeManagerAccessor.java +++ b/src/main/java/ru/betterend/mixin/common/RecipeManagerAccessor.java @@ -5,16 +5,16 @@ import java.util.Map; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import net.minecraft.recipe.Recipe; -import net.minecraft.recipe.RecipeManager; -import net.minecraft.recipe.RecipeType; -import net.minecraft.util.Identifier; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeManager; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.resources.ResourceLocation; @Mixin(RecipeManager.class) public interface RecipeManagerAccessor { @Accessor("recipes") - Map, Map>> getRecipes(); + Map, Map>> getRecipes(); @Accessor("recipes") - void setRecipes(Map, Map>> recipes); + void setRecipes(Map, Map>> recipes); } \ No newline at end of file diff --git a/src/main/java/ru/betterend/mixin/common/RecipeManagerMixin.java b/src/main/java/ru/betterend/mixin/common/RecipeManagerMixin.java index 38497ec6..10dce970 100644 --- a/src/main/java/ru/betterend/mixin/common/RecipeManagerMixin.java +++ b/src/main/java/ru/betterend/mixin/common/RecipeManagerMixin.java @@ -16,39 +16,42 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.google.gson.JsonElement; import net.minecraft.inventory.Inventory; -import net.minecraft.recipe.Recipe; -import net.minecraft.recipe.RecipeManager; -import net.minecraft.recipe.RecipeType; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeManager; +import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Util; import net.minecraft.util.profiler.Profiler; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.recipe.EndRecipeManager; @Mixin(RecipeManager.class) public class RecipeManagerMixin { @Shadow - private Map, Map>> recipes; + private Map, Map>> recipes; @Inject(method = "apply", at = @At(value = "RETURN")) - private void beSetRecipes(Map map, ResourceManager resourceManager, Profiler profiler, CallbackInfo info) { + private void beSetRecipes(Map map, ResourceManager resourceManager, + Profiler profiler, CallbackInfo info) { recipes = EndRecipeManager.getMap(recipes); } @Shadow - private > Map> getAllOfType(RecipeType type) { + private > Map> getAllOfType( + RecipeType type) { return null; } /** * @author paulevs - * @reason Remove conflicts with vanilla tags - * Change recipe order to show mod recipes first, helps when block have vanilla tag - * (example - mod stone with vanilla tags and furnace from that stone) + * @reason Remove conflicts with vanilla tags Change recipe order to show mod + * recipes first, helps when block have vanilla tag (example - mod stone + * with vanilla tags and furnace from that stone) */ @Overwrite - public > Optional getFirstMatch(RecipeType type, C inventory, World world) { + public > Optional getFirstMatch(RecipeType type, C inventory, + Level world) { Collection> values = getAllOfType(type).values(); List> list = new ArrayList>(values); list.sort((v1, v2) -> { diff --git a/src/main/java/ru/betterend/mixin/common/ServerPlayerEntityMixin.java b/src/main/java/ru/betterend/mixin/common/ServerPlayerEntityMixin.java index 1342b15a..9c95d85e 100644 --- a/src/main/java/ru/betterend/mixin/common/ServerPlayerEntityMixin.java +++ b/src/main/java/ru/betterend/mixin/common/ServerPlayerEntityMixin.java @@ -10,9 +10,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.mojang.authlib.GameProfile; -import net.minecraft.entity.Entity; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.effect.StatusEffectInstance; +import net.minecraft.world.entity.player.PlayerEntity; import net.minecraft.network.packet.s2c.play.DifficultyS2CPacket; import net.minecraft.network.packet.s2c.play.EntityStatusEffectS2CPacket; import net.minecraft.network.packet.s2c.play.PlayerAbilitiesS2CPacket; @@ -21,19 +21,19 @@ import net.minecraft.network.packet.s2c.play.WorldEventS2CPacket; import net.minecraft.server.MinecraftServer; import net.minecraft.server.PlayerManager; import net.minecraft.server.network.ServerPlayNetworkHandler; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.ServerPlayerInteractionManager; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.TeleportTarget; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import net.minecraft.world.WorldProperties; import net.minecraft.world.biome.source.BiomeAccess; import ru.betterend.interfaces.TeleportingEntity; import ru.betterend.world.generator.GeneratorOptions; -@Mixin(ServerPlayerEntity.class) +@Mixin(ServerPlayer.class) public abstract class ServerPlayerEntityMixin extends PlayerEntity implements TeleportingEntity { @Shadow @@ -55,34 +55,38 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Te private BlockPos exitPos; - public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile profile) { + public ServerPlayerEntityMixin(Level world, BlockPos pos, float yaw, GameProfile profile) { super(world, pos, yaw, profile); } @Inject(method = "createEndSpawnPlatform", at = @At("HEAD"), cancellable = true) - private void be_createEndSpawnPlatform(ServerWorld world, BlockPos centerPos, CallbackInfo info) { + private void be_createEndSpawnPlatform(ServerLevel world, BlockPos centerPos, CallbackInfo info) { if (!GeneratorOptions.generateObsidianPlatform()) { info.cancel(); } } @Inject(method = "getTeleportTarget", at = @At("HEAD"), cancellable = true) - protected void be_getTeleportTarget(ServerWorld destination, CallbackInfoReturnable info) { + protected void be_getTeleportTarget(ServerLevel destination, CallbackInfoReturnable info) { if (beCanTeleport()) { - info.setReturnValue(new TeleportTarget(new Vec3d(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5), getVelocity(), yaw, pitch)); + info.setReturnValue(new TeleportTarget( + new Vec3d(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5), getVelocity(), yaw, pitch)); } } @Inject(method = "moveToWorld", at = @At("HEAD"), cancellable = true) - public void be_moveToWorld(ServerWorld destination, CallbackInfoReturnable info) { - if (beCanTeleport() && world instanceof ServerWorld) { + public void be_moveToWorld(ServerLevel destination, CallbackInfoReturnable info) { + if (beCanTeleport() && world instanceof ServerLevel) { this.inTeleportationState = true; - ServerWorld serverWorld = this.getServerWorld(); + ServerLevel serverWorld = this.getServerWorld(); WorldProperties worldProperties = destination.getLevelProperties(); - ServerPlayerEntity player = ServerPlayerEntity.class.cast(this); - this.networkHandler.sendPacket(new PlayerRespawnS2CPacket(destination.getDimension(), destination.getRegistryKey(), BiomeAccess.hashSeed(destination.getSeed()), - interactionManager.getGameMode(),interactionManager.getPreviousGameMode(), destination.isDebugWorld(), destination.isFlat(), true)); - this.networkHandler.sendPacket(new DifficultyS2CPacket(worldProperties.getDifficulty(), worldProperties.isDifficultyLocked())); + ServerPlayer player = ServerPlayer.class.cast(this); + this.networkHandler.sendPacket(new PlayerRespawnS2CPacket(destination.getDimension(), + destination.dimension(), BiomeAccess.hashSeed(destination.getSeed()), + interactionManager.getGameMode(), interactionManager.getPreviousGameMode(), + destination.isDebugWorld(), destination.isFlat(), true)); + this.networkHandler.sendPacket( + new DifficultyS2CPacket(worldProperties.getDifficulty(), worldProperties.isDifficultyLocked())); PlayerManager playerManager = this.server.getPlayerManager(); playerManager.sendCommandTree(player); serverWorld.removePlayer(player); @@ -95,7 +99,8 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Te this.setWorld(destination); destination.onPlayerChangeDimension(player); this.setRotation(teleportTarget.yaw, teleportTarget.pitch); - this.refreshPositionAfterTeleport(teleportTarget.position.x, teleportTarget.position.y, teleportTarget.position.z); + this.refreshPositionAfterTeleport(teleportTarget.position.x, teleportTarget.position.y, + teleportTarget.position.z); serverWorld.getProfiler().pop(); this.worldChanged(serverWorld); this.interactionManager.setWorld(destination); @@ -104,7 +109,8 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Te playerManager.sendPlayerStatus(player); for (StatusEffectInstance statusEffectInstance : this.getStatusEffects()) { - this.networkHandler.sendPacket(new EntityStatusEffectS2CPacket(getEntityId(), statusEffectInstance)); + this.networkHandler + .sendPacket(new EntityStatusEffectS2CPacket(getEntityId(), statusEffectInstance)); } this.networkHandler.sendPacket(new WorldEventS2CPacket(1032, BlockPos.ORIGIN, 0, false)); @@ -118,14 +124,14 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Te } @Shadow - abstract ServerWorld getServerWorld(); + abstract ServerLevel getServerWorld(); @Shadow - abstract void worldChanged(ServerWorld origin); + abstract void worldChanged(ServerLevel origin); @Shadow @Override - protected abstract TeleportTarget getTeleportTarget(ServerWorld destination); + protected abstract TeleportTarget getTeleportTarget(ServerLevel destination); @Override public void beSetExitPos(BlockPos pos) { diff --git a/src/main/java/ru/betterend/mixin/common/ServerWorldMixin.java b/src/main/java/ru/betterend/mixin/common/ServerWorldMixin.java index a48eca97..5ca3794c 100644 --- a/src/main/java/ru/betterend/mixin/common/ServerWorldMixin.java +++ b/src/main/java/ru/betterend/mixin/common/ServerWorldMixin.java @@ -17,11 +17,11 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtHelper; import net.minecraft.server.MinecraftServer; import net.minecraft.server.WorldGenerationProgressListener; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.core.BlockPos; import net.minecraft.util.registry.RegistryKey; -import net.minecraft.world.World; -import net.minecraft.world.dimension.DimensionType; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.gen.Spawner; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.level.ServerWorldProperties; @@ -31,36 +31,39 @@ import ru.betterend.util.DataFixerUtil; import ru.betterend.util.WorldDataUtil; import ru.betterend.world.generator.GeneratorOptions; -@Mixin(ServerWorld.class) +@Mixin(ServerLevel.class) public class ServerWorldMixin { private static final int DEV_VERSION = be_getVersionInt("63.63.63"); private static final int FIX_VERSION = DEV_VERSION; private static String lastWorld = null; - + @Inject(method = "*", at = @At("TAIL")) - private void be_onServerWorldInit(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session, ServerWorldProperties properties, RegistryKey registryKey, DimensionType dimensionType, WorldGenerationProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, boolean debugWorld, long l, List list, boolean bl, CallbackInfo info) { + private void be_onServerWorldInit(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session, + ServerWorldProperties properties, RegistryKey registryKey, DimensionType dimensionType, + WorldGenerationProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, + boolean debugWorld, long l, List list, boolean bl, CallbackInfo info) { if (lastWorld != null && lastWorld.equals(session.getDirectoryName())) { return; } - + lastWorld = session.getDirectoryName(); - + @SuppressWarnings("resource") - ServerWorld world = (ServerWorld) (Object) this; - File dir = session.getWorldDirectory(world.getRegistryKey()); + ServerLevel world = (ServerLevel) (Object) this; + File dir = session.getWorldDirectory(world.dimension()); if (!new File(dir, "level.dat").exists()) { dir = dir.getParentFile(); } File data = new File(dir, "data/betterend_data.nbt"); - + ModMetadata meta = FabricLoader.getInstance().getModContainer(BetterEnd.MOD_ID).get().getMetadata(); int version = BetterEnd.isDevEnvironment() ? DEV_VERSION : be_getVersionInt(meta.getVersion().toString()); - + WorldDataUtil.load(data); CompoundTag root = WorldDataUtil.getRootTag(); int dataVersion = be_getVersionInt(root.getString("version")); GeneratorOptions.setPortalPos(NbtHelper.toBlockPos(root.getCompound("portal"))); - + if (dataVersion < version) { if (version < FIX_VERSION) { DataFixerUtil.fixData(data.getParentFile()); @@ -73,13 +76,13 @@ public class ServerWorldMixin { @Inject(method = "getSpawnPos", at = @At("HEAD"), cancellable = true) private void be_getSpawnPos(CallbackInfoReturnable info) { if (GeneratorOptions.changeSpawn()) { - if (((ServerWorld) (Object) this).getRegistryKey() == World.END) { + if (((ServerLevel) (Object) this).dimension() == Level.END) { info.setReturnValue(GeneratorOptions.getSpawn()); info.cancel(); } } } - + private static int be_getVersionInt(String version) { if (version.isEmpty()) { return 0; @@ -87,12 +90,11 @@ public class ServerWorldMixin { try { String[] values = version.split("\\."); return Integer.parseInt(values[0]) << 12 | Integer.parseInt(values[1]) << 6 | Integer.parseInt(values[1]); - } - catch (Exception e) { + } catch (Exception e) { return 0; } } - + private static String be_getVersionString(int version) { int a = (version >> 12) & 63; int b = (version >> 6) & 63; diff --git a/src/main/java/ru/betterend/mixin/common/SlimeEntityMixin.java b/src/main/java/ru/betterend/mixin/common/SlimeEntityMixin.java index f4042106..d4874e59 100644 --- a/src/main/java/ru/betterend/mixin/common/SlimeEntityMixin.java +++ b/src/main/java/ru/betterend/mixin/common/SlimeEntityMixin.java @@ -3,14 +3,15 @@ package ru.betterend.mixin.common; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import net.minecraft.entity.mob.SlimeEntity; +import net.minecraft.world.entity.mob.SlimeEntity; import ru.betterend.interfaces.ISlime; @Mixin(SlimeEntity.class) public class SlimeEntityMixin implements ISlime { @Shadow - protected void setSize(int size, boolean heal) {} - + protected void setSize(int size, boolean heal) { + } + @Override public void beSetSlimeSize(int size, boolean heal) { setSize(size, heal); diff --git a/src/main/java/ru/betterend/mixin/common/TagGroupLoaderMixin.java b/src/main/java/ru/betterend/mixin/common/TagGroupLoaderMixin.java index 21038c9e..8f7c02d2 100644 --- a/src/main/java/ru/betterend/mixin/common/TagGroupLoaderMixin.java +++ b/src/main/java/ru/betterend/mixin/common/TagGroupLoaderMixin.java @@ -11,22 +11,23 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import net.minecraft.resource.ResourceManager; -import net.minecraft.tag.Tag; -import net.minecraft.tag.TagGroupLoader; -import net.minecraft.util.Identifier; +import net.minecraft.tags.Tag; +import net.minecraft.tags.TagGroupLoader; +import net.minecraft.resources.ResourceLocation; import ru.betterend.util.TagHelper; @Mixin(TagGroupLoader.class) public class TagGroupLoaderMixin { - + @Shadow private String entryType; - + @Inject(method = "prepareReload", at = @At("RETURN"), cancellable = true) - public void be_prepareReload(ResourceManager manager, Executor prepareExecutor, CallbackInfoReturnable>> info) { - CompletableFuture> future = info.getReturnValue(); + public void be_prepareReload(ResourceManager manager, Executor prepareExecutor, + CallbackInfoReturnable>> info) { + CompletableFuture> future = info.getReturnValue(); info.setReturnValue(CompletableFuture.supplyAsync(() -> { - Map map = future.join(); + Map map = future.join(); TagHelper.apply(entryType, map); return map; })); diff --git a/src/main/java/ru/betterend/noise/VoronoiNoise.java b/src/main/java/ru/betterend/noise/VoronoiNoise.java index cddc7b4d..c7735336 100644 --- a/src/main/java/ru/betterend/noise/VoronoiNoise.java +++ b/src/main/java/ru/betterend/noise/VoronoiNoise.java @@ -2,13 +2,13 @@ package ru.betterend.noise; import java.util.Random; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import ru.betterend.util.MHelper; public class VoronoiNoise { private static final Random RANDOM = new Random(); final int seed; - + public VoronoiNoise() { this(0); } @@ -16,7 +16,7 @@ public class VoronoiNoise { public VoronoiNoise(int seed) { this.seed = seed; } - + private int getSeed(int x, int y, int z) { int h = seed + x * 374761393 + y * 668265263 + z; h = (h ^ (h >> 13)) * 1274126177; @@ -27,13 +27,13 @@ public class VoronoiNoise { int ix = MHelper.floor(x); int iy = MHelper.floor(y); int iz = MHelper.floor(z); - + float px = (float) (x - ix); float py = (float) (y - iy); float pz = (float) (z - iz); - + float d = 10; - + for (int pox = -1; pox < 2; pox++) { for (int poy = -1; poy < 2; poy++) { for (int poz = -1; poz < 2; poz++) { @@ -48,19 +48,19 @@ public class VoronoiNoise { } } } - + return Math.sqrt(d); } - + public BlockPos[] getPos(double x, double y, double z, double scale) { int ix = MHelper.floor(x); int iy = MHelper.floor(y); int iz = MHelper.floor(z); - + float px = (float) (x - ix); float py = (float) (y - iy); float pz = (float) (z - iz); - + float d = 10; float selX = 0; float selY = 0; @@ -68,7 +68,7 @@ public class VoronoiNoise { float selXPre = 0; float selYPre = 0; float selZPre = 0; - + for (int pox = -1; pox < 2; pox++) { for (int poy = -1; poy < 2; poy++) { for (int poz = -1; poz < 2; poz++) { @@ -89,9 +89,11 @@ public class VoronoiNoise { } } } - - BlockPos p1 = new BlockPos((ix + (double) selX) * scale, (iy + (double) selY) * scale, (iz + (double) selZ) * scale); - BlockPos p2 = new BlockPos((ix + (double) selXPre) * scale, (iy + (double) selYPre) * scale, (iz + (double) selZPre) * scale); - return new BlockPos[] {p1, p2}; + + BlockPos p1 = new BlockPos((ix + (double) selX) * scale, (iy + (double) selY) * scale, + (iz + (double) selZ) * scale); + BlockPos p2 = new BlockPos((ix + (double) selXPre) * scale, (iy + (double) selYPre) * scale, + (iz + (double) selZPre) * scale); + return new BlockPos[] { p1, p2 }; } } diff --git a/src/main/java/ru/betterend/particle/FireflyParticle.java b/src/main/java/ru/betterend/particle/FireflyParticle.java index 5bb620f4..808d69fc 100644 --- a/src/main/java/ru/betterend/particle/FireflyParticle.java +++ b/src/main/java/ru/betterend/particle/FireflyParticle.java @@ -2,25 +2,26 @@ package ru.betterend.particle; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.particle.AnimatedParticle; +import net.minecraft.client.particle.SimpleAnimatedParticle; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; -import net.minecraft.client.particle.SpriteProvider; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.particle.DefaultParticleType; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.util.Mth; import ru.betterend.util.MHelper; @Environment(EnvType.CLIENT) -public class FireflyParticle extends AnimatedParticle { +public class FireflyParticle extends SimpleAnimatedParticle { private double preVX; private double preVY; private double preVZ; private double nextVX; private double nextVY; private double nextVZ; - - protected FireflyParticle(ClientWorld world, double x, double y, double z, SpriteProvider sprites, double r, double g, double b) { + + protected FireflyParticle(ClientLevel world, double x, double y, double z, SpriteSet sprites, double r, double g, + double b) { super(world, x, y, z, sprites, 0); setSprite(sprites.getSprite(random)); this.maxAge = MHelper.randRange(150, 300, random); @@ -28,16 +29,16 @@ public class FireflyParticle extends AnimatedParticle { this.setTargetColor(15916745); this.setSpriteForAge(spriteProvider); this.setColorAlpha(0); - + preVX = random.nextGaussian() * 0.02; preVY = random.nextGaussian() * 0.02; preVZ = random.nextGaussian() * 0.02; - + nextVX = random.nextGaussian() * 0.02; nextVY = random.nextGaussian() * 0.02; nextVZ = random.nextGaussian() * 0.02; } - + @Override public void tick() { int ticks = this.age & 31; @@ -50,31 +51,31 @@ public class FireflyParticle extends AnimatedParticle { nextVZ = random.nextGaussian() * 0.02; } double delta = (double) ticks / 31.0; - - this.velocityX = MathHelper.lerp(delta, preVX, nextVX); - this.velocityY = MathHelper.lerp(delta, preVY, nextVY); - this.velocityZ = MathHelper.lerp(delta, preVZ, nextVZ); - + + this.velocityX = Mth.lerp(delta, preVX, nextVX); + this.velocityY = Mth.lerp(delta, preVY, nextVY); + this.velocityZ = Mth.lerp(delta, preVZ, nextVZ); + if (this.age <= 60) { this.setColorAlpha(this.age / 60F); - } - else if (this.age > maxAge - 60) { + } else if (this.age > maxAge - 60) { this.setColorAlpha((maxAge - this.age) / 60F); } - + super.tick(); } @Environment(EnvType.CLIENT) - public static class FireflyParticleFactory implements ParticleFactory { - private final SpriteProvider sprites; + public static class FireflyParticleFactory implements ParticleFactory { + private final SpriteSet sprites; - public FireflyParticleFactory(SpriteProvider sprites) { + public FireflyParticleFactory(SpriteSet sprites) { this.sprites = sprites; } @Override - public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) { + public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z, + double vX, double vY, double vZ) { return new FireflyParticle(world, x, y, z, sprites, 1, 1, 1); } } diff --git a/src/main/java/ru/betterend/particle/GlowingSphereParticleEffect.java b/src/main/java/ru/betterend/particle/GlowingSphereParticleEffect.java index 6abe69f1..2c971282 100644 --- a/src/main/java/ru/betterend/particle/GlowingSphereParticleEffect.java +++ b/src/main/java/ru/betterend/particle/GlowingSphereParticleEffect.java @@ -3,12 +3,12 @@ package ru.betterend.particle; import java.util.Locale; import net.minecraft.network.PacketByteBuf; -import net.minecraft.particle.ParticleEffect; -import net.minecraft.particle.ParticleType; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.Registry; import ru.betterend.registry.EndParticles; -public class GlowingSphereParticleEffect implements ParticleEffect { +public class GlowingSphereParticleEffect implements ParticleOptions { private final float red; private final float green; private final float blue; @@ -33,7 +33,8 @@ public class GlowingSphereParticleEffect implements ParticleEffect { @Override public String asString() { - return String.format(Locale.ROOT, "%s %.2f %.2f %.2f", Registry.PARTICLE_TYPE.getId(this.getType()), this.red, this.green, this.blue); + return String.format(Locale.ROOT, "%s %.2f %.2f %.2f", Registry.PARTICLE_TYPE.getId(this.getType()), this.red, + this.green, this.blue); } public float getRed() { diff --git a/src/main/java/ru/betterend/particle/InfusionParticle.java b/src/main/java/ru/betterend/particle/InfusionParticle.java index 3df16b65..e856a4a0 100644 --- a/src/main/java/ru/betterend/particle/InfusionParticle.java +++ b/src/main/java/ru/betterend/particle/InfusionParticle.java @@ -6,14 +6,15 @@ import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.ParticleTextureSheet; import net.minecraft.client.particle.SpriteBillboardParticle; -import net.minecraft.client.particle.SpriteProvider; -import net.minecraft.client.world.ClientWorld; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.client.multiplayer.ClientLevel; public class InfusionParticle extends SpriteBillboardParticle { - - private final SpriteProvider spriteProvider; - public InfusionParticle(ClientWorld clientWorld, double x, double y, double z, double velocityX, double velocityY, double velocityZ, float[] palette, SpriteProvider spriteProvider) { + private final SpriteSet spriteProvider; + + public InfusionParticle(ClientLevel clientWorld, double x, double y, double z, double velocityX, double velocityY, + double velocityZ, float[] palette, SpriteSet spriteProvider) { super(clientWorld, x, y, z, 0.0, 0.0, 0.0); this.setSpriteForAge(spriteProvider); this.spriteProvider = spriteProvider; @@ -30,7 +31,7 @@ public class InfusionParticle extends SpriteBillboardParticle { public ParticleTextureSheet getType() { return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; } - + @Override public void tick() { this.prevPosX = this.x; @@ -49,13 +50,14 @@ public class InfusionParticle extends SpriteBillboardParticle { @Environment(EnvType.CLIENT) public static class InfusionFactory implements ParticleFactory { - private final SpriteProvider spriteProvider; - - public InfusionFactory(SpriteProvider spriteProvider) { + private final SpriteSet spriteProvider; + + public InfusionFactory(SpriteSet spriteProvider) { this.spriteProvider = spriteProvider; } - - public Particle createParticle(InfusionParticleType particleType, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i) { + + public Particle createParticle(InfusionParticleType particleType, ClientLevel clientWorld, double d, double e, + double f, double g, double h, double i) { return new InfusionParticle(clientWorld, d, e, f, g, h, i, particleType.getPalette(), this.spriteProvider); } } diff --git a/src/main/java/ru/betterend/particle/InfusionParticleType.java b/src/main/java/ru/betterend/particle/InfusionParticleType.java index 498dfde8..6d237c06 100644 --- a/src/main/java/ru/betterend/particle/InfusionParticleType.java +++ b/src/main/java/ru/betterend/particle/InfusionParticleType.java @@ -8,25 +8,27 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.command.argument.ItemStackArgument; import net.minecraft.command.argument.ItemStringReader; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraft.network.PacketByteBuf; -import net.minecraft.particle.ParticleEffect; -import net.minecraft.particle.ParticleType; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.Registry; import ru.betterend.registry.EndParticles; import ru.betterend.util.ColorUtil; -public class InfusionParticleType extends ParticleType implements ParticleEffect { +public class InfusionParticleType extends ParticleType implements ParticleOptions { public static final Codec CODEC = ItemStack.CODEC.xmap(itemStack -> { return new InfusionParticleType(EndParticles.INFUSION, itemStack); }, infusionParticleType -> { return infusionParticleType.itemStack; }); - public static final ParticleEffect.Factory PARAMETERS_FACTORY = new ParticleEffect.Factory() { - public InfusionParticleType read(ParticleType particleType, StringReader stringReader) throws CommandSyntaxException { + public static final ParticleOptions.Factory PARAMETERS_FACTORY = new ParticleOptions.Factory() { + public InfusionParticleType read(ParticleType particleType, StringReader stringReader) + throws CommandSyntaxException { stringReader.expect(' '); ItemStringReader itemStringReader = new ItemStringReader(stringReader, false).consume(); - ItemStack itemStack = new ItemStackArgument(itemStringReader.getItem(), itemStringReader.getTag()).createStack(1, false); + ItemStack itemStack = new ItemStackArgument(itemStringReader.getItem(), itemStringReader.getTag()) + .createStack(1, false); return new InfusionParticleType(particleType, itemStack); } @@ -34,20 +36,20 @@ public class InfusionParticleType extends ParticleType imp return new InfusionParticleType(particleType, packetByteBuf.readItemStack()); } }; - + private ParticleType type; private ItemStack itemStack; - + public InfusionParticleType(ParticleType particleType, ItemStack stack) { super(true, PARAMETERS_FACTORY); this.type = particleType; this.itemStack = stack; } - + public InfusionParticleType(ItemStack stack) { this(EndParticles.INFUSION, stack); } - + @Environment(EnvType.CLIENT) public float[] getPalette() { int color = ColorUtil.extractColor(itemStack.getItem()); diff --git a/src/main/java/ru/betterend/particle/ParticleBlackSpore.java b/src/main/java/ru/betterend/particle/ParticleBlackSpore.java index be4164ed..2185c4e5 100644 --- a/src/main/java/ru/betterend/particle/ParticleBlackSpore.java +++ b/src/main/java/ru/betterend/particle/ParticleBlackSpore.java @@ -2,43 +2,44 @@ package ru.betterend.particle; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.particle.AnimatedParticle; +import net.minecraft.client.particle.SimpleAnimatedParticle; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.ParticleTextureSheet; -import net.minecraft.client.particle.SpriteProvider; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.particle.DefaultParticleType; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.util.Mth; import ru.betterend.util.MHelper; @Environment(EnvType.CLIENT) -public class ParticleBlackSpore extends AnimatedParticle { +public class ParticleBlackSpore extends SimpleAnimatedParticle { private double preVX; private double preVY; private double preVZ; private double nextVX; private double nextVY; private double nextVZ; - - protected ParticleBlackSpore(ClientWorld world, double x, double y, double z, double r, double g, double b, SpriteProvider sprites) { + + protected ParticleBlackSpore(ClientLevel world, double x, double y, double z, double r, double g, double b, + SpriteSet sprites) { super(world, x, y, z, sprites, 0); setSprite(sprites.getSprite(random)); - + this.maxAge = MHelper.randRange(30, 60, random); this.scale = MHelper.randRange(0.05F, 0.15F, random); this.setColor(1, 1, 1); this.setColorAlpha(0); - + preVX = random.nextGaussian() * 0.015; preVY = 0; preVZ = random.nextGaussian() * 0.015; - + nextVX = random.nextGaussian() * 0.015; nextVY = random.nextFloat() * 0.02 + 0.01; nextVZ = random.nextGaussian() * 0.015; } - + @Override public void tick() { int ticks = this.age & 15; @@ -51,41 +52,41 @@ public class ParticleBlackSpore extends AnimatedParticle { nextVZ = random.nextGaussian() * 0.015; } double delta = (double) ticks / 15.0; - + if (this.age <= 15) { this.setColorAlpha(this.age / 15F); - } - else if (this.age >= this.maxAge - 15) { + } else if (this.age >= this.maxAge - 15) { this.setColorAlpha((this.maxAge - this.age) / 15F); } - + if (this.age >= this.maxAge) { this.markDead(); } - - this.velocityX = MathHelper.lerp(delta, preVX, nextVX); - this.velocityY = MathHelper.lerp(delta, preVY, nextVY); - this.velocityZ = MathHelper.lerp(delta, preVZ, nextVZ); - + + this.velocityX = Mth.lerp(delta, preVX, nextVX); + this.velocityY = Mth.lerp(delta, preVY, nextVY); + this.velocityZ = Mth.lerp(delta, preVZ, nextVZ); + super.tick(); } - + @Override public ParticleTextureSheet getType() { return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; } @Environment(EnvType.CLIENT) - public static class FactoryBlackSpore implements ParticleFactory { + public static class FactoryBlackSpore implements ParticleFactory { - private final SpriteProvider sprites; + private final SpriteSet sprites; - public FactoryBlackSpore(SpriteProvider sprites) { + public FactoryBlackSpore(SpriteSet sprites) { this.sprites = sprites; } @Override - public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) { + public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z, + double vX, double vY, double vZ) { return new ParticleBlackSpore(world, x, y, z, 1, 1, 1, sprites); } } diff --git a/src/main/java/ru/betterend/particle/ParticleGeyser.java b/src/main/java/ru/betterend/particle/ParticleGeyser.java index 47df964c..dbe6f814 100644 --- a/src/main/java/ru/betterend/particle/ParticleGeyser.java +++ b/src/main/java/ru/betterend/particle/ParticleGeyser.java @@ -6,19 +6,20 @@ import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.ParticleTextureSheet; import net.minecraft.client.particle.SpriteBillboardParticle; -import net.minecraft.client.particle.SpriteProvider; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.particle.DefaultParticleType; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.core.BlockPos.MutableBlockPos; import ru.betterend.util.MHelper; @Environment(EnvType.CLIENT) public class ParticleGeyser extends SpriteBillboardParticle { - private Mutable mut = new Mutable(); + private MutableBlockPos mut = new MutableBlockPos(); private boolean changeDir = false; private boolean check = true; - - protected ParticleGeyser(ClientWorld world, double x, double y, double z, double vx, double vy, double vz, SpriteProvider sprites) { + + protected ParticleGeyser(ClientLevel world, double x, double y, double z, double vx, double vy, double vz, + SpriteSet sprites) { super(world, x, y, z, vx, vy, vz); setSprite(sprites); this.maxAge = MHelper.randRange(400, 800, random); @@ -27,28 +28,26 @@ public class ParticleGeyser extends SpriteBillboardParticle { this.velocityZ = vz; this.prevPosY = y - 0.125; } - + @Override public void tick() { - + if (this.prevPosY == this.y || this.age > this.maxAge) { this.markDead(); - } - else { + } else { if (this.age >= this.maxAge - 200) { this.setColorAlpha((this.maxAge - this.age) / 200F); } - + this.scale += 0.005F; this.velocityY = 0.125; - + if (changeDir) { changeDir = false; check = false; this.velocityX += MHelper.randRange(-0.2, 0.2, random); this.velocityZ += MHelper.randRange(-0.2, 0.2, random); - } - else if (check) { + } else if (check) { changeDir = world.getBlockState(mut.set(x, y, z)).getFluidState().isEmpty(); this.velocityX = 0; this.velocityZ = 0; @@ -56,23 +55,24 @@ public class ParticleGeyser extends SpriteBillboardParticle { } super.tick(); } - + @Override public ParticleTextureSheet getType() { return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; } @Environment(EnvType.CLIENT) - public static class FactoryGeyser implements ParticleFactory { + public static class FactoryGeyser implements ParticleFactory { - private final SpriteProvider sprites; + private final SpriteSet sprites; - public FactoryGeyser(SpriteProvider sprites) { + public FactoryGeyser(SpriteSet sprites) { this.sprites = sprites; } @Override - public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) { + public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z, + double vX, double vY, double vZ) { return new ParticleGeyser(world, x, y, z, 0, 0.125, 0, sprites); } } diff --git a/src/main/java/ru/betterend/particle/ParticleGlowingSphere.java b/src/main/java/ru/betterend/particle/ParticleGlowingSphere.java index f7ac89bb..2628d725 100644 --- a/src/main/java/ru/betterend/particle/ParticleGlowingSphere.java +++ b/src/main/java/ru/betterend/particle/ParticleGlowingSphere.java @@ -2,17 +2,17 @@ package ru.betterend.particle; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.particle.AnimatedParticle; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.particle.SimpleAnimatedParticle; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; -import net.minecraft.client.particle.SpriteProvider; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.particle.DefaultParticleType; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.util.Mth; import ru.betterend.util.MHelper; @Environment(EnvType.CLIENT) -public class ParticleGlowingSphere extends AnimatedParticle { +public class ParticleGlowingSphere extends SimpleAnimatedParticle { private int ticks; private double preVX; private double preVY; @@ -20,27 +20,28 @@ public class ParticleGlowingSphere extends AnimatedParticle { private double nextVX; private double nextVY; private double nextVZ; - - protected ParticleGlowingSphere(ClientWorld world, double x, double y, double z, SpriteProvider sprites, double r, double g, double b) { + + protected ParticleGlowingSphere(ClientLevel world, double x, double y, double z, SpriteSet sprites, double r, + double g, double b) { super(world, x, y, z, sprites, 0); - setSprite(sprites.getSprite(random)); - this.maxAge = MHelper.randRange(150, 300, random); + setSprite(sprites.get(random)); + this.lifetime = MHelper.randRange(150, 300, random); this.scale = MHelper.randRange(0.05F, 0.15F, random); - this.setTargetColor(15916745); - this.setSpriteForAge(spriteProvider); - + this.setFadeColor(15916745); + this.setSpriteFromAge(sprites); + preVX = random.nextGaussian() * 0.02; preVY = random.nextGaussian() * 0.02; preVZ = random.nextGaussian() * 0.02; - + nextVX = random.nextGaussian() * 0.02; nextVY = random.nextGaussian() * 0.02; nextVZ = random.nextGaussian() * 0.02; } - + @Override public void tick() { - ticks ++; + ticks++; if (ticks > 30) { preVX = nextVX; preVY = nextVY; @@ -51,25 +52,26 @@ public class ParticleGlowingSphere extends AnimatedParticle { ticks = 0; } double delta = (double) ticks / 30.0; - - this.velocityX = MathHelper.lerp(delta, preVX, nextVX); - this.velocityY = MathHelper.lerp(delta, preVY, nextVY); - this.velocityZ = MathHelper.lerp(delta, preVZ, nextVZ); - + + this.velocityX = Mth.lerp(delta, preVX, nextVX); + this.velocityY = Mth.lerp(delta, preVY, nextVY); + this.velocityZ = Mth.lerp(delta, preVZ, nextVZ); + super.tick(); } @Environment(EnvType.CLIENT) - public static class FactoryGlowingSphere implements ParticleFactory { + public static class FactoryGlowingSphere implements ParticleFactory { - private final SpriteProvider sprites; + private final SpriteSet sprites; - public FactoryGlowingSphere(SpriteProvider sprites) { + public FactoryGlowingSphere(SpriteSet sprites) { this.sprites = sprites; } @Override - public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) { + public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z, + double vX, double vY, double vZ) { return new ParticleGlowingSphere(world, x, y, z, sprites, 1, 1, 1); } } diff --git a/src/main/java/ru/betterend/particle/ParticleJungleSpore.java b/src/main/java/ru/betterend/particle/ParticleJungleSpore.java index 6028b09e..691ad9e9 100644 --- a/src/main/java/ru/betterend/particle/ParticleJungleSpore.java +++ b/src/main/java/ru/betterend/particle/ParticleJungleSpore.java @@ -2,18 +2,19 @@ package ru.betterend.particle; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.particle.AnimatedParticle; +import net.minecraft.client.particle.SimpleAnimatedParticle; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; -import net.minecraft.client.particle.SpriteProvider; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.particle.DefaultParticleType; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.particles.SimpleParticleType; import ru.betterend.util.MHelper; @Environment(EnvType.CLIENT) -public class ParticleJungleSpore extends AnimatedParticle { - - protected ParticleJungleSpore(ClientWorld world, double x, double y, double z, SpriteProvider sprites, double r, double g, double b) { +public class ParticleJungleSpore extends SimpleAnimatedParticle { + + protected ParticleJungleSpore(ClientLevel world, double x, double y, double z, SpriteSet sprites, double r, + double g, double b) { super(world, x, y, z, sprites, 0); setSprite(sprites.getSprite(random)); this.maxAge = MHelper.randRange(150, 300, random); @@ -22,11 +23,11 @@ public class ParticleJungleSpore extends AnimatedParticle { this.setSpriteForAge(spriteProvider); this.setColorAlpha(0); } - + @Override public void tick() { super.tick(); - + int ticks = this.age % 30; if (ticks == 0) { this.velocityX = random.nextGaussian() * 0.02; @@ -34,36 +35,34 @@ public class ParticleJungleSpore extends AnimatedParticle { this.velocityZ = random.nextGaussian() * 0.02; ticks = 0; } - + if (this.age <= 30) { float delta = ticks / 30F; this.setColorAlpha(delta); - } - else if (this.age >= this.maxAge) { + } else if (this.age >= this.maxAge) { this.setColorAlpha(0); - } - else if (this.age >= this.maxAge - 30) { + } else if (this.age >= this.maxAge - 30) { this.setColorAlpha((this.maxAge - this.age) / 30F); - } - else { + } else { this.setColorAlpha(1); } - + this.velocityY -= 0.001F; this.velocityX *= 0.99F; this.velocityZ *= 0.99F; } @Environment(EnvType.CLIENT) - public static class FactoryJungleSpore implements ParticleFactory { - private final SpriteProvider sprites; + public static class FactoryJungleSpore implements ParticleFactory { + private final SpriteSet sprites; - public FactoryJungleSpore(SpriteProvider sprites) { + public FactoryJungleSpore(SpriteSet sprites) { this.sprites = sprites; } @Override - public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) { + public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z, + double vX, double vY, double vZ) { return new ParticleJungleSpore(world, x, y, z, sprites, 1, 1, 1); } } diff --git a/src/main/java/ru/betterend/particle/ParticleSnowflake.java b/src/main/java/ru/betterend/particle/ParticleSnowflake.java index 1cfccec9..1801fada 100644 --- a/src/main/java/ru/betterend/particle/ParticleSnowflake.java +++ b/src/main/java/ru/betterend/particle/ParticleSnowflake.java @@ -6,10 +6,10 @@ import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.ParticleTextureSheet; import net.minecraft.client.particle.SpriteBillboardParticle; -import net.minecraft.client.particle.SpriteProvider; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.particle.DefaultParticleType; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.util.Mth; import ru.betterend.util.MHelper; @Environment(EnvType.CLIENT) @@ -21,27 +21,28 @@ public class ParticleSnowflake extends SpriteBillboardParticle { private double nextVX; private double nextVY; private double nextVZ; - - protected ParticleSnowflake(ClientWorld world, double x, double y, double z, double r, double g, double b, SpriteProvider sprites) { + + protected ParticleSnowflake(ClientLevel world, double x, double y, double z, double r, double g, double b, + SpriteSet sprites) { super(world, x, y, z, r, g, b); setSprite(sprites); - + this.maxAge = MHelper.randRange(150, 300, random); this.scale = MHelper.randRange(0.05F, 0.2F, random); this.setColorAlpha(0F); - + preVX = random.nextGaussian() * 0.015; preVY = random.nextGaussian() * 0.015; preVZ = random.nextGaussian() * 0.015; - + nextVX = random.nextGaussian() * 0.015; nextVY = random.nextGaussian() * 0.015; nextVZ = random.nextGaussian() * 0.015; } - + @Override public void tick() { - ticks ++; + ticks++; if (ticks > 200) { preVX = nextVX; preVY = nextVY; @@ -55,41 +56,41 @@ public class ParticleSnowflake extends SpriteBillboardParticle { ticks = 0; } double delta = (double) ticks / 200.0; - + if (this.age <= 40) { this.setColorAlpha(this.age / 40F); - } - else if (this.age >= this.maxAge - 40) { + } else if (this.age >= this.maxAge - 40) { this.setColorAlpha((this.maxAge - this.age) / 40F); } - + if (this.age >= this.maxAge) { this.markDead(); } - - this.velocityX = MathHelper.lerp(delta, preVX, nextVX); - this.velocityY = MathHelper.lerp(delta, preVY, nextVY); - this.velocityZ = MathHelper.lerp(delta, preVZ, nextVZ); - + + this.velocityX = Mth.lerp(delta, preVX, nextVX); + this.velocityY = Mth.lerp(delta, preVY, nextVY); + this.velocityZ = Mth.lerp(delta, preVZ, nextVZ); + super.tick(); } - + @Override public ParticleTextureSheet getType() { return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; } @Environment(EnvType.CLIENT) - public static class FactorySnowflake implements ParticleFactory { + public static class FactorySnowflake implements ParticleFactory { - private final SpriteProvider sprites; + private final SpriteSet sprites; - public FactorySnowflake(SpriteProvider sprites) { + public FactorySnowflake(SpriteSet sprites) { this.sprites = sprites; } @Override - public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) { + public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z, + double vX, double vY, double vZ) { return new ParticleSnowflake(world, x, y, z, 1, 1, 1, sprites); } } diff --git a/src/main/java/ru/betterend/particle/ParticleSulphur.java b/src/main/java/ru/betterend/particle/ParticleSulphur.java index 3f0cf51d..74a3d9f7 100644 --- a/src/main/java/ru/betterend/particle/ParticleSulphur.java +++ b/src/main/java/ru/betterend/particle/ParticleSulphur.java @@ -6,10 +6,10 @@ import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.ParticleTextureSheet; import net.minecraft.client.particle.SpriteBillboardParticle; -import net.minecraft.client.particle.SpriteProvider; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.particle.DefaultParticleType; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.util.Mth; import ru.betterend.util.MHelper; @Environment(EnvType.CLIENT) @@ -21,28 +21,29 @@ public class ParticleSulphur extends SpriteBillboardParticle { private double nextVX; private double nextVY; private double nextVZ; - - protected ParticleSulphur(ClientWorld world, double x, double y, double z, double r, double g, double b, SpriteProvider sprites) { + + protected ParticleSulphur(ClientLevel world, double x, double y, double z, double r, double g, double b, + SpriteSet sprites) { super(world, x, y, z, r, g, b); setSprite(sprites); - + this.maxAge = MHelper.randRange(150, 300, random); this.scale = MHelper.randRange(0.05F, 0.15F, random); this.setColor(1, 1, 1); this.setColorAlpha(0); - + preVX = random.nextGaussian() * 0.015; preVY = random.nextGaussian() * 0.015; preVZ = random.nextGaussian() * 0.015; - + nextVX = random.nextGaussian() * 0.015; nextVY = random.nextGaussian() * 0.015; nextVZ = random.nextGaussian() * 0.015; } - + @Override public void tick() { - ticks ++; + ticks++; if (ticks > 200) { preVX = nextVX; preVY = nextVY; @@ -56,41 +57,41 @@ public class ParticleSulphur extends SpriteBillboardParticle { ticks = 0; } double delta = (double) ticks / 200.0; - + if (this.age <= 40) { this.setColorAlpha(this.age / 40F); - } - else if (this.age >= this.maxAge - 40) { + } else if (this.age >= this.maxAge - 40) { this.setColorAlpha((this.maxAge - this.age) / 40F); } - + if (this.age >= this.maxAge) { this.markDead(); } - - this.velocityX = MathHelper.lerp(delta, preVX, nextVX); - this.velocityY = MathHelper.lerp(delta, preVY, nextVY); - this.velocityZ = MathHelper.lerp(delta, preVZ, nextVZ); - + + this.velocityX = Mth.lerp(delta, preVX, nextVX); + this.velocityY = Mth.lerp(delta, preVY, nextVY); + this.velocityZ = Mth.lerp(delta, preVZ, nextVZ); + super.tick(); } - + @Override public ParticleTextureSheet getType() { return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; } @Environment(EnvType.CLIENT) - public static class FactorySulphur implements ParticleFactory { + public static class FactorySulphur implements ParticleFactory { - private final SpriteProvider sprites; + private final SpriteSet sprites; - public FactorySulphur(SpriteProvider sprites) { + public FactorySulphur(SpriteSet sprites) { this.sprites = sprites; } @Override - public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) { + public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z, + double vX, double vY, double vZ) { return new ParticleSulphur(world, x, y, z, 1, 1, 1, sprites); } } diff --git a/src/main/java/ru/betterend/particle/ParticleTenaneaPetal.java b/src/main/java/ru/betterend/particle/ParticleTenaneaPetal.java index 27e9a496..52e438bb 100644 --- a/src/main/java/ru/betterend/particle/ParticleTenaneaPetal.java +++ b/src/main/java/ru/betterend/particle/ParticleTenaneaPetal.java @@ -2,52 +2,53 @@ package ru.betterend.particle; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.color.block.BlockColorProvider; +import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.ParticleTextureSheet; import net.minecraft.client.particle.SpriteBillboardParticle; -import net.minecraft.client.particle.SpriteProvider; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.particle.DefaultParticleType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; import ru.betterend.interfaces.IColorProvider; import ru.betterend.registry.EndBlocks; import ru.betterend.util.MHelper; @Environment(EnvType.CLIENT) public class ParticleTenaneaPetal extends SpriteBillboardParticle { - private static BlockColorProvider provider; - + private static BlockColor provider; + private double preVX; private double preVY; private double preVZ; private double nextVX; private double nextVY; private double nextVZ; - - protected ParticleTenaneaPetal(ClientWorld world, double x, double y, double z, double r, double g, double b, SpriteProvider sprites) { + + protected ParticleTenaneaPetal(ClientLevel world, double x, double y, double z, double r, double g, double b, + SpriteSet sprites) { super(world, x, y, z, r, g, b); setSprite(sprites); - + if (provider == null) { IColorProvider block = (IColorProvider) EndBlocks.TENANEA_FLOWERS; - provider = block.getProvider(); + provider = block.getBlockProvider(); } int color = provider.getColor(null, null, new BlockPos(x, y, z), 0); this.colorRed = ((color >> 16) & 255) / 255F; this.colorGreen = ((color >> 8) & 255) / 255F; this.colorBlue = ((color) & 255) / 255F; - + this.maxAge = MHelper.randRange(120, 200, random); this.scale = MHelper.randRange(0.05F, 0.15F, random); this.setColorAlpha(0); - + preVX = 0; preVY = 0; preVZ = 0; - + nextVX = random.nextGaussian() * 0.02; nextVY = -random.nextDouble() * 0.02 - 0.02; nextVZ = random.nextGaussian() * 0.02; @@ -57,7 +58,7 @@ public class ParticleTenaneaPetal extends SpriteBillboardParticle { public int getColorMultiplier(float tint) { return 15728880; } - + @Override public void tick() { int ticks = this.age & 63; @@ -70,41 +71,41 @@ public class ParticleTenaneaPetal extends SpriteBillboardParticle { nextVZ = random.nextGaussian() * 0.02; } double delta = (double) ticks / 63.0; - + if (this.age <= 40) { this.setColorAlpha(this.age / 40F); - } - else if (this.age >= this.maxAge - 40) { + } else if (this.age >= this.maxAge - 40) { this.setColorAlpha((this.maxAge - this.age) / 40F); } - + if (this.age >= this.maxAge) { this.markDead(); } - - this.velocityX = MathHelper.lerp(delta, preVX, nextVX); - this.velocityY = MathHelper.lerp(delta, preVY, nextVY); - this.velocityZ = MathHelper.lerp(delta, preVZ, nextVZ); - + + this.velocityX = Mth.lerp(delta, preVX, nextVX); + this.velocityY = Mth.lerp(delta, preVY, nextVY); + this.velocityZ = Mth.lerp(delta, preVZ, nextVZ); + super.tick(); } - + @Override public ParticleTextureSheet getType() { return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; } @Environment(EnvType.CLIENT) - public static class FactoryTenaneaPetal implements ParticleFactory { + public static class FactoryTenaneaPetal implements ParticleFactory { - private final SpriteProvider sprites; + private final SpriteSet sprites; - public FactoryTenaneaPetal(SpriteProvider sprites) { + public FactoryTenaneaPetal(SpriteSet sprites) { this.sprites = sprites; } @Override - public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) { + public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z, + double vX, double vY, double vZ) { return new ParticleTenaneaPetal(world, x, y, z, 1, 1, 1, sprites); } } diff --git a/src/main/java/ru/betterend/particle/PaticlePortalSphere.java b/src/main/java/ru/betterend/particle/PaticlePortalSphere.java index 7268fcf5..7566c67b 100644 --- a/src/main/java/ru/betterend/particle/PaticlePortalSphere.java +++ b/src/main/java/ru/betterend/particle/PaticlePortalSphere.java @@ -2,16 +2,16 @@ package ru.betterend.particle; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.particle.AnimatedParticle; +import net.minecraft.client.particle.SimpleAnimatedParticle; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; -import net.minecraft.client.particle.SpriteProvider; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.particle.DefaultParticleType; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.util.Mth; import ru.betterend.util.MHelper; -public class PaticlePortalSphere extends AnimatedParticle { +public class PaticlePortalSphere extends SimpleAnimatedParticle { private int ticks; private double preVX; private double preVY; @@ -19,8 +19,8 @@ public class PaticlePortalSphere extends AnimatedParticle { private double nextVX; private double nextVY; private double nextVZ; - - public PaticlePortalSphere(ClientWorld world, double x, double y, double z, SpriteProvider spriteProvider) { + + public PaticlePortalSphere(ClientLevel world, double x, double y, double z, SpriteSet spriteProvider) { super(world, x, y, z, spriteProvider, 0); setSprite(spriteProvider.getSprite(random)); this.maxAge = MHelper.randRange(20, 80, random); @@ -28,16 +28,16 @@ public class PaticlePortalSphere extends AnimatedParticle { this.setColor(0xFEBBD5); this.setTargetColor(0xBBFEE4); this.setSpriteForAge(spriteProvider); - + preVX = random.nextGaussian() * 0.02; preVY = random.nextGaussian() * 0.02; preVZ = random.nextGaussian() * 0.02; - + nextVX = random.nextGaussian() * 0.02; nextVY = random.nextGaussian() * 0.02; nextVZ = random.nextGaussian() * 0.02; } - + @Override public void tick() { ticks++; @@ -51,25 +51,26 @@ public class PaticlePortalSphere extends AnimatedParticle { ticks = 0; } double delta = (double) ticks / 30.0; - - this.velocityX = MathHelper.lerp(delta, preVX, nextVX); - this.velocityY = MathHelper.lerp(delta, preVY, nextVY); - this.velocityZ = MathHelper.lerp(delta, preVZ, nextVZ); - + + this.velocityX = Mth.lerp(delta, preVX, nextVX); + this.velocityY = Mth.lerp(delta, preVY, nextVY); + this.velocityZ = Mth.lerp(delta, preVZ, nextVZ); + super.tick(); } @Environment(EnvType.CLIENT) - public static class FactoryPortalSphere implements ParticleFactory { + public static class FactoryPortalSphere implements ParticleFactory { - private final SpriteProvider sprites; + private final SpriteSet sprites; - public FactoryPortalSphere(SpriteProvider sprites) { + public FactoryPortalSphere(SpriteSet sprites) { this.sprites = sprites; } @Override - public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) { + public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z, + double vX, double vY, double vZ) { return new PaticlePortalSphere(world, x, y, z, sprites); } } diff --git a/src/main/java/ru/betterend/particle/SmaragdantParticle.java b/src/main/java/ru/betterend/particle/SmaragdantParticle.java index bf19c400..2cb5aac3 100644 --- a/src/main/java/ru/betterend/particle/SmaragdantParticle.java +++ b/src/main/java/ru/betterend/particle/SmaragdantParticle.java @@ -2,43 +2,44 @@ package ru.betterend.particle; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.particle.AnimatedParticle; +import net.minecraft.client.particle.SimpleAnimatedParticle; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.ParticleTextureSheet; -import net.minecraft.client.particle.SpriteProvider; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.particle.DefaultParticleType; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.util.Mth; import ru.betterend.util.MHelper; @Environment(EnvType.CLIENT) -public class SmaragdantParticle extends AnimatedParticle { +public class SmaragdantParticle extends SimpleAnimatedParticle { private double preVX; private double preVY; private double preVZ; private double nextVX; private double nextVY; private double nextVZ; - - protected SmaragdantParticle(ClientWorld world, double x, double y, double z, double r, double g, double b, SpriteProvider sprites) { + + protected SmaragdantParticle(ClientLevel world, double x, double y, double z, double r, double g, double b, + SpriteSet sprites) { super(world, x, y, z, sprites, 0); setSprite(sprites.getSprite(random)); - + this.maxAge = MHelper.randRange(60, 120, random); this.scale = MHelper.randRange(0.05F, 0.15F, random); this.setColor(1, 1, 1); this.setColorAlpha(0); - + preVX = random.nextGaussian() * 0.01; preVY = random.nextGaussian() * 0.01; preVZ = random.nextGaussian() * 0.01; - + nextVX = random.nextGaussian() * 0.01; nextVY = random.nextGaussian() * 0.01; nextVZ = random.nextGaussian() * 0.01; } - + @Override public void tick() { int ticks = this.age & 31; @@ -51,41 +52,41 @@ public class SmaragdantParticle extends AnimatedParticle { nextVZ = random.nextGaussian() * 0.015; } double delta = (double) ticks / 31.0; - + if (this.age <= 31) { this.setColorAlpha(this.age / 31F); - } - else if (this.age >= this.maxAge - 31) { + } else if (this.age >= this.maxAge - 31) { this.setColorAlpha((this.maxAge - this.age) / 31F); } - + if (this.age >= this.maxAge) { this.markDead(); } - - this.velocityX = MathHelper.lerp(delta, preVX, nextVX); - this.velocityY = MathHelper.lerp(delta, preVY, nextVY); - this.velocityZ = MathHelper.lerp(delta, preVZ, nextVZ); - + + this.velocityX = Mth.lerp(delta, preVX, nextVX); + this.velocityY = Mth.lerp(delta, preVY, nextVY); + this.velocityZ = Mth.lerp(delta, preVZ, nextVZ); + super.tick(); } - + @Override public ParticleTextureSheet getType() { return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; } @Environment(EnvType.CLIENT) - public static class SmaragdantParticleFactory implements ParticleFactory { + public static class SmaragdantParticleFactory implements ParticleFactory { - private final SpriteProvider sprites; + private final SpriteSet sprites; - public SmaragdantParticleFactory(SpriteProvider sprites) { + public SmaragdantParticleFactory(SpriteSet sprites) { this.sprites = sprites; } @Override - public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) { + public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z, + double vX, double vY, double vZ) { return new SmaragdantParticle(world, x, y, z, 1, 1, 1, sprites); } } diff --git a/src/main/java/ru/betterend/patterns/BlockPatterned.java b/src/main/java/ru/betterend/patterns/BlockPatterned.java index 182b695b..61feee5d 100644 --- a/src/main/java/ru/betterend/patterns/BlockPatterned.java +++ b/src/main/java/ru/betterend/patterns/BlockPatterned.java @@ -2,13 +2,14 @@ package ru.betterend.patterns; import java.io.Reader; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; public interface BlockPatterned extends Patterned { default String getStatesPattern(Reader data) { return null; } - default Identifier statePatternId() { + + default ResourceLocation statePatternId() { return null; } } diff --git a/src/main/java/ru/betterend/patterns/Patterns.java b/src/main/java/ru/betterend/patterns/Patterns.java index 67c72d3e..eba3e869 100644 --- a/src/main/java/ru/betterend/patterns/Patterns.java +++ b/src/main/java/ru/betterend/patterns/Patterns.java @@ -13,121 +13,138 @@ import com.google.common.collect.Maps; import net.minecraft.client.MinecraftClient; import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import ru.betterend.BetterEnd; public class Patterns { - - //Blockstates - public final static Identifier STATE_SIMPLE = BetterEnd.makeID("patterns/blockstate/block.json"); - public final static Identifier STATE_SLAB = BetterEnd.makeID("patterns/blockstate/slab.json"); - public final static Identifier STATE_STAIRS = BetterEnd.makeID("patterns/blockstate/stairs.json"); - public final static Identifier STATE_WALL = BetterEnd.makeID("patterns/blockstate/wall.json"); - public final static Identifier STATE_FENCE = BetterEnd.makeID("patterns/blockstate/fence.json"); - public final static Identifier STATE_BUTTON = BetterEnd.makeID("patterns/blockstate/button.json"); - public final static Identifier STATE_PILLAR = BetterEnd.makeID("patterns/blockstate/pillar.json"); - public final static Identifier STATE_PLATE = BetterEnd.makeID("patterns/blockstate/pressure_plate.json"); - public final static Identifier STATE_PLATE_ROTATED = BetterEnd.makeID("patterns/blockstate/pressure_plate_rotated.json"); - public final static Identifier STATE_DOOR = BetterEnd.makeID("patterns/blockstate/door.json"); - public final static Identifier STATE_SAPLING = BetterEnd.makeID("patterns/blockstate/sapling.json"); - public final static Identifier STATE_GATE = BetterEnd.makeID("patterns/blockstate/fence_gate.json"); - public final static Identifier STATE_TRAPDOOR = BetterEnd.makeID("patterns/blockstate/trapdoor.json"); - public final static Identifier STATE_LADDER = BetterEnd.makeID("patterns/blockstate/ladder.json"); - public final static Identifier STATE_BARREL = BetterEnd.makeID("patterns/blockstate/barrel.json"); - public final static Identifier STATE_PEDESTAL = BetterEnd.makeID("patterns/blockstate/pedestal.json"); - public final static Identifier STATE_STONE_LANTERN = BetterEnd.makeID("patterns/blockstate/stone_lantern.json"); - public final static Identifier STATE_DIRECT = BetterEnd.makeID("patterns/blockstate/direct.json"); - public final static Identifier STATE_BULB_LANTERN = BetterEnd.makeID("patterns/blockstate/bulb_lantern.json"); - public final static Identifier STATE_COMPOSTER = BetterEnd.makeID("patterns/blockstate/composter.json"); - public final static Identifier STATE_BARS = BetterEnd.makeID("patterns/blockstate/bars.json"); - public final static Identifier STATE_ANVIL = BetterEnd.makeID("patterns/blockstate/anvil.json"); - public final static Identifier STATE_ANVIL_LONG = BetterEnd.makeID("patterns/blockstate/anvil_long.json"); - public final static Identifier STATE_CHAIN = BetterEnd.makeID("patterns/blockstate/chain.json"); - public final static Identifier STATE_CHANDELIER = BetterEnd.makeID("patterns/blockstate/chandelier.json"); - public final static Identifier STATE_FURNACE = BetterEnd.makeID("patterns/blockstate/furnace.json"); - public final static Identifier STATE_ROTATED_TOP = BetterEnd.makeID("patterns/blockstate/rotated_top.json"); - public final static Identifier STATE_TRIPLE_ROTATED_TOP = BetterEnd.makeID("patterns/blockstate/triple_rotated_top.json"); - public final static Identifier STATE_STALACTITE = BetterEnd.makeID("patterns/blockstate/stalactite.json"); - - //Models Block - public final static Identifier BLOCK_EMPTY = BetterEnd.makeID("patterns/block/empty.json"); - public final static Identifier BLOCK_BASE = BetterEnd.makeID("patterns/block/block.json"); - public final static Identifier BLOCK_SIDED = BetterEnd.makeID("patterns/block/block_sided.json"); - public final static Identifier BLOCK_BOTTOM_TOP = BetterEnd.makeID("patterns/block/block_bottom_top.json"); - public final static Identifier BLOCK_SLAB = BetterEnd.makeID("patterns/block/slab.json"); - public final static Identifier BLOCK_STAIR = BetterEnd.makeID("patterns/block/stairs.json"); - public final static Identifier BLOCK_STAIR_INNER = BetterEnd.makeID("patterns/block/inner_stairs.json"); - public final static Identifier BLOCK_STAIR_OUTER = BetterEnd.makeID("patterns/block/outer_stairs.json"); - public final static Identifier BLOCK_WALL_POST = BetterEnd.makeID("patterns/block/wall_post.json"); - public final static Identifier BLOCK_WALL_SIDE = BetterEnd.makeID("patterns/block/wall_side.json"); - public final static Identifier BLOCK_WALL_SIDE_TALL = BetterEnd.makeID("patterns/block/wall_side_tall.json"); - public final static Identifier BLOCK_FENCE_POST = BetterEnd.makeID("patterns/block/fence_post.json"); - public final static Identifier BLOCK_FENCE_SIDE = BetterEnd.makeID("patterns/block/fence_side.json"); - public final static Identifier BLOCK_BUTTON = BetterEnd.makeID("patterns/block/button.json"); - public final static Identifier BLOCK_BUTTON_PRESSED = BetterEnd.makeID("patterns/block/button_pressed.json"); - public final static Identifier BLOCK_PILLAR = BetterEnd.makeID("patterns/block/pillar.json"); - public final static Identifier BLOCK_PLATE_UP = BetterEnd.makeID("patterns/block/pressure_plate_up.json"); - public final static Identifier BLOCK_PLATE_DOWN = BetterEnd.makeID("patterns/block/pressure_plate_down.json"); - public final static Identifier BLOCK_DOOR_TOP = BetterEnd.makeID("patterns/block/door_top.json"); - public final static Identifier BLOCK_DOOR_TOP_HINGE = BetterEnd.makeID("patterns/block/door_top_hinge.json"); - public final static Identifier BLOCK_DOOR_BOTTOM = BetterEnd.makeID("patterns/block/door_bottom.json"); - public final static Identifier BLOCK_DOOR_BOTTOM_HINGE = BetterEnd.makeID("patterns/block/door_bottom_hinge.json"); - public final static Identifier BLOCK_CROSS = BetterEnd.makeID("patterns/block/cross.json"); - public final static Identifier BLOCK_CROSS_SHADED = BetterEnd.makeID("patterns/block/cross_shaded.json"); - public final static Identifier BLOCK_GATE_CLOSED = BetterEnd.makeID("patterns/block/fence_gate_closed.json"); - public final static Identifier BLOCK_GATE_CLOSED_WALL = BetterEnd.makeID("patterns/block/wall_gate_closed.json"); - public final static Identifier BLOCK_GATE_OPEN = BetterEnd.makeID("patterns/block/fence_gate_open.json"); - public final static Identifier BLOCK_GATE_OPEN_WALL = BetterEnd.makeID("patterns/block/wall_gate_open.json"); - public final static Identifier BLOCK_TRAPDOOR = BetterEnd.makeID("patterns/block/trapdoor.json"); - public final static Identifier BLOCK_LADDER = BetterEnd.makeID("patterns/block/ladder.json"); - public final static Identifier BLOCK_BARREL_OPEN = BetterEnd.makeID("patterns/block/barrel_open.json"); - public final static Identifier BLOCK_PEDESTAL_DEFAULT = BetterEnd.makeID("patterns/block/pedestal_default.json"); - public final static Identifier BLOKC_PEDESTAL_COLUMN = BetterEnd.makeID("patterns/block/pedestal_column.json"); - public final static Identifier BLOCK_PEDESTAL_COLUMN_TOP = BetterEnd.makeID("patterns/block/pedestal_column_top.json"); - public final static Identifier BLOCK_PEDESTAL_TOP = BetterEnd.makeID("patterns/block/pedestal_top.json"); - public final static Identifier BLOCK_PEDESTAL_BOTTOM = BetterEnd.makeID("patterns/block/pedestal_bottom.json"); - public final static Identifier BLOCK_PEDESTAL_PILLAR = BetterEnd.makeID("patterns/block/pedestal_pillar.json"); - public final static Identifier BLOCK_BOOKSHELF = BetterEnd.makeID("patterns/block/bookshelf.json"); - public final static Identifier BLOCK_STONE_LANTERN_CEIL = BetterEnd.makeID("patterns/block/stone_lantern_ceil.json"); - public final static Identifier BLOCK_STONE_LANTERN_FLOOR = BetterEnd.makeID("patterns/block/stone_lantern_floor.json"); - public final static Identifier BLOCK_BULB_LANTERN_FLOOR = BetterEnd.makeID("patterns/block/bulb_lantern_floor.json"); - public final static Identifier BLOCK_BULB_LANTERN_CEIL = BetterEnd.makeID("patterns/block/bulb_lantern_ceil.json"); - public final static Identifier BLOCK_PETAL_COLORED = BetterEnd.makeID("models/block/block_petal_colored.json"); - public final static Identifier BLOCK_COMPOSTER = BetterEnd.makeID("patterns/block/composter.json"); - public final static Identifier BLOCK_COLORED = BetterEnd.makeID("patterns/block/block_colored.json"); - public final static Identifier BLOCK_BARS_POST = BetterEnd.makeID("patterns/block/bars_post.json"); - public final static Identifier BLOCK_BARS_SIDE = BetterEnd.makeID("patterns/block/bars_side.json"); - public final static Identifier BLOCK_ANVIL = BetterEnd.makeID("patterns/block/anvil.json"); - public final static Identifier BLOCK_CHAIN = BetterEnd.makeID("patterns/block/chain.json"); - public final static Identifier BLOCK_CHANDELIER_FLOOR = BetterEnd.makeID("patterns/block/chandelier_floor.json"); - public final static Identifier BLOCK_CHANDELIER_WALL = BetterEnd.makeID("patterns/block/chandelier_wall.json"); - public final static Identifier BLOCK_CHANDELIER_CEIL = BetterEnd.makeID("patterns/block/chandelier_ceil.json"); - public final static Identifier BLOCK_FURNACE = BetterEnd.makeID("patterns/block/furnace.json"); - public final static Identifier BLOCK_FURNACE_GLOW = BetterEnd.makeID("patterns/block/furnace_glow.json"); - public final static Identifier BLOCK_TOP_SIDE_BOTTOM = BetterEnd.makeID("patterns/block/top_side_bottom.json"); - public final static Identifier BLOCK_PATH = BetterEnd.makeID("patterns/block/path.json"); - - //Models Item - public final static Identifier ITEM_WALL = BetterEnd.makeID("patterns/item/pattern_wall.json"); - public final static Identifier ITEM_FENCE = BetterEnd.makeID("patterns/item/pattern_fence.json"); - public final static Identifier ITEM_BUTTON = BetterEnd.makeID("patterns/item/pattern_button.json"); - public final static Identifier ITEM_CHEST = BetterEnd.makeID("patterns/item/pattern_chest.json"); - public final static Identifier ITEM_BLOCK = BetterEnd.makeID("patterns/item/pattern_block_item.json"); - public final static Identifier ITEM_GENERATED = BetterEnd.makeID("patterns/item/pattern_item_generated.json"); - public final static Identifier ITEM_HANDHELD = BetterEnd.makeID("patterns/item/pattern_item_handheld.json"); - public final static Identifier ITEM_SPAWN_EGG = BetterEnd.makeID("patterns/item/pattern_item_spawn_egg.json"); - + + // Blockstates + public final static ResourceLocation STATE_SIMPLE = BetterEnd.makeID("patterns/blockstate/block.json"); + public final static ResourceLocation STATE_SLAB = BetterEnd.makeID("patterns/blockstate/slab.json"); + public final static ResourceLocation STATE_STAIRS = BetterEnd.makeID("patterns/blockstate/stairs.json"); + public final static ResourceLocation STATE_WALL = BetterEnd.makeID("patterns/blockstate/wall.json"); + public final static ResourceLocation STATE_FENCE = BetterEnd.makeID("patterns/blockstate/fence.json"); + public final static ResourceLocation STATE_BUTTON = BetterEnd.makeID("patterns/blockstate/button.json"); + public final static ResourceLocation STATE_PILLAR = BetterEnd.makeID("patterns/blockstate/pillar.json"); + public final static ResourceLocation STATE_PLATE = BetterEnd.makeID("patterns/blockstate/pressure_plate.json"); + public final static ResourceLocation STATE_PLATE_ROTATED = BetterEnd + .makeID("patterns/blockstate/pressure_plate_rotated.json"); + public final static ResourceLocation STATE_DOOR = BetterEnd.makeID("patterns/blockstate/door.json"); + public final static ResourceLocation STATE_SAPLING = BetterEnd.makeID("patterns/blockstate/sapling.json"); + public final static ResourceLocation STATE_GATE = BetterEnd.makeID("patterns/blockstate/fence_gate.json"); + public final static ResourceLocation STATE_TRAPDOOR = BetterEnd.makeID("patterns/blockstate/trapdoor.json"); + public final static ResourceLocation STATE_LADDER = BetterEnd.makeID("patterns/blockstate/ladder.json"); + public final static ResourceLocation STATE_BARREL = BetterEnd.makeID("patterns/blockstate/barrel.json"); + public final static ResourceLocation STATE_PEDESTAL = BetterEnd.makeID("patterns/blockstate/pedestal.json"); + public final static ResourceLocation STATE_STONE_LANTERN = BetterEnd + .makeID("patterns/blockstate/stone_lantern.json"); + public final static ResourceLocation STATE_DIRECT = BetterEnd.makeID("patterns/blockstate/direct.json"); + public final static ResourceLocation STATE_BULB_LANTERN = BetterEnd.makeID("patterns/blockstate/bulb_lantern.json"); + public final static ResourceLocation STATE_COMPOSTER = BetterEnd.makeID("patterns/blockstate/composter.json"); + public final static ResourceLocation STATE_BARS = BetterEnd.makeID("patterns/blockstate/bars.json"); + public final static ResourceLocation STATE_ANVIL = BetterEnd.makeID("patterns/blockstate/anvil.json"); + public final static ResourceLocation STATE_ANVIL_LONG = BetterEnd.makeID("patterns/blockstate/anvil_long.json"); + public final static ResourceLocation STATE_CHAIN = BetterEnd.makeID("patterns/blockstate/chain.json"); + public final static ResourceLocation STATE_CHANDELIER = BetterEnd.makeID("patterns/blockstate/chandelier.json"); + public final static ResourceLocation STATE_FURNACE = BetterEnd.makeID("patterns/blockstate/furnace.json"); + public final static ResourceLocation STATE_ROTATED_TOP = BetterEnd.makeID("patterns/blockstate/rotated_top.json"); + public final static ResourceLocation STATE_TRIPLE_ROTATED_TOP = BetterEnd + .makeID("patterns/blockstate/triple_rotated_top.json"); + public final static ResourceLocation STATE_STALACTITE = BetterEnd.makeID("patterns/blockstate/stalactite.json"); + + // Models Block + public final static ResourceLocation BLOCK_EMPTY = BetterEnd.makeID("patterns/block/empty.json"); + public final static ResourceLocation BLOCK_BASE = BetterEnd.makeID("patterns/block/block.json"); + public final static ResourceLocation BLOCK_SIDED = BetterEnd.makeID("patterns/block/block_sided.json"); + public final static ResourceLocation BLOCK_BOTTOM_TOP = BetterEnd.makeID("patterns/block/block_bottom_top.json"); + public final static ResourceLocation BLOCK_SLAB = BetterEnd.makeID("patterns/block/slab.json"); + public final static ResourceLocation BLOCK_STAIR = BetterEnd.makeID("patterns/block/stairs.json"); + public final static ResourceLocation BLOCK_STAIR_INNER = BetterEnd.makeID("patterns/block/inner_stairs.json"); + public final static ResourceLocation BLOCK_STAIR_OUTER = BetterEnd.makeID("patterns/block/outer_stairs.json"); + public final static ResourceLocation BLOCK_WALL_POST = BetterEnd.makeID("patterns/block/wall_post.json"); + public final static ResourceLocation BLOCK_WALL_SIDE = BetterEnd.makeID("patterns/block/wall_side.json"); + public final static ResourceLocation BLOCK_WALL_SIDE_TALL = BetterEnd.makeID("patterns/block/wall_side_tall.json"); + public final static ResourceLocation BLOCK_FENCE_POST = BetterEnd.makeID("patterns/block/fence_post.json"); + public final static ResourceLocation BLOCK_FENCE_SIDE = BetterEnd.makeID("patterns/block/fence_side.json"); + public final static ResourceLocation BLOCK_BUTTON = BetterEnd.makeID("patterns/block/button.json"); + public final static ResourceLocation BLOCK_BUTTON_PRESSED = BetterEnd.makeID("patterns/block/button_pressed.json"); + public final static ResourceLocation BLOCK_PILLAR = BetterEnd.makeID("patterns/block/pillar.json"); + public final static ResourceLocation BLOCK_PLATE_UP = BetterEnd.makeID("patterns/block/pressure_plate_up.json"); + public final static ResourceLocation BLOCK_PLATE_DOWN = BetterEnd.makeID("patterns/block/pressure_plate_down.json"); + public final static ResourceLocation BLOCK_DOOR_TOP = BetterEnd.makeID("patterns/block/door_top.json"); + public final static ResourceLocation BLOCK_DOOR_TOP_HINGE = BetterEnd.makeID("patterns/block/door_top_hinge.json"); + public final static ResourceLocation BLOCK_DOOR_BOTTOM = BetterEnd.makeID("patterns/block/door_bottom.json"); + public final static ResourceLocation BLOCK_DOOR_BOTTOM_HINGE = BetterEnd + .makeID("patterns/block/door_bottom_hinge.json"); + public final static ResourceLocation BLOCK_CROSS = BetterEnd.makeID("patterns/block/cross.json"); + public final static ResourceLocation BLOCK_CROSS_SHADED = BetterEnd.makeID("patterns/block/cross_shaded.json"); + public final static ResourceLocation BLOCK_GATE_CLOSED = BetterEnd.makeID("patterns/block/fence_gate_closed.json"); + public final static ResourceLocation BLOCK_GATE_CLOSED_WALL = BetterEnd + .makeID("patterns/block/wall_gate_closed.json"); + public final static ResourceLocation BLOCK_GATE_OPEN = BetterEnd.makeID("patterns/block/fence_gate_open.json"); + public final static ResourceLocation BLOCK_GATE_OPEN_WALL = BetterEnd.makeID("patterns/block/wall_gate_open.json"); + public final static ResourceLocation BLOCK_TRAPDOOR = BetterEnd.makeID("patterns/block/trapdoor.json"); + public final static ResourceLocation BLOCK_LADDER = BetterEnd.makeID("patterns/block/ladder.json"); + public final static ResourceLocation BLOCK_BARREL_OPEN = BetterEnd.makeID("patterns/block/barrel_open.json"); + public final static ResourceLocation BLOCK_PEDESTAL_DEFAULT = BetterEnd + .makeID("patterns/block/pedestal_default.json"); + public final static ResourceLocation BLOKC_PEDESTAL_COLUMN = BetterEnd + .makeID("patterns/block/pedestal_column.json"); + public final static ResourceLocation BLOCK_PEDESTAL_COLUMN_TOP = BetterEnd + .makeID("patterns/block/pedestal_column_top.json"); + public final static ResourceLocation BLOCK_PEDESTAL_TOP = BetterEnd.makeID("patterns/block/pedestal_top.json"); + public final static ResourceLocation BLOCK_PEDESTAL_BOTTOM = BetterEnd + .makeID("patterns/block/pedestal_bottom.json"); + public final static ResourceLocation BLOCK_PEDESTAL_PILLAR = BetterEnd + .makeID("patterns/block/pedestal_pillar.json"); + public final static ResourceLocation BLOCK_BOOKSHELF = BetterEnd.makeID("patterns/block/bookshelf.json"); + public final static ResourceLocation BLOCK_STONE_LANTERN_CEIL = BetterEnd + .makeID("patterns/block/stone_lantern_ceil.json"); + public final static ResourceLocation BLOCK_STONE_LANTERN_FLOOR = BetterEnd + .makeID("patterns/block/stone_lantern_floor.json"); + public final static ResourceLocation BLOCK_BULB_LANTERN_FLOOR = BetterEnd + .makeID("patterns/block/bulb_lantern_floor.json"); + public final static ResourceLocation BLOCK_BULB_LANTERN_CEIL = BetterEnd + .makeID("patterns/block/bulb_lantern_ceil.json"); + public final static ResourceLocation BLOCK_PETAL_COLORED = BetterEnd + .makeID("models/block/block_petal_colored.json"); + public final static ResourceLocation BLOCK_COMPOSTER = BetterEnd.makeID("patterns/block/composter.json"); + public final static ResourceLocation BLOCK_COLORED = BetterEnd.makeID("patterns/block/block_colored.json"); + public final static ResourceLocation BLOCK_BARS_POST = BetterEnd.makeID("patterns/block/bars_post.json"); + public final static ResourceLocation BLOCK_BARS_SIDE = BetterEnd.makeID("patterns/block/bars_side.json"); + public final static ResourceLocation BLOCK_ANVIL = BetterEnd.makeID("patterns/block/anvil.json"); + public final static ResourceLocation BLOCK_CHAIN = BetterEnd.makeID("patterns/block/chain.json"); + public final static ResourceLocation BLOCK_CHANDELIER_FLOOR = BetterEnd + .makeID("patterns/block/chandelier_floor.json"); + public final static ResourceLocation BLOCK_CHANDELIER_WALL = BetterEnd + .makeID("patterns/block/chandelier_wall.json"); + public final static ResourceLocation BLOCK_CHANDELIER_CEIL = BetterEnd + .makeID("patterns/block/chandelier_ceil.json"); + public final static ResourceLocation BLOCK_FURNACE = BetterEnd.makeID("patterns/block/furnace.json"); + public final static ResourceLocation BLOCK_FURNACE_GLOW = BetterEnd.makeID("patterns/block/furnace_glow.json"); + public final static ResourceLocation BLOCK_TOP_SIDE_BOTTOM = BetterEnd + .makeID("patterns/block/top_side_bottom.json"); + public final static ResourceLocation BLOCK_PATH = BetterEnd.makeID("patterns/block/path.json"); + + // Models Item + public final static ResourceLocation ITEM_WALL = BetterEnd.makeID("patterns/item/pattern_wall.json"); + public final static ResourceLocation ITEM_FENCE = BetterEnd.makeID("patterns/item/pattern_fence.json"); + public final static ResourceLocation ITEM_BUTTON = BetterEnd.makeID("patterns/item/pattern_button.json"); + public final static ResourceLocation ITEM_CHEST = BetterEnd.makeID("patterns/item/pattern_chest.json"); + public final static ResourceLocation ITEM_BLOCK = BetterEnd.makeID("patterns/item/pattern_block_item.json"); + public final static ResourceLocation ITEM_GENERATED = BetterEnd.makeID("patterns/item/pattern_item_generated.json"); + public final static ResourceLocation ITEM_HANDHELD = BetterEnd.makeID("patterns/item/pattern_item_handheld.json"); + public final static ResourceLocation ITEM_SPAWN_EGG = BetterEnd.makeID("patterns/item/pattern_item_spawn_egg.json"); + public static String createJson(Reader data, String parent, String block) { try (BufferedReader buffer = new BufferedReader(data)) { - return buffer.lines().collect(Collectors.joining()) - .replace("%parent%", parent) - .replace("%block%", block); + return buffer.lines().collect(Collectors.joining()).replace("%parent%", parent).replace("%block%", block); } catch (Exception ex) { return null; } } - - public static String createJson(Identifier patternId, String parent, String block) { + + public static String createJson(ResourceLocation patternId, String parent, String block) { ResourceManager resourceManager = MinecraftClient.getInstance().getResourceManager(); try (InputStream input = resourceManager.getResource(patternId).getInputStream()) { return createJson(new InputStreamReader(input, StandardCharsets.UTF_8), parent, block); @@ -136,17 +153,17 @@ public class Patterns { } } - public static String createJson(Identifier patternId, String texture) { + public static String createJson(ResourceLocation patternId, String texture) { Map textures = Maps.newHashMap(); textures.put("%texture%", texture); return createJson(patternId, textures); } - public static String createJson(Identifier patternId, Map textures) { + public static String createJson(ResourceLocation patternId, Map textures) { ResourceManager resourceManager = MinecraftClient.getInstance().getResourceManager(); try (InputStream input = resourceManager.getResource(patternId).getInputStream()) { - String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)) - .lines().collect(Collectors.joining()); + String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines() + .collect(Collectors.joining()); for (Entry texture : textures.entrySet()) { json = json.replace(texture.getKey(), texture.getValue()); } diff --git a/src/main/java/ru/betterend/recipe/AlloyingRecipes.java b/src/main/java/ru/betterend/recipe/AlloyingRecipes.java index aade6259..0204b435 100644 --- a/src/main/java/ru/betterend/recipe/AlloyingRecipes.java +++ b/src/main/java/ru/betterend/recipe/AlloyingRecipes.java @@ -1,46 +1,25 @@ package ru.betterend.recipe; -import net.minecraft.block.Blocks; -import net.minecraft.item.Items; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.Items; import ru.betterend.recipe.builders.AlloyingRecipe; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndItems; public class AlloyingRecipes { public static void register() { - AlloyingRecipe.Builder.create("additional_iron") - .setInput(Blocks.IRON_ORE, Blocks.IRON_ORE) - .setOutput(Items.IRON_INGOT, 3) - .setExpiriense(2.1F) - .build(); - AlloyingRecipe.Builder.create("additional_gold") - .setInput(Blocks.GOLD_ORE, Blocks.GOLD_ORE) - .setOutput(Items.GOLD_INGOT, 3) - .setExpiriense(3F) - .build(); - AlloyingRecipe.Builder.create("additional_netherite") - .setInput(Blocks.ANCIENT_DEBRIS, Blocks.ANCIENT_DEBRIS) - .setOutput(Items.NETHERITE_SCRAP, 3) - .setExpiriense(6F) - .setSmeltTime(1000) - .build(); - AlloyingRecipe.Builder.create("terminite_ingot") - .setInput(Items.IRON_INGOT, EndItems.ENDER_DUST) - .setOutput(EndBlocks.TERMINITE.ingot, 1) - .setExpiriense(2.5F) - .setSmeltTime(450) - .build(); - AlloyingRecipe.Builder.create("aeternium_ingot") - .setInput(EndBlocks.TERMINITE.ingot, Items.NETHERITE_INGOT) - .setOutput(EndItems.AETERNIUM_INGOT, 1) - .setExpiriense(4.5F) - .setSmeltTime(850) - .build(); + AlloyingRecipe.Builder.create("additional_iron").setInput(Blocks.IRON_ORE, Blocks.IRON_ORE) + .setOutput(Items.IRON_INGOT, 3).setExpiriense(2.1F).build(); + AlloyingRecipe.Builder.create("additional_gold").setInput(Blocks.GOLD_ORE, Blocks.GOLD_ORE) + .setOutput(Items.GOLD_INGOT, 3).setExpiriense(3F).build(); + AlloyingRecipe.Builder.create("additional_netherite").setInput(Blocks.ANCIENT_DEBRIS, Blocks.ANCIENT_DEBRIS) + .setOutput(Items.NETHERITE_SCRAP, 3).setExpiriense(6F).setSmeltTime(1000).build(); + AlloyingRecipe.Builder.create("terminite_ingot").setInput(Items.IRON_INGOT, EndItems.ENDER_DUST) + .setOutput(EndBlocks.TERMINITE.ingot, 1).setExpiriense(2.5F).setSmeltTime(450).build(); + AlloyingRecipe.Builder.create("aeternium_ingot").setInput(EndBlocks.TERMINITE.ingot, Items.NETHERITE_INGOT) + .setOutput(EndItems.AETERNIUM_INGOT, 1).setExpiriense(4.5F).setSmeltTime(850).build(); AlloyingRecipe.Builder.create("terminite_ingot_thallasium") - .setInput(EndBlocks.THALLASIUM.ingot, EndItems.ENDER_DUST) - .setOutput(EndBlocks.TERMINITE.ingot, 1) - .setExpiriense(2.5F) - .setSmeltTime(450) - .build(); + .setInput(EndBlocks.THALLASIUM.ingot, EndItems.ENDER_DUST).setOutput(EndBlocks.TERMINITE.ingot, 1) + .setExpiriense(2.5F).setSmeltTime(450).build(); } } diff --git a/src/main/java/ru/betterend/recipe/AnvilRecipes.java b/src/main/java/ru/betterend/recipe/AnvilRecipes.java index 2a4db6a7..b72ce6d4 100644 --- a/src/main/java/ru/betterend/recipe/AnvilRecipes.java +++ b/src/main/java/ru/betterend/recipe/AnvilRecipes.java @@ -1,67 +1,33 @@ package ru.betterend.recipe; -import net.minecraft.item.Items; +import net.minecraft.world.item.Items; import ru.betterend.item.material.EndToolMaterial; import ru.betterend.recipe.builders.AnvilRecipe; import ru.betterend.registry.EndItems; public class AnvilRecipes { public static void register() { - AnvilRecipe.Builder.create("ender_pearl_to_dust") - .setInput(Items.ENDER_PEARL) - .setOutput(EndItems.ENDER_DUST) - .setToolLevel(4) - .setDamage(5) - .build(); - AnvilRecipe.Builder.create("ender_shard_to_dust") - .setInput(EndItems.ENDER_SHARD) - .setOutput(EndItems.ENDER_DUST) - .setToolLevel(0) - .setDamage(3) - .build(); - - int anvilLevel = EndToolMaterial.AETERNIUM.getMiningLevel(); - AnvilRecipe.Builder.create("aeternium_axe_head") - .setInput(EndItems.AETERNIUM_INGOT) - .setOutput(EndItems.AETERNIUM_AXE_HEAD) - .setAnvilLevel(anvilLevel) - .setToolLevel(4) - .setDamage(6) - .build(); - AnvilRecipe.Builder.create("aeternium_pickaxe_head") - .setInput(EndItems.AETERNIUM_INGOT) - .setOutput(EndItems.AETERNIUM_PICKAXE_HEAD) - .setAnvilLevel(anvilLevel) - .setToolLevel(4) - .setDamage(6) - .build(); - AnvilRecipe.Builder.create("aeternium_shovel_head") - .setInput(EndItems.AETERNIUM_INGOT) - .setOutput(EndItems.AETERNIUM_SHOVEL_HEAD) - .setAnvilLevel(anvilLevel) - .setToolLevel(4) - .setDamage(6) - .build(); - AnvilRecipe.Builder.create("aeternium_hoe_head") - .setInput(EndItems.AETERNIUM_INGOT) - .setOutput(EndItems.AETERNIUM_HOE_HEAD) - .setAnvilLevel(anvilLevel) - .setToolLevel(4) - .setDamage(6) - .build(); - AnvilRecipe.Builder.create("aeternium_hammer_head") - .setInput(EndItems.AETERNIUM_INGOT) - .setOutput(EndItems.AETERNIUM_HAMMER_HEAD) - .setAnvilLevel(anvilLevel) - .setToolLevel(4) - .setDamage(6) - .build(); - AnvilRecipe.Builder.create("aeternium_sword_blade") - .setInput(EndItems.AETERNIUM_INGOT) - .setOutput(EndItems.AETERNIUM_SWORD_BLADE) - .setAnvilLevel(anvilLevel) - .setToolLevel(4) - .setDamage(6) - .build(); + AnvilRecipe.Builder.create("ender_pearl_to_dust").setInput(Items.ENDER_PEARL).setOutput(EndItems.ENDER_DUST) + .setToolLevel(4).setDamage(5).build(); + AnvilRecipe.Builder.create("ender_shard_to_dust").setInput(EndItems.ENDER_SHARD).setOutput(EndItems.ENDER_DUST) + .setToolLevel(0).setDamage(3).build(); + + int anvilLevel = EndToolMaterial.AETERNIUM.getLevel(); + AnvilRecipe.Builder.create("aeternium_axe_head").setInput(EndItems.AETERNIUM_INGOT) + .setOutput(EndItems.AETERNIUM_AXE_HEAD).setAnvilLevel(anvilLevel).setToolLevel(4).setDamage(6).build(); + AnvilRecipe.Builder.create("aeternium_pickaxe_head").setInput(EndItems.AETERNIUM_INGOT) + .setOutput(EndItems.AETERNIUM_PICKAXE_HEAD).setAnvilLevel(anvilLevel).setToolLevel(4).setDamage(6) + .build(); + AnvilRecipe.Builder.create("aeternium_shovel_head").setInput(EndItems.AETERNIUM_INGOT) + .setOutput(EndItems.AETERNIUM_SHOVEL_HEAD).setAnvilLevel(anvilLevel).setToolLevel(4).setDamage(6) + .build(); + AnvilRecipe.Builder.create("aeternium_hoe_head").setInput(EndItems.AETERNIUM_INGOT) + .setOutput(EndItems.AETERNIUM_HOE_HEAD).setAnvilLevel(anvilLevel).setToolLevel(4).setDamage(6).build(); + AnvilRecipe.Builder.create("aeternium_hammer_head").setInput(EndItems.AETERNIUM_INGOT) + .setOutput(EndItems.AETERNIUM_HAMMER_HEAD).setAnvilLevel(anvilLevel).setToolLevel(4).setDamage(6) + .build(); + AnvilRecipe.Builder.create("aeternium_sword_blade").setInput(EndItems.AETERNIUM_INGOT) + .setOutput(EndItems.AETERNIUM_SWORD_BLADE).setAnvilLevel(anvilLevel).setToolLevel(4).setDamage(6) + .build(); } } diff --git a/src/main/java/ru/betterend/recipe/CraftingRecipes.java b/src/main/java/ru/betterend/recipe/CraftingRecipes.java index e510cdc5..bee10313 100644 --- a/src/main/java/ru/betterend/recipe/CraftingRecipes.java +++ b/src/main/java/ru/betterend/recipe/CraftingRecipes.java @@ -1,10 +1,10 @@ package ru.betterend.recipe; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraft.potion.PotionUtil; import net.minecraft.potion.Potions; import ru.betterend.BetterEnd; @@ -15,71 +15,66 @@ import ru.betterend.registry.EndItems; import ru.betterend.registry.EndTags; public class CraftingRecipes { - + public static void register() { if (BetterEnd.hasGuideBook()) { - GridRecipe.make("guide_book", GuideBookItem.GUIDE_BOOK) - .setShape("D", "B", "C") - .addMaterial('D', EndItems.ENDER_DUST) - .addMaterial('B', Items.BOOK) - .addMaterial('C', EndItems.CRYSTAL_SHARDS) - .build(); + GridRecipe.make("guide_book", GuideBookItem.GUIDE_BOOK).setShape("D", "B", "C") + .addMaterial('D', EndItems.ENDER_DUST).addMaterial('B', Items.BOOK) + .addMaterial('C', EndItems.CRYSTAL_SHARDS).build(); } - - GridRecipe.make("ender_perl_to_block", EndBlocks.ENDER_BLOCK) - .setShape("OO", "OO") - .addMaterial('O', Items.ENDER_PEARL) - .build(); - GridRecipe.make("ender_block_to_perl", Items.ENDER_PEARL) - .addMaterial('#', EndBlocks.ENDER_BLOCK) - .setOutputCount(4) - .setList("#") - .build(); - - GridRecipe.make("end_stone_smelter", EndBlocks.END_STONE_SMELTER) - .setShape("T#T", "V V", "T#T") - .addMaterial('#', Blocks.END_STONE_BRICKS) - .addMaterial('T', EndBlocks.THALLASIUM.ingot) - .addMaterial('V', EndTags.FURNACES) - .build(); - - registerPedestal("andesite_pedestal", EndBlocks.ANDESITE_PEDESTAL, Blocks.POLISHED_ANDESITE_SLAB, Blocks.POLISHED_ANDESITE); - registerPedestal("diorite_pedestal", EndBlocks.DIORITE_PEDESTAL, Blocks.POLISHED_DIORITE_SLAB, Blocks.POLISHED_DIORITE); - registerPedestal("granite_pedestal", EndBlocks.GRANITE_PEDESTAL, Blocks.POLISHED_GRANITE_SLAB, Blocks.POLISHED_GRANITE); + + GridRecipe.make("ender_perl_to_block", EndBlocks.ENDER_BLOCK).setShape("OO", "OO") + .addMaterial('O', Items.ENDER_PEARL).build(); + GridRecipe.make("ender_block_to_perl", Items.ENDER_PEARL).addMaterial('#', EndBlocks.ENDER_BLOCK) + .setOutputCount(4).setList("#").build(); + + GridRecipe.make("end_stone_smelter", EndBlocks.END_STONE_SMELTER).setShape("T#T", "V V", "T#T") + .addMaterial('#', Blocks.END_STONE_BRICKS).addMaterial('T', EndBlocks.THALLASIUM.ingot) + .addMaterial('V', EndTags.FURNACES).build(); + + registerPedestal("andesite_pedestal", EndBlocks.ANDESITE_PEDESTAL, Blocks.POLISHED_ANDESITE_SLAB, + Blocks.POLISHED_ANDESITE); + registerPedestal("diorite_pedestal", EndBlocks.DIORITE_PEDESTAL, Blocks.POLISHED_DIORITE_SLAB, + Blocks.POLISHED_DIORITE); + registerPedestal("granite_pedestal", EndBlocks.GRANITE_PEDESTAL, Blocks.POLISHED_GRANITE_SLAB, + Blocks.POLISHED_GRANITE); registerPedestal("quartz_pedestal", EndBlocks.QUARTZ_PEDESTAL, Blocks.QUARTZ_SLAB, Blocks.QUARTZ_PILLAR); registerPedestal("purpur_pedestal", EndBlocks.PURPUR_PEDESTAL, Blocks.PURPUR_SLAB, Blocks.PURPUR_PILLAR); - - GridRecipe.make("infusion_pedestal", EndBlocks.INFUSION_PEDESTAL) - .setShape(" Y ", "O#O", " # ") - .addMaterial('O', Items.ENDER_PEARL) - .addMaterial('Y', Items.ENDER_EYE) - .addMaterial('#', Blocks.OBSIDIAN) - .build(); - + + GridRecipe.make("infusion_pedestal", EndBlocks.INFUSION_PEDESTAL).setShape(" Y ", "O#O", " # ") + .addMaterial('O', Items.ENDER_PEARL).addMaterial('Y', Items.ENDER_EYE).addMaterial('#', Blocks.OBSIDIAN) + .build(); + String material = "aeternium"; - GridRecipe.make(material + "_block", EndBlocks.AETERNIUM_BLOCK) - .setShape("III", "III", "III") - .addMaterial('I', EndItems.AETERNIUM_INGOT) - .build(); + GridRecipe.make(material + "_block", EndBlocks.AETERNIUM_BLOCK).setShape("III", "III", "III") + .addMaterial('I', EndItems.AETERNIUM_INGOT).build(); GridRecipe.make(material + "_block_to_ingot", EndItems.AETERNIUM_INGOT) - .addMaterial('#', EndBlocks.AETERNIUM_BLOCK) - .setOutputCount(9) - .setList("#") - .build(); - - GridRecipe.make("blue_vine_seed_dye", Items.BLUE_DYE).setList("#").addMaterial('#', EndBlocks.BLUE_VINE_SEED).build(); - GridRecipe.make("creeping_moss_dye", Items.CYAN_DYE).setList("#").addMaterial('#', EndBlocks.CREEPING_MOSS).build(); - GridRecipe.make("umbrella_moss_dye", Items.YELLOW_DYE).setList("#").addMaterial('#', EndBlocks.UMBRELLA_MOSS).build(); - GridRecipe.make("umbrella_moss_tall_dye", Items.YELLOW_DYE).setOutputCount(2).setList("#").addMaterial('#', EndBlocks.UMBRELLA_MOSS_TALL).build(); - GridRecipe.make("shadow_plant_dye", Items.BLACK_DYE).setList("#").addMaterial('#', EndBlocks.SHADOW_PLANT).build(); - - GridRecipe.make("paper", Items.PAPER).setShape("###").addMaterial('#', EndItems.END_LILY_LEAF_DRIED).setOutputCount(3).build(); - - GridRecipe.make("aurora_block", EndBlocks.AURORA_CRYSTAL).setShape("##", "##").addMaterial('#', EndItems.CRYSTAL_SHARDS).build(); - GridRecipe.make("lotus_block", EndBlocks.END_LOTUS.log).setShape("##", "##").addMaterial('#', EndBlocks.END_LOTUS_STEM).build(); - GridRecipe.make("needlegrass_stick", Items.STICK).setList("#").setOutputCount(2).addMaterial('#', EndBlocks.NEEDLEGRASS).build(); - GridRecipe.make("shadow_berry_seeds", EndBlocks.SHADOW_BERRY).setList("#").setOutputCount(4).addMaterial('#', EndItems.SHADOW_BERRY_RAW).build(); - GridRecipe.make("purple_polypore_dye", Items.PURPLE_DYE).setList("#").addMaterial('#', EndBlocks.PURPLE_POLYPORE).build(); + .addMaterial('#', EndBlocks.AETERNIUM_BLOCK).setOutputCount(9).setList("#").build(); + + GridRecipe.make("blue_vine_seed_dye", Items.BLUE_DYE).setList("#").addMaterial('#', EndBlocks.BLUE_VINE_SEED) + .build(); + GridRecipe.make("creeping_moss_dye", Items.CYAN_DYE).setList("#").addMaterial('#', EndBlocks.CREEPING_MOSS) + .build(); + GridRecipe.make("umbrella_moss_dye", Items.YELLOW_DYE).setList("#").addMaterial('#', EndBlocks.UMBRELLA_MOSS) + .build(); + GridRecipe.make("umbrella_moss_tall_dye", Items.YELLOW_DYE).setOutputCount(2).setList("#") + .addMaterial('#', EndBlocks.UMBRELLA_MOSS_TALL).build(); + GridRecipe.make("shadow_plant_dye", Items.BLACK_DYE).setList("#").addMaterial('#', EndBlocks.SHADOW_PLANT) + .build(); + + GridRecipe.make("paper", Items.PAPER).setShape("###").addMaterial('#', EndItems.END_LILY_LEAF_DRIED) + .setOutputCount(3).build(); + + GridRecipe.make("aurora_block", EndBlocks.AURORA_CRYSTAL).setShape("##", "##") + .addMaterial('#', EndItems.CRYSTAL_SHARDS).build(); + GridRecipe.make("lotus_block", EndBlocks.END_LOTUS.log).setShape("##", "##") + .addMaterial('#', EndBlocks.END_LOTUS_STEM).build(); + GridRecipe.make("needlegrass_stick", Items.STICK).setList("#").setOutputCount(2) + .addMaterial('#', EndBlocks.NEEDLEGRASS).build(); + GridRecipe.make("shadow_berry_seeds", EndBlocks.SHADOW_BERRY).setList("#").setOutputCount(4) + .addMaterial('#', EndItems.SHADOW_BERRY_RAW).build(); + GridRecipe.make("purple_polypore_dye", Items.PURPLE_DYE).setList("#") + .addMaterial('#', EndBlocks.PURPLE_POLYPORE).build(); registerLantern("end_stone_lantern", EndBlocks.END_STONE_LANTERN, Blocks.END_STONE_BRICK_SLAB); registerLantern("andesite_lantern", EndBlocks.ANDESITE_LANTERN, Blocks.ANDESITE_SLAB); @@ -88,136 +83,130 @@ public class CraftingRecipes { registerLantern("quartz_lantern", EndBlocks.QUARTZ_LANTERN, Blocks.QUARTZ_SLAB); registerLantern("purpur_lantern", EndBlocks.PURPUR_LANTERN, Blocks.PURPUR_SLAB); registerLantern("blackstone_lantern", EndBlocks.BLACKSTONE_LANTERN, Blocks.BLACKSTONE_SLAB); - - GridRecipe.make("amber_gem", EndItems.AMBER_GEM).setShape("##", "##").addMaterial('#', EndItems.RAW_AMBER).build(); - GridRecipe.make("amber_block", EndBlocks.AMBER_BLOCK).setShape("##", "##").addMaterial('#', EndItems.AMBER_GEM).build(); - GridRecipe.make("amber_gem_block", EndItems.AMBER_GEM).setOutputCount(4).setList("#").addMaterial('#', EndBlocks.AMBER_BLOCK).build(); - GridRecipe.make("iron_bulb_lantern", EndBlocks.IRON_BULB_LANTERN).setShape("C", "I", "#").addMaterial('C', Items.CHAIN).addMaterial('I', Items.IRON_INGOT).addMaterial('#', EndItems.GLOWING_BULB).build(); - GridRecipe.make("twisted_moss_dye", Items.PINK_DYE).setList("#").addMaterial('#', EndBlocks.TWISTED_MOSS).build(); - GridRecipe.make("byshy_grass_dye", Items.MAGENTA_DYE).setList("#").addMaterial('#', EndBlocks.BUSHY_GRASS).build(); + + GridRecipe.make("amber_gem", EndItems.AMBER_GEM).setShape("##", "##").addMaterial('#', EndItems.RAW_AMBER) + .build(); + GridRecipe.make("amber_block", EndBlocks.AMBER_BLOCK).setShape("##", "##").addMaterial('#', EndItems.AMBER_GEM) + .build(); + GridRecipe.make("amber_gem_block", EndItems.AMBER_GEM).setOutputCount(4).setList("#") + .addMaterial('#', EndBlocks.AMBER_BLOCK).build(); + GridRecipe.make("iron_bulb_lantern", EndBlocks.IRON_BULB_LANTERN).setShape("C", "I", "#") + .addMaterial('C', Items.CHAIN).addMaterial('I', Items.IRON_INGOT) + .addMaterial('#', EndItems.GLOWING_BULB).build(); + GridRecipe.make("twisted_moss_dye", Items.PINK_DYE).setList("#").addMaterial('#', EndBlocks.TWISTED_MOSS) + .build(); + GridRecipe.make("byshy_grass_dye", Items.MAGENTA_DYE).setList("#").addMaterial('#', EndBlocks.BUSHY_GRASS) + .build(); GridRecipe.make("tail_moss_dye", Items.GRAY_DYE).setList("#").addMaterial('#', EndBlocks.TAIL_MOSS).build(); - GridRecipe.make("petal_block", EndBlocks.HYDRALUX_PETAL_BLOCK).setShape("##", "##").addMaterial('#', EndItems.HYDRALUX_PETAL).build(); - GridRecipe.make("petal_white_dye", Items.WHITE_DYE).setList("#").addMaterial('#', EndItems.HYDRALUX_PETAL).build(); - - GridRecipe.make("sweet_berry_jelly", EndItems.SWEET_BERRY_JELLY) - .setList("JWSB") - .addMaterial('J', EndItems.GELATINE) - .addMaterial('W', PotionUtil.setPotion(new ItemStack(Items.POTION), Potions.WATER)) - .addMaterial('S', Items.SUGAR).addMaterial('B', Items.SWEET_BERRIES) - .build(); - - GridRecipe.make("shadow_berry_jelly", EndItems.SHADOW_BERRY_JELLY) - .setList("JWSB") - .addMaterial('J', EndItems.GELATINE) - .addMaterial('W', PotionUtil.setPotion(new ItemStack(Items.POTION), Potions.WATER)) - .addMaterial('S', Items.SUGAR) - .addMaterial('B', EndItems.SHADOW_BERRY_COOKED) - .build(); - - GridRecipe.make("sulphur_gunpowder", Items.GUNPOWDER).setList("SCB").addMaterial('S', EndItems.CRYSTALLINE_SULPHUR).addMaterial('C', Items.COAL, Items.CHARCOAL).addMaterial('B', Items.BONE_MEAL).build(); - - GridRecipe.make("dense_emerald_ice", EndBlocks.DENSE_EMERALD_ICE).setShape("##", "##").addMaterial('#', EndBlocks.EMERALD_ICE).build(); - GridRecipe.make("ancient_emerald_ice", EndBlocks.ANCIENT_EMERALD_ICE).setShape("###", "###", "###").addMaterial('#', EndBlocks.DENSE_EMERALD_ICE).build(); - - GridRecipe.make("charnia_cyan_dye", Items.CYAN_DYE).setList("#").addMaterial('#', EndBlocks.CHARNIA_CYAN).build(); - GridRecipe.make("charnia_green_dye", Items.GREEN_DYE).setList("#").addMaterial('#', EndBlocks.CHARNIA_GREEN).build(); - GridRecipe.make("charnia_light_blue_dye", Items.LIGHT_BLUE_DYE).setList("#").addMaterial('#', EndBlocks.CHARNIA_LIGHT_BLUE).build(); - GridRecipe.make("charnia_orange_dye", Items.ORANGE_DYE).setList("#").addMaterial('#', EndBlocks.CHARNIA_ORANGE).build(); - GridRecipe.make("charnia_purple_dye", Items.PURPLE_DYE).setList("#").addMaterial('#', EndBlocks.CHARNIA_PURPLE).build(); + GridRecipe.make("petal_block", EndBlocks.HYDRALUX_PETAL_BLOCK).setShape("##", "##") + .addMaterial('#', EndItems.HYDRALUX_PETAL).build(); + GridRecipe.make("petal_white_dye", Items.WHITE_DYE).setList("#").addMaterial('#', EndItems.HYDRALUX_PETAL) + .build(); + + GridRecipe.make("sweet_berry_jelly", EndItems.SWEET_BERRY_JELLY).setList("JWSB") + .addMaterial('J', EndItems.GELATINE) + .addMaterial('W', PotionUtil.setPotion(new ItemStack(Items.POTION), Potions.WATER)) + .addMaterial('S', Items.SUGAR).addMaterial('B', Items.SWEET_BERRIES).build(); + + GridRecipe.make("shadow_berry_jelly", EndItems.SHADOW_BERRY_JELLY).setList("JWSB") + .addMaterial('J', EndItems.GELATINE) + .addMaterial('W', PotionUtil.setPotion(new ItemStack(Items.POTION), Potions.WATER)) + .addMaterial('S', Items.SUGAR).addMaterial('B', EndItems.SHADOW_BERRY_COOKED).build(); + + GridRecipe.make("sulphur_gunpowder", Items.GUNPOWDER).setList("SCB") + .addMaterial('S', EndItems.CRYSTALLINE_SULPHUR).addMaterial('C', Items.COAL, Items.CHARCOAL) + .addMaterial('B', Items.BONE_MEAL).build(); + + GridRecipe.make("dense_emerald_ice", EndBlocks.DENSE_EMERALD_ICE).setShape("##", "##") + .addMaterial('#', EndBlocks.EMERALD_ICE).build(); + GridRecipe.make("ancient_emerald_ice", EndBlocks.ANCIENT_EMERALD_ICE).setShape("###", "###", "###") + .addMaterial('#', EndBlocks.DENSE_EMERALD_ICE).build(); + + GridRecipe.make("charnia_cyan_dye", Items.CYAN_DYE).setList("#").addMaterial('#', EndBlocks.CHARNIA_CYAN) + .build(); + GridRecipe.make("charnia_green_dye", Items.GREEN_DYE).setList("#").addMaterial('#', EndBlocks.CHARNIA_GREEN) + .build(); + GridRecipe.make("charnia_light_blue_dye", Items.LIGHT_BLUE_DYE).setList("#") + .addMaterial('#', EndBlocks.CHARNIA_LIGHT_BLUE).build(); + GridRecipe.make("charnia_orange_dye", Items.ORANGE_DYE).setList("#").addMaterial('#', EndBlocks.CHARNIA_ORANGE) + .build(); + GridRecipe.make("charnia_purple_dye", Items.PURPLE_DYE).setList("#").addMaterial('#', EndBlocks.CHARNIA_PURPLE) + .build(); GridRecipe.make("charnia_red_dye", Items.RED_DYE).setList("#").addMaterial('#', EndBlocks.CHARNIA_RED).build(); - - GridRecipe.make("respawn_obelisk", EndBlocks.RESPAWN_OBELISK) - .setShape("CSC", "CSC", "AAA") - .addMaterial('C', EndBlocks.AURORA_CRYSTAL) - .addMaterial('S', EndItems.ETERNAL_CRYSTAL) - .addMaterial('A', EndBlocks.AMBER_BLOCK) - .build(); - - GridRecipe.make("hopper", Blocks.HOPPER) - .setShape("I I", "ICI", " I ") - .addMaterial('I', Items.IRON_INGOT) - .addMaterial('C', EndTags.ITEM_CHEST) - .build(); - - GridRecipe.make("shulker_box", Blocks.SHULKER_BOX) - .setShape("S", "C", "S") - .addMaterial('S', Items.SHULKER_SHELL) - .addMaterial('C', EndTags.ITEM_CHEST) - .build(); - - GridRecipe.make("twisted_umbrella_moss_dye", Items.PURPLE_DYE).setList("#").addMaterial('#', EndBlocks.TWISTED_UMBRELLA_MOSS).build(); - GridRecipe.make("twisted_umbrella_moss_dye_tall", Items.PURPLE_DYE).setOutputCount(2).setList("#").addMaterial('#', EndBlocks.TWISTED_UMBRELLA_MOSS_TALL).build(); - - GridRecipe.make("leather_to_stripes", EndItems.LEATHER_STRIPE) - .setList("L") - .addMaterial('L', Items.LEATHER) - .setOutputCount(3) - .build(); - GridRecipe.make("stripes_to_leather", Items.LEATHER) - .setList("SSS") - .addMaterial('S', EndItems.LEATHER_STRIPE) - .build(); - GridRecipe.make("leather_wrapped_stick", EndItems.LEATHER_WRAPPED_STICK) - .setList("SL") - .addMaterial('S', Items.STICK) - .addMaterial('L', EndItems.LEATHER_STRIPE) - .build(); - - GridRecipe.make("fiber_string", Items.STRING).setOutputCount(6).setShape("#", "#", "#").addMaterial('#', EndItems.SILK_FIBER).build(); - - GridRecipe.make("ender_eye_amber", Items.ENDER_EYE) - .setShape("SAS", "APA", "SAS") - .addMaterial('S', EndItems.CRYSTAL_SHARDS) - .addMaterial('A', EndItems.AMBER_GEM) - .addMaterial('P', Items.ENDER_PEARL) - .build(); - - GridRecipe.make("iron_chandelier", EndBlocks.IRON_CHANDELIER).setShape("I#I", " # ").addMaterial('#', Items.IRON_INGOT).addMaterial('I', EndItems.LUMECORN_ROD).setGroup("end_metal_chandelier").build(); - GridRecipe.make("gold_chandelier", EndBlocks.GOLD_CHANDELIER).setShape("I#I", " # ").addMaterial('#', Items.GOLD_INGOT).addMaterial('I', EndItems.LUMECORN_ROD).setGroup("end_metal_chandelier").build(); - - GridRecipe.make("missing_tile", EndBlocks.MISSING_TILE) - .setOutputCount(4) - .setShape("#P", "P#") - .addMaterial('#', EndBlocks.VIOLECITE.stone, EndBlocks.VIOLECITE.bricks, EndBlocks.VIOLECITE.tiles) - .addMaterial('P', Blocks.PURPUR_BLOCK) - .build(); + + GridRecipe.make("respawn_obelisk", EndBlocks.RESPAWN_OBELISK).setShape("CSC", "CSC", "AAA") + .addMaterial('C', EndBlocks.AURORA_CRYSTAL).addMaterial('S', EndItems.ETERNAL_CRYSTAL) + .addMaterial('A', EndBlocks.AMBER_BLOCK).build(); + + GridRecipe.make("hopper", Blocks.HOPPER).setShape("I I", "ICI", " I ").addMaterial('I', Items.IRON_INGOT) + .addMaterial('C', EndTags.ITEM_CHEST).build(); + + GridRecipe.make("shulker_box", Blocks.SHULKER_BOX).setShape("S", "C", "S").addMaterial('S', Items.SHULKER_SHELL) + .addMaterial('C', EndTags.ITEM_CHEST).build(); + + GridRecipe.make("twisted_umbrella_moss_dye", Items.PURPLE_DYE).setList("#") + .addMaterial('#', EndBlocks.TWISTED_UMBRELLA_MOSS).build(); + GridRecipe.make("twisted_umbrella_moss_dye_tall", Items.PURPLE_DYE).setOutputCount(2).setList("#") + .addMaterial('#', EndBlocks.TWISTED_UMBRELLA_MOSS_TALL).build(); + + GridRecipe.make("leather_to_stripes", EndItems.LEATHER_STRIPE).setList("L").addMaterial('L', Items.LEATHER) + .setOutputCount(3).build(); + GridRecipe.make("stripes_to_leather", Items.LEATHER).setList("SSS").addMaterial('S', EndItems.LEATHER_STRIPE) + .build(); + GridRecipe.make("leather_wrapped_stick", EndItems.LEATHER_WRAPPED_STICK).setList("SL") + .addMaterial('S', Items.STICK).addMaterial('L', EndItems.LEATHER_STRIPE).build(); + + GridRecipe.make("fiber_string", Items.STRING).setOutputCount(6).setShape("#", "#", "#") + .addMaterial('#', EndItems.SILK_FIBER).build(); + + GridRecipe.make("ender_eye_amber", Items.ENDER_EYE).setShape("SAS", "APA", "SAS") + .addMaterial('S', EndItems.CRYSTAL_SHARDS).addMaterial('A', EndItems.AMBER_GEM) + .addMaterial('P', Items.ENDER_PEARL).build(); + + GridRecipe.make("iron_chandelier", EndBlocks.IRON_CHANDELIER).setShape("I#I", " # ") + .addMaterial('#', Items.IRON_INGOT).addMaterial('I', EndItems.LUMECORN_ROD) + .setGroup("end_metal_chandelier").build(); + GridRecipe.make("gold_chandelier", EndBlocks.GOLD_CHANDELIER).setShape("I#I", " # ") + .addMaterial('#', Items.GOLD_INGOT).addMaterial('I', EndItems.LUMECORN_ROD) + .setGroup("end_metal_chandelier").build(); + + GridRecipe.make("missing_tile", EndBlocks.MISSING_TILE).setOutputCount(4).setShape("#P", "P#") + .addMaterial('#', EndBlocks.VIOLECITE.stone, EndBlocks.VIOLECITE.bricks, EndBlocks.VIOLECITE.tiles) + .addMaterial('P', Blocks.PURPUR_BLOCK).build(); registerHammer("iron", Items.IRON_INGOT, EndItems.IRON_HAMMER); registerHammer("golden", Items.GOLD_INGOT, EndItems.GOLDEN_HAMMER); registerHammer("diamond", Items.DIAMOND, EndItems.DIAMOND_HAMMER); - GridRecipe.make("charcoal_block", EndBlocks.CHARCOAL_BLOCK).setShape("###", "###", "###").addMaterial('#', Items.CHARCOAL).build(); - GridRecipe.make("end_stone_furnace", EndBlocks.END_STONE_FURNACE).setShape("###", "# #", "###").addMaterial('#', Blocks.END_STONE).build(); - GridRecipe.make("filalux_lantern", EndBlocks.FILALUX_LANTERN).setShape("###", "###", "###").addMaterial('#', EndBlocks.FILALUX).build(); - - GridRecipe.make("silk_moth_hive", EndBlocks.SILK_MOTH_HIVE).setShape("#L#", "LML", "#L#").addMaterial('#', EndBlocks.TENANEA.planks).addMaterial('L', EndBlocks.TENANEA_LEAVES).addMaterial('M', EndItems.SILK_MOTH_MATRIX).build(); - GridRecipe.make("cave_pumpkin_pie", EndItems.CAVE_PUMPKIN_PIE).setShape(" B ", "BPB", " B ").addMaterial('P', EndBlocks.CAVE_PUMPKIN).addMaterial('B', EndItems.BLOSSOM_BERRY, EndItems.SHADOW_BERRY_RAW).build(); - GridRecipe.make("cave_pumpkin_seeds", EndBlocks.CAVE_PUMPKIN_SEED).setOutputCount(4).setList("#").addMaterial('#', EndBlocks.CAVE_PUMPKIN).build(); + GridRecipe.make("charcoal_block", EndBlocks.CHARCOAL_BLOCK).setShape("###", "###", "###") + .addMaterial('#', Items.CHARCOAL).build(); + GridRecipe.make("end_stone_furnace", EndBlocks.END_STONE_FURNACE).setShape("###", "# #", "###") + .addMaterial('#', Blocks.END_STONE).build(); + GridRecipe.make("filalux_lantern", EndBlocks.FILALUX_LANTERN).setShape("###", "###", "###") + .addMaterial('#', EndBlocks.FILALUX).build(); + + GridRecipe.make("silk_moth_hive", EndBlocks.SILK_MOTH_HIVE).setShape("#L#", "LML", "#L#") + .addMaterial('#', EndBlocks.TENANEA.planks).addMaterial('L', EndBlocks.TENANEA_LEAVES) + .addMaterial('M', EndItems.SILK_MOTH_MATRIX).build(); + GridRecipe.make("cave_pumpkin_pie", EndItems.CAVE_PUMPKIN_PIE).setShape(" B ", "BPB", " B ") + .addMaterial('P', EndBlocks.CAVE_PUMPKIN) + .addMaterial('B', EndItems.BLOSSOM_BERRY, EndItems.SHADOW_BERRY_RAW).build(); + GridRecipe.make("cave_pumpkin_seeds", EndBlocks.CAVE_PUMPKIN_SEED).setOutputCount(4).setList("#") + .addMaterial('#', EndBlocks.CAVE_PUMPKIN).build(); } - + private static void registerLantern(String name, Block lantern, Block slab) { - GridRecipe.make(name, lantern) - .setShape("S", "#", "S") - .addMaterial('#', EndItems.CRYSTAL_SHARDS) - .addMaterial('S', slab) - .setGroup("end_stone_lanterns") - .build(); + GridRecipe.make(name, lantern).setShape("S", "#", "S").addMaterial('#', EndItems.CRYSTAL_SHARDS) + .addMaterial('S', slab).setGroup("end_stone_lanterns").build(); } - + public static void registerPedestal(String name, Block pedestal, Block slab, Block pillar) { - GridRecipe.make(name, pedestal) - .setShape("S", "#", "S") - .addMaterial('S', slab) - .addMaterial('#', pillar) - .setOutputCount(2) - .build(); + GridRecipe.make(name, pedestal).setShape("S", "#", "S").addMaterial('S', slab).addMaterial('#', pillar) + .setOutputCount(2).build(); } private static void registerHammer(String name, Item material, Item result) { - GridRecipe.make(name + "_hammer", result) - .setShape("I I", "I#I", " # ") - .addMaterial('I', material) - .addMaterial('#', Items.STICK) - .build(); + GridRecipe.make(name + "_hammer", result).setShape("I I", "I#I", " # ").addMaterial('I', material) + .addMaterial('#', Items.STICK).build(); } } diff --git a/src/main/java/ru/betterend/recipe/EndRecipeManager.java b/src/main/java/ru/betterend/recipe/EndRecipeManager.java index 8a91076c..4a3eb2ca 100644 --- a/src/main/java/ru/betterend/recipe/EndRecipeManager.java +++ b/src/main/java/ru/betterend/recipe/EndRecipeManager.java @@ -5,52 +5,53 @@ import java.util.Map.Entry; import com.google.common.collect.Maps; -import net.minecraft.recipe.Recipe; -import net.minecraft.recipe.RecipeSerializer; -import net.minecraft.recipe.RecipeType; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; public class EndRecipeManager { - private static final Map, Map>> RECIPES = Maps.newHashMap(); + private static final Map, Map>> RECIPES = Maps.newHashMap(); public static void addRecipe(RecipeType type, Recipe recipe) { - Map> list = RECIPES.get(type); + Map> list = RECIPES.get(type); if (list == null) { list = Maps.newHashMap(); RECIPES.put(type, list); } list.put(recipe.getId(), recipe); } - + @SuppressWarnings("unchecked") - public static > T getRecipe(RecipeType type, Identifier id) { + public static > T getRecipe(RecipeType type, ResourceLocation id) { if (RECIPES.containsKey(type)) { return (T) RECIPES.get(type).get(id); } return null; } - public static Map, Map>> getMap(Map, Map>> recipes) { - Map, Map>> result = Maps.newHashMap(); + public static Map, Map>> getMap( + Map, Map>> recipes) { + Map, Map>> result = Maps.newHashMap(); for (RecipeType type : recipes.keySet()) { - Map> typeList = Maps.newHashMap(); + Map> typeList = Maps.newHashMap(); typeList.putAll(recipes.get(type)); result.put(type, typeList); } for (RecipeType type : RECIPES.keySet()) { - Map> list = RECIPES.get(type); + Map> list = RECIPES.get(type); if (list != null) { - Map> typeList = result.get(type); + Map> typeList = result.get(type); if (typeList == null) { typeList = Maps.newHashMap(); result.put(type, typeList); } - for (Entry> entry : list.entrySet()) { - Identifier id = entry.getKey(); + for (Entry> entry : list.entrySet()) { + ResourceLocation id = entry.getKey(); if (!typeList.containsKey(id)) typeList.put(id, entry.getValue()); } @@ -65,11 +66,11 @@ public class EndRecipeManager { } public static > RecipeType registerType(String type) { - Identifier recipeTypeId = BetterEnd.makeID(type); + ResourceLocation recipeTypeId = BetterEnd.makeID(type); return Registry.register(Registry.RECIPE_TYPE, recipeTypeId, new RecipeType() { public String toString() { return type; } - }); + }); } } \ No newline at end of file diff --git a/src/main/java/ru/betterend/recipe/FurnaceRecipes.java b/src/main/java/ru/betterend/recipe/FurnaceRecipes.java index da4f8a7e..de83076f 100644 --- a/src/main/java/ru/betterend/recipe/FurnaceRecipes.java +++ b/src/main/java/ru/betterend/recipe/FurnaceRecipes.java @@ -1,7 +1,7 @@ package ru.betterend.recipe; -import net.minecraft.block.Blocks; -import net.minecraft.item.Items; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.Items; import ru.betterend.recipe.builders.FurnaceRecipe; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndItems; @@ -14,7 +14,8 @@ public class FurnaceRecipes { FurnaceRecipe.make("end_fish", EndItems.END_FISH_RAW, EndItems.END_FISH_COOKED).buildFoodlike(); FurnaceRecipe.make("slime_ball", EndBlocks.JELLYSHROOM_CAP_PURPLE, Items.SLIME_BALL).build(); FurnaceRecipe.make("menger_sponge", EndBlocks.MENGER_SPONGE_WET, EndBlocks.MENGER_SPONGE).build(); - FurnaceRecipe.make("chorus_mushroom", EndItems.CHORUS_MUSHROOM_RAW, EndItems.CHORUS_MUSHROOM_COOKED).buildFoodlike(); + FurnaceRecipe.make("chorus_mushroom", EndItems.CHORUS_MUSHROOM_RAW, EndItems.CHORUS_MUSHROOM_COOKED) + .buildFoodlike(); FurnaceRecipe.make("bolux_mushroom", EndBlocks.BOLUX_MUSHROOM, EndItems.BOLUX_MUSHROOM_COOKED).buildFoodlike(); } } diff --git a/src/main/java/ru/betterend/recipe/InfusionRecipes.java b/src/main/java/ru/betterend/recipe/InfusionRecipes.java index 0be70464..6aba6304 100644 --- a/src/main/java/ru/betterend/recipe/InfusionRecipes.java +++ b/src/main/java/ru/betterend/recipe/InfusionRecipes.java @@ -1,588 +1,265 @@ package ru.betterend.recipe; -import net.minecraft.block.Blocks; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentLevelEntry; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.EnchantedBookItem; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentLevelEntry; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.EnchantedBookItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import ru.betterend.recipe.builders.InfusionRecipe; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndItems; public class InfusionRecipes { public static void register() { - InfusionRecipe.Builder.create("runed_flavolite") - .setInput(EndBlocks.FLAVOLITE.polished) - .setOutput(EndBlocks.FLAVOLITE_RUNED) - .addCatalyst(0, EndItems.CRYSTAL_SHARDS) - .addCatalyst(2, EndItems.CRYSTAL_SHARDS) - .addCatalyst(4, EndItems.CRYSTAL_SHARDS) - .addCatalyst(6, EndItems.CRYSTAL_SHARDS) - .setTime(100) - .build(); - - InfusionRecipe.Builder.create("eternal_crystal") - .setInput(Items.END_CRYSTAL) - .setOutput(EndItems.ETERNAL_CRYSTAL) - .addCatalyst(0, EndItems.CRYSTAL_SHARDS) - .addCatalyst(2, EndItems.CRYSTAL_SHARDS) - .addCatalyst(4, EndItems.CRYSTAL_SHARDS) - .addCatalyst(6, EndItems.CRYSTAL_SHARDS) - .addCatalyst(1, EndItems.ENDER_SHARD) - .addCatalyst(3, EndItems.ENDER_SHARD) - .addCatalyst(5, EndItems.ENDER_SHARD) - .addCatalyst(7, EndItems.ENDER_SHARD) - .setTime(250) - .build(); - - InfusionRecipe.Builder.create("crystalite_helmet") - .setInput(EndBlocks.TERMINITE.helmet) - .setOutput(EndItems.CRYSTALITE_HELMET) - .addCatalyst(0, EndItems.AMBER_GEM) - .addCatalyst(2, EndItems.CRYSTAL_SHARDS) - .addCatalyst(6, EndItems.CRYSTAL_SHARDS) - .setTime(150) - .build(); - InfusionRecipe.Builder.create("crystalite_chestplate") - .setInput(EndBlocks.TERMINITE.chestplate) - .setOutput(EndItems.CRYSTALITE_CHESTPLATE) - .addCatalyst(0, EndItems.AMBER_GEM) - .addCatalyst(1, EndItems.CRYSTAL_SHARDS) - .addCatalyst(3, EndItems.CRYSTAL_SHARDS) - .addCatalyst(5, EndItems.CRYSTAL_SHARDS) - .addCatalyst(7, EndItems.CRYSTAL_SHARDS) - .setTime(300) - .build(); - InfusionRecipe.Builder.create("crystalite_leggings") - .setInput(EndBlocks.TERMINITE.leggings) - .setOutput(EndItems.CRYSTALITE_LEGGINGS) - .addCatalyst(0, EndItems.AMBER_GEM) - .addCatalyst(2, EndItems.CRYSTAL_SHARDS) - .addCatalyst(4, EndItems.CRYSTAL_SHARDS) - .addCatalyst(6, EndItems.CRYSTAL_SHARDS) - .setTime(225) - .build(); - InfusionRecipe.Builder.create("crystalite_boots") - .setInput(EndBlocks.TERMINITE.boots) - .setOutput(EndItems.CRYSTALITE_BOOTS) - .addCatalyst(0, EndItems.AMBER_GEM) - .addCatalyst(2, EndItems.CRYSTAL_SHARDS) - .addCatalyst(6, EndItems.CRYSTAL_SHARDS) - .setTime(150) - .build(); - - InfusionRecipe.Builder.create("enchanted_petal") - .setInput(EndItems.HYDRALUX_PETAL) - .setOutput(EndItems.ENCHANTED_PETAL) - .addCatalyst(0, EndItems.CRYSTAL_SHARDS) - .addCatalyst(2, EndItems.CRYSTAL_SHARDS) - .addCatalyst(4, EndItems.CRYSTAL_SHARDS) - .addCatalyst(6, EndItems.CRYSTAL_SHARDS) - .setTime(75) - .build(); + InfusionRecipe.Builder.create("runed_flavolite").setInput(EndBlocks.FLAVOLITE.polished) + .setOutput(EndBlocks.FLAVOLITE_RUNED).addCatalyst(0, EndItems.CRYSTAL_SHARDS) + .addCatalyst(2, EndItems.CRYSTAL_SHARDS).addCatalyst(4, EndItems.CRYSTAL_SHARDS) + .addCatalyst(6, EndItems.CRYSTAL_SHARDS).setTime(100).build(); - InfusionRecipe.Builder.create("protection_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.PROTECTION, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(4, Items.TURTLE_HELMET) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("fire_protection_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.FIRE_PROTECTION, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.BLAZE_ROD) - .addCatalyst(4, Items.BLAZE_ROD) - .addCatalyst(6, Items.BLAZE_ROD) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("feather_falling_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.FEATHER_FALLING, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.FEATHER) - .addCatalyst(4, Items.FEATHER) - .addCatalyst(6, Items.FEATHER) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("blast_protection_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.BLAST_PROTECTION, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Blocks.OBSIDIAN) - .addCatalyst(4, Blocks.OBSIDIAN) - .addCatalyst(6, Blocks.OBSIDIAN) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("projectile_protection_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.PROJECTILE_PROTECTION, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.SCUTE) - .addCatalyst(4, Items.SHIELD) - .addCatalyst(6, Items.SCUTE) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("respiration_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.RESPIRATION, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.NAUTILUS_SHELL) - .addCatalyst(4, Items.NAUTILUS_SHELL) - .addCatalyst(6, Items.NAUTILUS_SHELL) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("aqua_affinity_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.AQUA_AFFINITY, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.PRISMARINE_CRYSTALS) - .addCatalyst(4, Items.PRISMARINE_CRYSTALS) - .addCatalyst(6, Items.PRISMARINE_CRYSTALS) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("thorns_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.THORNS, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Blocks.CACTUS) - .addCatalyst(4, Blocks.CACTUS) - .addCatalyst(6, Blocks.CACTUS) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("depth_strider_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.DEPTH_STRIDER, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Blocks.LILY_PAD) - .addCatalyst(4, EndBlocks.END_LILY_SEED) - .addCatalyst(6, Blocks.LILY_PAD) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("frost_walker_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.FROST_WALKER, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(4, EndBlocks.ANCIENT_EMERALD_ICE) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("soul_speed_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.SOUL_SPEED, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Blocks.SOUL_SAND, Blocks.SOUL_SOIL) - .addCatalyst(4, Blocks.SOUL_SAND, Blocks.SOUL_SOIL) - .addCatalyst(6, Blocks.SOUL_SAND, Blocks.SOUL_SOIL) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("sharpness_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.SHARPNESS, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(4, Items.NETHERITE_SCRAP) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("smite_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.SMITE, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Blocks.SUNFLOWER) - .addCatalyst(4, Items.GOLD_INGOT) - .addCatalyst(6, Blocks.SUNFLOWER) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("bane_of_arthropods_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.BANE_OF_ARTHROPODS, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.FERMENTED_SPIDER_EYE) - .addCatalyst(4, Items.IRON_INGOT) - .addCatalyst(6, Items.FERMENTED_SPIDER_EYE) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("knockback_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.KNOCKBACK, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.REDSTONE) - .addCatalyst(4, Blocks.PISTON) - .addCatalyst(6, Items.REDSTONE) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("fire_aspect_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.FIRE_ASPECT, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.BLAZE_POWDER) - .addCatalyst(4, Items.MAGMA_CREAM) - .addCatalyst(6, Items.BLAZE_POWDER) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("looting_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.LOOTING, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.EMERALD) - .addCatalyst(4, Items.GOLD_INGOT) - .addCatalyst(6, Items.EMERALD) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("sweeping_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.SWEEPING, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.GOLDEN_SWORD) - .addCatalyst(4, Items.IRON_SWORD) - .addCatalyst(6, Items.GOLDEN_SWORD) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("efficiency_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.EFFICIENCY, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, EndItems.AMBER_GEM) - .addCatalyst(4, EndItems.AMBER_GEM) - .addCatalyst(6, EndItems.AMBER_GEM) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("silk_touch_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.SILK_TOUCH, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Blocks.COBWEB) - .addCatalyst(4, EndItems.ETERNAL_CRYSTAL) - .addCatalyst(6, Blocks.COBWEB) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(375) - .build(); - InfusionRecipe.Builder.create("unbreaking_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.UNBREAKING, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.DIAMOND) - .addCatalyst(4, Items.DIAMOND) - .addCatalyst(6, Items.DIAMOND) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("fortune_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.FORTUNE, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.EMERALD) - .addCatalyst(4, Items.RABBIT_FOOT) - .addCatalyst(6, Items.EMERALD) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("power_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.POWER, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, EndItems.AMBER_GEM) - .addCatalyst(4, Items.DIAMOND_SWORD) - .addCatalyst(6, EndItems.AMBER_GEM) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("punch_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.PUNCH, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.POPPED_CHORUS_FRUIT) - .addCatalyst(4, Items.SPECTRAL_ARROW) - .addCatalyst(6, Items.POPPED_CHORUS_FRUIT) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("flame_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.FLAME, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.BLAZE_POWDER) - .addCatalyst(4, Items.SPECTRAL_ARROW) - .addCatalyst(6, Items.BLAZE_POWDER) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("infinity_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.INFINITY, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.SPECTRAL_ARROW) - .addCatalyst(4, EndItems.ETERNAL_CRYSTAL) - .addCatalyst(6, Items.SPECTRAL_ARROW) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(375) - .build(); - InfusionRecipe.Builder.create("luck_of_sea_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.LUCK_OF_THE_SEA, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.EMERALD) - .addCatalyst(4, Items.FISHING_ROD) - .addCatalyst(6, Items.EMERALD) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("lure_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.LURE, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.GOLD_NUGGET) - .addCatalyst(4, Items.FISHING_ROD) - .addCatalyst(6, Items.GOLD_NUGGET) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("loyalty_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.LOYALTY, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.ENDER_EYE) - .addCatalyst(4, Items.HEART_OF_THE_SEA) - .addCatalyst(6, Items.ENDER_EYE) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(375) - .build(); - InfusionRecipe.Builder.create("impaling_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.IMPALING, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.PRISMARINE_SHARD) - .addCatalyst(4, Items.IRON_SWORD) - .addCatalyst(6, Items.PRISMARINE_SHARD) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("riptide_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.RIPTIDE, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.LEAD) - .addCatalyst(4, Items.HEART_OF_THE_SEA) - .addCatalyst(6, Items.LEAD) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(375) - .build(); - InfusionRecipe.Builder.create("channeling_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.CHANNELING, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.CHAIN) - .addCatalyst(4, Items.HEART_OF_THE_SEA) - .addCatalyst(6, Items.CHAIN) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(375) - .build(); - InfusionRecipe.Builder.create("multishot_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.MULTISHOT, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.ARROW) - .addCatalyst(4, Items.SPECTRAL_ARROW) - .addCatalyst(6, Items.ARROW) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("quick_charge_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.QUICK_CHARGE, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.QUARTZ) - .addCatalyst(4, Items.GLOWSTONE_DUST) - .addCatalyst(6, Items.QUARTZ) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("piercing_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.PIERCING, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.GLOWSTONE_DUST) - .addCatalyst(4, Items.SPECTRAL_ARROW) - .addCatalyst(6, Items.GLOWSTONE_DUST) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(300) - .build(); - InfusionRecipe.Builder.create("mending_book") - .setInput(Items.BOOK) - .setOutput(createEnchantedBook(Enchantments.MENDING, 1)) - .addCatalyst(0, EndItems.ENCHANTED_PETAL) - .addCatalyst(2, Items.EXPERIENCE_BOTTLE) - .addCatalyst(4, Blocks.ANVIL) - .addCatalyst(6, Items.EXPERIENCE_BOTTLE) - .addCatalyst(1, Items.LAPIS_LAZULI) - .addCatalyst(3, Items.LAPIS_LAZULI) - .addCatalyst(5, Items.LAPIS_LAZULI) - .addCatalyst(7, Items.LAPIS_LAZULI) - .setGroup("enchantment") - .setTime(375) - .build(); + InfusionRecipe.Builder.create("eternal_crystal").setInput(Items.END_CRYSTAL).setOutput(EndItems.ETERNAL_CRYSTAL) + .addCatalyst(0, EndItems.CRYSTAL_SHARDS).addCatalyst(2, EndItems.CRYSTAL_SHARDS) + .addCatalyst(4, EndItems.CRYSTAL_SHARDS).addCatalyst(6, EndItems.CRYSTAL_SHARDS) + .addCatalyst(1, EndItems.ENDER_SHARD).addCatalyst(3, EndItems.ENDER_SHARD) + .addCatalyst(5, EndItems.ENDER_SHARD).addCatalyst(7, EndItems.ENDER_SHARD).setTime(250).build(); + + InfusionRecipe.Builder.create("crystalite_helmet").setInput(EndBlocks.TERMINITE.helmet) + .setOutput(EndItems.CRYSTALITE_HELMET).addCatalyst(0, EndItems.AMBER_GEM) + .addCatalyst(2, EndItems.CRYSTAL_SHARDS).addCatalyst(6, EndItems.CRYSTAL_SHARDS).setTime(150).build(); + InfusionRecipe.Builder.create("crystalite_chestplate").setInput(EndBlocks.TERMINITE.chestplate) + .setOutput(EndItems.CRYSTALITE_CHESTPLATE).addCatalyst(0, EndItems.AMBER_GEM) + .addCatalyst(1, EndItems.CRYSTAL_SHARDS).addCatalyst(3, EndItems.CRYSTAL_SHARDS) + .addCatalyst(5, EndItems.CRYSTAL_SHARDS).addCatalyst(7, EndItems.CRYSTAL_SHARDS).setTime(300).build(); + InfusionRecipe.Builder.create("crystalite_leggings").setInput(EndBlocks.TERMINITE.leggings) + .setOutput(EndItems.CRYSTALITE_LEGGINGS).addCatalyst(0, EndItems.AMBER_GEM) + .addCatalyst(2, EndItems.CRYSTAL_SHARDS).addCatalyst(4, EndItems.CRYSTAL_SHARDS) + .addCatalyst(6, EndItems.CRYSTAL_SHARDS).setTime(225).build(); + InfusionRecipe.Builder.create("crystalite_boots").setInput(EndBlocks.TERMINITE.boots) + .setOutput(EndItems.CRYSTALITE_BOOTS).addCatalyst(0, EndItems.AMBER_GEM) + .addCatalyst(2, EndItems.CRYSTAL_SHARDS).addCatalyst(6, EndItems.CRYSTAL_SHARDS).setTime(150).build(); + + InfusionRecipe.Builder.create("enchanted_petal").setInput(EndItems.HYDRALUX_PETAL) + .setOutput(EndItems.ENCHANTED_PETAL).addCatalyst(0, EndItems.CRYSTAL_SHARDS) + .addCatalyst(2, EndItems.CRYSTAL_SHARDS).addCatalyst(4, EndItems.CRYSTAL_SHARDS) + .addCatalyst(6, EndItems.CRYSTAL_SHARDS).setTime(75).build(); + + InfusionRecipe.Builder.create("protection_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.PROTECTION, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(4, Items.TURTLE_HELMET).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(300).build(); + InfusionRecipe.Builder.create("fire_protection_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.FIRE_PROTECTION, 1)) + .addCatalyst(0, EndItems.ENCHANTED_PETAL).addCatalyst(2, Items.BLAZE_ROD) + .addCatalyst(4, Items.BLAZE_ROD).addCatalyst(6, Items.BLAZE_ROD).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(300).build(); + InfusionRecipe.Builder.create("feather_falling_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.FEATHER_FALLING, 1)) + .addCatalyst(0, EndItems.ENCHANTED_PETAL).addCatalyst(2, Items.FEATHER).addCatalyst(4, Items.FEATHER) + .addCatalyst(6, Items.FEATHER).addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(300).build(); + InfusionRecipe.Builder.create("blast_protection_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.BLAST_PROTECTION, 1)) + .addCatalyst(0, EndItems.ENCHANTED_PETAL).addCatalyst(2, Blocks.OBSIDIAN) + .addCatalyst(4, Blocks.OBSIDIAN).addCatalyst(6, Blocks.OBSIDIAN).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(300).build(); + InfusionRecipe.Builder.create("projectile_protection_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.PROJECTILE_PROTECTION, 1)) + .addCatalyst(0, EndItems.ENCHANTED_PETAL).addCatalyst(2, Items.SCUTE).addCatalyst(4, Items.SHIELD) + .addCatalyst(6, Items.SCUTE).addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(300).build(); + InfusionRecipe.Builder.create("respiration_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.RESPIRATION, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.NAUTILUS_SHELL).addCatalyst(4, Items.NAUTILUS_SHELL) + .addCatalyst(6, Items.NAUTILUS_SHELL).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(300).build(); + InfusionRecipe.Builder.create("aqua_affinity_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.AQUA_AFFINITY, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.PRISMARINE_CRYSTALS).addCatalyst(4, Items.PRISMARINE_CRYSTALS) + .addCatalyst(6, Items.PRISMARINE_CRYSTALS).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(300).build(); + InfusionRecipe.Builder.create("thorns_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.THORNS, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Blocks.CACTUS).addCatalyst(4, Blocks.CACTUS).addCatalyst(6, Blocks.CACTUS) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(300).build(); + InfusionRecipe.Builder.create("depth_strider_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.DEPTH_STRIDER, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Blocks.LILY_PAD).addCatalyst(4, EndBlocks.END_LILY_SEED).addCatalyst(6, Blocks.LILY_PAD) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(300).build(); + InfusionRecipe.Builder.create("frost_walker_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.FROST_WALKER, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(4, EndBlocks.ANCIENT_EMERALD_ICE).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(300).build(); + InfusionRecipe.Builder.create("soul_speed_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.SOUL_SPEED, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Blocks.SOUL_SAND, Blocks.SOUL_SOIL).addCatalyst(4, Blocks.SOUL_SAND, Blocks.SOUL_SOIL) + .addCatalyst(6, Blocks.SOUL_SAND, Blocks.SOUL_SOIL).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(300).build(); + InfusionRecipe.Builder.create("sharpness_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.SHARPNESS, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(4, Items.NETHERITE_SCRAP).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(300).build(); + InfusionRecipe.Builder.create("smite_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.SMITE, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Blocks.SUNFLOWER).addCatalyst(4, Items.GOLD_INGOT).addCatalyst(6, Blocks.SUNFLOWER) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(300).build(); + InfusionRecipe.Builder.create("bane_of_arthropods_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.BANE_OF_ARTHROPODS, 1)) + .addCatalyst(0, EndItems.ENCHANTED_PETAL).addCatalyst(2, Items.FERMENTED_SPIDER_EYE) + .addCatalyst(4, Items.IRON_INGOT).addCatalyst(6, Items.FERMENTED_SPIDER_EYE) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(300).build(); + InfusionRecipe.Builder.create("knockback_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.KNOCKBACK, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.REDSTONE).addCatalyst(4, Blocks.PISTON).addCatalyst(6, Items.REDSTONE) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(300).build(); + InfusionRecipe.Builder.create("fire_aspect_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.FIRE_ASPECT, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.BLAZE_POWDER).addCatalyst(4, Items.MAGMA_CREAM).addCatalyst(6, Items.BLAZE_POWDER) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(300).build(); + InfusionRecipe.Builder.create("looting_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.LOOTING, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.EMERALD).addCatalyst(4, Items.GOLD_INGOT).addCatalyst(6, Items.EMERALD) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(300).build(); + InfusionRecipe.Builder.create("sweeping_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.SWEEPING, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.GOLDEN_SWORD).addCatalyst(4, Items.IRON_SWORD).addCatalyst(6, Items.GOLDEN_SWORD) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(300).build(); + InfusionRecipe.Builder.create("efficiency_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.EFFICIENCY, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, EndItems.AMBER_GEM).addCatalyst(4, EndItems.AMBER_GEM) + .addCatalyst(6, EndItems.AMBER_GEM).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(300).build(); + InfusionRecipe.Builder.create("silk_touch_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.SILK_TOUCH, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Blocks.COBWEB).addCatalyst(4, EndItems.ETERNAL_CRYSTAL).addCatalyst(6, Blocks.COBWEB) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(375).build(); + InfusionRecipe.Builder.create("unbreaking_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.UNBREAKING, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.DIAMOND).addCatalyst(4, Items.DIAMOND).addCatalyst(6, Items.DIAMOND) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(300).build(); + InfusionRecipe.Builder.create("fortune_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.BLOCK_FORTUNE, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.EMERALD).addCatalyst(4, Items.RABBIT_FOOT).addCatalyst(6, Items.EMERALD) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(300).build(); + InfusionRecipe.Builder.create("power_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.POWER, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, EndItems.AMBER_GEM).addCatalyst(4, Items.DIAMOND_SWORD) + .addCatalyst(6, EndItems.AMBER_GEM).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(300).build(); + InfusionRecipe.Builder.create("punch_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.PUNCH, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.POPPED_CHORUS_FRUIT).addCatalyst(4, Items.SPECTRAL_ARROW) + .addCatalyst(6, Items.POPPED_CHORUS_FRUIT).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(300).build(); + InfusionRecipe.Builder.create("flame_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.FLAME, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.BLAZE_POWDER).addCatalyst(4, Items.SPECTRAL_ARROW) + .addCatalyst(6, Items.BLAZE_POWDER).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(300).build(); + InfusionRecipe.Builder.create("infinity_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.INFINITY, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.SPECTRAL_ARROW).addCatalyst(4, EndItems.ETERNAL_CRYSTAL) + .addCatalyst(6, Items.SPECTRAL_ARROW).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(375).build(); + InfusionRecipe.Builder.create("luck_of_sea_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.LUCK_OF_THE_SEA, 1)) + .addCatalyst(0, EndItems.ENCHANTED_PETAL).addCatalyst(2, Items.EMERALD) + .addCatalyst(4, Items.FISHING_ROD).addCatalyst(6, Items.EMERALD).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(300).build(); + InfusionRecipe.Builder.create("lure_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.LURE, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.GOLD_NUGGET).addCatalyst(4, Items.FISHING_ROD).addCatalyst(6, Items.GOLD_NUGGET) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(300).build(); + InfusionRecipe.Builder.create("loyalty_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.LOYALTY, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.ENDER_EYE).addCatalyst(4, Items.HEART_OF_THE_SEA).addCatalyst(6, Items.ENDER_EYE) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(375).build(); + InfusionRecipe.Builder.create("impaling_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.IMPALING, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.PRISMARINE_SHARD).addCatalyst(4, Items.IRON_SWORD) + .addCatalyst(6, Items.PRISMARINE_SHARD).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(300).build(); + InfusionRecipe.Builder.create("riptide_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.RIPTIDE, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.LEAD).addCatalyst(4, Items.HEART_OF_THE_SEA).addCatalyst(6, Items.LEAD) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(375).build(); + InfusionRecipe.Builder.create("channeling_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.CHANNELING, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.CHAIN).addCatalyst(4, Items.HEART_OF_THE_SEA).addCatalyst(6, Items.CHAIN) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(375).build(); + InfusionRecipe.Builder.create("multishot_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.MULTISHOT, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.ARROW).addCatalyst(4, Items.SPECTRAL_ARROW).addCatalyst(6, Items.ARROW) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(300).build(); + InfusionRecipe.Builder.create("quick_charge_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.QUICK_CHARGE, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.QUARTZ).addCatalyst(4, Items.GLOWSTONE_DUST).addCatalyst(6, Items.QUARTZ) + .addCatalyst(1, Items.LAPIS_LAZULI).addCatalyst(3, Items.LAPIS_LAZULI) + .addCatalyst(5, Items.LAPIS_LAZULI).addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment") + .setTime(300).build(); + InfusionRecipe.Builder.create("piercing_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.PIERCING, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.GLOWSTONE_DUST).addCatalyst(4, Items.SPECTRAL_ARROW) + .addCatalyst(6, Items.GLOWSTONE_DUST).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(300).build(); + InfusionRecipe.Builder.create("mending_book").setInput(Items.BOOK) + .setOutput(createEnchantedBook(Enchantments.MENDING, 1)).addCatalyst(0, EndItems.ENCHANTED_PETAL) + .addCatalyst(2, Items.EXPERIENCE_BOTTLE).addCatalyst(4, Blocks.ANVIL) + .addCatalyst(6, Items.EXPERIENCE_BOTTLE).addCatalyst(1, Items.LAPIS_LAZULI) + .addCatalyst(3, Items.LAPIS_LAZULI).addCatalyst(5, Items.LAPIS_LAZULI) + .addCatalyst(7, Items.LAPIS_LAZULI).setGroup("enchantment").setTime(375).build(); } - + private static ItemStack createEnchantedBook(Enchantment enchantment, int level) { ItemStack book = new ItemStack(Items.ENCHANTED_BOOK); EnchantedBookItem.addEnchantment(book, new EnchantmentLevelEntry(enchantment, level)); diff --git a/src/main/java/ru/betterend/recipe/SmithingRecipes.java b/src/main/java/ru/betterend/recipe/SmithingRecipes.java index eeac8bc4..a48ce9f0 100644 --- a/src/main/java/ru/betterend/recipe/SmithingRecipes.java +++ b/src/main/java/ru/betterend/recipe/SmithingRecipes.java @@ -1,87 +1,45 @@ package ru.betterend.recipe; -import net.minecraft.item.Items; +import net.minecraft.world.item.Items; import ru.betterend.recipe.builders.SmithingTableRecipe; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndItems; public class SmithingRecipes { - - public static void register() { - SmithingTableRecipe.create("aeternium_sword_handle") - .setResult(EndItems.AETERNIUM_SWORD_HANDLE) - .setBase(EndBlocks.TERMINITE.ingot) - .setAddition(EndItems.LEATHER_WRAPPED_STICK) - .build(); - - SmithingTableRecipe.create("aeternium_sword") - .setResult(EndItems.AETERNIUM_SWORD) - .setBase(EndItems.AETERNIUM_SWORD_BLADE) - .setAddition(EndItems.AETERNIUM_SWORD_HANDLE) - .build(); - SmithingTableRecipe.create("aeternium_pickaxe") - .setResult(EndItems.AETERNIUM_PICKAXE) - .setBase(EndItems.AETERNIUM_PICKAXE_HEAD) - .setAddition(EndItems.LEATHER_WRAPPED_STICK) - .build(); - SmithingTableRecipe.create("aeternium_axe") - .setResult(EndItems.AETERNIUM_AXE) - .setBase(EndItems.AETERNIUM_AXE_HEAD) - .setAddition(EndItems.LEATHER_WRAPPED_STICK) - .build(); - SmithingTableRecipe.create("aeternium_shovel") - .setResult(EndItems.AETERNIUM_SHOVEL) - .setBase(EndItems.AETERNIUM_SHOVEL_HEAD) - .setAddition(EndItems.LEATHER_WRAPPED_STICK) - .build(); - SmithingTableRecipe.create("aeternium_hoe") - .setResult(EndItems.AETERNIUM_HOE) - .setBase(EndItems.AETERNIUM_HOE_HEAD) - .setAddition(EndItems.LEATHER_WRAPPED_STICK) - .build(); - SmithingTableRecipe.create("aeternium_hammer") - .setResult(EndItems.AETERNIUM_HAMMER) - .setBase(EndItems.AETERNIUM_HAMMER_HEAD) - .setAddition(EndItems.LEATHER_WRAPPED_STICK) - .build(); - SmithingTableRecipe.create("netherite_hammer") - .setResult(EndItems.NETHERITE_HAMMER) - .setBase(EndItems.DIAMOND_HAMMER) - .setAddition(Items.NETHERITE_INGOT) - .build(); - - SmithingTableRecipe.create("aeternium_helmet") - .setResult(EndItems.AETERNIUM_HELMET) - .setBase(EndBlocks.TERMINITE.helmet) - .setAddition(EndItems.AETERNIUM_INGOT) - .build(); - SmithingTableRecipe.create("aeternium_chestplate") - .setResult(EndItems.AETERNIUM_CHESTPLATE) - .setBase(EndBlocks.TERMINITE.chestplate) - .setAddition(EndItems.AETERNIUM_INGOT) - .build(); - SmithingTableRecipe.create("aeternium_leggings") - .setResult(EndItems.AETERNIUM_LEGGINGS) - .setBase(EndBlocks.TERMINITE.leggings) - .setAddition(EndItems.AETERNIUM_INGOT) - .build(); - SmithingTableRecipe.create("aeternium_boots") - .setResult(EndItems.AETERNIUM_BOOTS) - .setBase(EndBlocks.TERMINITE.boots) - .setAddition(EndItems.AETERNIUM_INGOT) - .build(); - - SmithingTableRecipe.create("thallasium_anvil_updrade") - .setResult(EndBlocks.TERMINITE.anvil) - .setBase(EndBlocks.THALLASIUM.anvil) - .setAddition(EndBlocks.TERMINITE.block) - .build(); - - SmithingTableRecipe.create("terminite_anvil_updrade") - .setResult(EndBlocks.AETERNIUM_ANVIL) - .setBase(EndBlocks.TERMINITE.anvil) - .setAddition(EndBlocks.AETERNIUM_BLOCK) - .build(); + public static void register() { + SmithingTableRecipe.create("aeternium_sword_handle").setResult(EndItems.AETERNIUM_SWORD_HANDLE) + .setBase(EndBlocks.TERMINITE.ingot).setAddition(EndItems.LEATHER_WRAPPED_STICK).build(); + + SmithingTableRecipe.create("aeternium_sword").setResult(EndItems.AETERNIUM_SWORD) + .setBase(EndItems.AETERNIUM_SWORD_BLADE).setAddition(EndItems.AETERNIUM_SWORD_HANDLE).build(); + SmithingTableRecipe.create("aeternium_pickaxe").setResult(EndItems.AETERNIUM_PICKAXE) + .setBase(EndItems.AETERNIUM_PICKAXE_HEAD).setAddition(EndItems.LEATHER_WRAPPED_STICK).build(); + SmithingTableRecipe.create("aeternium_axe").setResult(EndItems.AETERNIUM_AXE) + .setBase(EndItems.AETERNIUM_AXE_HEAD).setAddition(EndItems.LEATHER_WRAPPED_STICK).build(); + SmithingTableRecipe.create("aeternium_shovel").setResult(EndItems.AETERNIUM_SHOVEL) + .setBase(EndItems.AETERNIUM_SHOVEL_HEAD).setAddition(EndItems.LEATHER_WRAPPED_STICK).build(); + SmithingTableRecipe.create("aeternium_hoe").setResult(EndItems.AETERNIUM_HOE) + .setBase(EndItems.AETERNIUM_HOE_HEAD).setAddition(EndItems.LEATHER_WRAPPED_STICK).build(); + SmithingTableRecipe.create("aeternium_hammer").setResult(EndItems.AETERNIUM_HAMMER) + .setBase(EndItems.AETERNIUM_HAMMER_HEAD).setAddition(EndItems.LEATHER_WRAPPED_STICK).build(); + + SmithingTableRecipe.create("netherite_hammer").setResult(EndItems.NETHERITE_HAMMER) + .setBase(EndItems.DIAMOND_HAMMER).setAddition(Items.NETHERITE_INGOT).build(); + + SmithingTableRecipe.create("aeternium_helmet").setResult(EndItems.AETERNIUM_HELMET) + .setBase(EndBlocks.TERMINITE.helmet).setAddition(EndItems.AETERNIUM_INGOT).build(); + SmithingTableRecipe.create("aeternium_chestplate").setResult(EndItems.AETERNIUM_CHESTPLATE) + .setBase(EndBlocks.TERMINITE.chestplate).setAddition(EndItems.AETERNIUM_INGOT).build(); + SmithingTableRecipe.create("aeternium_leggings").setResult(EndItems.AETERNIUM_LEGGINGS) + .setBase(EndBlocks.TERMINITE.leggings).setAddition(EndItems.AETERNIUM_INGOT).build(); + SmithingTableRecipe.create("aeternium_boots").setResult(EndItems.AETERNIUM_BOOTS) + .setBase(EndBlocks.TERMINITE.boots).setAddition(EndItems.AETERNIUM_INGOT).build(); + + SmithingTableRecipe.create("thallasium_anvil_updrade").setResult(EndBlocks.TERMINITE.anvil) + .setBase(EndBlocks.THALLASIUM.anvil).setAddition(EndBlocks.TERMINITE.block).build(); + + SmithingTableRecipe.create("terminite_anvil_updrade").setResult(EndBlocks.AETERNIUM_ANVIL) + .setBase(EndBlocks.TERMINITE.anvil).setAddition(EndBlocks.AETERNIUM_BLOCK).build(); } } diff --git a/src/main/java/ru/betterend/recipe/builders/AlloyingRecipe.java b/src/main/java/ru/betterend/recipe/builders/AlloyingRecipe.java index 1467b497..69874cb2 100644 --- a/src/main/java/ru/betterend/recipe/builders/AlloyingRecipe.java +++ b/src/main/java/ru/betterend/recipe/builders/AlloyingRecipe.java @@ -6,19 +6,19 @@ import com.google.gson.JsonObject; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.inventory.Inventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemConvertible; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemConvertible; +import net.minecraft.world.item.ItemStack; import net.minecraft.network.PacketByteBuf; -import net.minecraft.recipe.Ingredient; -import net.minecraft.recipe.Recipe; -import net.minecraft.recipe.RecipeSerializer; -import net.minecraft.recipe.RecipeType; -import net.minecraft.tag.Tag; -import net.minecraft.util.Identifier; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.tags.Tag; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.JsonHelper; import net.minecraft.util.collection.DefaultedList; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.BetterEnd; import ru.betterend.config.Configs; import ru.betterend.interfaces.BetterEndRecipe; @@ -28,22 +28,23 @@ import ru.betterend.util.ItemUtil; import ru.betterend.util.RecipeHelper; public class AlloyingRecipe implements Recipe, BetterEndRecipe { - + public final static String GROUP = "alloying"; public final static RecipeType TYPE = EndRecipeManager.registerType(GROUP); public final static Serializer SERIALIZER = EndRecipeManager.registerSerializer(GROUP, new Serializer()); - public final static Identifier ID = BetterEnd.makeID(GROUP); - + public final static ResourceLocation ID = BetterEnd.makeID(GROUP); + protected final RecipeType type; - protected final Identifier id; + protected final ResourceLocation id; protected final Ingredient primaryInput; protected final Ingredient secondaryInput; protected final ItemStack output; protected final String group; protected final float experience; protected final int smeltTime; - - public AlloyingRecipe(Identifier id, String group, Ingredient primaryInput, Ingredient secondaryInput, ItemStack output, float experience, int smeltTime) { + + public AlloyingRecipe(ResourceLocation id, String group, Ingredient primaryInput, Ingredient secondaryInput, + ItemStack output, float experience, int smeltTime) { this.group = group; this.id = id; this.primaryInput = primaryInput; @@ -53,11 +54,11 @@ public class AlloyingRecipe implements Recipe, BetterEndRecipe { this.smeltTime = smeltTime; this.type = TYPE; } - + public float getExperience() { return this.experience; } - + public int getSmeltTime() { return this.smeltTime; } @@ -67,14 +68,14 @@ public class AlloyingRecipe implements Recipe, BetterEndRecipe { DefaultedList defaultedList = DefaultedList.of(); defaultedList.add(primaryInput); defaultedList.add(secondaryInput); - + return defaultedList; } @Override - public boolean matches(Inventory inv, World world) { - return this.primaryInput.test(inv.getStack(0)) && this.secondaryInput.test(inv.getStack(1)) || - this.primaryInput.test(inv.getStack(1)) && this.secondaryInput.test(inv.getStack(0)); + public boolean matches(Inventory inv, Level world) { + return this.primaryInput.test(inv.getStack(0)) && this.secondaryInput.test(inv.getStack(1)) + || this.primaryInput.test(inv.getStack(1)) && this.secondaryInput.test(inv.getStack(0)); } @Override @@ -93,7 +94,7 @@ public class AlloyingRecipe implements Recipe, BetterEndRecipe { } @Override - public Identifier getId() { + public ResourceLocation getId() { return this.id; } @@ -106,23 +107,23 @@ public class AlloyingRecipe implements Recipe, BetterEndRecipe { public RecipeType getType() { return this.type; } - + @Override @Environment(EnvType.CLIENT) public String getGroup() { return this.group; } - + @Environment(EnvType.CLIENT) public ItemStack getRecipeKindIcon() { return new ItemStack(EndBlocks.END_STONE_SMELTER); } - + public static class Builder { private final static Builder INSTANCE = new Builder(); private static boolean exist; - - public static Builder create(Identifier id) { + + public static Builder create(ResourceLocation id) { INSTANCE.id = id; INSTANCE.group = String.format("%s_%s", GROUP, id); INSTANCE.primaryInput = null; @@ -131,15 +132,15 @@ public class AlloyingRecipe implements Recipe, BetterEndRecipe { INSTANCE.experience = 0.0F; INSTANCE.smeltTime = 350; exist = Configs.RECIPE_CONFIG.getBoolean("alloying", id.getPath(), true); - + return INSTANCE; } - + public static Builder create(String id) { return create(BetterEnd.makeID(id)); } - - private Identifier id; + + private ResourceLocation id; private Ingredient primaryInput; private Ingredient secondaryInput; private ItemStack output; @@ -147,79 +148,82 @@ public class AlloyingRecipe implements Recipe, BetterEndRecipe { private float experience; private int smeltTime; private boolean alright = true; - - private Builder() {} - + + private Builder() { + } + public Builder setGroup(String group) { this.group = group; return this; } - + public Builder setPrimaryInput(ItemConvertible... inputs) { for (ItemConvertible item : inputs) { this.alright &= RecipeHelper.exists(item); } - this.primaryInput = Ingredient.ofItems(inputs); + this.primaryInput = Ingredient.of(inputs); return this; } - + public Builder setSecondaryInput(ItemConvertible... inputs) { for (ItemConvertible item : inputs) { this.alright &= RecipeHelper.exists(item); } - this.secondaryInput = Ingredient.ofItems(inputs); + this.secondaryInput = Ingredient.of(inputs); return this; } - + public Builder setPrimaryInput(Tag input) { this.primaryInput = Ingredient.fromTag(input); return this; } - + public Builder setSecondaryInput(Tag input) { this.secondaryInput = Ingredient.fromTag(input); return this; } - + public Builder setInput(ItemConvertible primaryInput, ItemConvertible secondaryInput) { this.setPrimaryInput(primaryInput); this.setSecondaryInput(secondaryInput); return this; } - + public Builder setInput(Tag primaryInput, Tag secondaryInput) { this.setPrimaryInput(primaryInput); this.setSecondaryInput(secondaryInput); return this; } - + public Builder setOutput(ItemConvertible output, int amount) { this.alright &= RecipeHelper.exists(output); this.output = new ItemStack(output, amount); return this; } - + public Builder setExpiriense(float amount) { this.experience = amount; return this; } - + public Builder setSmeltTime(int time) { this.smeltTime = time; return this; } - + public void build() { if (exist) { if (primaryInput == null) { - BetterEnd.LOGGER.warning("Primary input for Alloying recipe can't be 'null', recipe {} will be ignored!", id); + BetterEnd.LOGGER.warning( + "Primary input for Alloying recipe can't be 'null', recipe {} will be ignored!", id); return; } - if(secondaryInput == null) { - BetterEnd.LOGGER.warning("Secondary input for Alloying can't be 'null', recipe {} will be ignored!", id); + if (secondaryInput == null) { + BetterEnd.LOGGER.warning("Secondary input for Alloying can't be 'null', recipe {} will be ignored!", + id); return; } - if(output == null) { + if (output == null) { BetterEnd.LOGGER.warning("Output for Alloying can't be 'null', recipe {} will be ignored!", id); return; } @@ -231,14 +235,15 @@ public class AlloyingRecipe implements Recipe, BetterEndRecipe { BetterEnd.LOGGER.debug("Can't add Alloying recipe {}! Ingeredient or output not exists.", id); return; } - EndRecipeManager.addRecipe(TYPE, new AlloyingRecipe(id, group, primaryInput, secondaryInput, output, experience, smeltTime)); + EndRecipeManager.addRecipe(TYPE, + new AlloyingRecipe(id, group, primaryInput, secondaryInput, output, experience, smeltTime)); } } } - + public static class Serializer implements RecipeSerializer { @Override - public AlloyingRecipe read(Identifier id, JsonObject json) { + public AlloyingRecipe read(ResourceLocation id, JsonObject json) { JsonArray ingredients = JsonHelper.getArray(json, "ingredients"); Ingredient primaryInput = Ingredient.fromJson(ingredients.get(0)); Ingredient secondaryInput = Ingredient.fromJson(ingredients.get(1)); @@ -250,19 +255,19 @@ public class AlloyingRecipe implements Recipe, BetterEndRecipe { } float experience = JsonHelper.getFloat(json, "experience", 0.0F); int smeltTime = JsonHelper.getInt(json, "smelttime", 350); - + return new AlloyingRecipe(id, group, primaryInput, secondaryInput, output, experience, smeltTime); } @Override - public AlloyingRecipe read(Identifier id, PacketByteBuf packetBuffer) { + public AlloyingRecipe read(ResourceLocation id, PacketByteBuf packetBuffer) { String group = packetBuffer.readString(32767); Ingredient primary = Ingredient.fromPacket(packetBuffer); Ingredient secondary = Ingredient.fromPacket(packetBuffer); ItemStack output = packetBuffer.readItemStack(); float experience = packetBuffer.readFloat(); int smeltTime = packetBuffer.readVarInt(); - + return new AlloyingRecipe(id, group, primary, secondary, output, experience, smeltTime); } diff --git a/src/main/java/ru/betterend/recipe/builders/AnvilRecipe.java b/src/main/java/ru/betterend/recipe/builders/AnvilRecipe.java index 13cc06d4..f46d27fe 100644 --- a/src/main/java/ru/betterend/recipe/builders/AnvilRecipe.java +++ b/src/main/java/ru/betterend/recipe/builders/AnvilRecipe.java @@ -6,22 +6,22 @@ import com.google.gson.JsonObject; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.entity.player.PlayerEntity; import net.minecraft.inventory.Inventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemConvertible; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ToolItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemConvertible; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ToolItem; import net.minecraft.network.PacketByteBuf; -import net.minecraft.recipe.Ingredient; -import net.minecraft.recipe.Recipe; -import net.minecraft.recipe.RecipeSerializer; -import net.minecraft.recipe.RecipeType; -import net.minecraft.tag.Tag; -import net.minecraft.util.Identifier; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.tags.Tag; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.JsonHelper; import net.minecraft.util.collection.DefaultedList; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.BetterEnd; import ru.betterend.config.Configs; import ru.betterend.interfaces.BetterEndRecipe; @@ -31,21 +31,22 @@ import ru.betterend.util.ItemUtil; import ru.betterend.util.RecipeHelper; public class AnvilRecipe implements Recipe, BetterEndRecipe { - + public final static String GROUP = "smithing"; public final static RecipeType TYPE = EndRecipeManager.registerType(GROUP); public final static Serializer SERIALIZER = EndRecipeManager.registerSerializer(GROUP, new Serializer()); - public final static Identifier ID = BetterEnd.makeID(GROUP); - - private final Identifier id; + public final static ResourceLocation ID = BetterEnd.makeID(GROUP); + + private final ResourceLocation id; private final Ingredient input; private final ItemStack output; private final int damage; private final int toolLevel; private final int anvilLevel; private final int inputCount; - - public AnvilRecipe(Identifier identifier, Ingredient input, ItemStack output, int inputCount, int toolLevel, int anvilLevel, int damage) { + + public AnvilRecipe(ResourceLocation identifier, Ingredient input, ItemStack output, int inputCount, int toolLevel, + int anvilLevel, int damage) { this.id = identifier; this.input = input; this.output = output; @@ -64,34 +65,35 @@ public class AnvilRecipe implements Recipe, BetterEndRecipe { public ItemStack getOutput() { return this.output; } - + @Override - public boolean matches(Inventory craftingInventory, World world) { + public boolean matches(Inventory craftingInventory, Level world) { return this.matches(craftingInventory); } - + @Override public ItemStack craft(Inventory craftingInventory) { return this.output.copy(); } - + public ItemStack craft(Inventory craftingInventory, PlayerEntity player) { if (!player.isCreative()) { - if (!checkHammerDurability(craftingInventory, player)) return ItemStack.EMPTY; + if (!checkHammerDurability(craftingInventory, player)) + return ItemStack.EMPTY; ItemStack hammer = craftingInventory.getStack(1); - hammer.damage(this.damage, player, entity -> - entity.sendEquipmentBreakStatus(null)); + hammer.damage(this.damage, player, entity -> entity.sendEquipmentBreakStatus(null)); } return this.craft(craftingInventory); } public boolean checkHammerDurability(Inventory craftingInventory, PlayerEntity player) { - if (player.isCreative()) return true; + if (player.isCreative()) + return true; ItemStack hammer = craftingInventory.getStack(1); int damage = hammer.getDamage() + this.damage; return damage < hammer.getMaxDamage(); } - + public boolean matches(Inventory craftingInventory) { ItemStack hammer = craftingInventory.getStack(1); if (hammer.isEmpty() || !EndTags.HAMMERS.contains(hammer.getItem())) { @@ -99,12 +101,11 @@ public class AnvilRecipe implements Recipe, BetterEndRecipe { } ItemStack material = craftingInventory.getStack(0); int materialCount = material.getCount(); - int level = ((ToolItem) hammer.getItem()).getMaterial().getMiningLevel(); - return this.input.test(craftingInventory.getStack(0)) && - materialCount >= this.inputCount && - level >= this.toolLevel; + int level = ((ToolItem) hammer.getItem()).getTier().getLevel(); + return this.input.test(craftingInventory.getStack(0)) && materialCount >= this.inputCount + && level >= this.toolLevel; } - + public int getDamage() { return this.damage; } @@ -120,10 +121,10 @@ public class AnvilRecipe implements Recipe, BetterEndRecipe { @Override public DefaultedList getPreviewInputs() { DefaultedList defaultedList = DefaultedList.of(); - defaultedList.add(Ingredient.ofStacks(EndTags.HAMMERS.values().stream().filter(hammer -> - ((ToolItem) hammer).getMaterial().getMiningLevel() >= toolLevel).map(ItemStack::new))); + defaultedList.add(Ingredient.ofStacks(EndTags.HAMMERS.values().stream() + .filter(hammer -> ((ToolItem) hammer).getTier().getLevel() >= toolLevel).map(ItemStack::new))); defaultedList.add(input); - + return defaultedList; } @@ -134,7 +135,7 @@ public class AnvilRecipe implements Recipe, BetterEndRecipe { } @Override - public Identifier getId() { + public ResourceLocation getId() { return this.id; } @@ -142,7 +143,7 @@ public class AnvilRecipe implements Recipe, BetterEndRecipe { public RecipeType getType() { return TYPE; } - + @Override public boolean isIgnoredInRecipeBook() { return true; @@ -150,10 +151,13 @@ public class AnvilRecipe implements Recipe, BetterEndRecipe { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; AnvilRecipe that = (AnvilRecipe) o; - return damage == that.damage && toolLevel == that.toolLevel && id.equals(that.id) && input.equals(that.input) && output.equals(that.output); + return damage == that.damage && toolLevel == that.toolLevel && id.equals(that.id) && input.equals(that.input) + && output.equals(that.output); } @Override @@ -168,12 +172,12 @@ public class AnvilRecipe implements Recipe, BetterEndRecipe { public static class Builder { private final static Builder INSTANCE = new Builder(); - + public static Builder create(String id) { return create(BetterEnd.makeID(id)); } - - public static Builder create(Identifier id) { + + public static Builder create(ResourceLocation id) { INSTANCE.id = id; INSTANCE.input = null; INSTANCE.output = null; @@ -182,11 +186,11 @@ public class AnvilRecipe implements Recipe, BetterEndRecipe { INSTANCE.anvilLevel = 1; INSTANCE.damage = 1; INSTANCE.alright = true; - + return INSTANCE; } - - private Identifier id; + + private ResourceLocation id; private Ingredient input; private ItemStack output; private int inputCount = 1; @@ -194,20 +198,21 @@ public class AnvilRecipe implements Recipe, BetterEndRecipe { private int anvilLevel = 1; private int damage = 1; private boolean alright; - - private Builder() {} - + + private Builder() { + } + public Builder setInput(ItemConvertible... inputItems) { this.alright &= RecipeHelper.exists(inputItems); - this.setInput(Ingredient.ofItems(inputItems)); + this.setInput(Ingredient.of(inputItems)); return this; } - + public Builder setInput(Tag inputTag) { this.setInput(Ingredient.fromTag(inputTag)); return this; } - + public Builder setInput(Ingredient ingredient) { this.input = ingredient; return this; @@ -217,17 +222,17 @@ public class AnvilRecipe implements Recipe, BetterEndRecipe { this.inputCount = count; return this; } - + public Builder setOutput(ItemConvertible output) { return this.setOutput(output, 1); } - + public Builder setOutput(ItemConvertible output, int amount) { this.alright &= RecipeHelper.exists(output); this.output = new ItemStack(output, amount); return this; } - + public Builder setToolLevel(int level) { this.toolLevel = level; return this; @@ -237,19 +242,19 @@ public class AnvilRecipe implements Recipe, BetterEndRecipe { this.anvilLevel = level; return this; } - + public Builder setDamage(int damage) { this.damage = damage; return this; } - + public void build() { if (Configs.RECIPE_CONFIG.getBoolean("anvil", id.getPath(), true)) { if (input == null) { BetterEnd.LOGGER.warning("Input for Anvil recipe can't be 'null', recipe {} will be ignored!", id); return; } - if(output == null) { + if (output == null) { BetterEnd.LOGGER.warning("Output for Anvil recipe can't be 'null', recipe {} will be ignored!", id); return; } @@ -261,14 +266,15 @@ public class AnvilRecipe implements Recipe, BetterEndRecipe { BetterEnd.LOGGER.debug("Can't add Anvil recipe {}! Ingeredient or output not exists.", id); return; } - EndRecipeManager.addRecipe(TYPE, new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage)); + EndRecipeManager.addRecipe(TYPE, + new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage)); } } } public static class Serializer implements RecipeSerializer { @Override - public AnvilRecipe read(Identifier id, JsonObject json) { + public AnvilRecipe read(ResourceLocation id, JsonObject json) { Ingredient input = Ingredient.fromJson(json.get("input")); JsonObject result = JsonHelper.getObject(json, "result"); ItemStack output = ItemUtil.fromJsonRecipe(result); @@ -279,19 +285,19 @@ public class AnvilRecipe implements Recipe, BetterEndRecipe { int toolLevel = JsonHelper.getInt(json, "toolLevel", 1); int anvilLevel = JsonHelper.getInt(json, "anvilLevel", 1); int damage = JsonHelper.getInt(json, "damage", 1); - + return new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage); } @Override - public AnvilRecipe read(Identifier id, PacketByteBuf packetBuffer) { + public AnvilRecipe read(ResourceLocation id, PacketByteBuf packetBuffer) { Ingredient input = Ingredient.fromPacket(packetBuffer); ItemStack output = packetBuffer.readItemStack(); int inputCount = packetBuffer.readVarInt(); int toolLevel = packetBuffer.readVarInt(); int anvilLevel = packetBuffer.readVarInt(); int damage = packetBuffer.readVarInt(); - + return new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage); } diff --git a/src/main/java/ru/betterend/recipe/builders/FurnaceRecipe.java b/src/main/java/ru/betterend/recipe/builders/FurnaceRecipe.java index 6744a774..cdf09e24 100644 --- a/src/main/java/ru/betterend/recipe/builders/FurnaceRecipe.java +++ b/src/main/java/ru/betterend/recipe/builders/FurnaceRecipe.java @@ -1,14 +1,14 @@ package ru.betterend.recipe.builders; -import net.minecraft.item.ItemConvertible; -import net.minecraft.item.ItemStack; -import net.minecraft.recipe.BlastingRecipe; -import net.minecraft.recipe.CampfireCookingRecipe; -import net.minecraft.recipe.Ingredient; -import net.minecraft.recipe.RecipeType; -import net.minecraft.recipe.SmeltingRecipe; -import net.minecraft.recipe.SmokingRecipe; -import net.minecraft.util.Identifier; +import net.minecraft.world.item.ItemConvertible; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.BlastingRecipe; +import net.minecraft.world.item.crafting.CampfireCookingRecipe; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.SmeltingRecipe; +import net.minecraft.world.item.crafting.SmokingRecipe; +import net.minecraft.resources.ResourceLocation; import ru.betterend.BetterEnd; import ru.betterend.config.Configs; import ru.betterend.recipe.EndRecipeManager; @@ -16,7 +16,7 @@ import ru.betterend.util.RecipeHelper; public class FurnaceRecipe { private static final FurnaceRecipe INSTANCE = new FurnaceRecipe(); - + private ItemConvertible input; private ItemConvertible output; private boolean exist; @@ -25,9 +25,10 @@ public class FurnaceRecipe { private int count; private int time; private float xp; - - private FurnaceRecipe() {} - + + private FurnaceRecipe() { + } + public static FurnaceRecipe make(String name, ItemConvertible input, ItemConvertible output) { INSTANCE.name = name; INSTANCE.group = ""; @@ -36,64 +37,68 @@ public class FurnaceRecipe { INSTANCE.count = 1; INSTANCE.time = 200; INSTANCE.xp = 0; - INSTANCE.exist = Configs.RECIPE_CONFIG.getBoolean("furnace", name, true) && RecipeHelper.exists(output) && RecipeHelper.exists(input); + INSTANCE.exist = Configs.RECIPE_CONFIG.getBoolean("furnace", name, true) && RecipeHelper.exists(output) + && RecipeHelper.exists(input); return INSTANCE; } - + public FurnaceRecipe setGroup(String group) { this.group = group; return this; } - + public FurnaceRecipe setOutputCount(int count) { this.count = count; return this; } - + public FurnaceRecipe setXP(float xp) { this.xp = xp; return this; } - + public FurnaceRecipe setCookTime(int time) { this.time = time; return this; } - + public void build() { build(false, false, false); } - + public void buildWithBlasting() { build(true, false, false); } - + public void buildFoodlike() { build(false, true, true); } - + public void build(boolean blasting, boolean campfire, boolean smoker) { if (exist) { - Identifier id = BetterEnd.makeID(name); - SmeltingRecipe recipe = new SmeltingRecipe(id, group, Ingredient.ofItems(input), new ItemStack(output, count), xp, time); + ResourceLocation id = BetterEnd.makeID(name); + SmeltingRecipe recipe = new SmeltingRecipe(id, group, Ingredient.of(input), new ItemStack(output, count), + xp, time); EndRecipeManager.addRecipe(RecipeType.SMELTING, recipe); - + if (blasting) { - BlastingRecipe recipe2 = new BlastingRecipe(id, group, Ingredient.ofItems(input), new ItemStack(output, count), xp, time / 2); + BlastingRecipe recipe2 = new BlastingRecipe(id, group, Ingredient.of(input), + new ItemStack(output, count), xp, time / 2); EndRecipeManager.addRecipe(RecipeType.BLASTING, recipe2); } - + if (campfire) { - CampfireCookingRecipe recipe2 = new CampfireCookingRecipe(id, group, Ingredient.ofItems(input), new ItemStack(output, count), xp, time * 3); + CampfireCookingRecipe recipe2 = new CampfireCookingRecipe(id, group, Ingredient.of(input), + new ItemStack(output, count), xp, time * 3); EndRecipeManager.addRecipe(RecipeType.CAMPFIRE_COOKING, recipe2); } - + if (smoker) { - SmokingRecipe recipe2 = new SmokingRecipe(id, group, Ingredient.ofItems(input), new ItemStack(output, count), xp, time / 2); + SmokingRecipe recipe2 = new SmokingRecipe(id, group, Ingredient.of(input), new ItemStack(output, count), + xp, time / 2); EndRecipeManager.addRecipe(RecipeType.SMOKING, recipe2); } - } - else { + } else { BetterEnd.LOGGER.debug("Furnace recipe {} couldn't be added", name); } } diff --git a/src/main/java/ru/betterend/recipe/builders/GridRecipe.java b/src/main/java/ru/betterend/recipe/builders/GridRecipe.java index 3aa19988..c51f2090 100644 --- a/src/main/java/ru/betterend/recipe/builders/GridRecipe.java +++ b/src/main/java/ru/betterend/recipe/builders/GridRecipe.java @@ -5,16 +5,16 @@ import java.util.Map; import com.google.common.collect.Maps; -import net.minecraft.item.Item; -import net.minecraft.item.ItemConvertible; -import net.minecraft.item.ItemStack; -import net.minecraft.recipe.CraftingRecipe; -import net.minecraft.recipe.Ingredient; -import net.minecraft.recipe.RecipeType; -import net.minecraft.recipe.ShapedRecipe; -import net.minecraft.recipe.ShapelessRecipe; -import net.minecraft.tag.Tag; -import net.minecraft.util.Identifier; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemConvertible; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.ShapedRecipe; +import net.minecraft.world.item.crafting.ShapelessRecipe; +import net.minecraft.tags.Tag; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.collection.DefaultedList; import ru.betterend.BetterEnd; import ru.betterend.config.Configs; @@ -23,10 +23,10 @@ import ru.betterend.util.RecipeHelper; public class GridRecipe { private static final GridRecipe INSTANCE = new GridRecipe(); - + private String name; private ItemConvertible output; - + private String group; private RecipeType type; private boolean shaped; @@ -34,22 +34,23 @@ public class GridRecipe { private Map materialKeys = Maps.newHashMap(); private int count; private boolean exist = true; - - private GridRecipe() {} - + + private GridRecipe() { + } + public static GridRecipe make(String name, ItemConvertible output) { INSTANCE.name = name; INSTANCE.output = output; - + INSTANCE.group = ""; INSTANCE.type = RecipeType.CRAFTING; INSTANCE.shaped = true; - INSTANCE.shape = new String[] {"#"}; + INSTANCE.shape = new String[] { "#" }; INSTANCE.materialKeys.clear(); INSTANCE.count = 1; - + INSTANCE.exist = Configs.RECIPE_CONFIG.getBoolean("grid", name, true) && RecipeHelper.exists(output); - + return INSTANCE; } @@ -57,65 +58,66 @@ public class GridRecipe { this.group = group; return this; } - + public GridRecipe setShape(String... shape) { this.shape = shape; return this; } - + public GridRecipe setList(String shape) { this.shape = new String[] { shape }; this.shaped = false; return this; } - + public GridRecipe addMaterial(char key, Tag value) { return addMaterial(key, Ingredient.fromTag(value)); } - + public GridRecipe addMaterial(char key, ItemStack... value) { return addMaterial(key, Ingredient.ofStacks(Arrays.stream(value))); } - + public GridRecipe addMaterial(char key, ItemConvertible... values) { - for (ItemConvertible item: values) { + for (ItemConvertible item : values) { exist &= RecipeHelper.exists(item); } - return addMaterial(key, Ingredient.ofItems(values)); + return addMaterial(key, Ingredient.of(values)); } - + private GridRecipe addMaterial(char key, Ingredient value) { materialKeys.put(key, value); return this; } - + public GridRecipe setOutputCount(int count) { this.count = count; return this; } - + private DefaultedList getMaterials(int width, int height) { DefaultedList materials = DefaultedList.ofSize(width * height, Ingredient.EMPTY); int pos = 0; - for (String line: shape) { + for (String line : shape) { for (int i = 0; i < width; i++) { char c = line.charAt(i); Ingredient material = materialKeys.get(c); - materials.set(pos ++, material == null ? Ingredient.EMPTY : material); + materials.set(pos++, material == null ? Ingredient.EMPTY : material); } } return materials; } - + public void build() { if (exist) { int height = shape.length; int width = shape[0].length(); ItemStack result = new ItemStack(output, count); - Identifier id = BetterEnd.makeID(name); + ResourceLocation id = BetterEnd.makeID(name); DefaultedList materials = this.getMaterials(width, height); - - CraftingRecipe recipe = shaped ? new ShapedRecipe(id, group, width, height, materials, result) : new ShapelessRecipe(id, group, result, materials); + + CraftingRecipe recipe = shaped ? new ShapedRecipe(id, group, width, height, materials, result) + : new ShapelessRecipe(id, group, result, materials); EndRecipeManager.addRecipe(type, recipe); } else { BetterEnd.LOGGER.debug("Recipe {} couldn't be added", name); diff --git a/src/main/java/ru/betterend/recipe/builders/InfusionRecipe.java b/src/main/java/ru/betterend/recipe/builders/InfusionRecipe.java index 5a876161..079c0b07 100644 --- a/src/main/java/ru/betterend/recipe/builders/InfusionRecipe.java +++ b/src/main/java/ru/betterend/recipe/builders/InfusionRecipe.java @@ -6,17 +6,17 @@ import com.google.gson.JsonObject; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.item.ItemConvertible; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemConvertible; +import net.minecraft.world.item.ItemStack; import net.minecraft.network.PacketByteBuf; -import net.minecraft.recipe.Ingredient; -import net.minecraft.recipe.Recipe; -import net.minecraft.recipe.RecipeSerializer; -import net.minecraft.recipe.RecipeType; -import net.minecraft.util.Identifier; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.JsonHelper; import net.minecraft.util.collection.DefaultedList; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import ru.betterend.BetterEnd; import ru.betterend.config.Configs; import ru.betterend.interfaces.BetterEndRecipe; @@ -25,38 +25,39 @@ import ru.betterend.rituals.InfusionRitual; import ru.betterend.util.ItemUtil; public class InfusionRecipe implements Recipe, BetterEndRecipe { - + public final static String GROUP = "infusion"; public final static RecipeType TYPE = EndRecipeManager.registerType(GROUP); public final static Serializer SERIALIZER = EndRecipeManager.registerSerializer(GROUP, new Serializer()); - public final static Identifier ID = BetterEnd.makeID(GROUP); - - private final Identifier id; + public final static ResourceLocation ID = BetterEnd.makeID(GROUP); + + private final ResourceLocation id; private Ingredient input; private ItemStack output; private int time = 1; private Ingredient[] catalysts = new Ingredient[8]; private String group; - - private InfusionRecipe(Identifier id) { + + private InfusionRecipe(ResourceLocation id) { this(id, null, null); } - - private InfusionRecipe(Identifier id, Ingredient input, ItemStack output) { + + private InfusionRecipe(ResourceLocation id, Ingredient input, ItemStack output) { this.id = id; this.input = input; this.output = output; Arrays.fill(catalysts, Ingredient.EMPTY); } - + public int getInfusionTime() { return this.time; } @Override - public boolean matches(InfusionRitual inv, World world) { + public boolean matches(InfusionRitual inv, Level world) { boolean valid = this.input.test(inv.getStack(0)); - if (!valid) return false; + if (!valid) + return false; for (int i = 0; i < 8; i++) { valid &= this.catalysts[i].test(inv.getStack(i + 1)); } @@ -72,7 +73,7 @@ public class InfusionRecipe implements Recipe, BetterEndRecipe { public boolean fits(int width, int height) { return true; } - + @Override public DefaultedList getPreviewInputs() { DefaultedList defaultedList = DefaultedList.of(); @@ -89,10 +90,10 @@ public class InfusionRecipe implements Recipe, BetterEndRecipe { } @Override - public Identifier getId() { + public ResourceLocation getId() { return this.id; } - + @Override @Environment(EnvType.CLIENT) public String getGroup() { @@ -108,79 +109,82 @@ public class InfusionRecipe implements Recipe, BetterEndRecipe { public RecipeType getType() { return TYPE; } - + public static class Builder { private final static Builder INSTANCE = new Builder(); private static boolean exist; - + public static Builder create(String id) { return create(BetterEnd.makeID(id)); } - - public static Builder create(Identifier id) { + + public static Builder create(ResourceLocation id) { INSTANCE.id = id; INSTANCE.input = null; INSTANCE.output = null; INSTANCE.time = 1; exist = Configs.RECIPE_CONFIG.getBoolean("infusion", id.getPath(), true); - + Arrays.fill(INSTANCE.catalysts, Ingredient.EMPTY); - + return INSTANCE; } - - private Identifier id; + + private ResourceLocation id; private Ingredient input; private ItemStack output; private String group; private int time = 1; private Ingredient[] catalysts = new Ingredient[8]; - + private Builder() { Arrays.fill(catalysts, Ingredient.EMPTY); } - + public Builder setGroup(String group) { this.group = group; return this; } - + public Builder setInput(ItemConvertible input) { - this.input = Ingredient.ofItems(input); + this.input = Ingredient.of(input); return this; } - + public Builder setOutput(ItemConvertible output) { this.output = new ItemStack(output); this.output.setCount(1); return this; } - + public Builder setOutput(ItemStack output) { this.output = output; this.output.setCount(1); return this; } - + public Builder setTime(int time) { this.time = time; return this; } - + public Builder addCatalyst(int slot, ItemConvertible... items) { - if (slot > 7) return this; - this.catalysts[slot] = Ingredient.ofItems(items); + if (slot > 7) + return this; + this.catalysts[slot] = Ingredient.of(items); return this; } - + public void build() { if (exist) { if (input == null) { - BetterEnd.LOGGER.warning("Input for Infusion recipe can't be 'null', recipe {} will be ignored!", id); + BetterEnd.LOGGER.warning("Input for Infusion recipe can't be 'null', recipe {} will be ignored!", + id); return; } if (output == null) { - BetterEnd.LOGGER.warning("Output for Infusion recipe can't be 'null', recipe {} will be ignored!", id); + BetterEnd.LOGGER.warning("Output for Infusion recipe can't be 'null', recipe {} will be ignored!", + id); return; } InfusionRecipe recipe = new InfusionRecipe(id, input, output); @@ -188,8 +192,10 @@ public class InfusionRecipe implements Recipe, BetterEndRecipe { recipe.time = time; int empty = 0; for (int i = 0; i < catalysts.length; i++) { - if (catalysts[i].isEmpty()) empty++; - else recipe.catalysts[i] = catalysts[i]; + if (catalysts[i].isEmpty()) + empty++; + else + recipe.catalysts[i] = catalysts[i]; } if (empty == catalysts.length) { BetterEnd.LOGGER.warning("At least one catalyst must be non empty, recipe {} will be ignored!", id); @@ -199,10 +205,10 @@ public class InfusionRecipe implements Recipe, BetterEndRecipe { } } } - + public static class Serializer implements RecipeSerializer { @Override - public InfusionRecipe read(Identifier id, JsonObject json) { + public InfusionRecipe read(ResourceLocation id, JsonObject json) { InfusionRecipe recipe = new InfusionRecipe(id); recipe.input = Ingredient.fromJson(json.get("input")); JsonObject result = JsonHelper.getObject(json, "result"); @@ -212,7 +218,7 @@ public class InfusionRecipe implements Recipe, BetterEndRecipe { } recipe.group = JsonHelper.getString(json, "group", GROUP); recipe.time = JsonHelper.getInt(json, "time", 1); - + JsonObject catalysts = JsonHelper.asObject(json, "catalysts"); ItemStack catalyst = ItemUtil.fromStackString(JsonHelper.getString(catalysts, "north", "")); recipe.catalysts[0] = Ingredient.ofStacks(Arrays.stream(new ItemStack[] { catalyst })); @@ -230,12 +236,12 @@ public class InfusionRecipe implements Recipe, BetterEndRecipe { recipe.catalysts[6] = Ingredient.ofStacks(Arrays.stream(new ItemStack[] { catalyst })); catalyst = ItemUtil.fromStackString(JsonHelper.getString(catalysts, "north_west", "")); recipe.catalysts[7] = Ingredient.ofStacks(Arrays.stream(new ItemStack[] { catalyst })); - + return recipe; } @Override - public InfusionRecipe read(Identifier id, PacketByteBuf buffer) { + public InfusionRecipe read(ResourceLocation id, PacketByteBuf buffer) { InfusionRecipe recipe = new InfusionRecipe(id); recipe.input = Ingredient.fromPacket(buffer); recipe.output = buffer.readItemStack(); diff --git a/src/main/java/ru/betterend/recipe/builders/SmithingTableRecipe.java b/src/main/java/ru/betterend/recipe/builders/SmithingTableRecipe.java index d5935492..d2172a2c 100644 --- a/src/main/java/ru/betterend/recipe/builders/SmithingTableRecipe.java +++ b/src/main/java/ru/betterend/recipe/builders/SmithingTableRecipe.java @@ -1,88 +1,91 @@ package ru.betterend.recipe.builders; -import net.minecraft.item.Item; -import net.minecraft.item.ItemConvertible; -import net.minecraft.item.ItemStack; -import net.minecraft.recipe.Ingredient; -import net.minecraft.recipe.RecipeType; -import net.minecraft.recipe.SmithingRecipe; -import net.minecraft.tag.Tag; -import net.minecraft.util.Identifier; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemConvertible; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.SmithingRecipe; +import net.minecraft.tags.Tag; +import net.minecraft.resources.ResourceLocation; import ru.betterend.BetterEnd; import ru.betterend.config.Configs; import ru.betterend.recipe.EndRecipeManager; import ru.betterend.util.RecipeHelper; public class SmithingTableRecipe { - + private final static SmithingTableRecipe BUILDER = new SmithingTableRecipe(); private final static RecipeType TYPE = RecipeType.SMITHING; - + public static SmithingTableRecipe create(String name) { return create(BetterEnd.makeID(name)); } - - public static SmithingTableRecipe create(Identifier id) { + + public static SmithingTableRecipe create(ResourceLocation id) { BUILDER.id = id; BUILDER.base = null; BUILDER.addition = null; BUILDER.result = null; BUILDER.alright = true; - + return BUILDER; } - - private Identifier id; + + private ResourceLocation id; private Ingredient base; private Ingredient addition; private ItemStack result; private boolean alright; - - private SmithingTableRecipe() {} - + + private SmithingTableRecipe() { + } + public SmithingTableRecipe setResult(ItemConvertible item) { return this.setResult(item, 1); } - + public SmithingTableRecipe setResult(ItemConvertible item, int count) { this.alright &= RecipeHelper.exists(item); this.result = new ItemStack(item, count); return this; } - + public SmithingTableRecipe setBase(ItemConvertible... items) { this.alright &= RecipeHelper.exists(items); - this.base = Ingredient.ofItems(items); + this.base = Ingredient.of(items); return this; } - + public SmithingTableRecipe setBase(Tag tag) { this.base = (Ingredient.fromTag(tag)); return this; } - + public SmithingTableRecipe setAddition(ItemConvertible... items) { this.alright &= RecipeHelper.exists(items); - this.addition = Ingredient.ofItems(items); + this.addition = Ingredient.of(items); return this; } - + public SmithingTableRecipe setAddition(Tag tag) { this.addition = (Ingredient.fromTag(tag)); return this; } - + public void build() { if (Configs.RECIPE_CONFIG.getBoolean("smithing", id.getPath(), true)) { if (base == null) { - BetterEnd.LOGGER.warning("Base input for Smithing recipe can't be 'null', recipe {} will be ignored!", id); + BetterEnd.LOGGER.warning("Base input for Smithing recipe can't be 'null', recipe {} will be ignored!", + id); return; } if (addition == null) { - BetterEnd.LOGGER.warning("Addition input for Smithing recipe can't be 'null', recipe {} will be ignored!", id); + BetterEnd.LOGGER + .warning("Addition input for Smithing recipe can't be 'null', recipe {} will be ignored!", id); return; } - if(result == null) { + if (result == null) { BetterEnd.LOGGER.warning("Result for Smithing recipe can't be 'null', recipe {} will be ignored!", id); return; } diff --git a/src/main/java/ru/betterend/registry/EndBiomes.java b/src/main/java/ru/betterend/registry/EndBiomes.java index 3bf04bb4..8b133da5 100644 --- a/src/main/java/ru/betterend/registry/EndBiomes.java +++ b/src/main/java/ru/betterend/registry/EndBiomes.java @@ -20,9 +20,9 @@ import net.fabricmc.fabric.impl.biome.InternalBiomeData; import net.fabricmc.fabric.impl.biome.WeightedBiomePicker; import net.minecraft.client.MinecraftClient; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.registry.BuiltinRegistries; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome.Category; @@ -61,28 +61,28 @@ import ru.betterend.world.generator.BiomePicker; import ru.betterend.world.generator.BiomeType; public class EndBiomes { - private static final HashMap ID_MAP = Maps.newHashMap(); + private static final HashMap ID_MAP = Maps.newHashMap(); private static final HashMap CLIENT = Maps.newHashMap(); - public static final Set FABRIC_VOID = Sets.newHashSet(); - private static final Set SUBBIOMES_UNMUTABLES = Sets.newHashSet(); - + public static final Set FABRIC_VOID = Sets.newHashSet(); + private static final Set SUBBIOMES_UNMUTABLES = Sets.newHashSet(); + public static final BiomePicker LAND_BIOMES = new BiomePicker(); public static final BiomePicker VOID_BIOMES = new BiomePicker(); public static final BiomePicker CAVE_BIOMES = new BiomePicker(); public static final List SUBBIOMES = Lists.newArrayList(); private static final JsonObject EMPTY_JSON = new JsonObject(); - + private static Registry biomeRegistry; - + // Vanilla Land public static final EndBiome END = registerBiome(BiomeKeys.THE_END, BiomeType.LAND, 1F); public static final EndBiome END_MIDLANDS = registerSubBiome(BiomeKeys.END_MIDLANDS, END, 0.5F); public static final EndBiome END_HIGHLANDS = registerSubBiome(BiomeKeys.END_HIGHLANDS, END, 0.5F); - + // Vanilla Void public static final EndBiome END_BARRENS = registerBiome(BiomeKeys.END_BARRENS, BiomeType.VOID, 1F); public static final EndBiome SMALL_END_ISLANDS = registerBiome(BiomeKeys.SMALL_END_ISLANDS, BiomeType.VOID, 1); - + // Better End Land public static final EndBiome FOGGY_MUSHROOMLAND = registerBiome(new FoggyMushroomlandBiome(), BiomeType.LAND); public static final EndBiome CHORUS_FOREST = registerBiome(new ChorusForestBiome(), BiomeType.LAND); @@ -101,37 +101,39 @@ public class EndBiomes { public static final EndBiome DRY_SHRUBLAND = registerBiome(new DryShrublandBiome(), BiomeType.LAND); public static final EndBiome LANTERN_WOODS = registerBiome(new LanternWoodsBiome(), BiomeType.LAND); public static final EndBiome NEON_OASIS = registerSubBiome(new NeonOasisBiome(), DUST_WASTELANDS); - + // Better End Void public static final EndBiome ICE_STARFIELD = registerBiome(new BiomeIceStarfield(), BiomeType.VOID); - + // Better End Caves public static final EndCaveBiome EMPTY_END_CAVE = registerCaveBiome(new EmptyEndCaveBiome()); public static final EndCaveBiome EMPTY_SMARAGDANT_CAVE = registerCaveBiome(new EmptySmaragdantCaveBiome()); public static final EndCaveBiome LUSH_SMARAGDANT_CAVE = registerCaveBiome(new LushSmaragdantCaveBiome()); public static final EndCaveBiome EMPTY_AURORA_CAVE = registerCaveBiome(new EmptyAuroraCaveBiome()); public static final EndCaveBiome LUSH_AURORA_CAVE = registerCaveBiome(new LushAuroraCaveBiome()); - - public static void register() {} - + + public static void register() { + } + public static void mutateRegistry(Registry biomeRegistry) { EndBiomes.biomeRegistry = biomeRegistry; - + LAND_BIOMES.clearMutables(); VOID_BIOMES.clearMutables(); CAVE_BIOMES.clearMutables(); - + if (FABRIC_VOID.isEmpty()) { loadFabricAPIBiomes(); } - + Map configs = Maps.newHashMap(); - + biomeRegistry.forEach((biome) -> { if (biome.getCategory() == Category.THEEND) { - Identifier id = biomeRegistry.getId(biome); + ResourceLocation id = biomeRegistry.getId(biome); if (Configs.BIOME_CONFIG.getBoolean(id, "enabled", true)) { - if (!LAND_BIOMES.containsImmutable(id) && !VOID_BIOMES.containsImmutable(id) && !SUBBIOMES_UNMUTABLES.contains(id)) { + if (!LAND_BIOMES.containsImmutable(id) && !VOID_BIOMES.containsImmutable(id) + && !SUBBIOMES_UNMUTABLES.contains(id)) { JsonObject config = configs.get(id.getNamespace()); if (config == null) { config = loadJsonConfig(id.getNamespace()); @@ -152,8 +154,7 @@ public class EndBiomes { if (isVoid) { VOID_BIOMES.addBiomeMutable(endBiome); - } - else { + } else { LAND_BIOMES.addBiomeMutable(endBiome); } ID_MAP.put(id, endBiome); @@ -163,31 +164,31 @@ public class EndBiomes { }); Integrations.addBiomes(); Configs.BIOME_CONFIG.saveChanges(); - + rebuildPicker(LAND_BIOMES, biomeRegistry); rebuildPicker(VOID_BIOMES, biomeRegistry); rebuildPicker(CAVE_BIOMES, biomeRegistry); - + SUBBIOMES.forEach((endBiome) -> { endBiome.updateActualBiomes(biomeRegistry); }); - + CLIENT.clear(); } - + private static void rebuildPicker(BiomePicker picker, Registry biomeRegistry) { picker.rebuild(); picker.getBiomes().forEach((endBiome) -> { endBiome.updateActualBiomes(biomeRegistry); }); } - + private static void loadFabricAPIBiomes() { List> biomes = Lists.newArrayList(); biomes.addAll(getBiomes(InternalBiomeData.getEndBiomesMap().get(BiomeKeys.SMALL_END_ISLANDS))); biomes.addAll(getBiomes(InternalBiomeData.getEndBarrensMap().get(BiomeKeys.END_BARRENS))); biomes.forEach((key) -> FABRIC_VOID.add(key.getValue())); - + if (BetterEnd.isDevEnvironment()) { System.out.println("=================================="); System.out.println("Added void biomes from Fabric API:"); @@ -197,49 +198,55 @@ public class EndBiomes { System.out.println("=================================="); } } - + private static List> getBiomes(WeightedBiomePicker picker) { IBiomeList biomeList = (IBiomeList) (Object) picker; return biomeList == null ? Collections.emptyList() : biomeList.getBiomes(); } - + private static JsonObject loadJsonConfig(String namespace) { - InputStream inputstream = EndBiomes.class.getResourceAsStream("/data/" + namespace + "/end_biome_properties.json"); + InputStream inputstream = EndBiomes.class + .getResourceAsStream("/data/" + namespace + "/end_biome_properties.json"); if (inputstream != null) { return JsonFactory.getJsonObject(inputstream); - } - else { + } else { return EMPTY_JSON; } } - + /** - * Initialize registry if it was not initialized in world generation (when using mods/datapacks, that overrides the End generation) + * Initialize registry if it was not initialized in world generation (when using + * mods/datapacks, that overrides the End generation) + * * @param server - {@link MinecraftServer} */ public static void initRegistry(MinecraftServer server) { if (biomeRegistry == null) { - biomeRegistry = server.getRegistryManager().get(Registry.BIOME_KEY); + biomeRegistry = server.registryAccess().get(Registry.BIOME_KEY); } } - + /** - * Registers new {@link EndBiome} and adds it to picker, can be used to add existing mod biomes into the End. - * @param biome - {@link Biome} instance - * @param type - {@link BiomeType} + * Registers new {@link EndBiome} and adds it to picker, can be used to add + * existing mod biomes into the End. + * + * @param biome - {@link Biome} instance + * @param type - {@link BiomeType} * @param genChance - generation chance [0.0F - Infinity] * @return registered {@link EndBiome} */ public static EndBiome registerBiome(Biome biome, BiomeType type, float genChance) { return registerBiome(biome, type, 1, genChance); } - + /** - * Registers new {@link EndBiome} and adds it to picker, can be used to add existing mod biomes into the End. - * @param biome - {@link Biome} instance - * @param type - {@link BiomeType} + * Registers new {@link EndBiome} and adds it to picker, can be used to add + * existing mod biomes into the End. + * + * @param biome - {@link Biome} instance + * @param type - {@link BiomeType} * @param fogDensity - density of fog (def: 1F) [0.0F - Infinity] - * @param genChance - generation chance [0.0F - Infinity] + * @param genChance - generation chance [0.0F - Infinity] * @return registered {@link EndBiome} */ public static EndBiome registerBiome(Biome biome, BiomeType type, float fogDensity, float genChance) { @@ -249,27 +256,32 @@ public class EndBiomes { } return endBiome; } - + /** - * Registers new {@link EndBiome} from existed {@link Biome} and put as a sub-biome into selected parent. - * @param biome - {@link Biome} instance - * @param parent - {@link EndBiome} to be linked with + * Registers new {@link EndBiome} from existed {@link Biome} and put as a + * sub-biome into selected parent. + * + * @param biome - {@link Biome} instance + * @param parent - {@link EndBiome} to be linked with * @param genChance - generation chance [0.0F - Infinity] * @return registered {@link EndBiome} */ public static EndBiome registerSubBiome(Biome biome, EndBiome parent, float genChance, boolean hasCaves) { return registerSubBiome(biome, parent, 1, genChance, hasCaves); } - + /** - * Registers new {@link EndBiome} from existed {@link Biome} and put as a sub-biome into selected parent. - * @param biome - {@link Biome} instance - * @param parent - {@link EndBiome} to be linked with + * Registers new {@link EndBiome} from existed {@link Biome} and put as a + * sub-biome into selected parent. + * + * @param biome - {@link Biome} instance + * @param parent - {@link EndBiome} to be linked with * @param fogDensity - density of fog (def: 1F) [0.0F - Infinity] - * @param genChance - generation chance [0.0F - Infinity] + * @param genChance - generation chance [0.0F - Infinity] * @return registered {@link EndBiome} */ - public static EndBiome registerSubBiome(Biome biome, EndBiome parent, float fogDensity, float genChance, boolean hasCaves) { + public static EndBiome registerSubBiome(Biome biome, EndBiome parent, float fogDensity, float genChance, + boolean hasCaves) { EndBiome endBiome = new EndBiome(BuiltinRegistries.BIOME.getId(biome), biome, fogDensity, genChance, hasCaves); if (Configs.BIOME_CONFIG.getBoolean(endBiome.getID(), "enabled", true)) { parent.addSubBiome(endBiome); @@ -279,10 +291,11 @@ public class EndBiomes { } return endBiome; } - + /** * Put existing {@link EndBiome} as a sub-biome into selected parent. - * @param biome - {@link EndBiome} instance + * + * @param biome - {@link EndBiome} instance * @param parent - {@link EndBiome} to be linked with * @return registered {@link EndBiome} */ @@ -297,11 +310,12 @@ public class EndBiomes { } return biome; } - + /** * Registers {@link EndBiome} and adds it into worldgen. + * * @param biome - {@link EndBiome} instance - * @param type - {@link BiomeType} + * @param type - {@link BiomeType} * @return registered {@link EndBiome} */ public static EndBiome registerBiome(EndBiome biome, BiomeType type) { @@ -311,16 +325,17 @@ public class EndBiomes { ID_MAP.put(biome.getID(), biome); if (type == BiomeType.LAND) { addLandBiomeToFabricApi(biome); - } - else { + } else { addVoidBiomeToFabricApi(biome); } } return biome; } - + /** - * Put integration sub-biome {@link EndBiome} into subbiomes list and registers it. + * Put integration sub-biome {@link EndBiome} into subbiomes list and registers + * it. + * * @param biome - {@link EndBiome} instance * @return registered {@link EndBiome} */ @@ -334,13 +349,14 @@ public class EndBiomes { } return biome; } - + /** * Link integration sub-biome with parent. - * @param biome - {@link EndBiome} instance - * @param parent - {@link Identifier} parent id + * + * @param biome - {@link EndBiome} instance + * @param parent - {@link ResourceLocation} parent id */ - public static void addSubBiomeIntegration(EndBiome biome, Identifier parent) { + public static void addSubBiomeIntegration(EndBiome biome, ResourceLocation parent) { if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) { EndBiome parentBiome = ID_MAP.get(parent); if (parentBiome != null && !parentBiome.containsSubBiome(biome)) { @@ -348,20 +364,19 @@ public class EndBiomes { } } } - + public static EndBiome registerBiome(RegistryKey key, BiomeType type, float genChance) { return registerBiome(BuiltinRegistries.BIOME.get(key), type, genChance); } - + public static EndBiome registerSubBiome(RegistryKey key, EndBiome parent, float genChance) { return registerSubBiome(BuiltinRegistries.BIOME.get(key), parent, genChance, true); } - + private static void addToPicker(EndBiome biome, BiomeType type) { if (type == BiomeType.LAND) { LAND_BIOMES.addBiome(biome); - } - else { + } else { VOID_BIOMES.addBiome(biome); } } @@ -369,42 +384,42 @@ public class EndBiomes { private static void registerBiomeDirectly(EndBiome biome) { Registry.register(BuiltinRegistries.BIOME, biome.getID(), biome.getBiome()); } - + private static void addLandBiomeToFabricApi(EndBiome biome) { float weight = biome.getGenChanceImmutable(); RegistryKey key = BuiltinRegistries.BIOME.getKey(biome.getBiome()).get(); InternalBiomeData.addEndBiomeReplacement(BiomeKeys.END_HIGHLANDS, key, weight); InternalBiomeData.addEndBiomeReplacement(BiomeKeys.END_MIDLANDS, key, weight); } - + private static void addVoidBiomeToFabricApi(EndBiome biome) { float weight = biome.getGenChanceImmutable(); RegistryKey key = BuiltinRegistries.BIOME.getKey(biome.getBiome()).get(); InternalBiomeData.addEndBiomeReplacement(BiomeKeys.SMALL_END_ISLANDS, key, weight); } - + public static EndBiome getFromBiome(Biome biome) { return ID_MAP.getOrDefault(biomeRegistry.getId(biome), END); } - + @Environment(EnvType.CLIENT) public static EndBiome getRenderBiome(Biome biome) { EndBiome endBiome = CLIENT.get(biome); if (endBiome == null) { MinecraftClient minecraft = MinecraftClient.getInstance(); - Identifier id = minecraft.world.getRegistryManager().get(Registry.BIOME_KEY).getId(biome); + ResourceLocation id = minecraft.world.registryAccess().get(Registry.BIOME_KEY).getId(biome); endBiome = id == null ? END : ID_MAP.getOrDefault(id, END); CLIENT.put(biome, endBiome); } return endBiome; } - - public static Identifier getBiomeID(Biome biome) { - Identifier id = biomeRegistry.getId(biome); + + public static ResourceLocation getBiomeID(Biome biome) { + ResourceLocation id = biomeRegistry.getId(biome); return id == null ? END.getID() : id; } - public static EndBiome getBiome(Identifier biomeID) { + public static EndBiome getBiome(ResourceLocation biomeID) { return ID_MAP.getOrDefault(biomeID, END); } @@ -416,7 +431,7 @@ public class EndBiomes { result.addAll(SUBBIOMES); return result; } - + public static EndCaveBiome registerCaveBiome(EndCaveBiome biome) { if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) { registerBiomeDirectly(biome); @@ -425,12 +440,12 @@ public class EndBiomes { } return biome; } - + public static EndCaveBiome getCaveBiome(Random random) { return (EndCaveBiome) CAVE_BIOMES.getBiome(random); } - - public static boolean hasBiome(Identifier biomeID) { + + public static boolean hasBiome(ResourceLocation biomeID) { return ID_MAP.containsKey(biomeID); } } diff --git a/src/main/java/ru/betterend/registry/EndBlockEntities.java b/src/main/java/ru/betterend/registry/EndBlockEntities.java index 6b74d82c..96116a09 100644 --- a/src/main/java/ru/betterend/registry/EndBlockEntities.java +++ b/src/main/java/ru/betterend/registry/EndBlockEntities.java @@ -4,11 +4,11 @@ import java.util.List; import com.google.common.collect.Lists; -import net.minecraft.block.Block; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.BlockEntityType; -import net.minecraft.item.BlockItem; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.item.BlockItem; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; import ru.betterend.blocks.EndStoneSmelter; import ru.betterend.blocks.EternalPedestal; @@ -29,30 +29,35 @@ import ru.betterend.blocks.entities.InfusionPedestalEntity; import ru.betterend.blocks.entities.PedestalBlockEntity; public class EndBlockEntities { - public final static BlockEntityType END_STONE_SMELTER = registerBlockEntity(EndStoneSmelter.ID, + public final static BlockEntityType END_STONE_SMELTER = registerBlockEntity( + EndStoneSmelter.ID, BlockEntityType.Builder.create(EndStoneSmelterBlockEntity::new, EndBlocks.END_STONE_SMELTER)); public final static BlockEntityType PEDESTAL = registerBlockEntity("pedestal", BlockEntityType.Builder.create(PedestalBlockEntity::new, getPedestals())); - public final static BlockEntityType ETERNAL_PEDESTAL = registerBlockEntity("eternal_pedestal", - BlockEntityType.Builder.create(EternalPedestalEntity::new, EndBlocks.ETERNAL_PEDESTAL)); - public final static BlockEntityType INFUSION_PEDESTAL = registerBlockEntity("infusion_pedestal", + public final static BlockEntityType ETERNAL_PEDESTAL = registerBlockEntity( + "eternal_pedestal", BlockEntityType.Builder.create(EternalPedestalEntity::new, EndBlocks.ETERNAL_PEDESTAL)); + public final static BlockEntityType INFUSION_PEDESTAL = registerBlockEntity( + "infusion_pedestal", BlockEntityType.Builder.create(InfusionPedestalEntity::new, EndBlocks.INFUSION_PEDESTAL)); - public static final BlockEntityType CHEST = registerBlockEntity("chest", + public static final BlockEntityType CHEST = registerBlockEntity("chest", BlockEntityType.Builder.create(EChestBlockEntity::new, getChests())); public static final BlockEntityType BARREL = registerBlockEntity("barrel", BlockEntityType.Builder.create(EBarrelBlockEntity::new, getBarrels())); public static final BlockEntityType SIGN = registerBlockEntity("sign", BlockEntityType.Builder.create(ESignBlockEntity::new, getSigns())); - public final static BlockEntityType HYDROTHERMAL_VENT = registerBlockEntity("hydrother_malvent", + public final static BlockEntityType HYDROTHERMAL_VENT = registerBlockEntity( + "hydrother_malvent", BlockEntityType.Builder.create(BlockEntityHydrothermalVent::new, EndBlocks.HYDROTHERMAL_VENT)); public static final BlockEntityType FURNACE = registerBlockEntity("furnace", BlockEntityType.Builder.create(EFurnaceBlockEntity::new, getFurnaces())); - public static BlockEntityType registerBlockEntity(String id, BlockEntityType.Builder builder) { + public static BlockEntityType registerBlockEntity(String id, + BlockEntityType.Builder builder) { return Registry.register(Registry.BLOCK_ENTITY_TYPE, BetterEnd.makeID(id), builder.build(null)); } - - public static void register() {} + + public static void register() { + } static Block[] getChests() { List result = Lists.newArrayList(); @@ -66,7 +71,7 @@ public class EndBlockEntities { }); return result.toArray(new Block[] {}); } - + static Block[] getBarrels() { List result = Lists.newArrayList(); EndItems.getModBlocks().forEach((item) -> { @@ -79,7 +84,7 @@ public class EndBlockEntities { }); return result.toArray(new Block[] {}); } - + static Block[] getSigns() { List result = Lists.newArrayList(); EndItems.getModBlocks().forEach((item) -> { @@ -92,14 +97,14 @@ public class EndBlockEntities { }); return result.toArray(new Block[] {}); } - + static Block[] getPedestals() { List result = Lists.newArrayList(); EndItems.getModBlocks().forEach((item) -> { if (item instanceof BlockItem) { Block block = ((BlockItem) item).getBlock(); - if (block instanceof EternalPedestal || - block instanceof InfusionPedestal) return; + if (block instanceof EternalPedestal || block instanceof InfusionPedestal) + return; if (block instanceof PedestalBlock) { result.add(block); } @@ -107,7 +112,7 @@ public class EndBlockEntities { }); return result.toArray(new Block[] {}); } - + static Block[] getFurnaces() { List result = Lists.newArrayList(); EndItems.getModBlocks().forEach((item) -> { diff --git a/src/main/java/ru/betterend/registry/EndBlocks.java b/src/main/java/ru/betterend/registry/EndBlocks.java index ccb6104b..e4bb5310 100644 --- a/src/main/java/ru/betterend/registry/EndBlocks.java +++ b/src/main/java/ru/betterend/registry/EndBlocks.java @@ -1,13 +1,13 @@ package ru.betterend.registry; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.block.MaterialColor; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item.Settings; -import net.minecraft.item.LilyPadItem; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item.Properties; +import net.minecraft.world.item.LilyPadItem; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; import ru.betterend.blocks.*; import ru.betterend.blocks.basis.EndCropBlock; @@ -39,18 +39,23 @@ import ru.betterend.item.material.EndToolMaterial; public class EndBlocks { // Terrain // public static final Block ENDSTONE_DUST = registerBlock("endstone_dust", new EndstoneDustBlock()); - public static final Block END_MYCELIUM = registerBlock("end_mycelium", new EndTerrainBlock(MaterialColor.LIGHT_BLUE)); - public static final Block END_MOSS = registerBlock("end_moss", new EndTerrainBlock(MaterialColor.CYAN)); - public static final Block CHORUS_NYLIUM = registerBlock("chorus_nylium", new EndTerrainBlock(MaterialColor.MAGENTA)); - public static final Block CAVE_MOSS = registerBlock("cave_moss", new TripleTerrainBlock(MaterialColor.PURPLE)); - public static final Block CRYSTAL_MOSS = registerBlock("crystal_moss", new EndTerrainBlock(MaterialColor.PINK)); + public static final Block END_MYCELIUM = registerBlock("end_mycelium", + new EndTerrainBlock(MaterialColor.COLOR_LIGHT_BLUE)); + public static final Block END_MOSS = registerBlock("end_moss", new EndTerrainBlock(MaterialColor.COLOR_CYAN)); + public static final Block CHORUS_NYLIUM = registerBlock("chorus_nylium", + new EndTerrainBlock(MaterialColor.COLOR_MAGENTA)); + public static final Block CAVE_MOSS = registerBlock("cave_moss", + new TripleTerrainBlock(MaterialColor.COLOR_PURPLE)); + public static final Block CRYSTAL_MOSS = registerBlock("crystal_moss", + new EndTerrainBlock(MaterialColor.COLOR_PINK)); public static final Block SHADOW_GRASS = registerBlock("shadow_grass", new ShadowGrassBlock()); - public static final Block PINK_MOSS = registerBlock("pink_moss", new EndTerrainBlock(MaterialColor.PINK)); - public static final Block AMBER_MOSS = registerBlock("amber_moss", new EndTerrainBlock(MaterialColor.ORANGE)); - public static final Block JUNGLE_MOSS = registerBlock("jungle_moss", new EndTerrainBlock(MaterialColor.GREEN)); - public static final Block SANGNUM = registerBlock("sangnum", new EndTerrainBlock(MaterialColor.RED)); - public static final Block RUTISCUS = registerBlock("rutiscus", new EndTerrainBlock(MaterialColor.ORANGE)); - + public static final Block PINK_MOSS = registerBlock("pink_moss", new EndTerrainBlock(MaterialColor.COLOR_PINK)); + public static final Block AMBER_MOSS = registerBlock("amber_moss", new EndTerrainBlock(MaterialColor.COLOR_ORANGE)); + public static final Block JUNGLE_MOSS = registerBlock("jungle_moss", + new EndTerrainBlock(MaterialColor.COLOR_GREEN)); + public static final Block SANGNUM = registerBlock("sangnum", new EndTerrainBlock(MaterialColor.COLOR_RED)); + public static final Block RUTISCUS = registerBlock("rutiscus", new EndTerrainBlock(MaterialColor.COLOR_ORANGE)); + // Roads // public static final Block END_MYCELIUM_PATH = registerBlock("end_mycelium_path", new EndPathBlock(END_MYCELIUM)); public static final Block END_MOSS_PATH = registerBlock("end_moss_path", new EndPathBlock(END_MOSS)); @@ -63,93 +68,130 @@ public class EndBlocks { public static final Block JUNGLE_MOSS_PATH = registerBlock("jungle_moss_path", new EndPathBlock(JUNGLE_MOSS)); public static final Block SANGNUM_PATH = registerBlock("sangnum_path", new EndPathBlock(SANGNUM)); public static final Block RUTISCUS_PATH = registerBlock("rutiscus_path", new EndPathBlock(RUTISCUS)); - + public static final Block MOSSY_OBSIDIAN = registerBlock("mossy_obsidian", new MossyObsidian()); - public static final Block DRAGON_BONE_BLOCK = registerBlock("dragon_bone_block", new EndPillarBlock(Blocks.BONE_BLOCK)); - public static final Block DRAGON_BONE_STAIRS = registerBlock("dragon_bone_stairs", new EndStairsBlock(DRAGON_BONE_BLOCK)); + public static final Block DRAGON_BONE_BLOCK = registerBlock("dragon_bone_block", + new EndPillarBlock(Blocks.BONE_BLOCK)); + public static final Block DRAGON_BONE_STAIRS = registerBlock("dragon_bone_stairs", + new EndStairsBlock(DRAGON_BONE_BLOCK)); public static final Block DRAGON_BONE_SLAB = registerBlock("dragon_bone_slab", new EndSlabBlock(DRAGON_BONE_BLOCK)); public static final Block MOSSY_DRAGON_BONE = registerBlock("mossy_dragon_bone", new MossyDragonBoneBlock()); - + // Rocks // public static final StoneMaterial FLAVOLITE = new StoneMaterial("flavolite", MaterialColor.SAND); - public static final StoneMaterial VIOLECITE = new StoneMaterial("violecite", MaterialColor.PURPLE); - public static final StoneMaterial SULPHURIC_ROCK = new StoneMaterial("sulphuric_rock", MaterialColor.BROWN); - public static final StoneMaterial VIRID_jADESTONE = new StoneMaterial("virid_jadestone", MaterialColor.GREEN); - public static final StoneMaterial AZURE_jADESTONE = new StoneMaterial("azure_jadestone", MaterialColor.LIGHT_BLUE); - public static final StoneMaterial SANDY_jADESTONE = new StoneMaterial("sandy_jadestone", MaterialColor.YELLOW); + public static final StoneMaterial VIOLECITE = new StoneMaterial("violecite", MaterialColor.COLOR_PURPLE); + public static final StoneMaterial SULPHURIC_ROCK = new StoneMaterial("sulphuric_rock", MaterialColor.COLOR_BROWN); + public static final StoneMaterial VIRID_jADESTONE = new StoneMaterial("virid_jadestone", MaterialColor.COLOR_GREEN); + public static final StoneMaterial AZURE_jADESTONE = new StoneMaterial("azure_jadestone", + MaterialColor.COLOR_LIGHT_BLUE); + public static final StoneMaterial SANDY_jADESTONE = new StoneMaterial("sandy_jadestone", + MaterialColor.COLOR_YELLOW); public static final Block BRIMSTONE = registerBlock("brimstone", new BrimstoneBlock()); public static final Block SULPHUR_CRYSTAL = registerBlock("sulphur_crystal", new SulphurCrystalBlock()); public static final Block MISSING_TILE = registerBlock("missing_tile", new MissingTileBlock()); - + public static final Block FLAVOLITE_RUNED = registerBlock("flavolite_runed", new RunedFlavolite()); - public static final Block FLAVOLITE_RUNED_ETERNAL = registerBlock("flavolite_runed_eternal", new EternalRunedFlavolite()); - - public static final Block ANDESITE_PEDESTAL = registerBlock("andesite_pedestal", new PedestalVanilla(Blocks.ANDESITE)); + public static final Block FLAVOLITE_RUNED_ETERNAL = registerBlock("flavolite_runed_eternal", + new EternalRunedFlavolite()); + + public static final Block ANDESITE_PEDESTAL = registerBlock("andesite_pedestal", + new PedestalVanilla(Blocks.ANDESITE)); public static final Block DIORITE_PEDESTAL = registerBlock("diorite_pedestal", new PedestalVanilla(Blocks.DIORITE)); public static final Block GRANITE_PEDESTAL = registerBlock("granite_pedestal", new PedestalVanilla(Blocks.GRANITE)); - public static final Block QUARTZ_PEDESTAL = registerBlock("quartz_pedestal", new PedestalVanilla(Blocks.QUARTZ_BLOCK)); - public static final Block PURPUR_PEDESTAL = registerBlock("purpur_pedestal", new PedestalVanilla(Blocks.PURPUR_BLOCK)); - + public static final Block QUARTZ_PEDESTAL = registerBlock("quartz_pedestal", + new PedestalVanilla(Blocks.QUARTZ_BLOCK)); + public static final Block PURPUR_PEDESTAL = registerBlock("purpur_pedestal", + new PedestalVanilla(Blocks.PURPUR_BLOCK)); + public static final Block HYDROTHERMAL_VENT = registerBlock("hydrothermal_vent", new HydrothermalVentBlock()); public static final Block VENT_BUBBLE_COLUMN = registerBlockNI("vent_bubble_column", new VentBubbleColumnBlock()); - + public static final Block DENSE_SNOW = registerBlock("dense_snow", new DenseSnowBlock()); public static final Block EMERALD_ICE = registerBlock("emerald_ice", new EmeraldIceBlock()); public static final Block DENSE_EMERALD_ICE = registerBlock("dense_emerald_ice", new DenseEmeraldIceBlock()); public static final Block ANCIENT_EMERALD_ICE = registerBlock("ancient_emerald_ice", new AncientEmeraldIceBlock()); - - public static final Block END_STONE_STALACTITE = registerBlock("end_stone_stalactite", new StalactiteBlock(Blocks.END_STONE)); - public static final Block END_STONE_STALACTITE_CAVEMOSS = registerBlock("end_stone_stalactite_cavemoss", new StalactiteBlock(CAVE_MOSS)); - + + public static final Block END_STONE_STALACTITE = registerBlock("end_stone_stalactite", + new StalactiteBlock(Blocks.END_STONE)); + public static final Block END_STONE_STALACTITE_CAVEMOSS = registerBlock("end_stone_stalactite_cavemoss", + new StalactiteBlock(CAVE_MOSS)); + // Wooden Materials And Trees // - public static final Block MOSSY_GLOWSHROOM_SAPLING = registerBlock("mossy_glowshroom_sapling", new MossyGlowshroomSaplingBlock()); - public static final Block MOSSY_GLOWSHROOM_CAP = registerBlock("mossy_glowshroom_cap", new MossyGlowshroomCapBlock()); - public static final Block MOSSY_GLOWSHROOM_HYMENOPHORE = registerBlock("mossy_glowshroom_hymenophore", new GlowingHymenophoreBlock()); - public static final Block MOSSY_GLOWSHROOM_FUR = registerBlock("mossy_glowshroom_fur", new FurBlock(MOSSY_GLOWSHROOM_SAPLING, 15, 16, true)); - public static final WoodenMaterial MOSSY_GLOWSHROOM = new WoodenMaterial("mossy_glowshroom", MaterialColor.GRAY, MaterialColor.WOOD); - - public static final Block PYTHADENDRON_SAPLING = registerBlock("pythadendron_sapling", new PythadendronSaplingBlock()); - public static final Block PYTHADENDRON_LEAVES = registerBlock("pythadendron_leaves", new EndLeavesBlock(PYTHADENDRON_SAPLING, MaterialColor.MAGENTA)); - public static final WoodenMaterial PYTHADENDRON = new WoodenMaterial("pythadendron", MaterialColor.MAGENTA, MaterialColor.PURPLE); - + public static final Block MOSSY_GLOWSHROOM_SAPLING = registerBlock("mossy_glowshroom_sapling", + new MossyGlowshroomSaplingBlock()); + public static final Block MOSSY_GLOWSHROOM_CAP = registerBlock("mossy_glowshroom_cap", + new MossyGlowshroomCapBlock()); + public static final Block MOSSY_GLOWSHROOM_HYMENOPHORE = registerBlock("mossy_glowshroom_hymenophore", + new GlowingHymenophoreBlock()); + public static final Block MOSSY_GLOWSHROOM_FUR = registerBlock("mossy_glowshroom_fur", + new FurBlock(MOSSY_GLOWSHROOM_SAPLING, 15, 16, true)); + public static final WoodenMaterial MOSSY_GLOWSHROOM = new WoodenMaterial("mossy_glowshroom", + MaterialColor.COLOR_GRAY, MaterialColor.WOOD); + + public static final Block PYTHADENDRON_SAPLING = registerBlock("pythadendron_sapling", + new PythadendronSaplingBlock()); + public static final Block PYTHADENDRON_LEAVES = registerBlock("pythadendron_leaves", + new EndLeavesBlock(PYTHADENDRON_SAPLING, MaterialColor.COLOR_MAGENTA)); + public static final WoodenMaterial PYTHADENDRON = new WoodenMaterial("pythadendron", MaterialColor.COLOR_MAGENTA, + MaterialColor.COLOR_PURPLE); + public static final Block END_LOTUS_SEED = registerBlock("end_lotus_seed", new EndLotusSeedBlock()); public static final Block END_LOTUS_STEM = registerBlock("end_lotus_stem", new EndLotusStemBlock()); public static final Block END_LOTUS_LEAF = registerBlockNI("end_lotus_leaf", new EndLotusLeafBlock()); public static final Block END_LOTUS_FLOWER = registerBlockNI("end_lotus_flower", new EndLotusFlowerBlock()); - public static final WoodenMaterial END_LOTUS = new WoodenMaterial("end_lotus", MaterialColor.LIGHT_BLUE, MaterialColor.CYAN); - + public static final WoodenMaterial END_LOTUS = new WoodenMaterial("end_lotus", MaterialColor.COLOR_LIGHT_BLUE, + MaterialColor.COLOR_CYAN); + public static final Block LACUGROVE_SAPLING = registerBlock("lacugrove_sapling", new LacugroveSaplingBlock()); - public static final Block LACUGROVE_LEAVES = registerBlock("lacugrove_leaves", new EndLeavesBlock(LACUGROVE_SAPLING, MaterialColor.CYAN)); - public static final WoodenMaterial LACUGROVE = new WoodenMaterial("lacugrove", MaterialColor.BROWN, MaterialColor.YELLOW); - + public static final Block LACUGROVE_LEAVES = registerBlock("lacugrove_leaves", + new EndLeavesBlock(LACUGROVE_SAPLING, MaterialColor.COLOR_CYAN)); + public static final WoodenMaterial LACUGROVE = new WoodenMaterial("lacugrove", MaterialColor.COLOR_BROWN, + MaterialColor.COLOR_YELLOW); + public static final Block DRAGON_TREE_SAPLING = registerBlock("dragon_tree_sapling", new DragonTreeSaplingBlock()); - public static final Block DRAGON_TREE_LEAVES = registerBlock("dragon_tree_leaves", new EndLeavesBlock(DRAGON_TREE_SAPLING, MaterialColor.MAGENTA)); - public static final WoodenMaterial DRAGON_TREE = new WoodenMaterial("dragon_tree", MaterialColor.BLACK, MaterialColor.MAGENTA); - + public static final Block DRAGON_TREE_LEAVES = registerBlock("dragon_tree_leaves", + new EndLeavesBlock(DRAGON_TREE_SAPLING, MaterialColor.COLOR_MAGENTA)); + public static final WoodenMaterial DRAGON_TREE = new WoodenMaterial("dragon_tree", MaterialColor.COLOR_BLACK, + MaterialColor.COLOR_MAGENTA); + public static final Block TENANEA_SAPLING = registerBlock("tenanea_sapling", new TenaneaSaplingBlock()); - public static final Block TENANEA_LEAVES = registerBlock("tenanea_leaves", new EndLeavesBlock(TENANEA_SAPLING, MaterialColor.PINK)); + public static final Block TENANEA_LEAVES = registerBlock("tenanea_leaves", + new EndLeavesBlock(TENANEA_SAPLING, MaterialColor.COLOR_PINK)); public static final Block TENANEA_FLOWERS = registerBlock("tenanea_flowers", new TenaneaFlowersBlock()); - public static final Block TENANEA_OUTER_LEAVES = registerBlock("tenanea_outer_leaves", new FurBlock(TENANEA_SAPLING, 32)); - public static final WoodenMaterial TENANEA = new WoodenMaterial("tenanea", MaterialColor.BROWN, MaterialColor.PINK); - + public static final Block TENANEA_OUTER_LEAVES = registerBlock("tenanea_outer_leaves", + new FurBlock(TENANEA_SAPLING, 32)); + public static final WoodenMaterial TENANEA = new WoodenMaterial("tenanea", MaterialColor.COLOR_BROWN, + MaterialColor.COLOR_PINK); + public static final Block HELIX_TREE_SAPLING = registerBlock("helix_tree_sapling", new HelixTreeSaplingBlock()); public static final Block HELIX_TREE_LEAVES = registerBlock("helix_tree_leaves", new HelixTreeLeavesBlock()); - public static final WoodenMaterial HELIX_TREE = new WoodenMaterial("helix_tree", MaterialColor.GRAY, MaterialColor.ORANGE); - - public static final Block UMBRELLA_TREE_SAPLING = registerBlock("umbrella_tree_sapling", new UmbrellaTreeSaplingBlock()); - public static final Block UMBRELLA_TREE_MEMBRANE = registerBlock("umbrella_tree_membrane", new UmbrellaTreeMembraneBlock()); - public static final Block UMBRELLA_TREE_CLUSTER = registerBlock("umbrella_tree_cluster", new UmbrellaTreeClusterBlock()); - public static final Block UMBRELLA_TREE_CLUSTER_EMPTY = registerBlock("umbrella_tree_cluster_empty", new UmbrellaTreeClusterEmptyBlock()); - public static final WoodenMaterial UMBRELLA_TREE = new WoodenMaterial("umbrella_tree", MaterialColor.BLUE, MaterialColor.GREEN); - - public static final Block JELLYSHROOM_CAP_PURPLE = registerBlock("jellyshroom_cap_purple", new JellyshroomCapBlock(217, 142, 255, 164, 0, 255)); - public static final WoodenMaterial JELLYSHROOM = new WoodenMaterial("jellyshroom", MaterialColor.PURPLE, MaterialColor.LIGHT_BLUE); - + public static final WoodenMaterial HELIX_TREE = new WoodenMaterial("helix_tree", MaterialColor.COLOR_GRAY, + MaterialColor.COLOR_ORANGE); + + public static final Block UMBRELLA_TREE_SAPLING = registerBlock("umbrella_tree_sapling", + new UmbrellaTreeSaplingBlock()); + public static final Block UMBRELLA_TREE_MEMBRANE = registerBlock("umbrella_tree_membrane", + new UmbrellaTreeMembraneBlock()); + public static final Block UMBRELLA_TREE_CLUSTER = registerBlock("umbrella_tree_cluster", + new UmbrellaTreeClusterBlock()); + public static final Block UMBRELLA_TREE_CLUSTER_EMPTY = registerBlock("umbrella_tree_cluster_empty", + new UmbrellaTreeClusterEmptyBlock()); + public static final WoodenMaterial UMBRELLA_TREE = new WoodenMaterial("umbrella_tree", MaterialColor.COLOR_BLUE, + MaterialColor.COLOR_GREEN); + + public static final Block JELLYSHROOM_CAP_PURPLE = registerBlock("jellyshroom_cap_purple", + new JellyshroomCapBlock(217, 142, 255, 164, 0, 255)); + public static final WoodenMaterial JELLYSHROOM = new WoodenMaterial("jellyshroom", MaterialColor.COLOR_PURPLE, + MaterialColor.COLOR_LIGHT_BLUE); + public static final Block LUCERNIA_SAPLING = registerBlock("lucernia_sapling", new TenaneaSaplingBlock()); - public static final Block LUCERNIA_LEAVES = registerBlock("lucernia_leaves", new EndLeavesBlock(LUCERNIA_SAPLING, MaterialColor.ORANGE)); - public static final Block LUCERNIA_OUTER_LEAVES = registerBlock("lucernia_outer_leaves", new FurBlock(LUCERNIA_SAPLING, 32)); - public static final WoodenMaterial LUCERNIA = new WoodenMaterial("lucernia", MaterialColor.ORANGE, MaterialColor.ORANGE); - + public static final Block LUCERNIA_LEAVES = registerBlock("lucernia_leaves", + new EndLeavesBlock(LUCERNIA_SAPLING, MaterialColor.COLOR_ORANGE)); + public static final Block LUCERNIA_OUTER_LEAVES = registerBlock("lucernia_outer_leaves", + new FurBlock(LUCERNIA_SAPLING, 32)); + public static final WoodenMaterial LUCERNIA = new WoodenMaterial("lucernia", MaterialColor.COLOR_ORANGE, + MaterialColor.COLOR_ORANGE); + // Small Plants // public static final Block UMBRELLA_MOSS = registerBlock("umbrella_moss", new UmbrellaMossBlock()); public static final Block UMBRELLA_MOSS_TALL = registerBlock("umbrella_moss_tall", new UmbrellaMossTallBlock()); @@ -160,59 +202,75 @@ public class EndBlocks { public static final Block SHADOW_PLANT = registerBlock("shadow_plant", new TerrainPlantBlock(SHADOW_GRASS)); public static final Block BUSHY_GRASS = registerBlock("bushy_grass", new TerrainPlantBlock(PINK_MOSS)); public static final Block AMBER_GRASS = registerBlock("amber_grass", new TerrainPlantBlock(AMBER_MOSS)); - public static final Block TWISTED_UMBRELLA_MOSS = registerBlock("twisted_umbrella_moss", new TwistedUmbrellaMossBlock()); - public static final Block TWISTED_UMBRELLA_MOSS_TALL = registerBlock("twisted_umbrella_moss_tall", new TwistedUmbrellaMossTallBlock()); + public static final Block TWISTED_UMBRELLA_MOSS = registerBlock("twisted_umbrella_moss", + new TwistedUmbrellaMossBlock()); + public static final Block TWISTED_UMBRELLA_MOSS_TALL = registerBlock("twisted_umbrella_moss_tall", + new TwistedUmbrellaMossTallBlock()); public static final Block JUNGLE_GRASS = registerBlock("jungle_grass", new TerrainPlantBlock(JUNGLE_MOSS)); public static final Block BLOOMING_COOKSONIA = registerBlock("blooming_cooksonia", new TerrainPlantBlock(END_MOSS)); public static final Block SALTEAGO = registerBlock("salteago", new TerrainPlantBlock(END_MOSS)); public static final Block VAIOLUSH_FERN = registerBlock("vaiolush_fern", new TerrainPlantBlock(END_MOSS)); public static final Block FRACTURN = registerBlock("fracturn", new TerrainPlantBlock(END_MOSS)); - public static final Block CLAWFERN = registerBlock("clawfern", new TerrainPlantBlock(SANGNUM, MOSSY_OBSIDIAN, MOSSY_DRAGON_BONE)); - public static final Block GLOBULAGUS = registerBlock("globulagus", new TerrainPlantBlock(SANGNUM, MOSSY_OBSIDIAN, MOSSY_DRAGON_BONE)); + public static final Block CLAWFERN = registerBlock("clawfern", + new TerrainPlantBlock(SANGNUM, MOSSY_OBSIDIAN, MOSSY_DRAGON_BONE)); + public static final Block GLOBULAGUS = registerBlock("globulagus", + new TerrainPlantBlock(SANGNUM, MOSSY_OBSIDIAN, MOSSY_DRAGON_BONE)); public static final Block ORANGO = registerBlock("orango", new TerrainPlantBlock(RUTISCUS)); public static final Block AERIDIUM = registerBlock("aeridium", new TerrainPlantBlock(RUTISCUS)); public static final Block LUTEBUS = registerBlock("lutebus", new TerrainPlantBlock(RUTISCUS)); public static final Block LAMELLARIUM = registerBlock("lamellarium", new TerrainPlantBlock(RUTISCUS)); - + public static final Block BLUE_VINE_SEED = registerBlock("blue_vine_seed", new BlueVineSeedBlock()); public static final Block BLUE_VINE = registerBlockNI("blue_vine", new BlueVineBlock()); public static final Block BLUE_VINE_LANTERN = registerBlock("blue_vine_lantern", new BlueVineLanternBlock()); - public static final Block BLUE_VINE_FUR = registerBlock("blue_vine_fur", new FurBlock(BLUE_VINE_SEED, 15, 3, false)); - + public static final Block BLUE_VINE_FUR = registerBlock("blue_vine_fur", + new FurBlock(BLUE_VINE_SEED, 15, 3, false)); + public static final Block LANCELEAF_SEED = registerBlock("lanceleaf_seed", new LanceleafSeedBlock()); public static final Block LANCELEAF = registerBlockNI("lanceleaf", new LanceleafBlock()); - + public static final Block GLOWING_PILLAR_SEED = registerBlock("glowing_pillar_seed", new GlowingPillarSeedBlock()); - public static final Block GLOWING_PILLAR_ROOTS = registerBlockNI("glowing_pillar_roots", new GlowingPillarRootsBlock()); - public static final Block GLOWING_PILLAR_LUMINOPHOR = registerBlock("glowing_pillar_luminophor", new GlowingPillarLuminophorBlock()); - public static final Block GLOWING_PILLAR_LEAVES = registerBlock("glowing_pillar_leaves", new FurBlock(GLOWING_PILLAR_SEED, 15, 3, false)); - + public static final Block GLOWING_PILLAR_ROOTS = registerBlockNI("glowing_pillar_roots", + new GlowingPillarRootsBlock()); + public static final Block GLOWING_PILLAR_LUMINOPHOR = registerBlock("glowing_pillar_luminophor", + new GlowingPillarLuminophorBlock()); + public static final Block GLOWING_PILLAR_LEAVES = registerBlock("glowing_pillar_leaves", + new FurBlock(GLOWING_PILLAR_SEED, 15, 3, false)); + public static final Block SMALL_JELLYSHROOM = registerBlock("small_jellyshroom", new SmallJellyshroomBlock()); public static final Block BOLUX_MUSHROOM = registerBlock("bolux_mushroom", new BoluxMushroomBlock()); - + public static final Block LUMECORN_SEED = registerBlock("lumecorn_seed", new LumecornSeedBlock()); public static final Block LUMECORN = registerBlockNI("lumecorn", new LumecornBlock()); - - public static final Block SMALL_AMARANITA_MUSHROOM = registerBlock("small_amaranita_mushroom", new SmallAmaranitaBlock()); - public static final Block LARGE_AMARANITA_MUSHROOM = registerBlockNI("large_amaranita_mushroom", new LargeAmaranitaBlock()); + + public static final Block SMALL_AMARANITA_MUSHROOM = registerBlock("small_amaranita_mushroom", + new SmallAmaranitaBlock()); + public static final Block LARGE_AMARANITA_MUSHROOM = registerBlockNI("large_amaranita_mushroom", + new LargeAmaranitaBlock()); public static final Block AMARANITA_STEM = registerBlock("amaranita_stem", new AmaranitaStemBlock()); public static final Block AMARANITA_HYPHAE = registerBlock("amaranita_hyphae", new AmaranitaStemBlock()); - public static final Block AMARANITA_HYMENOPHORE = registerBlock("amaranita_hymenophore", new AmaranitaHymenophoreBlock()); + public static final Block AMARANITA_HYMENOPHORE = registerBlock("amaranita_hymenophore", + new AmaranitaHymenophoreBlock()); public static final Block AMARANITA_LANTERN = registerBlock("amaranita_lantern", new GlowingHymenophoreBlock()); - public static final Block AMARANITA_FUR = registerBlock("amaranita_fur", new FurBlock(MOSSY_GLOWSHROOM_SAPLING, 15, 4, true)); + public static final Block AMARANITA_FUR = registerBlock("amaranita_fur", + new FurBlock(MOSSY_GLOWSHROOM_SAPLING, 15, 4, true)); public static final Block AMARANITA_CAP = registerBlock("amaranita_cap", new AmaranitaCapBlock()); - + public static final Block NEON_CACTUS = registerBlock("neon_cactus", new NeonCactusBlock()); - + // Crops public static final Block SHADOW_BERRY = registerBlock("shadow_berry", new ShadowBerryBlock()); - public static final Block BLOSSOM_BERRY = registerBlock("blossom_berry_seed", new EndCropBlock(EndItems.BLOSSOM_BERRY, PINK_MOSS)); - public static final Block AMBER_ROOT = registerBlock("amber_root_seed", new EndCropBlock(EndItems.AMBER_ROOT_RAW, AMBER_MOSS)); - public static final Block CHORUS_MUSHROOM = registerBlock("chorus_mushroom_seed", new EndCropBlock(EndItems.CHORUS_MUSHROOM_RAW, CHORUS_NYLIUM)); - public static final Block PEARLBERRY = registerBlock("pearlberry_seed", new EndCropBlock(EndItems.BLOSSOM_BERRY, END_MOSS, END_MYCELIUM)); + public static final Block BLOSSOM_BERRY = registerBlock("blossom_berry_seed", + new EndCropBlock(EndItems.BLOSSOM_BERRY, PINK_MOSS)); + public static final Block AMBER_ROOT = registerBlock("amber_root_seed", + new EndCropBlock(EndItems.AMBER_ROOT_RAW, AMBER_MOSS)); + public static final Block CHORUS_MUSHROOM = registerBlock("chorus_mushroom_seed", + new EndCropBlock(EndItems.CHORUS_MUSHROOM_RAW, CHORUS_NYLIUM)); + public static final Block PEARLBERRY = registerBlock("pearlberry_seed", + new EndCropBlock(EndItems.BLOSSOM_BERRY, END_MOSS, END_MYCELIUM)); public static final Block CAVE_PUMPKIN_SEED = registerBlock("cave_pumpkin_seed", new CavePumpkinVineBlock()); public static final Block CAVE_PUMPKIN = registerBlock("cave_pumpkin", new CavePumpkinBlock()); - + // Water plants public static final Block BUBBLE_CORAL = registerBlock("bubble_coral", new BubbleCoralBlock()); public static final Block MENGER_SPONGE = registerBlock("menger_sponge", new MengerSpongeBlock()); @@ -223,24 +281,26 @@ public class EndBlocks { public static final Block CHARNIA_LIGHT_BLUE = registerBlock("charnia_light_blue", new CharniaBlock()); public static final Block CHARNIA_CYAN = registerBlock("charnia_cyan", new CharniaBlock()); public static final Block CHARNIA_GREEN = registerBlock("charnia_green", new CharniaBlock()); - + public static final Block END_LILY = registerBlockNI("end_lily", new EndLilyBlock()); public static final Block END_LILY_SEED = registerBlock("end_lily_seed", new EndLilySeedBlock()); - - public static final Block HYDRALUX_SAPLING = registerBlock("hydralux_sapling", new HydraluxSaplingBlock()); + + public static final Block HYDRALUX_SAPLING = registerBlock("hydralux_sapling", new HydraluxSaplingBlock()); public static final Block HYDRALUX = registerBlockNI("hydralux", new HydraluxBlock()); public static final Block HYDRALUX_PETAL_BLOCK = registerBlock("hydralux_petal_block", new HydraluxPetalBlock()); - public static final ColoredMaterial HYDRALUX_PETAL_BLOCK_COLORED = new ColoredMaterial(HydraluxPetalColoredBlock::new, HYDRALUX_PETAL_BLOCK, true); - + public static final ColoredMaterial HYDRALUX_PETAL_BLOCK_COLORED = new ColoredMaterial( + HydraluxPetalColoredBlock::new, HYDRALUX_PETAL_BLOCK, true); + public static final Block POND_ANEMONE = registerBlock("pond_anemone", new PondAnemoneBlock()); - + public static final Block FLAMAEA = registerBlock("flamaea", new FlamaeaBlock()); - - public static final Block CAVE_BUSH = registerBlock("cave_bush", new SimpleLeavesBlock(MaterialColor.MAGENTA)); - + + public static final Block CAVE_BUSH = registerBlock("cave_bush", + new SimpleLeavesBlock(MaterialColor.COLOR_MAGENTA)); + public static final Block MURKWEED = registerBlock("murkweed", new MurkweedBlock()); public static final Block NEEDLEGRASS = registerBlock("needlegrass", new NeedlegrassBlock()); - + // Wall Plants // public static final Block PURPLE_POLYPORE = registerBlock("purple_polypore", new WallMushroomBlock(13)); public static final Block AURANT_POLYPORE = registerBlock("aurant_polypore", new WallMushroomBlock(13)); @@ -251,7 +311,7 @@ public class EndBlocks { public static final Block BULB_MOSS = registerBlock("bulb_moss", new EndWallPlantBlock(12)); public static final Block JUNGLE_FERN = registerBlock("jungle_fern", new EndWallPlantBlock()); public static final Block RUSCUS = registerBlock("ruscus", new EndWallPlantBlock()); - + // Vines // public static final Block DENSE_VINE = registerBlock("dense_vine", new VineBlock(15, true)); public static final Block TWISTED_VINE = registerBlock("twisted_vine", new VineBlock()); @@ -263,58 +323,72 @@ public class EndBlocks { public static final Block FILALUX = registerBlock("filalux", new FilaluxBlock()); public static final Block FILALUX_WINGS = registerBlock("filalux_wings", new FilaluxWingsBlock()); public static final Block FILALUX_LANTERN = registerBlock("filalux_lantern", new FilaluxLanternBlock()); - + // Mob-Related public static final Block SILK_MOTH_NEST = registerBlock("silk_moth_nest", new SilkMothNestBlock()); public static final Block SILK_MOTH_HIVE = registerBlock("silk_moth_hive", new SilkMothHiveBlock()); - + // Ores // public static final Block ENDER_ORE = registerBlock("ender_ore", new EndOreBlock(EndItems.ENDER_SHARD, 1, 3, 5)); public static final Block AMBER_ORE = registerBlock("amber_ore", new EndOreBlock(EndItems.RAW_AMBER, 1, 2, 4)); - + // Materials // - public static final MetalMaterial THALLASIUM = MetalMaterial.makeNormal("thallasium", MaterialColor.BLUE, EndToolMaterial.THALLASIUM, EndArmorMaterial.THALLASIUM); - public static final MetalMaterial TERMINITE = MetalMaterial.makeOreless("terminite", MaterialColor.field_25708, 7F, 9F, EndToolMaterial.TERMINITE, EndArmorMaterial.TERMINITE); + public static final MetalMaterial THALLASIUM = MetalMaterial.makeNormal("thallasium", MaterialColor.COLOR_BLUE, + EndToolMaterial.THALLASIUM, EndArmorMaterial.THALLASIUM); + public static final MetalMaterial TERMINITE = MetalMaterial.makeOreless("terminite", MaterialColor.field_25708, 7F, + 9F, EndToolMaterial.TERMINITE, EndArmorMaterial.TERMINITE); public static final Block AETERNIUM_BLOCK = registerBlock("aeternium_block", new AeterniumBlock()); public static final Block CHARCOAL_BLOCK = registerBlock("charcoal_block", new CharcoalBlock()); - + public static final Block ENDER_BLOCK = registerBlock("ender_block", new EnderBlock()); public static final Block AURORA_CRYSTAL = registerBlock("aurora_crystal", new AuroraCrystalBlock()); public static final Block AMBER_BLOCK = registerBlock("amber_block", new AmberBlock()); public static final Block SMARAGDANT_CRYSTAL = registerBlock("smaragdant_crystal", new SmaragdantCrystalBlock()); - public static final CrystalSubblocksMaterial SMARAGDANT_SUBBLOCKS = new CrystalSubblocksMaterial("smaragdant_crystal", SMARAGDANT_CRYSTAL); - public static final Block SMARAGDANT_CRYSTAL_SHARD = registerBlock("smaragdant_crystal_shard", new SmaragdantCrystalShardBlock()); - + public static final CrystalSubblocksMaterial SMARAGDANT_SUBBLOCKS = new CrystalSubblocksMaterial( + "smaragdant_crystal", SMARAGDANT_CRYSTAL); + public static final Block SMARAGDANT_CRYSTAL_SHARD = registerBlock("smaragdant_crystal_shard", + new SmaragdantCrystalShardBlock()); + public static final Block RESPAWN_OBELISK = registerBlock("respawn_obelisk", new RespawnObeliskBlock()); - + // Lanterns - public static final Block ANDESITE_LANTERN = registerBlock("andesite_lantern", new StoneLanternBlock(Blocks.ANDESITE)); + public static final Block ANDESITE_LANTERN = registerBlock("andesite_lantern", + new StoneLanternBlock(Blocks.ANDESITE)); public static final Block DIORITE_LANTERN = registerBlock("diorite_lantern", new StoneLanternBlock(Blocks.DIORITE)); public static final Block GRANITE_LANTERN = registerBlock("granite_lantern", new StoneLanternBlock(Blocks.GRANITE)); - public static final Block QUARTZ_LANTERN = registerBlock("quartz_lantern", new StoneLanternBlock(Blocks.QUARTZ_BLOCK)); - public static final Block PURPUR_LANTERN = registerBlock("purpur_lantern", new StoneLanternBlock(Blocks.PURPUR_BLOCK)); - public static final Block END_STONE_LANTERN = registerBlock("end_stone_lantern", new StoneLanternBlock(Blocks.END_STONE)); - public static final Block BLACKSTONE_LANTERN = registerBlock("blackstone_lantern", new StoneLanternBlock(Blocks.BLACKSTONE)); - + public static final Block QUARTZ_LANTERN = registerBlock("quartz_lantern", + new StoneLanternBlock(Blocks.QUARTZ_BLOCK)); + public static final Block PURPUR_LANTERN = registerBlock("purpur_lantern", + new StoneLanternBlock(Blocks.PURPUR_BLOCK)); + public static final Block END_STONE_LANTERN = registerBlock("end_stone_lantern", + new StoneLanternBlock(Blocks.END_STONE)); + public static final Block BLACKSTONE_LANTERN = registerBlock("blackstone_lantern", + new StoneLanternBlock(Blocks.BLACKSTONE)); + public static final Block IRON_BULB_LANTERN = registerBlock("iron_bulb_lantern", new BulbVineLanternBlock()); - public static final ColoredMaterial IRON_BULB_LANTERN_COLORED = new ColoredMaterial(BulbVineLanternColoredBlock::new, IRON_BULB_LANTERN, false); - - public static final Block IRON_CHANDELIER = EndBlocks.registerBlock("iron_chandelier", new ChandelierBlock(Blocks.GOLD_BLOCK)); - public static final Block GOLD_CHANDELIER = EndBlocks.registerBlock("gold_chandelier", new ChandelierBlock(Blocks.GOLD_BLOCK)); - + public static final ColoredMaterial IRON_BULB_LANTERN_COLORED = new ColoredMaterial( + BulbVineLanternColoredBlock::new, IRON_BULB_LANTERN, false); + + public static final Block IRON_CHANDELIER = EndBlocks.registerBlock("iron_chandelier", + new ChandelierBlock(Blocks.GOLD_BLOCK)); + public static final Block GOLD_CHANDELIER = EndBlocks.registerBlock("gold_chandelier", + new ChandelierBlock(Blocks.GOLD_BLOCK)); + // Blocks With Entity // - public static final Block END_STONE_FURNACE = registerBlock("end_stone_furnace", new EndFurnaceBlock(Blocks.END_STONE)); + public static final Block END_STONE_FURNACE = registerBlock("end_stone_furnace", + new EndFurnaceBlock(Blocks.END_STONE)); public static final Block END_STONE_SMELTER = registerBlock("end_stone_smelter", new EndStoneSmelter()); public static final Block ETERNAL_PEDESTAL = registerBlock("eternal_pedestal", new EternalPedestal()); public static final Block INFUSION_PEDESTAL = registerBlock("infusion_pedestal", new InfusionPedestal()); public static final Block AETERNIUM_ANVIL = registerBlock("aeternium_anvil", new AeterniumAnvil()); - + // Technical public static final Block END_PORTAL_BLOCK = registerBlockNI("end_portal_block", new EndPortalBlock()); - - public static void register() {} - - public static Block registerBlock(Identifier id, Block block) { + + public static void register() { + } + + public static Block registerBlock(ResourceLocation id, Block block) { if (!Configs.BLOCK_CONFIG.getBooleanRoot(id.getPath(), true)) { return block; } @@ -326,20 +400,19 @@ public class EndBlocks { maxCount = item.getStackSize(); placeOnWater = item.canPlaceOnWater(); } - Settings item = EndItems.makeBlockItemSettings().maxCount(maxCount); + Properties item = EndItems.makeBlockItemSettings().maxCount(maxCount); if (placeOnWater) { EndItems.registerBlockItem(id, new LilyPadItem(block, item)); - } - else { + } else { EndItems.registerBlockItem(id, new BlockItem(block, item)); } return block; } - + public static Block registerBlock(String name, Block block) { return registerBlock(BetterEnd.makeID(name), block); } - + public static Block registerBlockNI(String name, Block block) { return Registry.register(Registry.BLOCK, BetterEnd.makeID(name), block); } diff --git a/src/main/java/ru/betterend/registry/EndEntities.java b/src/main/java/ru/betterend/registry/EndEntities.java index 9863bd9b..a7864691 100644 --- a/src/main/java/ru/betterend/registry/EndEntities.java +++ b/src/main/java/ru/betterend/registry/EndEntities.java @@ -2,15 +2,15 @@ package ru.betterend.registry; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityDimensions; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.EntityType.EntityFactory; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.SpawnGroup; -import net.minecraft.entity.attribute.DefaultAttributeContainer.Builder; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityDimensions; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.EntityType.EntityFactory; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.SpawnGroup; +import net.minecraft.world.entity.attribute.DefaultAttributeContainer.Builder; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; import ru.betterend.config.Configs; import ru.betterend.entity.CubozoaEntity; @@ -23,13 +23,25 @@ import ru.betterend.util.MHelper; import ru.betterend.util.SpawnHelper; public class EndEntities { - public static final EntityType DRAGONFLY = register("dragonfly", SpawnGroup.AMBIENT, 0.6F, 0.5F, DragonflyEntity::new, DragonflyEntity.createMobAttributes(), true, MHelper.color(32, 42, 176), MHelper.color(115, 225, 249)); - public static final EntityType END_SLIME = register("end_slime", SpawnGroup.MONSTER, 2F, 2F, EndSlimeEntity::new, EndSlimeEntity.createMobAttributes(), false, MHelper.color(28, 28, 28), MHelper.color(99, 11, 99)); - public static final EntityType END_FISH = register("end_fish", SpawnGroup.WATER_AMBIENT, 0.5F, 0.5F, EndFishEntity::new, EndFishEntity.createMobAttributes(), true, MHelper.color(3, 50, 76), MHelper.color(120, 206, 255)); - public static final EntityType SHADOW_WALKER = register("shadow_walker", SpawnGroup.MONSTER, 0.6F, 1.95F, ShadowWalkerEntity::new, ShadowWalkerEntity.createMobAttributes(), true, MHelper.color(30, 30, 30), MHelper.color(5, 5, 5)); - public static final EntityType CUBOZOA = register("cubozoa", SpawnGroup.WATER_AMBIENT, 0.6F, 1F, CubozoaEntity::new, CubozoaEntity.createMobAttributes(), true, MHelper.color(151, 77, 181), MHelper.color(93, 176, 238)); - public static final EntityType SILK_MOTH = register("silk_moth", SpawnGroup.AMBIENT, 0.6F, 0.6F, SilkMothEntity::new, SilkMothEntity.createMobAttributes(), true, MHelper.color(198, 138, 204), MHelper.color(242, 220, 236)); - + public static final EntityType DRAGONFLY = register("dragonfly", SpawnGroup.AMBIENT, 0.6F, 0.5F, + DragonflyEntity::new, DragonflyEntity.createMobAttributes(), true, MHelper.color(32, 42, 176), + MHelper.color(115, 225, 249)); + public static final EntityType END_SLIME = register("end_slime", SpawnGroup.MONSTER, 2F, 2F, + EndSlimeEntity::new, EndSlimeEntity.createMobAttributes(), false, MHelper.color(28, 28, 28), + MHelper.color(99, 11, 99)); + public static final EntityType END_FISH = register("end_fish", SpawnGroup.WATER_AMBIENT, 0.5F, 0.5F, + EndFishEntity::new, EndFishEntity.createMobAttributes(), true, MHelper.color(3, 50, 76), + MHelper.color(120, 206, 255)); + public static final EntityType SHADOW_WALKER = register("shadow_walker", SpawnGroup.MONSTER, + 0.6F, 1.95F, ShadowWalkerEntity::new, ShadowWalkerEntity.createMobAttributes(), true, + MHelper.color(30, 30, 30), MHelper.color(5, 5, 5)); + public static final EntityType CUBOZOA = register("cubozoa", SpawnGroup.WATER_AMBIENT, 0.6F, 1F, + CubozoaEntity::new, CubozoaEntity.createMobAttributes(), true, MHelper.color(151, 77, 181), + MHelper.color(93, 176, 238)); + public static final EntityType SILK_MOTH = register("silk_moth", SpawnGroup.AMBIENT, 0.6F, 0.6F, + SilkMothEntity::new, SilkMothEntity.createMobAttributes(), true, MHelper.color(198, 138, 204), + MHelper.color(242, 220, 236)); + public static void register() { SpawnHelper.restrictionAir(DRAGONFLY, DragonflyEntity::canSpawn); SpawnHelper.restrictionLand(END_SLIME, EndSlimeEntity::canSpawn); @@ -38,19 +50,25 @@ public class EndEntities { SpawnHelper.restrictionWater(CUBOZOA, CubozoaEntity::canSpawn); SpawnHelper.restrictionAir(SILK_MOTH, SilkMothEntity::canSpawn); } - - protected static EntityType register(String name, SpawnGroup group, float width, float height, EntityFactory entity) { - Identifier id = BetterEnd.makeID(name); - EntityType type = FabricEntityTypeBuilder.create(group, entity).dimensions(EntityDimensions.fixed(width, height)).build(); + + protected static EntityType register(String name, SpawnGroup group, float width, float height, + EntityFactory entity) { + ResourceLocation id = BetterEnd.makeID(name); + EntityType type = FabricEntityTypeBuilder.create(group, entity) + .dimensions(EntityDimensions.fixed(width, height)).build(); if (Configs.ENTITY_CONFIG.getBooleanRoot(id.getPath(), true)) { return Registry.register(Registry.ENTITY_TYPE, id, type); } return type; } - - private static EntityType register(String name, SpawnGroup group, float width, float height, EntityFactory entity, Builder attributes, boolean fixedSize, int eggColor, int dotsColor) { - Identifier id = BetterEnd.makeID(name); - EntityType type = FabricEntityTypeBuilder.create(group, entity).dimensions(fixedSize ? EntityDimensions.fixed(width, height) : EntityDimensions.changing(width, height)).build(); + + private static EntityType register(String name, SpawnGroup group, float width, + float height, EntityFactory entity, Builder attributes, boolean fixedSize, int eggColor, int dotsColor) { + ResourceLocation id = BetterEnd.makeID(name); + EntityType type = FabricEntityTypeBuilder.create(group, entity) + .dimensions( + fixedSize ? EntityDimensions.fixed(width, height) : EntityDimensions.changing(width, height)) + .build(); if (Configs.ENTITY_CONFIG.getBooleanRoot(id.getPath(), true)) { FabricDefaultAttributeRegistry.register(type, attributes); EndItems.registerEgg("spawn_egg_" + name, type, eggColor, dotsColor); diff --git a/src/main/java/ru/betterend/registry/EndEntitiesRenders.java b/src/main/java/ru/betterend/registry/EndEntitiesRenders.java index 35d2a367..5719b6f8 100644 --- a/src/main/java/ru/betterend/registry/EndEntitiesRenders.java +++ b/src/main/java/ru/betterend/registry/EndEntitiesRenders.java @@ -5,7 +5,7 @@ import java.util.function.Function; import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.MobEntityRenderer; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.EntityType; import ru.betterend.entity.render.RendererEntityCubozoa; import ru.betterend.entity.render.RendererEntityDragonfly; import ru.betterend.entity.render.RendererEntityEndFish; @@ -14,7 +14,7 @@ import ru.betterend.entity.render.RendererEntityShadowWalker; import ru.betterend.entity.render.SilkMothEntityRenderer; public class EndEntitiesRenders { - + public static void register() { register(EndEntities.DRAGONFLY, RendererEntityDragonfly::new); register(EndEntities.END_SLIME, RendererEntityEndSlime::new); @@ -23,7 +23,7 @@ public class EndEntitiesRenders { register(EndEntities.CUBOZOA, RendererEntityCubozoa::new); register(EndEntities.SILK_MOTH, SilkMothEntityRenderer::new); } - + private static void register(EntityType type, Function> render) { EntityRendererRegistry.INSTANCE.register(type, (entityRenderDispatcher, context) -> { return render.apply(entityRenderDispatcher); diff --git a/src/main/java/ru/betterend/registry/EndFeatures.java b/src/main/java/ru/betterend/registry/EndFeatures.java index cc003815..ffb8ef58 100644 --- a/src/main/java/ru/betterend/registry/EndFeatures.java +++ b/src/main/java/ru/betterend/registry/EndFeatures.java @@ -5,8 +5,8 @@ import java.util.function.Supplier; import com.google.common.collect.Lists; -import net.minecraft.block.Blocks; -import net.minecraft.util.Identifier; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.feature.ConfiguredFeature; @@ -74,165 +74,258 @@ import ru.betterend.world.generator.GeneratorOptions; public class EndFeatures { // Trees // - public static final EndFeature MOSSY_GLOWSHROOM = new EndFeature("mossy_glowshroom", new MossyGlowshroomFeature(), 3); - public static final EndFeature PYTHADENDRON_TREE = new EndFeature("pythadendron_tree", new PythadendronTreeFeature(), 2); + public static final EndFeature MOSSY_GLOWSHROOM = new EndFeature("mossy_glowshroom", new MossyGlowshroomFeature(), + 3); + public static final EndFeature PYTHADENDRON_TREE = new EndFeature("pythadendron_tree", + new PythadendronTreeFeature(), 2); public static final EndFeature LACUGROVE = new EndFeature("lacugrove", new LacugroveFeature(), 4); public static final EndFeature DRAGON_TREE = new EndFeature("dragon_tree", new DragonTreeFeature(), 3); public static final EndFeature TENANEA = new EndFeature("tenanea", new TenaneaFeature(), 3); public static final EndFeature HELIX_TREE = new EndFeature("helix_tree", new HelixTreeFeature(), 2); public static final EndFeature UMBRELLA_TREE = new EndFeature("umbrella_tree", new UmbrellaTreeFeature(), 4); public static final EndFeature JELLYSHROOM = new EndFeature("jellyshroom", new JellyshroomFeature(), 3); - public static final EndFeature GIGANTIC_AMARANITA = new EndFeature("gigantic_amaranita", new GiganticAmaranitaFeature(), 1); + public static final EndFeature GIGANTIC_AMARANITA = new EndFeature("gigantic_amaranita", + new GiganticAmaranitaFeature(), 1); public static final EndFeature LUCERNIA = new EndFeature("lucernia", new LucerniaFeature(), 3); - + // Bushes // - public static final EndFeature PYTHADENDRON_BUSH = new EndFeature("pythadendron_bush", new BushFeature(EndBlocks.PYTHADENDRON_LEAVES, EndBlocks.PYTHADENDRON.bark), 4); - public static final EndFeature DRAGON_TREE_BUSH = new EndFeature("dragon_tree_bush", new BushFeature(EndBlocks.DRAGON_TREE_LEAVES, EndBlocks.DRAGON_TREE.bark), 15); + public static final EndFeature PYTHADENDRON_BUSH = new EndFeature("pythadendron_bush", + new BushFeature(EndBlocks.PYTHADENDRON_LEAVES, EndBlocks.PYTHADENDRON.bark), 4); + public static final EndFeature DRAGON_TREE_BUSH = new EndFeature("dragon_tree_bush", + new BushFeature(EndBlocks.DRAGON_TREE_LEAVES, EndBlocks.DRAGON_TREE.bark), 15); public static final EndFeature TENANEA_BUSH = new EndFeature("tenanea_bush", new TenaneaBushFeature(), 10); public static final EndFeature LUMECORN = new EndFeature("lumecorn", new Lumecorn(), 5); public static final EndFeature LARGE_AMARANITA = new EndFeature("large_amaranita", new LargeAmaranitaFeature(), 5); - public static final EndFeature LUCERNIA_BUSH = new EndFeature("lucernia_bush", new BushWithOuterFeature(EndBlocks.LUCERNIA_LEAVES, EndBlocks.LUCERNIA_OUTER_LEAVES, EndBlocks.LUCERNIA.bark), 10); + public static final EndFeature LUCERNIA_BUSH = new EndFeature("lucernia_bush", new BushWithOuterFeature( + EndBlocks.LUCERNIA_LEAVES, EndBlocks.LUCERNIA_OUTER_LEAVES, EndBlocks.LUCERNIA.bark), 10); public static final EndFeature NEON_CACTUS = new EndFeature("neon_cactus", new NeonCactusFeature(), 2); - + // Plants // - public static final EndFeature UMBRELLA_MOSS = new EndFeature("umbrella_moss", new DoublePlantFeature(EndBlocks.UMBRELLA_MOSS, EndBlocks.UMBRELLA_MOSS_TALL, 5), 5); - public static final EndFeature CREEPING_MOSS = new EndFeature("creeping_moss", new SinglePlantFeature(EndBlocks.CREEPING_MOSS, 5), 5); + public static final EndFeature UMBRELLA_MOSS = new EndFeature("umbrella_moss", + new DoublePlantFeature(EndBlocks.UMBRELLA_MOSS, EndBlocks.UMBRELLA_MOSS_TALL, 5), 5); + public static final EndFeature CREEPING_MOSS = new EndFeature("creeping_moss", + new SinglePlantFeature(EndBlocks.CREEPING_MOSS, 5), 5); public static final EndFeature BLUE_VINE = new EndFeature("blue_vine", new BlueVineFeature(), 1); - public static final EndFeature CHORUS_GRASS = new EndFeature("chorus_grass", new SinglePlantFeature(EndBlocks.CHORUS_GRASS, 4), 5); - public static final EndFeature CRYSTAL_GRASS = new EndFeature("crystal_grass", new SinglePlantFeature(EndBlocks.CRYSTAL_GRASS, 8, false), 5); - public static final EndFeature SHADOW_PLANT = new EndFeature("shadow_plant", new SinglePlantFeature(EndBlocks.SHADOW_PLANT, 6), 9); - public static final EndFeature MURKWEED = new EndFeature("murkweed", new SinglePlantFeature(EndBlocks.MURKWEED, 3), 2); - public static final EndFeature NEEDLEGRASS = new EndFeature("needlegrass", new SinglePlantFeature(EndBlocks.NEEDLEGRASS, 3), 2); - public static final EndFeature SHADOW_BERRY = new EndFeature("shadow_berry", new SinglePlantFeature(EndBlocks.SHADOW_BERRY, 2), 1); - public static final EndFeature BUSHY_GRASS = new EndFeature("bushy_grass", new SinglePlantFeature(EndBlocks.BUSHY_GRASS, 8, false), 20); - public static final EndFeature BUSHY_GRASS_WG = new EndFeature("bushy_grass_wg", new SinglePlantFeature(EndBlocks.BUSHY_GRASS, 5), 10); - public static final EndFeature AMBER_GRASS = new EndFeature("amber_grass", new SinglePlantFeature(EndBlocks.AMBER_GRASS, 6), 9); + public static final EndFeature CHORUS_GRASS = new EndFeature("chorus_grass", + new SinglePlantFeature(EndBlocks.CHORUS_GRASS, 4), 5); + public static final EndFeature CRYSTAL_GRASS = new EndFeature("crystal_grass", + new SinglePlantFeature(EndBlocks.CRYSTAL_GRASS, 8, false), 5); + public static final EndFeature SHADOW_PLANT = new EndFeature("shadow_plant", + new SinglePlantFeature(EndBlocks.SHADOW_PLANT, 6), 9); + public static final EndFeature MURKWEED = new EndFeature("murkweed", new SinglePlantFeature(EndBlocks.MURKWEED, 3), + 2); + public static final EndFeature NEEDLEGRASS = new EndFeature("needlegrass", + new SinglePlantFeature(EndBlocks.NEEDLEGRASS, 3), 2); + public static final EndFeature SHADOW_BERRY = new EndFeature("shadow_berry", + new SinglePlantFeature(EndBlocks.SHADOW_BERRY, 2), 1); + public static final EndFeature BUSHY_GRASS = new EndFeature("bushy_grass", + new SinglePlantFeature(EndBlocks.BUSHY_GRASS, 8, false), 20); + public static final EndFeature BUSHY_GRASS_WG = new EndFeature("bushy_grass_wg", + new SinglePlantFeature(EndBlocks.BUSHY_GRASS, 5), 10); + public static final EndFeature AMBER_GRASS = new EndFeature("amber_grass", + new SinglePlantFeature(EndBlocks.AMBER_GRASS, 6), 9); public static final EndFeature LANCELEAF = new EndFeature("lanceleaf", new LanceleafFeature(), 3); public static final EndFeature GLOW_PILLAR = new EndFeature("glow_pillar", new GlowPillarFeature(), 1); - public static final EndFeature TWISTED_UMBRELLA_MOSS = new EndFeature("twisted_umbrella_moss", new DoublePlantFeature(EndBlocks.TWISTED_UMBRELLA_MOSS, EndBlocks.TWISTED_UMBRELLA_MOSS_TALL, 6), 5); - public static final EndFeature JUNGLE_GRASS = new EndFeature("jungle_grass", new SinglePlantFeature(EndBlocks.JUNGLE_GRASS, 7, 3), 8); - public static final EndFeature SMALL_JELLYSHROOM_FLOOR = new EndFeature("small_jellyshroom_floor", new SinglePlantFeature(EndBlocks.SMALL_JELLYSHROOM, 5, 5), 4); - public static final EndFeature BLOSSOM_BERRY = new EndFeature("blossom_berry", new SinglePlantFeature(EndBlocks.BLOSSOM_BERRY, 3, 3), 2); - public static final EndFeature BLOOMING_COOKSONIA = new EndFeature("blooming_cooksonia", new SinglePlantFeature(EndBlocks.BLOOMING_COOKSONIA, 5), 5); - public static final EndFeature SALTEAGO = new EndFeature("salteago", new SinglePlantFeature(EndBlocks.SALTEAGO, 5), 5); - public static final EndFeature VAIOLUSH_FERN = new EndFeature("vaiolush_fern", new SinglePlantFeature(EndBlocks.VAIOLUSH_FERN, 5), 5); - public static final EndFeature FRACTURN = new EndFeature("fracturn", new SinglePlantFeature(EndBlocks.FRACTURN, 5), 5); - public static final EndFeature UMBRELLA_MOSS_RARE = new EndFeature("umbrella_moss_rare", new SinglePlantFeature(EndBlocks.UMBRELLA_MOSS, 3), 2); - public static final EndFeature CREEPING_MOSS_RARE = new EndFeature("creeping_moss_rare", new SinglePlantFeature(EndBlocks.CREEPING_MOSS, 3), 2); - public static final EndFeature TWISTED_UMBRELLA_MOSS_RARE = new EndFeature("twisted_umbrella_moss_rare", new SinglePlantFeature(EndBlocks.TWISTED_UMBRELLA_MOSS, 3), 2); + public static final EndFeature TWISTED_UMBRELLA_MOSS = new EndFeature("twisted_umbrella_moss", + new DoublePlantFeature(EndBlocks.TWISTED_UMBRELLA_MOSS, EndBlocks.TWISTED_UMBRELLA_MOSS_TALL, 6), 5); + public static final EndFeature JUNGLE_GRASS = new EndFeature("jungle_grass", + new SinglePlantFeature(EndBlocks.JUNGLE_GRASS, 7, 3), 8); + public static final EndFeature SMALL_JELLYSHROOM_FLOOR = new EndFeature("small_jellyshroom_floor", + new SinglePlantFeature(EndBlocks.SMALL_JELLYSHROOM, 5, 5), 4); + public static final EndFeature BLOSSOM_BERRY = new EndFeature("blossom_berry", + new SinglePlantFeature(EndBlocks.BLOSSOM_BERRY, 3, 3), 2); + public static final EndFeature BLOOMING_COOKSONIA = new EndFeature("blooming_cooksonia", + new SinglePlantFeature(EndBlocks.BLOOMING_COOKSONIA, 5), 5); + public static final EndFeature SALTEAGO = new EndFeature("salteago", new SinglePlantFeature(EndBlocks.SALTEAGO, 5), + 5); + public static final EndFeature VAIOLUSH_FERN = new EndFeature("vaiolush_fern", + new SinglePlantFeature(EndBlocks.VAIOLUSH_FERN, 5), 5); + public static final EndFeature FRACTURN = new EndFeature("fracturn", new SinglePlantFeature(EndBlocks.FRACTURN, 5), + 5); + public static final EndFeature UMBRELLA_MOSS_RARE = new EndFeature("umbrella_moss_rare", + new SinglePlantFeature(EndBlocks.UMBRELLA_MOSS, 3), 2); + public static final EndFeature CREEPING_MOSS_RARE = new EndFeature("creeping_moss_rare", + new SinglePlantFeature(EndBlocks.CREEPING_MOSS, 3), 2); + public static final EndFeature TWISTED_UMBRELLA_MOSS_RARE = new EndFeature("twisted_umbrella_moss_rare", + new SinglePlantFeature(EndBlocks.TWISTED_UMBRELLA_MOSS, 3), 2); public static final EndFeature ORANGO = new EndFeature("orango", new SinglePlantFeature(EndBlocks.ORANGO, 5), 6); - public static final EndFeature AERIDIUM = new EndFeature("aeridium", new SinglePlantFeature(EndBlocks.AERIDIUM, 5, 4), 5); - public static final EndFeature LUTEBUS = new EndFeature("lutebus", new SinglePlantFeature(EndBlocks.LUTEBUS, 5, 2), 5); - public static final EndFeature LAMELLARIUM = new EndFeature("lamellarium", new SinglePlantFeature(EndBlocks.LAMELLARIUM, 5), 6); - public static final EndFeature SMALL_AMARANITA = new EndFeature("small_amaranita", new SinglePlantFeature(EndBlocks.SMALL_AMARANITA_MUSHROOM, 5, 5), 4); - public static final EndFeature GLOBULAGUS = new EndFeature("globulagus", new SinglePlantFeature(EndBlocks.GLOBULAGUS, 5, 3), 6); - public static final EndFeature CLAWFERN = new EndFeature("clawfern", new SinglePlantFeature(EndBlocks.CLAWFERN, 5, 4), 5); - public static final EndFeature BOLUX_MUSHROOM = new EndFeature("bolux_mushroom", new SinglePlantFeature(EndBlocks.BOLUX_MUSHROOM, 5, 5), 2); - public static final EndFeature CHORUS_MUSHROOM = new EndFeature("chorus_mushroom", new SinglePlantFeature(EndBlocks.CHORUS_MUSHROOM, 5, 5), 1); - public static final EndFeature AMBER_ROOT = new EndFeature("amber_root", new SinglePlantFeature(EndBlocks.AMBER_ROOT, 5, 5), 1); - public static final EndFeature PEARLBERRY = new EndFeature("pearlberry", new SinglePlantFeature(EndBlocks.PEARLBERRY, 5, 5), 1); - + public static final EndFeature AERIDIUM = new EndFeature("aeridium", + new SinglePlantFeature(EndBlocks.AERIDIUM, 5, 4), 5); + public static final EndFeature LUTEBUS = new EndFeature("lutebus", new SinglePlantFeature(EndBlocks.LUTEBUS, 5, 2), + 5); + public static final EndFeature LAMELLARIUM = new EndFeature("lamellarium", + new SinglePlantFeature(EndBlocks.LAMELLARIUM, 5), 6); + public static final EndFeature SMALL_AMARANITA = new EndFeature("small_amaranita", + new SinglePlantFeature(EndBlocks.SMALL_AMARANITA_MUSHROOM, 5, 5), 4); + public static final EndFeature GLOBULAGUS = new EndFeature("globulagus", + new SinglePlantFeature(EndBlocks.GLOBULAGUS, 5, 3), 6); + public static final EndFeature CLAWFERN = new EndFeature("clawfern", + new SinglePlantFeature(EndBlocks.CLAWFERN, 5, 4), 5); + public static final EndFeature BOLUX_MUSHROOM = new EndFeature("bolux_mushroom", + new SinglePlantFeature(EndBlocks.BOLUX_MUSHROOM, 5, 5), 2); + public static final EndFeature CHORUS_MUSHROOM = new EndFeature("chorus_mushroom", + new SinglePlantFeature(EndBlocks.CHORUS_MUSHROOM, 5, 5), 1); + public static final EndFeature AMBER_ROOT = new EndFeature("amber_root", + new SinglePlantFeature(EndBlocks.AMBER_ROOT, 5, 5), 1); + public static final EndFeature PEARLBERRY = new EndFeature("pearlberry", + new SinglePlantFeature(EndBlocks.PEARLBERRY, 5, 5), 1); + // Vines // - public static final EndFeature DENSE_VINE = new EndFeature("dense_vine", new VineFeature(EndBlocks.DENSE_VINE, 24), 3); - public static final EndFeature TWISTED_VINE = new EndFeature("twisted_vine", new VineFeature(EndBlocks.TWISTED_VINE, 24), 3); + public static final EndFeature DENSE_VINE = new EndFeature("dense_vine", new VineFeature(EndBlocks.DENSE_VINE, 24), + 3); + public static final EndFeature TWISTED_VINE = new EndFeature("twisted_vine", + new VineFeature(EndBlocks.TWISTED_VINE, 24), 3); public static final EndFeature BULB_VINE = new EndFeature("bulb_vine", new VineFeature(EndBlocks.BULB_VINE, 24), 5); - public static final EndFeature JUNGLE_VINE = new EndFeature("jungle_vine", new VineFeature(EndBlocks.JUNGLE_VINE, 24), 5); - + public static final EndFeature JUNGLE_VINE = new EndFeature("jungle_vine", + new VineFeature(EndBlocks.JUNGLE_VINE, 24), 5); + // Ceil plants - public static final EndFeature SMALL_JELLYSHROOM_CEIL = new EndFeature("small_jellyshroom_ceil", new SingleInvertedScatterFeature(EndBlocks.SMALL_JELLYSHROOM, 8), 8); - + public static final EndFeature SMALL_JELLYSHROOM_CEIL = new EndFeature("small_jellyshroom_ceil", + new SingleInvertedScatterFeature(EndBlocks.SMALL_JELLYSHROOM, 8), 8); + // Wall Plants // - public static final EndFeature PURPLE_POLYPORE = new EndFeature("purple_polypore", new WallPlantOnLogFeature(EndBlocks.PURPLE_POLYPORE, 3), 5); - public static final EndFeature AURANT_POLYPORE = new EndFeature("aurant_polypore", new WallPlantOnLogFeature(EndBlocks.AURANT_POLYPORE, 3), 5); - public static final EndFeature TAIL_MOSS = new EndFeature("tail_moss", new WallPlantFeature(EndBlocks.TAIL_MOSS, 3), 15); - public static final EndFeature CYAN_MOSS = new EndFeature("cyan_moss", new WallPlantFeature(EndBlocks.CYAN_MOSS, 3), 15); - public static final EndFeature TAIL_MOSS_WOOD = new EndFeature("tail_moss_wood", new WallPlantOnLogFeature(EndBlocks.TAIL_MOSS, 4), 25); - public static final EndFeature CYAN_MOSS_WOOD = new EndFeature("cyan_moss_wood", new WallPlantOnLogFeature(EndBlocks.CYAN_MOSS, 4), 25); - public static final EndFeature TWISTED_MOSS = new EndFeature("twisted_moss", new WallPlantFeature(EndBlocks.TWISTED_MOSS, 6), 15); - public static final EndFeature TWISTED_MOSS_WOOD = new EndFeature("twisted_moss_wood", new WallPlantOnLogFeature(EndBlocks.TWISTED_MOSS, 6), 25); - public static final EndFeature BULB_MOSS = new EndFeature("bulb_moss", new WallPlantFeature(EndBlocks.BULB_MOSS, 6), 1); - public static final EndFeature BULB_MOSS_WOOD = new EndFeature("bulb_moss_wood", new WallPlantOnLogFeature(EndBlocks.BULB_MOSS, 6), 15); - public static final EndFeature SMALL_JELLYSHROOM_WALL = new EndFeature("small_jellyshroom_wall", new WallPlantFeature(EndBlocks.SMALL_JELLYSHROOM, 4), 4); - public static final EndFeature SMALL_JELLYSHROOM_WOOD = new EndFeature("small_jellyshroom_wood", new WallPlantOnLogFeature(EndBlocks.SMALL_JELLYSHROOM, 4), 8); - public static final EndFeature JUNGLE_FERN_WOOD = new EndFeature("jungle_fern_wood", new WallPlantOnLogFeature(EndBlocks.JUNGLE_FERN, 3), 12); + public static final EndFeature PURPLE_POLYPORE = new EndFeature("purple_polypore", + new WallPlantOnLogFeature(EndBlocks.PURPLE_POLYPORE, 3), 5); + public static final EndFeature AURANT_POLYPORE = new EndFeature("aurant_polypore", + new WallPlantOnLogFeature(EndBlocks.AURANT_POLYPORE, 3), 5); + public static final EndFeature TAIL_MOSS = new EndFeature("tail_moss", new WallPlantFeature(EndBlocks.TAIL_MOSS, 3), + 15); + public static final EndFeature CYAN_MOSS = new EndFeature("cyan_moss", new WallPlantFeature(EndBlocks.CYAN_MOSS, 3), + 15); + public static final EndFeature TAIL_MOSS_WOOD = new EndFeature("tail_moss_wood", + new WallPlantOnLogFeature(EndBlocks.TAIL_MOSS, 4), 25); + public static final EndFeature CYAN_MOSS_WOOD = new EndFeature("cyan_moss_wood", + new WallPlantOnLogFeature(EndBlocks.CYAN_MOSS, 4), 25); + public static final EndFeature TWISTED_MOSS = new EndFeature("twisted_moss", + new WallPlantFeature(EndBlocks.TWISTED_MOSS, 6), 15); + public static final EndFeature TWISTED_MOSS_WOOD = new EndFeature("twisted_moss_wood", + new WallPlantOnLogFeature(EndBlocks.TWISTED_MOSS, 6), 25); + public static final EndFeature BULB_MOSS = new EndFeature("bulb_moss", new WallPlantFeature(EndBlocks.BULB_MOSS, 6), + 1); + public static final EndFeature BULB_MOSS_WOOD = new EndFeature("bulb_moss_wood", + new WallPlantOnLogFeature(EndBlocks.BULB_MOSS, 6), 15); + public static final EndFeature SMALL_JELLYSHROOM_WALL = new EndFeature("small_jellyshroom_wall", + new WallPlantFeature(EndBlocks.SMALL_JELLYSHROOM, 4), 4); + public static final EndFeature SMALL_JELLYSHROOM_WOOD = new EndFeature("small_jellyshroom_wood", + new WallPlantOnLogFeature(EndBlocks.SMALL_JELLYSHROOM, 4), 8); + public static final EndFeature JUNGLE_FERN_WOOD = new EndFeature("jungle_fern_wood", + new WallPlantOnLogFeature(EndBlocks.JUNGLE_FERN, 3), 12); public static final EndFeature RUSCUS = new EndFeature("ruscus", new WallPlantFeature(EndBlocks.RUSCUS, 6), 10); - public static final EndFeature RUSCUS_WOOD = new EndFeature("ruscus_wood", new WallPlantOnLogFeature(EndBlocks.RUSCUS, 6), 10); - + public static final EndFeature RUSCUS_WOOD = new EndFeature("ruscus_wood", + new WallPlantOnLogFeature(EndBlocks.RUSCUS, 6), 10); + // Sky plants public static final EndFeature FILALUX = new EndFeature("filalux", new FilaluxFeature(), 1); - + // Water // - public static final EndFeature BUBBLE_CORAL = new EndFeature("bubble_coral", new UnderwaterPlantFeature(EndBlocks.BUBBLE_CORAL, 6), 10); - public static final EndFeature BUBBLE_CORAL_RARE = new EndFeature("bubble_coral_rare", new UnderwaterPlantFeature(EndBlocks.BUBBLE_CORAL, 3), 4); + public static final EndFeature BUBBLE_CORAL = new EndFeature("bubble_coral", + new UnderwaterPlantFeature(EndBlocks.BUBBLE_CORAL, 6), 10); + public static final EndFeature BUBBLE_CORAL_RARE = new EndFeature("bubble_coral_rare", + new UnderwaterPlantFeature(EndBlocks.BUBBLE_CORAL, 3), 4); public static final EndFeature END_LILY = new EndFeature("end_lily", new EndLilyFeature(6), 10); public static final EndFeature END_LILY_RARE = new EndFeature("end_lily_rare", new EndLilyFeature(3), 4); public static final EndFeature END_LOTUS = new EndFeature("end_lotus", new EndLotusFeature(7), 5); public static final EndFeature END_LOTUS_LEAF = new EndFeature("end_lotus_leaf", new EndLotusLeafFeature(20), 25); public static final EndFeature HYDRALUX = new EndFeature("hydralux", new HydraluxFeature(5), 5); - public static final EndFeature POND_ANEMONE = new EndFeature("pond_anemone", new UnderwaterPlantFeature(EndBlocks.POND_ANEMONE, 6), 10); - - public static final EndFeature CHARNIA_RED = new EndFeature("charnia_red", new CharniaFeature(EndBlocks.CHARNIA_RED), 10); - public static final EndFeature CHARNIA_PURPLE = new EndFeature("charnia_purple", new CharniaFeature(EndBlocks.CHARNIA_PURPLE), 10); - public static final EndFeature CHARNIA_CYAN = new EndFeature("charnia_cyan", new CharniaFeature(EndBlocks.CHARNIA_CYAN), 10); - public static final EndFeature CHARNIA_LIGHT_BLUE = new EndFeature("charnia_light_blue", new CharniaFeature(EndBlocks.CHARNIA_LIGHT_BLUE), 10); - public static final EndFeature CHARNIA_ORANGE = new EndFeature("charnia_orange", new CharniaFeature(EndBlocks.CHARNIA_ORANGE), 10); - public static final EndFeature CHARNIA_GREEN = new EndFeature("charnia_green", new CharniaFeature(EndBlocks.CHARNIA_GREEN), 10); + public static final EndFeature POND_ANEMONE = new EndFeature("pond_anemone", + new UnderwaterPlantFeature(EndBlocks.POND_ANEMONE, 6), 10); + + public static final EndFeature CHARNIA_RED = new EndFeature("charnia_red", + new CharniaFeature(EndBlocks.CHARNIA_RED), 10); + public static final EndFeature CHARNIA_PURPLE = new EndFeature("charnia_purple", + new CharniaFeature(EndBlocks.CHARNIA_PURPLE), 10); + public static final EndFeature CHARNIA_CYAN = new EndFeature("charnia_cyan", + new CharniaFeature(EndBlocks.CHARNIA_CYAN), 10); + public static final EndFeature CHARNIA_LIGHT_BLUE = new EndFeature("charnia_light_blue", + new CharniaFeature(EndBlocks.CHARNIA_LIGHT_BLUE), 10); + public static final EndFeature CHARNIA_ORANGE = new EndFeature("charnia_orange", + new CharniaFeature(EndBlocks.CHARNIA_ORANGE), 10); + public static final EndFeature CHARNIA_GREEN = new EndFeature("charnia_green", + new CharniaFeature(EndBlocks.CHARNIA_GREEN), 10); public static final EndFeature MENGER_SPONGE = new EndFeature("menger_sponge", new MengerSpongeFeature(5), 1); - public static final EndFeature CHARNIA_RED_RARE = new EndFeature("charnia_red_rare", new CharniaFeature(EndBlocks.CHARNIA_RED), 2); - public static final EndFeature BIOME_ISLAND = EndFeature.makeFeatureConfigured("overworld_island", new BiomeIslandFeature()); - public static final EndFeature FLAMAEA = new EndFeature("flamaea", new SinglePlantFeature(EndBlocks.FLAMAEA, 12, false, 5), 20); - + public static final EndFeature CHARNIA_RED_RARE = new EndFeature("charnia_red_rare", + new CharniaFeature(EndBlocks.CHARNIA_RED), 2); + public static final EndFeature BIOME_ISLAND = EndFeature.makeFeatureConfigured("overworld_island", + new BiomeIslandFeature()); + public static final EndFeature FLAMAEA = new EndFeature("flamaea", + new SinglePlantFeature(EndBlocks.FLAMAEA, 12, false, 5), 20); + // Terrain // public static final EndFeature END_LAKE = EndFeature.makeLakeFeature("end_lake", new EndLakeFeature(), 4); - public static final EndFeature END_LAKE_NORMAL = EndFeature.makeLakeFeature("end_lake_normal", new EndLakeFeature(), 20); - public static final EndFeature END_LAKE_RARE = EndFeature.makeLakeFeature("end_lake_rare", new EndLakeFeature(), 40); + public static final EndFeature END_LAKE_NORMAL = EndFeature.makeLakeFeature("end_lake_normal", new EndLakeFeature(), + 20); + public static final EndFeature END_LAKE_RARE = EndFeature.makeLakeFeature("end_lake_rare", new EndLakeFeature(), + 40); public static final EndFeature ROUND_CAVE = EndFeature.makeRawGenFeature("round_cave", new RoundCaveFeature(), 2); public static final EndFeature SPIRE = EndFeature.makeRawGenFeature("spire", new SpireFeature(), 2); - public static final EndFeature FLOATING_SPIRE = EndFeature.makeRawGenFeature("floating_spire", new FloatingSpireFeature(), 8); + public static final EndFeature FLOATING_SPIRE = EndFeature.makeRawGenFeature("floating_spire", + new FloatingSpireFeature(), 8); public static final EndFeature GEYSER = EndFeature.makeRawGenFeature("geyser", new GeyserFeature(), 8); - public static final EndFeature SULPHURIC_LAKE = EndFeature.makeLakeFeature("sulphuric_lake", new SulphuricLakeFeature(), 8); - public static final EndFeature SULPHURIC_CAVE = EndFeature.makeCountRawFeature("sulphuric_cave", new SulphuricCaveFeature(), 2); - public static final EndFeature ICE_STAR = EndFeature.makeRawGenFeature("ice_star", new IceStarFeature(5, 15, 10, 25), 15); - public static final EndFeature ICE_STAR_SMALL = EndFeature.makeRawGenFeature("ice_star_small", new IceStarFeature(3, 5, 7, 12), 8); - public static final EndFeature SURFACE_VENT = EndFeature.makeChansedFeature("surface_vent", new SurfaceVentFeature(), 4); - public static final EndFeature SULPHUR_HILL = EndFeature.makeChansedFeature("sulphur_hill", new SulphurHillFeature(), 8); - public static final EndFeature OBSIDIAN_PILLAR_BASEMENT = EndFeature.makeChansedFeature("obsidian_pillar_basement", new ObsidianPillarBasementFeature(), 8); - public static final EndFeature OBSIDIAN_BOULDER = EndFeature.makeChansedFeature("obsidian_boulder", new ObsidianBoulderFeature(), 10); - public static final EndFeature FALLEN_PILLAR = EndFeature.makeChansedFeature("fallen_pillar", new FallenPillarFeature(), 20); + public static final EndFeature SULPHURIC_LAKE = EndFeature.makeLakeFeature("sulphuric_lake", + new SulphuricLakeFeature(), 8); + public static final EndFeature SULPHURIC_CAVE = EndFeature.makeCountRawFeature("sulphuric_cave", + new SulphuricCaveFeature(), 2); + public static final EndFeature ICE_STAR = EndFeature.makeRawGenFeature("ice_star", + new IceStarFeature(5, 15, 10, 25), 15); + public static final EndFeature ICE_STAR_SMALL = EndFeature.makeRawGenFeature("ice_star_small", + new IceStarFeature(3, 5, 7, 12), 8); + public static final EndFeature SURFACE_VENT = EndFeature.makeChansedFeature("surface_vent", + new SurfaceVentFeature(), 4); + public static final EndFeature SULPHUR_HILL = EndFeature.makeChansedFeature("sulphur_hill", + new SulphurHillFeature(), 8); + public static final EndFeature OBSIDIAN_PILLAR_BASEMENT = EndFeature.makeChansedFeature("obsidian_pillar_basement", + new ObsidianPillarBasementFeature(), 8); + public static final EndFeature OBSIDIAN_BOULDER = EndFeature.makeChansedFeature("obsidian_boulder", + new ObsidianBoulderFeature(), 10); + public static final EndFeature FALLEN_PILLAR = EndFeature.makeChansedFeature("fallen_pillar", + new FallenPillarFeature(), 20); public static final EndFeature TUNEL_CAVE = EndFeature.makeRawGenFeature("tunel_cave", new TunelCaveFeature(), 2); - + // Ores // - public static final EndFeature THALLASIUM_ORE = EndFeature.makeOreFeature("thallasium_ore", EndBlocks.THALLASIUM.ore, 12, 6, 0, 16, 128); - public static final EndFeature ENDER_ORE = EndFeature.makeOreFeature("ender_ore", EndBlocks.ENDER_ORE, 8, 3, 0, 16, 128); - public static final EndFeature AMBER_ORE = EndFeature.makeOreFeature("amber_ore", EndBlocks.AMBER_ORE, 12, 6, 0, 16, 128); - public static final EndFeature VIOLECITE_LAYER = EndFeature.makeLayerFeature("violecite_layer", EndBlocks.VIOLECITE, 15, 16, 128, 8); - public static final EndFeature FLAVOLITE_LAYER = EndFeature.makeLayerFeature("flavolite_layer", EndBlocks.FLAVOLITE, 12, 16, 128, 6); - + public static final EndFeature THALLASIUM_ORE = EndFeature.makeOreFeature("thallasium_ore", + EndBlocks.THALLASIUM.ore, 12, 6, 0, 16, 128); + public static final EndFeature ENDER_ORE = EndFeature.makeOreFeature("ender_ore", EndBlocks.ENDER_ORE, 8, 3, 0, 16, + 128); + public static final EndFeature AMBER_ORE = EndFeature.makeOreFeature("amber_ore", EndBlocks.AMBER_ORE, 12, 6, 0, 16, + 128); + public static final EndFeature VIOLECITE_LAYER = EndFeature.makeLayerFeature("violecite_layer", EndBlocks.VIOLECITE, + 15, 16, 128, 8); + public static final EndFeature FLAVOLITE_LAYER = EndFeature.makeLayerFeature("flavolite_layer", EndBlocks.FLAVOLITE, + 12, 16, 128, 6); + // Buildings - public static final EndFeature CRASHED_SHIP = EndFeature.makeChansedFeature("crashed_ship", new CrashedShipFeature(), 500); - + public static final EndFeature CRASHED_SHIP = EndFeature.makeChansedFeature("crashed_ship", + new CrashedShipFeature(), 500); + // Mobs - public static final EndFeature SILK_MOTH_NEST = EndFeature.makeChansedFeature("silk_moth_nest", new SilkMothNestFeature(), 2); - + public static final EndFeature SILK_MOTH_NEST = EndFeature.makeChansedFeature("silk_moth_nest", + new SilkMothNestFeature(), 2); + // Caves public static final DefaultFeature SMARAGDANT_CRYSTAL = new SmaragdantCrystalFeature(); - public static final DefaultFeature SMARAGDANT_CRYSTAL_SHARD = new SingleBlockFeature(EndBlocks.SMARAGDANT_CRYSTAL_SHARD); + public static final DefaultFeature SMARAGDANT_CRYSTAL_SHARD = new SingleBlockFeature( + EndBlocks.SMARAGDANT_CRYSTAL_SHARD); public static final DefaultFeature BIG_AURORA_CRYSTAL = new BigAuroraCrystalFeature(); public static final DefaultFeature CAVE_BUSH = new BushFeature(EndBlocks.CAVE_BUSH, EndBlocks.CAVE_BUSH); public static final DefaultFeature CAVE_GRASS = new SingleBlockFeature(EndBlocks.CAVE_GRASS); public static final DefaultFeature RUBINEA = new VineFeature(EndBlocks.RUBINEA, 8); public static final DefaultFeature MAGNULA = new VineFeature(EndBlocks.MAGNULA, 8); - public static final DefaultFeature END_STONE_STALACTITE = new StalactiteFeature(true, EndBlocks.END_STONE_STALACTITE, Blocks.END_STONE); - public static final DefaultFeature END_STONE_STALAGMITE = new StalactiteFeature(false, EndBlocks.END_STONE_STALACTITE, Blocks.END_STONE); - public static final DefaultFeature END_STONE_STALACTITE_CAVEMOSS = new StalactiteFeature(true, EndBlocks.END_STONE_STALACTITE_CAVEMOSS, Blocks.END_STONE, EndBlocks.CAVE_MOSS); - public static final DefaultFeature END_STONE_STALAGMITE_CAVEMOSS = new StalactiteFeature(false, EndBlocks.END_STONE_STALACTITE_CAVEMOSS, EndBlocks.CAVE_MOSS); + public static final DefaultFeature END_STONE_STALACTITE = new StalactiteFeature(true, + EndBlocks.END_STONE_STALACTITE, Blocks.END_STONE); + public static final DefaultFeature END_STONE_STALAGMITE = new StalactiteFeature(false, + EndBlocks.END_STONE_STALACTITE, Blocks.END_STONE); + public static final DefaultFeature END_STONE_STALACTITE_CAVEMOSS = new StalactiteFeature(true, + EndBlocks.END_STONE_STALACTITE_CAVEMOSS, Blocks.END_STONE, EndBlocks.CAVE_MOSS); + public static final DefaultFeature END_STONE_STALAGMITE_CAVEMOSS = new StalactiteFeature(false, + EndBlocks.END_STONE_STALACTITE_CAVEMOSS, EndBlocks.CAVE_MOSS); public static final DefaultFeature CAVE_PUMPKIN = new CavePumpkinFeature(); - - public static void registerBiomeFeatures(Identifier id, Biome biome, List>>> features) { + + public static void registerBiomeFeatures(ResourceLocation id, Biome biome, + List>>> features) { if (id.getNamespace().equals(BetterEnd.MOD_ID)) { return; } - + if (GeneratorOptions.removeChorusFromVanillaBiomes()) { if (id.getNamespace().equals("minecraft")) { String path = id.getPath(); @@ -248,44 +341,43 @@ public class EndFeatures { } } } - + addFeature(FLAVOLITE_LAYER, features); addFeature(THALLASIUM_ORE, features); addFeature(ENDER_ORE, features); addFeature(CRASHED_SHIP, features); - + if (EndBiomes.getBiome(id).hasCaves()) { addFeature(ROUND_CAVE, features); addFeature(TUNEL_CAVE, features); } - + EndBiome endBiome = EndBiomes.getBiome(id); EndFeature feature = endBiome.getStructuresFeature(); if (feature != null) { addFeature(feature, features); } } - + public static void addDefaultFeatures(BiomeDefinition def) { def.addFeature(FLAVOLITE_LAYER); def.addFeature(THALLASIUM_ORE); def.addFeature(ENDER_ORE); def.addFeature(CRASHED_SHIP); - + if (def.hasCaves()) { def.addFeature(ROUND_CAVE); def.addFeature(TUNEL_CAVE); } } - + private static void addFeature(EndFeature feature, List>>> features) { int index = feature.getFeatureStep().ordinal(); if (features.size() > index) { features.get(index).add(() -> { return feature.getFeatureConfigured(); }); - } - else { + } else { List>> newFeature = Lists.newArrayList(); newFeature.add(() -> { return feature.getFeatureConfigured(); @@ -293,6 +385,7 @@ public class EndFeatures { features.add(newFeature); } } - - public static void register() {} + + public static void register() { + } } diff --git a/src/main/java/ru/betterend/registry/EndItems.java b/src/main/java/ru/betterend/registry/EndItems.java index 4e3dc6f3..fc5efa72 100644 --- a/src/main/java/ru/betterend/registry/EndItems.java +++ b/src/main/java/ru/betterend/registry/EndItems.java @@ -5,34 +5,27 @@ import java.util.List; import com.google.common.collect.Lists; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.DispenserBlock; -import net.minecraft.block.dispenser.ItemDispenserBehavior; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.*; +import net.minecraft.world.level.block.DispenserBlock; +import net.minecraft.world.level.block.dispenser.ItemDispenserBehavior; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.SpawnReason; +import net.minecraft.world.entity.effect.StatusEffectInstance; +import net.minecraft.world.entity.effect.StatusEffects; import net.minecraft.fluid.Fluids; -import net.minecraft.item.ArmorItem; -import net.minecraft.item.FishBucketItem; -import net.minecraft.item.FoodComponent; -import net.minecraft.item.FoodComponents; -import net.minecraft.item.Item; -import net.minecraft.item.Item.Settings; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.ShovelItem; -import net.minecraft.item.SpawnEggItem; -import net.minecraft.item.SwordItem; -import net.minecraft.item.ToolItem; -import net.minecraft.item.ToolMaterials; +import net.minecraft.world.item.FoodComponent; +import net.minecraft.world.item.FoodComponents; +import net.minecraft.world.item.Item.Properties; +import net.minecraft.world.item.ToolItem; +import net.minecraft.world.item.ToolMaterials; import net.minecraft.sound.SoundEvent; -import net.minecraft.tag.Tag; -import net.minecraft.util.Identifier; -import net.minecraft.util.Rarity; +import net.minecraft.tags.Tag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Rarity; import net.minecraft.util.math.BlockPointer; -import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Direction; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; import ru.betterend.config.Configs; import ru.betterend.item.DrinkItem; @@ -56,7 +49,7 @@ import ru.betterend.util.TagHelper; public class EndItems { private static final List MOD_BLOCKS = Lists.newArrayList(); private static final List MOD_ITEMS = Lists.newArrayList(); - + // Materials // public final static Item ENDER_DUST = registerItem("ender_dust"); public final static Item ENDER_SHARD = registerItem("ender_shard"); @@ -77,28 +70,43 @@ public class EndItems { public final static Item SILK_FIBER = registerItem("silk_fiber"); public final static Item LUMECORN_ROD = registerItem("lumecorn_rod"); public final static Item SILK_MOTH_MATRIX = registerItem("silk_moth_matrix"); - + // Music Discs - public final static Item MUSIC_DISC_STRANGE_AND_ALIEN = registerDisc("music_disc_strange_and_alien", 0, EndSounds.STRANGE_AND_ALIEN); - + public final static Item MUSIC_DISC_STRANGE_AND_ALIEN = registerDisc("music_disc_strange_and_alien", 0, + EndSounds.STRANGE_AND_ALIEN); + // Armor // - public static final Item AETERNIUM_HELMET = registerItem("aeternium_helmet", new EndArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.HEAD, makeItemSettings().fireproof())); - public static final Item AETERNIUM_CHESTPLATE = registerItem("aeternium_chestplate", new EndArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.CHEST, makeItemSettings().fireproof())); - public static final Item AETERNIUM_LEGGINGS = registerItem("aeternium_leggings", new EndArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.LEGS, makeItemSettings().fireproof())); - public static final Item AETERNIUM_BOOTS = registerItem("aeternium_boots", new EndArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.FEET, makeItemSettings().fireproof())); - public static final Item CRYSTALITE_HELMET = registerItem("crystalite_helmet", new EndArmorItem(EndArmorMaterial.CRYSTALITE, EquipmentSlot.HEAD, makeItemSettings().rarity(Rarity.UNCOMMON))); - public static final Item CRYSTALITE_CHESTPLATE = registerItem("crystalite_chestplate", new EndArmorItem(EndArmorMaterial.CRYSTALITE, EquipmentSlot.CHEST, makeItemSettings().rarity(Rarity.UNCOMMON))); - public static final Item CRYSTALITE_LEGGINGS = registerItem("crystalite_leggings", new EndArmorItem(EndArmorMaterial.CRYSTALITE, EquipmentSlot.LEGS, makeItemSettings().rarity(Rarity.UNCOMMON))); - public static final Item CRYSTALITE_BOOTS = registerItem("crystalite_boots", new EndArmorItem(EndArmorMaterial.CRYSTALITE, EquipmentSlot.FEET, makeItemSettings().rarity(Rarity.UNCOMMON))); - + public static final Item AETERNIUM_HELMET = registerItem("aeternium_helmet", + new EndArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.HEAD, makeItemSettings().fireResistant())); + public static final Item AETERNIUM_CHESTPLATE = registerItem("aeternium_chestplate", + new EndArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.CHEST, makeItemSettings().fireResistant())); + public static final Item AETERNIUM_LEGGINGS = registerItem("aeternium_leggings", + new EndArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.LEGS, makeItemSettings().fireResistant())); + public static final Item AETERNIUM_BOOTS = registerItem("aeternium_boots", + new EndArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.FEET, makeItemSettings().fireResistant())); + public static final Item CRYSTALITE_HELMET = registerItem("crystalite_helmet", new EndArmorItem( + EndArmorMaterial.CRYSTALITE, EquipmentSlot.HEAD, makeItemSettings().rarity(Rarity.UNCOMMON))); + public static final Item CRYSTALITE_CHESTPLATE = registerItem("crystalite_chestplate", new EndArmorItem( + EndArmorMaterial.CRYSTALITE, EquipmentSlot.CHEST, makeItemSettings().rarity(Rarity.UNCOMMON))); + public static final Item CRYSTALITE_LEGGINGS = registerItem("crystalite_leggings", new EndArmorItem( + EndArmorMaterial.CRYSTALITE, EquipmentSlot.LEGS, makeItemSettings().rarity(Rarity.UNCOMMON))); + public static final Item CRYSTALITE_BOOTS = registerItem("crystalite_boots", new EndArmorItem( + EndArmorMaterial.CRYSTALITE, EquipmentSlot.FEET, makeItemSettings().rarity(Rarity.UNCOMMON))); + // Tools // - public static final ToolItem AETERNIUM_SHOVEL = registerTool("aeternium_shovel", new EndShovelItem(EndToolMaterial.AETERNIUM, 1.5F, -3.0F, makeItemSettings().fireproof())); - public static final ToolItem AETERNIUM_SWORD = registerTool("aeternium_sword", new EndSwordItem(EndToolMaterial.AETERNIUM, 3, -2.4F, makeItemSettings().fireproof())); - public static final ToolItem AETERNIUM_PICKAXE = registerTool("aeternium_pickaxe", new EndPickaxeItem(EndToolMaterial.AETERNIUM, 1, -2.8F, makeItemSettings().fireproof())); - public static final ToolItem AETERNIUM_AXE = registerTool("aeternium_axe", new EndAxeItem(EndToolMaterial.AETERNIUM, 5.0F, -3.0F, makeItemSettings().fireproof())); - public static final ToolItem AETERNIUM_HOE = registerTool("aeternium_hoe", new EndHoeItem(EndToolMaterial.AETERNIUM, -3, 0.0F, makeItemSettings().fireproof())); - public static final ToolItem AETERNIUM_HAMMER = registerTool("aeternium_hammer", new EndHammerItem(EndToolMaterial.AETERNIUM, 6.0F, -3.0F, 0.3D, makeItemSettings().fireproof())); - + public static final ToolItem AETERNIUM_SHOVEL = registerTool("aeternium_shovel", + new EndShovelItem(EndToolMaterial.AETERNIUM, 1.5F, -3.0F, makeItemSettings().fireResistant())); + public static final ToolItem AETERNIUM_SWORD = registerTool("aeternium_sword", + new EndSwordItem(EndToolMaterial.AETERNIUM, 3, -2.4F, makeItemSettings().fireResistant())); + public static final ToolItem AETERNIUM_PICKAXE = registerTool("aeternium_pickaxe", + new EndPickaxeItem(EndToolMaterial.AETERNIUM, 1, -2.8F, makeItemSettings().fireResistant())); + public static final ToolItem AETERNIUM_AXE = registerTool("aeternium_axe", + new EndAxeItem(EndToolMaterial.AETERNIUM, 5.0F, -3.0F, makeItemSettings().fireResistant())); + public static final ToolItem AETERNIUM_HOE = registerTool("aeternium_hoe", + new EndHoeItem(EndToolMaterial.AETERNIUM, -3, 0.0F, makeItemSettings().fireResistant())); + public static final ToolItem AETERNIUM_HAMMER = registerTool("aeternium_hammer", + new EndHammerItem(EndToolMaterial.AETERNIUM, 6.0F, -3.0F, 0.3D, makeItemSettings().fireResistant())); + // Toolparts // public final static Item AETERNIUM_SHOVEL_HEAD = registerItem("aeternium_shovel_head"); public final static Item AETERNIUM_PICKAXE_HEAD = registerItem("aeternium_pickaxe_head"); @@ -109,42 +117,50 @@ public class EndItems { public final static Item AETERNIUM_SWORD_HANDLE = registerItem("aeternium_sword_handle"); // Hammers // - public static final ToolItem IRON_HAMMER = registerTool("iron_hammer", new EndHammerItem(ToolMaterials.IRON, 5.0F, -3.2F, 0.2D, makeItemSettings())); - public static final ToolItem GOLDEN_HAMMER = registerTool("golden_hammer", new EndHammerItem(ToolMaterials.GOLD, 4.5F, -3.4F, 0.3D, makeItemSettings())); - public static final ToolItem DIAMOND_HAMMER = registerTool("diamond_hammer", new EndHammerItem(ToolMaterials.DIAMOND, 5.5F, -3.1F, 0.2D, makeItemSettings())); - public static final ToolItem NETHERITE_HAMMER = registerTool("netherite_hammer", new EndHammerItem(ToolMaterials.NETHERITE, 5.0F, -3.0F, 0.2D, makeItemSettings().fireproof())); - + public static final ToolItem IRON_HAMMER = registerTool("iron_hammer", + new EndHammerItem(ToolMaterials.IRON, 5.0F, -3.2F, 0.2D, makeItemSettings())); + public static final ToolItem GOLDEN_HAMMER = registerTool("golden_hammer", + new EndHammerItem(ToolMaterials.GOLD, 4.5F, -3.4F, 0.3D, makeItemSettings())); + public static final ToolItem DIAMOND_HAMMER = registerTool("diamond_hammer", + new EndHammerItem(ToolMaterials.DIAMOND, 5.5F, -3.1F, 0.2D, makeItemSettings())); + public static final ToolItem NETHERITE_HAMMER = registerTool("netherite_hammer", + new EndHammerItem(ToolMaterials.NETHERITE, 5.0F, -3.0F, 0.2D, makeItemSettings().fireResistant())); + // Food // public final static Item SHADOW_BERRY_RAW = registerFood("shadow_berry_raw", 4, 0.5F); public final static Item SHADOW_BERRY_COOKED = registerFood("shadow_berry_cooked", 6, 0.7F); public final static Item END_FISH_RAW = registerFood("end_fish_raw", FoodComponents.SALMON); public final static Item END_FISH_COOKED = registerFood("end_fish_cooked", FoodComponents.COOKED_SALMON); - public final static Item BUCKET_END_FISH = registerItem("bucket_end_fish", new FishBucketItem(EndEntities.END_FISH, Fluids.WATER, makeItemSettings().maxCount(1))); + public final static Item BUCKET_END_FISH = registerItem("bucket_end_fish", + new FishBucketItem(EndEntities.END_FISH, Fluids.WATER, makeItemSettings().maxCount(1))); public final static Item SWEET_BERRY_JELLY = registerFood("sweet_berry_jelly", 6, 0.75F); - public final static Item SHADOW_BERRY_JELLY = registerFood("shadow_berry_jelly", 7, 0.75F, new StatusEffectInstance(StatusEffects.NIGHT_VISION, 400)); + public final static Item SHADOW_BERRY_JELLY = registerFood("shadow_berry_jelly", 7, 0.75F, + new StatusEffectInstance(StatusEffects.NIGHT_VISION, 400)); public final static Item BLOSSOM_BERRY = registerFood("blossom_berry", FoodComponents.APPLE); public final static Item AMBER_ROOT_RAW = registerFood("amber_root_raw", 2, 0.8F); public final static Item CHORUS_MUSHROOM_RAW = registerFood("chorus_mushroom_raw", 3, 0.5F); - public final static Item CHORUS_MUSHROOM_COOKED = registerFood("chorus_mushroom_cooked", FoodComponents.MUSHROOM_STEW); - public final static Item BOLUX_MUSHROOM_COOKED = registerFood("bolux_mushroom_cooked", FoodComponents.MUSHROOM_STEW); + public final static Item CHORUS_MUSHROOM_COOKED = registerFood("chorus_mushroom_cooked", + FoodComponents.MUSHROOM_STEW); + public final static Item BOLUX_MUSHROOM_COOKED = registerFood("bolux_mushroom_cooked", + FoodComponents.MUSHROOM_STEW); public final static Item CAVE_PUMPKIN_PIE = registerFood("cave_pumpkin_pie", FoodComponents.PUMPKIN_PIE); - + // Drinks // public final static Item UMBRELLA_CLUSTER_JUICE = registerDrink("umbrella_cluster_juice", 5, 0.7F); - + public static Item registerDisc(String name, int power, SoundEvent sound) { return registerItem(BetterEnd.makeID(name), new PatternedDiscItem(power, sound, makeItemSettings())); } - + public static Item registerItem(String name) { return registerItem(BetterEnd.makeID(name), new PatternedItem(makeItemSettings())); } - + public static Item registerItem(String name, Item item) { return registerItem(BetterEnd.makeID(name), item); } - - public static Item registerItem(Identifier id, Item item) { + + public static Item registerItem(ResourceLocation id, Item item) { if (item instanceof ArmorItem) { return registerArmor(id, item); } @@ -154,34 +170,34 @@ public class EndItems { registerItem(id, item, MOD_ITEMS); return item; } - - public static Item registerBlockItem(Identifier id, Item item) { + + public static Item registerBlockItem(ResourceLocation id, Item item) { registerItem(id, item, MOD_BLOCKS); return item; } - - private static void registerItem(Identifier id, Item item, List registry) { + + private static void registerItem(ResourceLocation id, Item item, List registry) { if (item != Items.AIR) { Registry.register(Registry.ITEM, id, item); registry.add(item); } } - - private static Item registerArmor(Identifier id, Item item) { + + private static Item registerArmor(ResourceLocation id, Item item) { if (!Configs.ITEM_CONFIG.getBoolean("armor", id.getPath(), true)) { return item; } registerItem(id, item, MOD_ITEMS); return item; } - + public static ToolItem registerTool(String name, ToolItem item) { - Identifier id = BetterEnd.makeID(name); + ResourceLocation id = BetterEnd.makeID(name); if (!Configs.ITEM_CONFIG.getBoolean("tools", id.getPath(), true)) { return item; } registerItem(id, item, MOD_ITEMS); - + if (item instanceof ShovelItem) { TagHelper.addTag((Tag.Identified) FabricToolTags.SHOVELS, item); } else if (item instanceof SwordItem) { @@ -195,17 +211,18 @@ public class EndItems { } else if (item instanceof EndHammerItem) { TagHelper.addTag((Tag.Identified) EndTags.HAMMERS, item); } - + return item; } - + public static Item registerEgg(String name, EntityType type, int background, int dots) { SpawnEggItem item = new EndSpawnEggItem(type, background, dots, makeItemSettings()); ItemDispenserBehavior behavior = new ItemDispenserBehavior() { public ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) { Direction direction = pointer.getBlockState().get(DispenserBlock.FACING); EntityType entityType = ((SpawnEggItem) stack.getItem()).getEntityType(stack.getTag()); - entityType.spawnFromItemStack(pointer.getWorld(), stack, null, pointer.getBlockPos().offset(direction), SpawnReason.DISPENSER, direction != Direction.UP, false); + entityType.spawnFromItemStack(pointer.getLevel(), stack, null, pointer.getBlockPos().offset(direction), + SpawnReason.DISPENSER, direction != Direction.UP, false); stack.decrement(1); return stack; } @@ -213,42 +230,43 @@ public class EndItems { DispenserBlock.registerBehavior(item, behavior); return registerItem(name, item); } - + public static Item registerFood(String name, int hunger, float saturation, StatusEffectInstance... effects) { FoodComponent.Builder builder = new FoodComponent.Builder().hunger(hunger).saturationModifier(saturation); - for (StatusEffectInstance effect: effects) { + for (StatusEffectInstance effect : effects) { builder.statusEffect(effect, 1F); } return registerFood(name, builder.build()); } - + public static Item registerFood(String name, FoodComponent foodComponent) { return registerItem(name, new PatternedItem(makeItemSettings().food(foodComponent))); } - + public static Item registerDrink(String name) { return registerItem(name, new DrinkItem(makeItemSettings().maxCount(1))); } - + public static Item registerDrink(String name, FoodComponent foodComponent) { return registerItem(name, new DrinkItem(makeItemSettings().maxCount(1).food(foodComponent))); } - + public static Item registerDrink(String name, int hunger, float saturation) { FoodComponent.Builder builder = new FoodComponent.Builder().hunger(hunger).saturationModifier(saturation); return registerDrink(name, builder.build()); } - public static Settings makeItemSettings() { - return new Item.Settings().group(CreativeTabs.TAB_ITEMS); - } - - public static Settings makeBlockItemSettings() { - return new Item.Settings().group(CreativeTabs.TAB_BLOCKS); + public static Properties makeItemSettings() { + return new Item.Properties().tab(CreativeTabs.TAB_ITEMS); + } + + public static Properties makeBlockItemSettings() { + return new Item.Properties().tab(CreativeTabs.TAB_BLOCKS); + } + + public static void register() { } - public static void register() {} - public static List getModBlocks() { return MOD_BLOCKS; } diff --git a/src/main/java/ru/betterend/registry/EndParticles.java b/src/main/java/ru/betterend/registry/EndParticles.java index ee8c6a2e..b08ef032 100644 --- a/src/main/java/ru/betterend/registry/EndParticles.java +++ b/src/main/java/ru/betterend/registry/EndParticles.java @@ -2,10 +2,10 @@ package ru.betterend.registry; import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes; -import net.minecraft.particle.DefaultParticleType; -import net.minecraft.particle.ParticleEffect; -import net.minecraft.particle.ParticleType; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; import ru.betterend.particle.FireflyParticle; import ru.betterend.particle.InfusionParticle; @@ -21,19 +21,20 @@ import ru.betterend.particle.PaticlePortalSphere; import ru.betterend.particle.SmaragdantParticle; public class EndParticles { - public static final DefaultParticleType GLOWING_SPHERE = register("glowing_sphere"); - public static final DefaultParticleType PORTAL_SPHERE = register("portal_sphere"); - public static final ParticleType INFUSION = register("infusion", FabricParticleTypes.complex(InfusionParticleType.PARAMETERS_FACTORY)); - public static final DefaultParticleType SULPHUR_PARTICLE = register("sulphur_particle"); - public static final DefaultParticleType GEYSER_PARTICLE = registerFar("geyser_particle"); - public static final DefaultParticleType SNOWFLAKE = register("snowflake"); - public static final DefaultParticleType AMBER_SPHERE = register("amber_sphere"); - public static final DefaultParticleType BLACK_SPORE = register("black_spore"); - public static final DefaultParticleType TENANEA_PETAL = register("tenanea_petal"); - public static final DefaultParticleType JUNGLE_SPORE = register("jungle_spore"); - public static final DefaultParticleType FIREFLY = register("firefly"); - public static final DefaultParticleType SMARAGDANT = register("smaragdant_particle"); - + public static final SimpleParticleType GLOWING_SPHERE = register("glowing_sphere"); + public static final SimpleParticleType PORTAL_SPHERE = register("portal_sphere"); + public static final ParticleType INFUSION = register("infusion", + FabricParticleTypes.complex(InfusionParticleType.PARAMETERS_FACTORY)); + public static final SimpleParticleType SULPHUR_PARTICLE = register("sulphur_particle"); + public static final SimpleParticleType GEYSER_PARTICLE = registerFar("geyser_particle"); + public static final SimpleParticleType SNOWFLAKE = register("snowflake"); + public static final SimpleParticleType AMBER_SPHERE = register("amber_sphere"); + public static final SimpleParticleType BLACK_SPORE = register("black_spore"); + public static final SimpleParticleType TENANEA_PETAL = register("tenanea_petal"); + public static final SimpleParticleType JUNGLE_SPORE = register("jungle_spore"); + public static final SimpleParticleType FIREFLY = register("firefly"); + public static final SimpleParticleType SMARAGDANT = register("smaragdant_particle"); + public static void register() { ParticleFactoryRegistry.getInstance().register(GLOWING_SPHERE, ParticleGlowingSphere.FactoryGlowingSphere::new); ParticleFactoryRegistry.getInstance().register(PORTAL_SPHERE, PaticlePortalSphere.FactoryPortalSphere::new); @@ -48,16 +49,16 @@ public class EndParticles { ParticleFactoryRegistry.getInstance().register(FIREFLY, FireflyParticle.FireflyParticleFactory::new); ParticleFactoryRegistry.getInstance().register(SMARAGDANT, SmaragdantParticle.SmaragdantParticleFactory::new); } - - private static DefaultParticleType register(String name) { + + private static SimpleParticleType register(String name) { return Registry.register(Registry.PARTICLE_TYPE, BetterEnd.makeID(name), FabricParticleTypes.simple()); } - - private static DefaultParticleType registerFar(String name) { + + private static SimpleParticleType registerFar(String name) { return Registry.register(Registry.PARTICLE_TYPE, BetterEnd.makeID(name), FabricParticleTypes.simple(true)); } - - private static ParticleType register(String name, ParticleType type) { + + private static ParticleType register(String name, ParticleType type) { return Registry.register(Registry.PARTICLE_TYPE, BetterEnd.makeID(name), type); } } diff --git a/src/main/java/ru/betterend/registry/EndPortals.java b/src/main/java/ru/betterend/registry/EndPortals.java index b75f1676..1e7cce4b 100644 --- a/src/main/java/ru/betterend/registry/EndPortals.java +++ b/src/main/java/ru/betterend/registry/EndPortals.java @@ -6,9 +6,9 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.Identifier; -import net.minecraft.world.World; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; import ru.betterend.BetterEnd; import ru.betterend.config.ConfigWriter; import ru.betterend.util.JsonFactory; @@ -16,10 +16,10 @@ import ru.betterend.util.MHelper; public class EndPortals { - public final static Identifier OVERWORLD_ID = World.OVERWORLD.getValue(); + public final static ResourceLocation OVERWORLD_ID = Level.OVERWORLD.getValue(); private static PortalInfo[] portals; - + public static void loadPortals() { File file = new File(ConfigWriter.MOD_CONFIG_DIR, "portals.json"); JsonObject json; @@ -42,26 +42,26 @@ public class EndPortals { portals[i] = new PortalInfo(array.get(i).getAsJsonObject()); } } - + public static int getCount() { return MHelper.max(portals.length - 1, 1); } - - public static ServerWorld getWorld(MinecraftServer server, int portalId) { + + public static ServerLevel getLevel(MinecraftServer server, int portalId) { if (portalId < 0 || portalId >= portals.length) { return server.getOverworld(); } - return portals[portalId].getWorld(server); + return portals[portalId].getLevel(server); } - public static Identifier getWorldId(int portalId) { + public static ResourceLocation getWorldId(int portalId) { if (portalId < 0 || portalId >= portals.length) { return OVERWORLD_ID; } return portals[portalId].dimension; } - - public static int getPortalIdByItem(Identifier item) { + + public static int getPortalIdByItem(ResourceLocation item) { for (int i = 0; i < portals.length; i++) { if (portals[i].item.equals(item)) { return i; @@ -69,7 +69,8 @@ public class EndPortals { } return 0; } - public static int getPortalIdByWorld(Identifier world) { + + public static int getPortalIdByWorld(ResourceLocation world) { for (int i = 0; i < portals.length; i++) { if (portals[i].dimension.equals(world)) { return i; @@ -77,12 +78,12 @@ public class EndPortals { } return 0; } - + public static int getColor(int state) { return portals[state].color; } - - public static boolean isAvailableItem(Identifier item) { + + public static boolean isAvailableItem(ResourceLocation item) { for (PortalInfo portal : portals) { if (portal.item.equals(item)) { return true; @@ -90,7 +91,7 @@ public class EndPortals { } return false; } - + private static JsonObject makeDefault(File file) { JsonObject jsonObject = new JsonObject(); JsonFactory.storeJson(file, jsonObject); @@ -100,46 +101,44 @@ public class EndPortals { JsonFactory.storeJson(file, jsonObject); return jsonObject; } - + private static PortalInfo makeDefault() { - return new PortalInfo(new Identifier("minecraft:overworld"), BetterEnd.makeID("eternal_crystal"), 255, 255, 255); + return new PortalInfo(new ResourceLocation("minecraft:overworld"), BetterEnd.makeID("eternal_crystal"), 255, + 255, 255); } - + private static class PortalInfo { - private final Identifier dimension; - private final Identifier item; + private final ResourceLocation dimension; + private final ResourceLocation item; private final int color; - private ServerWorld world; - + private ServerLevel world; + PortalInfo(JsonObject obj) { - this( - new Identifier(JsonFactory.getString(obj, "dimension", "minecraft:overworld")), - new Identifier(JsonFactory.getString(obj, "item", "betterend:eternal_crystal")), - JsonFactory.getInt(obj, "colorRed", 255), - JsonFactory.getInt(obj, "colorGreen", 255), - JsonFactory.getInt(obj, "colorBlue", 255) - ); + this(new ResourceLocation(JsonFactory.getString(obj, "dimension", "minecraft:overworld")), + new ResourceLocation(JsonFactory.getString(obj, "item", "betterend:eternal_crystal")), + JsonFactory.getInt(obj, "colorRed", 255), JsonFactory.getInt(obj, "colorGreen", 255), + JsonFactory.getInt(obj, "colorBlue", 255)); } - - PortalInfo(Identifier dimension, Identifier item, int r, int g, int b) { + + PortalInfo(ResourceLocation dimension, ResourceLocation item, int r, int g, int b) { this.dimension = dimension; this.item = item; this.color = MHelper.color(r, g, b); } - - ServerWorld getWorld(MinecraftServer server) { + + ServerLevel getLevel(MinecraftServer server) { if (world != null) { return world; } - for (ServerWorld world : server.getWorlds()) { - if (world.getRegistryKey().getValue().equals(dimension)) { + for (ServerLevel world : server.getWorlds()) { + if (world.dimension().location().equals(dimension)) { this.world = world; return world; } } return server.getOverworld(); } - + JsonObject toJson() { JsonObject obj = new JsonObject(); obj.addProperty("dimension", dimension.toString()); diff --git a/src/main/java/ru/betterend/registry/EndSounds.java b/src/main/java/ru/betterend/registry/EndSounds.java index fe2e5c71..5acdda1a 100644 --- a/src/main/java/ru/betterend/registry/EndSounds.java +++ b/src/main/java/ru/betterend/registry/EndSounds.java @@ -1,7 +1,7 @@ package ru.betterend.registry; import net.minecraft.sound.SoundEvent; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; public class EndSounds { @@ -10,7 +10,7 @@ public class EndSounds { public static final SoundEvent MUSIC_WATER = register("music", "water"); public static final SoundEvent MUSIC_DARK = register("music", "dark"); public static final SoundEvent MUSIC_OPENSPACE = register("music", "openspace"); - + // Ambient public static final SoundEvent AMBIENT_FOGGY_MUSHROOMLAND = register("ambient", "foggy_mushroomland"); public static final SoundEvent AMBIENT_CHORUS_FOREST = register("ambient", "chorus_forest"); @@ -21,18 +21,19 @@ public class EndSounds { public static final SoundEvent AMBIENT_SULPHUR_SPRINGS = register("ambient", "sulphur_springs"); public static final SoundEvent AMBIENT_UMBRELLA_JUNGLE = register("ambient", "umbrella_jungle"); public static final SoundEvent AMBIENT_GLOWING_GRASSLANDS = register("ambient", "glowing_grasslands"); - + // Entity public static final SoundEvent ENTITY_DRAGONFLY = register("entity", "dragonfly"); public static final SoundEvent ENTITY_SHADOW_WALKER = register("entity", "shadow_walker"); public static final SoundEvent ENTITY_SHADOW_WALKER_DAMAGE = register("entity", "shadow_walker_damage"); public static final SoundEvent ENTITY_SHADOW_WALKER_DEATH = register("entity", "shadow_walker_death"); - + // Records public static final SoundEvent STRANGE_AND_ALIEN = register("record", "strange_and_alien"); - - public static void register() {} - + + public static void register() { + } + private static SoundEvent register(String type, String id) { id = "betterend." + type + "." + id; return Registry.register(Registry.SOUND_EVENT, id, new SoundEvent(BetterEnd.makeID(id))); diff --git a/src/main/java/ru/betterend/registry/EndStructures.java b/src/main/java/ru/betterend/registry/EndStructures.java index bc241280..aba3747f 100644 --- a/src/main/java/ru/betterend/registry/EndStructures.java +++ b/src/main/java/ru/betterend/registry/EndStructures.java @@ -4,8 +4,8 @@ import java.util.Collection; import java.util.function.Supplier; import net.minecraft.structure.StructurePieceType; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.GenerationStep.Feature; import net.minecraft.world.gen.feature.ConfiguredStructureFeature; @@ -30,30 +30,43 @@ public class EndStructures { public static final StructurePieceType MOUNTAIN_PIECE = register("mountain_piece", CrystalMountainPiece::new); public static final StructurePieceType CAVE_PIECE = register("cave_piece", CavePiece::new); public static final StructurePieceType LAKE_PIECE = register("lake_piece", LakePiece::new); - public static final StructurePieceType PAINTED_MOUNTAIN_PIECE = register("painted_mountain_piece", PaintedMountainPiece::new); + public static final StructurePieceType PAINTED_MOUNTAIN_PIECE = register("painted_mountain_piece", + PaintedMountainPiece::new); public static final StructurePieceType NBT_PIECE = register("nbt_piece", NBTPiece::new); - - public static final EndStructureFeature GIANT_MOSSY_GLOWSHROOM = new EndStructureFeature("giant_mossy_glowshroom", new GiantMossyGlowshroomStructure(), Feature.SURFACE_STRUCTURES, 16, 8); - public static final EndStructureFeature MEGALAKE = new EndStructureFeature("megalake", new MegaLakeStructure(), Feature.RAW_GENERATION, 4, 1); - public static final EndStructureFeature MEGALAKE_SMALL = new EndStructureFeature("megalake_small", new MegaLakeSmallStructure(), Feature.RAW_GENERATION, 4, 1); - public static final EndStructureFeature MOUNTAIN = new EndStructureFeature("mountain", new MountainStructure(), Feature.RAW_GENERATION, 3, 2); - public static final EndStructureFeature PAINTED_MOUNTAIN = new EndStructureFeature("painted_mountain", new PaintedMountainStructure(), Feature.RAW_GENERATION, 3, 2); - public static final EndStructureFeature ETERNAL_PORTAL = new EndStructureFeature("eternal_portal", new EternalPortalStructure(), Feature.SURFACE_STRUCTURES, 16, 6); - public static final EndStructureFeature GIANT_ICE_STAR = new EndStructureFeature("giant_ice_star", new GiantIceStarStructure(), Feature.SURFACE_STRUCTURES, 16, 8); - - public static void register() {} - + + public static final EndStructureFeature GIANT_MOSSY_GLOWSHROOM = new EndStructureFeature("giant_mossy_glowshroom", + new GiantMossyGlowshroomStructure(), Feature.SURFACE_STRUCTURES, 16, 8); + public static final EndStructureFeature MEGALAKE = new EndStructureFeature("megalake", new MegaLakeStructure(), + Feature.RAW_GENERATION, 4, 1); + public static final EndStructureFeature MEGALAKE_SMALL = new EndStructureFeature("megalake_small", + new MegaLakeSmallStructure(), Feature.RAW_GENERATION, 4, 1); + public static final EndStructureFeature MOUNTAIN = new EndStructureFeature("mountain", new MountainStructure(), + Feature.RAW_GENERATION, 3, 2); + public static final EndStructureFeature PAINTED_MOUNTAIN = new EndStructureFeature("painted_mountain", + new PaintedMountainStructure(), Feature.RAW_GENERATION, 3, 2); + public static final EndStructureFeature ETERNAL_PORTAL = new EndStructureFeature("eternal_portal", + new EternalPortalStructure(), Feature.SURFACE_STRUCTURES, 16, 6); + public static final EndStructureFeature GIANT_ICE_STAR = new EndStructureFeature("giant_ice_star", + new GiantIceStarStructure(), Feature.SURFACE_STRUCTURES, 16, 8); + + public static void register() { + } + private static StructurePieceType register(String id, StructurePieceType pieceType) { return Registry.register(Registry.STRUCTURE_PIECE, BetterEnd.makeID(id), pieceType); } - - public static void registerBiomeStructures(Identifier id, Biome biome, Collection>> structures) { + + public static void registerBiomeStructures(ResourceLocation id, Biome biome, + Collection>> structures) { if (!id.getPath().contains("mountain") && !id.getPath().contains("lake")) { addStructure(ETERNAL_PORTAL, structures); } } - - private static void addStructure(EndStructureFeature feature, Collection>> structures) { - structures.add(() -> { return feature.getFeatureConfigured(); }); + + private static void addStructure(EndStructureFeature feature, + Collection>> structures) { + structures.add(() -> { + return feature.getFeatureConfigured(); + }); } } diff --git a/src/main/java/ru/betterend/registry/EndTags.java b/src/main/java/ru/betterend/registry/EndTags.java index b2f5f6a2..1c6cd6e1 100644 --- a/src/main/java/ru/betterend/registry/EndTags.java +++ b/src/main/java/ru/betterend/registry/EndTags.java @@ -5,19 +5,19 @@ import java.util.Arrays; import net.fabricmc.fabric.api.tag.TagRegistry; import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl; import net.fabricmc.fabric.impl.tool.attribute.handlers.ModdedToolsVanillaBlocksToolHandler; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.Material; -import net.minecraft.item.BlockItem; -import net.minecraft.item.FoodComponent; -import net.minecraft.item.Item; -import net.minecraft.tag.BlockTags; -import net.minecraft.tag.ItemTags; -import net.minecraft.tag.Tag; -import net.minecraft.tag.Tag.Identified; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.FoodComponent; +import net.minecraft.world.item.Item; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.tags.Tag; +import net.minecraft.tags.Tag.Identified; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome.Category; import net.minecraft.world.gen.surfacebuilder.SurfaceConfig; @@ -32,7 +32,7 @@ import ru.betterend.util.TagHelper; public class EndTags { // Table with common (c) tags: // https://fabricmc.net/wiki/tutorial:tags - + // Block Tags public static final Tag.Identified BOOKSHELVES = makeCommonBlockTag("bookshelves"); public static final Tag.Identified GEN_TERRAIN = makeBlockTag("gen_terrain"); @@ -41,72 +41,69 @@ public class EndTags { public static final Tag.Identified BLOCK_CHEST = makeCommonBlockTag("chest"); public static final Tag.Identified END_STONES = makeCommonBlockTag("end_stones"); public static final Tag.Identified DRAGON_IMMUNE = getMCBlockTag("dragon_immune"); - + // Item Tags public static final Tag.Identified ITEM_CHEST = makeCommonItemTag("chest"); public static final Tag.Identified IRON_INGOTS = makeCommonItemTag("iron_ingots"); public static final Tag.Identified FURNACES = makeCommonItemTag("furnaces"); public final static Tag HAMMERS = registerFabricItemTag("hammers"); - + public static Tag.Identified makeBlockTag(String name) { - Identifier id = BetterEnd.makeID(name); + ResourceLocation id = BetterEnd.makeID(name); Tag tag = BlockTags.getTagGroup().getTag(id); return tag == null ? (Identified) TagRegistry.block(id) : (Identified) tag; } - + public static Tag.Identified makeItemTag(String name) { - Identifier id = BetterEnd.makeID(name); + ResourceLocation id = BetterEnd.makeID(name); Tag tag = ItemTags.getTagGroup().getTag(id); return tag == null ? (Identified) TagRegistry.item(id) : (Identified) tag; } - + public static Tag.Identified makeCommonBlockTag(String name) { - Identifier id = new Identifier("c", name); + ResourceLocation id = new ResourceLocation("c", name); Tag tag = BlockTags.getTagGroup().getTag(id); return tag == null ? (Identified) TagRegistry.block(id) : (Identified) tag; } - + public static Tag.Identified makeCommonItemTag(String name) { - Identifier id = new Identifier("c", name); + ResourceLocation id = new ResourceLocation("c", name); Tag tag = ItemTags.getTagGroup().getTag(id); return tag == null ? (Identified) TagRegistry.item(id) : (Identified) tag; } - + public static Tag.Identified getMCBlockTag(String name) { - Identifier id = new Identifier(name); + ResourceLocation id = new ResourceLocation(name); Tag tag = BlockTags.getTagGroup().getTag(id); return tag == null ? (Identified) TagRegistry.block(id) : (Identified) tag; } - + public static void register() { addSurfaceBlock(Blocks.END_STONE); addSurfaceBlock(EndBlocks.THALLASIUM.ore); addSurfaceBlock(EndBlocks.ENDSTONE_DUST); addSurfaceBlock(EndBlocks.AMBER_ORE); - + EndItems.getModBlocks().forEach((item) -> { Block block = ((BlockItem) item).getBlock(); if (block instanceof EndTerrainBlock) { addSurfaceBlock(block); TagHelper.addTag(BlockTags.NYLIUM, block); - } - else if (block instanceof LeavesBlock || block instanceof SimpleLeavesBlock) { + } else if (block instanceof LeavesBlock || block instanceof SimpleLeavesBlock) { TagHelper.addTag(BlockTags.LEAVES, block); ComposterBlockAccessor.callRegisterCompostableItem(0.3F, block); - } - else if (block instanceof VineBlock) { + } else if (block instanceof VineBlock) { TagHelper.addTag(BlockTags.CLIMBABLE, block); - } - else if (block instanceof PedestalBlock) { + } else if (block instanceof PedestalBlock) { TagHelper.addTag(PEDESTALS, block); } - - Material mat = block.getDefaultState().getMaterial(); + + Material mat = block.defaultBlockState().getMaterial(); if (mat.equals(Material.PLANT) || mat.equals(Material.REPLACEABLE_PLANT)) { ComposterBlockAccessor.callRegisterCompostableItem(0.1F, block); } }); - + EndItems.getModItems().forEach((item) -> { if (item.isFood()) { FoodComponent food = item.getFoodComponent(); @@ -114,36 +111,31 @@ public class EndTags { ComposterBlockAccessor.callRegisterCompostableItem(compost, item); } }); - - TagHelper.addTag(GEN_TERRAIN, EndBlocks.ENDER_ORE, EndBlocks.FLAVOLITE.stone, EndBlocks.VIOLECITE.stone, EndBlocks.SULPHURIC_ROCK.stone, EndBlocks.BRIMSTONE); + + TagHelper.addTag(GEN_TERRAIN, EndBlocks.ENDER_ORE, EndBlocks.FLAVOLITE.stone, EndBlocks.VIOLECITE.stone, + EndBlocks.SULPHURIC_ROCK.stone, EndBlocks.BRIMSTONE); TagHelper.addTag(END_GROUND, EndBlocks.SULPHURIC_ROCK.stone, EndBlocks.BRIMSTONE); - ToolManagerImpl.tag(HAMMERS).register(new ModdedToolsVanillaBlocksToolHandler( - Arrays.asList( - EndItems.IRON_HAMMER, - EndItems.GOLDEN_HAMMER, - EndItems.DIAMOND_HAMMER, - EndItems.NETHERITE_HAMMER, - EndItems.AETERNIUM_HAMMER, - EndBlocks.THALLASIUM.hammer, - EndBlocks.TERMINITE.hammer - ) - )); - + ToolManagerImpl.tag(HAMMERS) + .register(new ModdedToolsVanillaBlocksToolHandler(Arrays.asList(EndItems.IRON_HAMMER, + EndItems.GOLDEN_HAMMER, EndItems.DIAMOND_HAMMER, EndItems.NETHERITE_HAMMER, + EndItems.AETERNIUM_HAMMER, EndBlocks.THALLASIUM.hammer, EndBlocks.TERMINITE.hammer))); + TagHelper.addTag(FURNACES, Blocks.FURNACE); TagHelper.addTag(BlockTags.ANVIL, EndBlocks.AETERNIUM_ANVIL); - + TagHelper.addTag(BlockTags.BEACON_BASE_BLOCKS, EndBlocks.AETERNIUM_BLOCK); TagHelper.addTag(ItemTags.BEACON_PAYMENT_ITEMS, EndItems.AETERNIUM_INGOT); - - TagHelper.addTag(EndTags.DRAGON_IMMUNE, EndBlocks.ENDER_ORE, EndBlocks.ETERNAL_PEDESTAL, EndBlocks.FLAVOLITE_RUNED_ETERNAL, EndBlocks.FLAVOLITE_RUNED); + + TagHelper.addTag(EndTags.DRAGON_IMMUNE, EndBlocks.ENDER_ORE, EndBlocks.ETERNAL_PEDESTAL, + EndBlocks.FLAVOLITE_RUNED_ETERNAL, EndBlocks.FLAVOLITE_RUNED); } - + public static void addSurfaceBlock(Block block) { TagHelper.addTag(END_GROUND, block); TagHelper.addTag(GEN_TERRAIN, block); } - + public static void addTerrainTags(Registry biomeRegistry) { biomeRegistry.forEach((biome) -> { if (biome.getCategory() == Category.THEEND) { @@ -156,8 +148,8 @@ public class EndTags { }); END_STONES.values().forEach(EndTags::addSurfaceBlock); } - + public static Tag registerFabricItemTag(String name) { - return TagRegistry.item(new Identifier("fabric", name)); + return TagRegistry.item(new ResourceLocation("fabric", name)); } } diff --git a/src/main/java/ru/betterend/registry/FilaluxBlock.java b/src/main/java/ru/betterend/registry/FilaluxBlock.java index 6b854712..eeb40f93 100644 --- a/src/main/java/ru/betterend/registry/FilaluxBlock.java +++ b/src/main/java/ru/betterend/registry/FilaluxBlock.java @@ -1,13 +1,13 @@ package ru.betterend.registry; -import net.minecraft.block.AbstractBlock; +import net.minecraft.world.level.block.AbstractBlock; import ru.betterend.blocks.basis.VineBlock; public class FilaluxBlock extends VineBlock { public FilaluxBlock() { super(15, true); } - + @Override public AbstractBlock.OffsetType getOffsetType() { return AbstractBlock.OffsetType.NONE; diff --git a/src/main/java/ru/betterend/registry/FilaluxWingsBlock.java b/src/main/java/ru/betterend/registry/FilaluxWingsBlock.java index 6ec82a17..12a8e20b 100644 --- a/src/main/java/ru/betterend/registry/FilaluxWingsBlock.java +++ b/src/main/java/ru/betterend/registry/FilaluxWingsBlock.java @@ -6,36 +6,37 @@ import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; +import net.minecraft.world.level.BlockGetter; import ru.betterend.blocks.basis.AttachedBlock; import ru.betterend.client.render.ERenderLayer; import ru.betterend.interfaces.IRenderTypeable; public class FilaluxWingsBlock extends AttachedBlock implements IRenderTypeable { private static final EnumMap BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); - + public FilaluxWingsBlock() { - super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(BlockSoundGroup.WET_GRASS).noCollision()); + super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.WET_GRASS) + .noCollision()); } @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - return BOUNDING_SHAPES.get(state.get(FACING)); + return BOUNDING_SHAPES.get(state.getValue(FACING)); } - + static { BOUNDING_SHAPES.put(Direction.UP, VoxelShapes.cuboid(0.0, 0.0, 0.0, 1.0, 0.5, 1.0)); BOUNDING_SHAPES.put(Direction.DOWN, VoxelShapes.cuboid(0.0, 0.5, 0.0, 1.0, 1.0, 1.0)); diff --git a/src/main/java/ru/betterend/registry/PondAnemoneBlock.java b/src/main/java/ru/betterend/registry/PondAnemoneBlock.java index 62d2ef2f..8b6073cb 100644 --- a/src/main/java/ru/betterend/registry/PondAnemoneBlock.java +++ b/src/main/java/ru/betterend/registry/PondAnemoneBlock.java @@ -6,56 +6,52 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.block.ShapeContext; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.AbstractBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.block.ShapeContext; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.core.BlockPos; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import ru.betterend.blocks.basis.UnderwaterPlantBlock; public class PondAnemoneBlock extends UnderwaterPlantBlock { private static final VoxelShape SHAPE = Block.createCuboidShape(2, 0, 2, 14, 14, 14); - + public PondAnemoneBlock() { - super(FabricBlockSettings.of(Material.UNDERWATER_PLANT) - .breakByTool(FabricToolTags.SHEARS) - .sounds(BlockSoundGroup.CORAL) - .breakByHand(true) - .luminance(13) - .noCollision()); + super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS) + .sounds(SoundType.CORAL).breakByHand(true).luminance(13).noCollision()); } - + @Override public AbstractBlock.OffsetType getOffsetType() { return AbstractBlock.OffsetType.NONE; } @Environment(EnvType.CLIENT) - public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { + public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { double x = pos.getX() + random.nextDouble(); double y = pos.getY() + random.nextDouble() * 0.5F + 0.5F; double z = pos.getZ() + random.nextDouble(); world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0.0D, 0.0D, 0.0D); } - + @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { return SHAPE; } - + @Override public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { return false; } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) { return false; } } diff --git a/src/main/java/ru/betterend/rituals/EternalRitual.java b/src/main/java/ru/betterend/rituals/EternalRitual.java index ab031512..34430016 100644 --- a/src/main/java/ru/betterend/rituals/EternalRitual.java +++ b/src/main/java/ru/betterend/rituals/EternalRitual.java @@ -14,28 +14,28 @@ import org.jetbrains.annotations.Nullable; import com.google.common.collect.Sets; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.item.Item; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtHelper; -import net.minecraft.particle.BlockStateParticleEffect; -import net.minecraft.particle.ParticleEffect; -import net.minecraft.particle.ParticleTypes; +import net.minecraft.core.particles.BlockStateParticleEffect; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundSource; +import net.minecraft.sounds.SoundEvents; import net.minecraft.state.property.BooleanProperty; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Registry; import net.minecraft.world.Heightmap; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.dimension.DimensionType; +import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.gen.feature.ConfiguredFeatures; import ru.betterend.BetterEnd; import ru.betterend.blocks.BlockProperties; @@ -47,22 +47,15 @@ import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndPortals; public class EternalRitual { - private final static Set STRUCTURE_MAP = Sets.newHashSet( - new Point(-4, -5), new Point(-4, 5), new Point(-6, 0), - new Point(4, -5), new Point(4, 5), new Point(6, 0)); - private final static Set FRAME_MAP = Sets.newHashSet( - new Point(0, 0), new Point(0, 6), new Point(1, 0), - new Point(1, 6), new Point(2, 1), new Point(2, 5), - new Point(3, 2), new Point(3, 3), new Point(3, 4)); - private final static Set PORTAL_MAP = Sets.newHashSet( - new Point(0, 0), new Point(0, 1), new Point(0, 2), - new Point(0, 3), new Point(0, 4), new Point(1, 0), - new Point(1, 1), new Point(1, 2), new Point(1, 3), - new Point(1, 4), new Point(2, 1), new Point(2, 2), - new Point(2, 3)); - private final static Set BASE_MAP = Sets.newHashSet( - new Point(3, 0), new Point(2, 0), new Point(2, 1), new Point(1, 1), - new Point(1, 2), new Point(0, 1), new Point(0, 2)); + private final static Set STRUCTURE_MAP = Sets.newHashSet(new Point(-4, -5), new Point(-4, 5), + new Point(-6, 0), new Point(4, -5), new Point(4, 5), new Point(6, 0)); + private final static Set FRAME_MAP = Sets.newHashSet(new Point(0, 0), new Point(0, 6), new Point(1, 0), + new Point(1, 6), new Point(2, 1), new Point(2, 5), new Point(3, 2), new Point(3, 3), new Point(3, 4)); + private final static Set PORTAL_MAP = Sets.newHashSet(new Point(0, 0), new Point(0, 1), new Point(0, 2), + new Point(0, 3), new Point(0, 4), new Point(1, 0), new Point(1, 1), new Point(1, 2), new Point(1, 3), + new Point(1, 4), new Point(2, 1), new Point(2, 2), new Point(2, 3)); + private final static Set BASE_MAP = Sets.newHashSet(new Point(3, 0), new Point(2, 0), new Point(2, 1), + new Point(1, 1), new Point(1, 2), new Point(0, 1), new Point(0, 2)); private final static Block BASE = EndBlocks.FLAVOLITE.tiles; private final static Block PEDESTAL = EndBlocks.ETERNAL_PEDESTAL; @@ -72,51 +65,50 @@ public class EternalRitual { public final static int SEARCH_RADIUS = calculateSearchSteps(48); - private World world; + private Level world; private Direction.Axis axis; - private Identifier targetWorldId; + private ResourceLocation targetWorldId; private BlockPos center; private BlockPos exit; private boolean active = false; - public EternalRitual(World world) { + public EternalRitual(Level world) { this.world = world; } - public EternalRitual(World world, BlockPos initial) { + public EternalRitual(Level world, BlockPos initial) { this(world); this.configure(initial); } - public void setWorld(World world) { + public void setWorld(Level world) { this.world = world; } @Nullable - public Identifier getTargetWorldId() { + public ResourceLocation getTargetWorldId() { return targetWorldId; } private boolean isInvalid() { - return world == null || world.isClient() || - center == null || axis == null; + return world == null || world.isClientSide() || center == null || axis == null; } public void checkStructure() { - if (isInvalid()) return; + if (isInvalid()) + return; Direction moveX, moveY; if (Direction.Axis.X == axis) { moveX = Direction.EAST; moveY = Direction.NORTH; - } - else { + } else { moveX = Direction.SOUTH; moveY = Direction.EAST; } - boolean valid = checkFrame(world, center.down()); + boolean valid = checkFrame(world, center.below()); Item item = null; for (Point pos : STRUCTURE_MAP) { - BlockPos.Mutable checkPos = center.mutableCopy(); + BlockPos.MutableBlockPos checkPos = center.mutable(); checkPos.move(moveX, pos.x).move(moveY, pos.y); valid &= isActive(checkPos); if (valid) { @@ -136,14 +128,14 @@ public class EternalRitual { } } - private boolean checkFrame(World world, BlockPos framePos) { + private boolean checkFrame(Level world, BlockPos framePos) { Direction moveDir = Direction.Axis.X == axis ? Direction.NORTH : Direction.EAST; boolean valid = true; for (Point point : FRAME_MAP) { - BlockPos pos = framePos.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y); + BlockPos pos = framePos.mutable().move(moveDir, point.x).move(Direction.UP, point.y); BlockState state = world.getBlockState(pos); valid &= state.getBlock() instanceof RunedFlavolite; - pos = framePos.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y); + pos = framePos.mutable().move(moveDir, -point.x).move(Direction.UP, point.y); state = world.getBlockState(pos); valid &= state.getBlock() instanceof RunedFlavolite; } @@ -155,25 +147,26 @@ public class EternalRitual { } private void activatePortal(Item keyItem) { - if (active) return; - Identifier itemId = Registry.ITEM.getId(keyItem); + if (active) + return; + ResourceLocation itemId = Registry.ITEM.getId(keyItem); int portalId = EndPortals.getPortalIdByItem(itemId); - World targetWorld = getTargetWorld(portalId); - Identifier worldId = targetWorld.getRegistryKey().getValue(); + Level targetWorld = getTargetWorld(portalId); + ResourceLocation worldId = targetWorld.dimension().location(); try { if (exit == null) { initPortal(worldId, portalId); } else { if (!worldId.equals(targetWorldId)) { initPortal(worldId, portalId); - } else if (!checkFrame(targetWorld, exit.down())) { + } else if (!checkFrame(targetWorld, exit.below())) { Direction.Axis portalAxis = (Direction.Axis.X == axis) ? Direction.Axis.Z : Direction.Axis.X; generatePortal(targetWorld, exit, portalAxis, portalId); } activatePortal(targetWorld, exit, portalId); } activatePortal(world, center, portalId); - doEffects((ServerWorld) world, center); + doEffects((ServerLevel) world, center); active = true; } catch (Exception ex) { BetterEnd.LOGGER.error("Create End portals error.", ex); @@ -183,95 +176,102 @@ public class EternalRitual { } } - private void initPortal(Identifier worldId, int portalId) { + private void initPortal(ResourceLocation worldId, int portalId) { targetWorldId = worldId; exit = findPortalPos(portalId); } - private void doEffects(ServerWorld serverWorld, BlockPos center) { + private void doEffects(ServerLevel serverWorld, BlockPos center) { Direction moveX, moveY; if (Direction.Axis.X == axis) { moveX = Direction.EAST; moveY = Direction.NORTH; - } - else { + } else { moveX = Direction.SOUTH; moveY = Direction.EAST; } for (Point pos : STRUCTURE_MAP) { - BlockPos.Mutable p = center.mutableCopy(); + BlockPos.MutableBlockPos p = center.mutable(); p.move(moveX, pos.x).move(moveY, pos.y); - serverWorld.spawnParticles(ParticleTypes.PORTAL, p.getX() + 0.5, p.getY() + 1.5, p.getZ() + 0.5, 20, 0, 0, 0, 1); - serverWorld.spawnParticles(ParticleTypes.REVERSE_PORTAL, p.getX() + 0.5, p.getY() + 1.5, p.getZ() + 0.5, 20, 0, 0, 0, 0.3); + serverWorld.sendParticles(ParticleTypes.PORTAL, p.getX() + 0.5, p.getY() + 1.5, p.getZ() + 0.5, 20, 0, 0, 0, + 1); + serverWorld.sendParticles(ParticleTypes.REVERSE_PORTAL, p.getX() + 0.5, p.getY() + 1.5, p.getZ() + 0.5, 20, + 0, 0, 0, 0.3); } - serverWorld.playSound(null, center, SoundEvents.BLOCK_END_PORTAL_SPAWN, SoundCategory.NEUTRAL, 16, 1); + serverWorld.playSound(null, center, SoundEvents.BLOCK_END_PORTAL_SPAWN, SoundSource.NEUTRAL, 16, 1); } - private void activatePortal(World world, BlockPos center, int portalId) { - BlockPos framePos = center.down(); + private void activatePortal(Level world, BlockPos center, int portalId) { + BlockPos framePos = center.below(); Direction moveDir = Direction.Axis.X == axis ? Direction.NORTH : Direction.EAST; - BlockState frame = FRAME.getDefaultState().with(ACTIVE, true); + BlockState frame = FRAME.defaultBlockState().with(ACTIVE, true); FRAME_MAP.forEach(point -> { - BlockPos pos = framePos.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y); + BlockPos pos = framePos.mutable().move(moveDir, point.x).move(Direction.UP, point.y); BlockState state = world.getBlockState(pos); - if (state.contains(ACTIVE) && !state.get(ACTIVE)) { - world.setBlockState(pos, frame); + if (state.contains(ACTIVE) && !state.getValue(ACTIVE)) { + world.setBlockAndUpdate(pos, frame); } - pos = framePos.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y); + pos = framePos.mutable().move(moveDir, -point.x).move(Direction.UP, point.y); state = world.getBlockState(pos); - if (state.contains(ACTIVE) && !state.get(ACTIVE)) { - world.setBlockState(pos, frame); + if (state.contains(ACTIVE) && !state.getValue(ACTIVE)) { + world.setBlockAndUpdate(pos, frame); } }); Direction.Axis portalAxis = Direction.Axis.X == axis ? Direction.Axis.Z : Direction.Axis.X; - BlockState portal = PORTAL.getDefaultState().with(EndPortalBlock.AXIS, portalAxis).with(EndPortalBlock.PORTAL, portalId); - ParticleEffect effect = new BlockStateParticleEffect(ParticleTypes.BLOCK, portal); - ServerWorld serverWorld = (ServerWorld) world; + BlockState portal = PORTAL.defaultBlockState().with(EndPortalBlock.AXIS, portalAxis).with(EndPortalBlock.PORTAL, + portalId); + ParticleOptions effect = new BlockStateParticleEffect(ParticleTypes.BLOCK, portal); + ServerLevel serverWorld = (ServerLevel) world; PORTAL_MAP.forEach(point -> { - BlockPos pos = center.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y); - if (!world.getBlockState(pos).isOf(PORTAL)) { - world.setBlockState(pos, portal); - serverWorld.spawnParticles(effect, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 10, 0.5, 0.5, 0.5, 0.1); - serverWorld.spawnParticles(ParticleTypes.REVERSE_PORTAL, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 10, 0.5, 0.5, 0.5, 0.3); + BlockPos pos = center.mutable().move(moveDir, point.x).move(Direction.UP, point.y); + if (!world.getBlockState(pos).is(PORTAL)) { + world.setBlockAndUpdate(pos, portal); + serverWorld.sendParticles(effect, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 10, 0.5, 0.5, + 0.5, 0.1); + serverWorld.sendParticles(ParticleTypes.REVERSE_PORTAL, pos.getX() + 0.5, pos.getY() + 0.5, + pos.getZ() + 0.5, 10, 0.5, 0.5, 0.5, 0.3); } - pos = center.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y); - if (!world.getBlockState(pos).isOf(PORTAL)) { - world.setBlockState(pos, portal); - serverWorld.spawnParticles(effect, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 10, 0.5, 0.5, 0.5, 0.1); - serverWorld.spawnParticles(ParticleTypes.REVERSE_PORTAL, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 10, 0.5, 0.5, 0.5, 0.3); + pos = center.mutable().move(moveDir, -point.x).move(Direction.UP, point.y); + if (!world.getBlockState(pos).is(PORTAL)) { + world.setBlockAndUpdate(pos, portal); + serverWorld.sendParticles(effect, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 10, 0.5, 0.5, + 0.5, 0.1); + serverWorld.sendParticles(ParticleTypes.REVERSE_PORTAL, pos.getX() + 0.5, pos.getY() + 0.5, + pos.getZ() + 0.5, 10, 0.5, 0.5, 0.5, 0.3); } }); } public void disablePortal(int state) { - if (!active || isInvalid()) return; + if (!active || isInvalid()) + return; removePortal(getTargetWorld(state), exit); removePortal(world, center); } - private void removePortal(World world, BlockPos center) { - BlockPos framePos = center.down(); + private void removePortal(Level world, BlockPos center) { + BlockPos framePos = center.below(); Direction moveDir = Direction.Axis.X == axis ? Direction.NORTH : Direction.EAST; FRAME_MAP.forEach(point -> { - BlockPos pos = framePos.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y); + BlockPos pos = framePos.mutable().move(moveDir, point.x).move(Direction.UP, point.y); BlockState state = world.getBlockState(pos); - if (state.isOf(FRAME) && state.get(ACTIVE)) { - world.setBlockState(pos, state.with(ACTIVE, false)); + if (state.is(FRAME) && state.getValue(ACTIVE)) { + world.setBlockAndUpdate(pos, state.with(ACTIVE, false)); } - pos = framePos.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y); + pos = framePos.mutable().move(moveDir, -point.x).move(Direction.UP, point.y); state = world.getBlockState(pos); - if (state.isOf(FRAME) && state.get(ACTIVE)) { - world.setBlockState(pos, state.with(ACTIVE, false)); + if (state.is(FRAME) && state.getValue(ACTIVE)) { + world.setBlockAndUpdate(pos, state.with(ACTIVE, false)); } }); PORTAL_MAP.forEach(point -> { - BlockPos pos = center.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y); - if (world.getBlockState(pos).isOf(PORTAL)) { + BlockPos pos = center.mutable().move(moveDir, point.x).move(Direction.UP, point.y); + if (world.getBlockState(pos).is(PORTAL)) { world.removeBlock(pos, false); } - pos = center.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y); - if (world.getBlockState(pos).isOf(PORTAL)) { + pos = center.mutable().move(moveDir, -point.x).move(Direction.UP, point.y); + if (world.getBlockState(pos).is(PORTAL)) { world.removeBlock(pos, false); } }); @@ -279,10 +279,10 @@ public class EternalRitual { } @Nullable - private BlockPos findFrame(World world, BlockPos.Mutable startPos) { - List foundPos = findAllBlockPos(world, startPos, (SEARCH_RADIUS >> 4) + 1, FRAME, - blockState -> blockState.isOf(FRAME) && !blockState.get(ACTIVE)); - for(BlockPos.Mutable testPos : foundPos) { + private BlockPos findFrame(Level world, BlockPos.MutableBlockPos startPos) { + List foundPos = findAllBlockPos(world, startPos, (SEARCH_RADIUS >> 4) + 1, FRAME, + blockState -> blockState.is(FRAME) && !blockState.get(ACTIVE)); + for (BlockPos.MutableBlockPos testPos : foundPos) { if (checkFrame(world, testPos)) { return testPos; } @@ -292,11 +292,12 @@ public class EternalRitual { private BlockPos findPortalPos(int portalId) { MinecraftServer server = world.getServer(); - ServerWorld targetWorld = (ServerWorld) getTargetWorld(portalId); - Registry registry = Objects.requireNonNull(server).getRegistryManager().getDimensionTypes(); - double multiplier = Objects.requireNonNull(registry.get(targetWorldId)).getCoordinateScale(); - BlockPos.Mutable basePos = center.mutableCopy().set(center.getX() / multiplier, center.getY(), center.getZ() / multiplier); - BlockPos framePos = findFrame(targetWorld, basePos.mutableCopy()); + ServerLevel targetWorld = (ServerLevel) getTargetWorld(portalId); + Registry registry = Objects.requireNonNull(server).registryAccess().dimensionTypes(); + double multiplier = Objects.requireNonNull(registry.get(targetWorldId)).coordinateScale(); + BlockPos.MutableBlockPos basePos = center.mutable().set(center.getX() / multiplier, center.getY(), + center.getZ() / multiplier); + BlockPos framePos = findFrame(targetWorld, basePos.mutable()); if (framePos != null) { return framePos.up(); } @@ -307,19 +308,22 @@ public class EternalRitual { return basePos.toImmutable(); } else { Direction direction = Direction.EAST; - BlockPos.Mutable checkPos = basePos.mutableCopy(); + BlockPos.MutableBlockPos checkPos = basePos.mutable(); int radius = (int) ((SEARCH_RADIUS / multiplier) + 1); for (int step = 1; step < radius; step++) { for (int i = 0; i < (step >> 1); i++) { Chunk chunk = targetWorld.getChunk(checkPos); if (chunk != null) { - int surfaceY = chunk.sampleHeightmap(Heightmap.Type.WORLD_SURFACE, checkPos.getX() & 15, checkPos.getZ() & 15); - int motionY = chunk.sampleHeightmap(Heightmap.Type.MOTION_BLOCKING, checkPos.getX() & 15, checkPos.getZ() & 15); + int surfaceY = chunk.sampleHeightmap(Heightmap.Type.WORLD_SURFACE, checkPos.getX() & 15, + checkPos.getZ() & 15); + int motionY = chunk.sampleHeightmap(Heightmap.Type.MOTION_BLOCKING, checkPos.getX() & 15, + checkPos.getZ() & 15); int ceil = Math.min(Math.max(surfaceY, motionY) + 1, worldCeil); - if (ceil < 5) continue; + if (ceil < 5) + continue; checkPos.setY(ceil); while (checkPos.getY() >= 5) { - if(checkIsAreaValid(targetWorld, checkPos, portalAxis)) { + if (checkIsAreaValid(targetWorld, checkPos, portalAxis)) { generatePortal(targetWorld, checkPos, portalAxis, portalId); return checkPos.toImmutable(); } @@ -328,46 +332,50 @@ public class EternalRitual { } checkPos.move(direction); } - direction = direction.rotateYClockwise(); + direction = direction.getClockWise(); } } - if (targetWorld.getRegistryKey() == World.END) { - ConfiguredFeatures.END_ISLAND.generate(targetWorld, targetWorld.getChunkManager().getChunkGenerator(), new Random(basePos.asLong()), basePos.down()); - } else if (targetWorld.getRegistryKey() == World.OVERWORLD) { - basePos.setY(targetWorld.getChunk(basePos).sampleHeightmap(Heightmap.Type.WORLD_SURFACE, basePos.getX(), basePos.getZ()) + 1); + if (targetWorld.dimension() == Level.END) { + ConfiguredFeatures.END_ISLAND.generate(targetWorld, targetWorld.getChunkManager().getChunkGenerator(), + new Random(basePos.asLong()), basePos.below()); + } else if (targetWorld.dimension() == Level.OVERWORLD) { + basePos.setY(targetWorld.getChunk(basePos).sampleHeightmap(Heightmap.Type.WORLD_SURFACE, basePos.getX(), + basePos.getZ()) + 1); } - EndFeatures.BIOME_ISLAND.getFeatureConfigured().generate(targetWorld, targetWorld.getChunkManager().getChunkGenerator(), new Random(basePos.asLong()), basePos.down()); + EndFeatures.BIOME_ISLAND.getFeatureConfigured().generate(targetWorld, + targetWorld.getChunkManager().getChunkGenerator(), new Random(basePos.asLong()), basePos.below()); generatePortal(targetWorld, basePos, portalAxis, portalId); return basePos.toImmutable(); } - private World getTargetWorld(int state) { - if (world.getRegistryKey() == World.END) { - return EndPortals.getWorld(world.getServer(), state); + private Level getTargetWorld(int state) { + if (world.dimension() == Level.END) { + return EndPortals.getLevel(world.getServer(), state); } - return Objects.requireNonNull(world.getServer()).getWorld(World.END); + return Objects.requireNonNull(world.getServer()).getLevel(Level.END); } - private boolean checkIsAreaValid(World world, BlockPos pos, Direction.Axis axis) { - if (pos.getY() >= world.getDimensionHeight() - 1) return false; - if (!isBaseValid(world, pos, axis)) return false; + private boolean checkIsAreaValid(Level world, BlockPos pos, Direction.Axis axis) { + if (pos.getY() >= world.getDimensionHeight() - 1) + return false; + if (!isBaseValid(world, pos, axis)) + return false; return EternalRitual.checkArea(world, pos, axis); } - private boolean isBaseValid(World world, BlockPos pos, Direction.Axis axis) { + private boolean isBaseValid(Level world, BlockPos pos, Direction.Axis axis) { boolean solid = true; if (axis.equals(Direction.Axis.X)) { - pos = pos.down().add(0, 0, -3); + pos = pos.below().add(0, 0, -3); for (int i = 0; i < 7; i++) { - BlockPos checkPos = pos.add(0, 0, i); + BlockPos checkPos = pos.offset(0, 0, i); BlockState state = world.getBlockState(checkPos); solid &= validBlock(world, checkPos, state); } - } - else { - pos = pos.down().add(-3, 0, 0); + } else { + pos = pos.below().add(-3, 0, 0); for (int i = 0; i < 7; i++) { - BlockPos checkPos = pos.add(i, 0, 0); + BlockPos checkPos = pos.offset(i, 0, 0); BlockState state = world.getBlockState(checkPos); solid &= validBlock(world, checkPos, state); } @@ -375,7 +383,7 @@ public class EternalRitual { return solid; } - private boolean validBlock(World world, BlockPos pos, BlockState state) { + private boolean validBlock(Level world, BlockPos pos, BlockState state) { return state.isSolidBlock(world, pos) && state.isFullCube(world, pos); } @@ -450,12 +458,12 @@ public class EternalRitual { } private boolean hasPedestal(BlockPos pos) { - return world.getBlockState(pos).isOf(PEDESTAL); + return world.getBlockState(pos).is(PEDESTAL); } private boolean isActive(BlockPos pos) { BlockState state = world.getBlockState(pos); - if (state.isOf(PEDESTAL)) { + if (state.is(PEDESTAL)) { EternalPedestalEntity pedestal = (EternalPedestalEntity) world.getBlockEntity(pos); if (pedestal != null) { if (!pedestal.hasRitual()) { @@ -467,7 +475,7 @@ public class EternalRitual { } } } - return state.get(ACTIVE); + return state.getValue(ACTIVE); } return false; } @@ -493,99 +501,107 @@ public class EternalRitual { exit = NbtHelper.toBlockPos(tag.getCompound("exit")); } if (tag.contains("key_item")) { - targetWorldId = new Identifier(tag.getString("key_item")); + targetWorldId = new ResourceLocation(tag.getString("key_item")); } } @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; EternalRitual ritual = (EternalRitual) o; - return world.equals(ritual.world) && - Objects.equals(center, ritual.center) && - Objects.equals(exit, ritual.exit); + return world.equals(ritual.world) && Objects.equals(center, ritual.center) && Objects.equals(exit, ritual.exit); } - public static void generatePortal(World world, BlockPos center, Direction.Axis axis, int portalId) { - BlockPos framePos = center.down(); + public static void generatePortal(Level world, BlockPos center, Direction.Axis axis, int portalId) { + BlockPos framePos = center.below(); Direction moveDir = Direction.Axis.X == axis ? Direction.EAST : Direction.NORTH; - BlockState frame = FRAME.getDefaultState().with(ACTIVE, true); + BlockState frame = FRAME.defaultBlockState().with(ACTIVE, true); FRAME_MAP.forEach(point -> { - BlockPos pos = framePos.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y); - world.setBlockState(pos, frame); - pos = framePos.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y); - world.setBlockState(pos, frame); + BlockPos pos = framePos.mutable().move(moveDir, point.x).move(Direction.UP, point.y); + world.setBlockAndUpdate(pos, frame); + pos = framePos.mutable().move(moveDir, -point.x).move(Direction.UP, point.y); + world.setBlockAndUpdate(pos, frame); }); - BlockState portal = PORTAL.getDefaultState().with(EndPortalBlock.AXIS, axis).with(EndPortalBlock.PORTAL, portalId); + BlockState portal = PORTAL.defaultBlockState().with(EndPortalBlock.AXIS, axis).with(EndPortalBlock.PORTAL, + portalId); PORTAL_MAP.forEach(point -> { - BlockPos pos = center.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y); - world.setBlockState(pos, portal); - pos = center.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y); - world.setBlockState(pos, portal); + BlockPos pos = center.mutable().move(moveDir, point.x).move(Direction.UP, point.y); + world.setBlockAndUpdate(pos, portal); + pos = center.mutable().move(moveDir, -point.x).move(Direction.UP, point.y); + world.setBlockAndUpdate(pos, portal); }); generateBase(world, framePos, moveDir); } - private static void generateBase(World world, BlockPos center, Direction moveX) { - BlockState base = BASE.getDefaultState(); - Direction moveY = moveX.rotateYClockwise(); + private static void generateBase(Level world, BlockPos center, Direction moveX) { + BlockState base = BASE.defaultBlockState(); + Direction moveY = moveX.getClockWise(); BASE_MAP.forEach(point -> { - BlockPos pos = center.mutableCopy().move(moveX, point.x).move(moveY, point.y); - world.setBlockState(pos, base); - pos = center.mutableCopy().move(moveX, -point.x).move(moveY, point.y); - world.setBlockState(pos, base); - pos = center.mutableCopy().move(moveX, point.x).move(moveY, -point.y); - world.setBlockState(pos, base); - pos = center.mutableCopy().move(moveX, -point.x).move(moveY, -point.y); - world.setBlockState(pos, base); + BlockPos pos = center.mutable().move(moveX, point.x).move(moveY, point.y); + world.setBlockAndUpdate(pos, base); + pos = center.mutable().move(moveX, -point.x).move(moveY, point.y); + world.setBlockAndUpdate(pos, base); + pos = center.mutable().move(moveX, point.x).move(moveY, -point.y); + world.setBlockAndUpdate(pos, base); + pos = center.mutable().move(moveX, -point.x).move(moveY, -point.y); + world.setBlockAndUpdate(pos, base); }); } - public static boolean checkArea(World world, BlockPos center, Direction.Axis axis) { + public static boolean checkArea(Level world, BlockPos center, Direction.Axis axis) { Direction moveDir = Direction.Axis.X == axis ? Direction.NORTH : Direction.EAST; - for (BlockPos checkPos : BlockPos.iterate(center.offset(moveDir.rotateYClockwise()), center.offset(moveDir.rotateYCounterclockwise()))) { + for (BlockPos checkPos : BlockPos.iterate(center.offset(moveDir.getClockWise()), + center.offset(moveDir.rotateYCounterclockwise()))) { for (Point point : PORTAL_MAP) { - BlockPos pos = checkPos.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y); + BlockPos pos = checkPos.mutable().move(moveDir, point.x).move(Direction.UP, point.y); BlockState state = world.getBlockState(pos); - if (isStateInvalid(state)) return false; - pos = checkPos.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y); + if (isStateInvalid(state)) + return false; + pos = checkPos.mutable().move(moveDir, -point.x).move(Direction.UP, point.y); state = world.getBlockState(pos); - if (isStateInvalid(state)) return false; + if (isStateInvalid(state)) + return false; } } return true; } private static boolean isStateInvalid(BlockState state) { - if (!state.getFluidState().isEmpty()) return true; + if (!state.getFluidState().isEmpty()) + return true; Material material = state.getMaterial(); return !material.isReplaceable() && !material.equals(Material.PLANT); } /** - * @param world World for search - * @param checkPos Start search position - * @param radius Search radius + * @param world Level for search + * @param checkPos Start search position + * @param radius Search radius * @param searchBlock Target block - * @param condition Predicate for test block states in the chunk section + * @param condition Predicate for test block states in the chunk section * * @return Position of the first found block or null. */ @Nullable - public static BlockPos.Mutable findBlockPos(World world, BlockPos.Mutable checkPos, int radius, Block searchBlock, Predicate condition) { + public static BlockPos.MutableBlockPos findBlockPos(Level world, BlockPos.MutableBlockPos checkPos, int radius, + Block searchBlock, Predicate condition) { Direction moveDirection = Direction.EAST; for (int step = 1; step < radius; step++) { for (int i = 0; i < (step >> 1); i++) { Chunk chunk = world.getChunk(checkPos); - if (!(chunk instanceof WorldChunk) || ((WorldChunk) chunk).isEmpty()) continue; + if (!(chunk instanceof WorldChunk) || ((WorldChunk) chunk).isEmpty()) + continue; for (ChunkSection section : chunk.getSectionArray()) { - if (section == null || !section.getContainer().hasAny(condition)) continue; + if (section == null || !section.getContainer().hasAny(condition)) + continue; for (int x = 0; x < 16; x++) { for (int y = 0; y < 16; y++) { - for(int z = 0; z < 16; z++) { + for (int z = 0; z < 16; z++) { BlockState checkState = section.getBlockState(x, y, z); - if (checkState.isOf(searchBlock)) { + if (checkState.is(searchBlock)) { int worldX = (chunk.getPos().x << 4) + x; int worldY = section.getYOffset() + y; int worldZ = (chunk.getPos().z << 4) + z; @@ -598,39 +614,42 @@ public class EternalRitual { } checkPos.move(moveDirection, 16); } - moveDirection = moveDirection.rotateYClockwise(); + moveDirection = moveDirection.getClockWise(); } return null; } /** - * @param world World for search - * @param checkPos Start search position - * @param radius Search radius + * @param world Level for search + * @param checkPos Start search position + * @param radius Search radius * @param searchBlock Target block - * @param condition Predicate for test block states in the chunk section + * @param condition Predicate for test block states in the chunk section * * @return List of positions of the all found blocks or empty list. */ - public static List findAllBlockPos(World world, BlockPos.Mutable checkPos, int radius, Block searchBlock, Predicate condition) { - List posFound = Lists.newArrayList(); + public static List findAllBlockPos(Level world, BlockPos.MutableBlockPos checkPos, + int radius, Block searchBlock, Predicate condition) { + List posFound = Lists.newArrayList(); Direction moveDirection = Direction.EAST; for (int step = 1; step < radius; step++) { for (int i = 0; i < (step >> 1); i++) { Chunk chunk = world.getChunk(checkPos); - if (!(chunk instanceof WorldChunk) || ((WorldChunk) chunk).isEmpty()) continue; + if (!(chunk instanceof WorldChunk) || ((WorldChunk) chunk).isEmpty()) + continue; for (ChunkSection section : chunk.getSectionArray()) { - if (section == null || !section.getContainer().hasAny(condition)) continue; + if (section == null || !section.getContainer().hasAny(condition)) + continue; for (int x = 0; x < 16; x++) { for (int y = 0; y < 16; y++) { - for(int z = 0; z < 16; z++) { + for (int z = 0; z < 16; z++) { BlockState checkState = section.getBlockState(x, y, z); - if (checkState.isOf(searchBlock)) { + if (checkState.is(searchBlock)) { int worldX = (chunk.getPos().x << 4) + x; int worldY = section.getYOffset() + y; int worldZ = (chunk.getPos().z << 4) + z; checkPos.set(worldX, worldY, worldZ); - posFound.add(checkPos.mutableCopy()); + posFound.add(checkPos.mutable()); } } } @@ -638,7 +657,7 @@ public class EternalRitual { } checkPos.move(moveDirection, 16); } - moveDirection = moveDirection.rotateYClockwise(); + moveDirection = moveDirection.getClockWise(); } return posFound; } diff --git a/src/main/java/ru/betterend/rituals/InfusionRitual.java b/src/main/java/ru/betterend/rituals/InfusionRitual.java index 0ac50e97..0db4530c 100644 --- a/src/main/java/ru/betterend/rituals/InfusionRitual.java +++ b/src/main/java/ru/betterend/rituals/InfusionRitual.java @@ -2,56 +2,56 @@ package ru.betterend.rituals; import java.awt.Point; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.entity.player.PlayerEntity; import net.minecraft.inventory.Inventory; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import net.minecraft.nbt.CompoundTag; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.World; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; import ru.betterend.blocks.entities.InfusionPedestalEntity; import ru.betterend.blocks.entities.PedestalBlockEntity; import ru.betterend.particle.InfusionParticleType; import ru.betterend.recipe.builders.InfusionRecipe; public class InfusionRitual implements Inventory { - private static final Point[] PEDESTALS_MAP = new Point[] { - new Point(0, 3), new Point(2, 2), new Point(3, 0), new Point(2, -2), - new Point(0, -3), new Point(-2, -2), new Point(-3, 0), new Point(-2, 2) - }; + private static final Point[] PEDESTALS_MAP = new Point[] { new Point(0, 3), new Point(2, 2), new Point(3, 0), + new Point(2, -2), new Point(0, -3), new Point(-2, -2), new Point(-3, 0), new Point(-2, 2) }; - private World world; + private Level world; private BlockPos worldPos; private InfusionRecipe activeRecipe; private boolean isDirty = false; private boolean hasRecipe = false; private int progress = 0; private int time = 0; - + private InfusionPedestalEntity input; private final PedestalBlockEntity[] catalysts = new PedestalBlockEntity[8]; - - public InfusionRitual(World world, BlockPos pos) { + + public InfusionRitual(Level world, BlockPos pos) { this.world = world; this.worldPos = pos; this.configure(); } - + public static Point[] getMap() { return PEDESTALS_MAP; } - + public void configure() { - if (world == null || world.isClient || worldPos == null) return; + if (world == null || world.isClientSide || worldPos == null) + return; BlockEntity inputEntity = world.getBlockEntity(worldPos); if (inputEntity instanceof InfusionPedestalEntity) { input = (InfusionPedestalEntity) inputEntity; } int i = 0; - for(Point point : PEDESTALS_MAP) { - BlockPos.Mutable checkPos = worldPos.mutableCopy().move(Direction.EAST, point.x).move(Direction.NORTH, point.y); + for (Point point : PEDESTALS_MAP) { + BlockPos.MutableBlockPos checkPos = worldPos.mutable().move(Direction.EAST, point.x).move(Direction.NORTH, + point.y); BlockEntity catalystEntity = world.getBlockEntity(checkPos); if (catalystEntity instanceof PedestalBlockEntity) { catalysts[i] = (PedestalBlockEntity) catalystEntity; @@ -61,9 +61,10 @@ public class InfusionRitual implements Inventory { } } } - + public boolean checkRecipe() { - if (!isValid()) return false; + if (!isValid()) + return false; InfusionRecipe recipe = world.getRecipeManager().getFirstMatch(InfusionRecipe.TYPE, this, world).orElse(null); if (hasRecipe()) { if (recipe == null) { @@ -89,7 +90,7 @@ public class InfusionRitual implements Inventory { } return false; } - + public void stop() { activeRecipe = null; hasRecipe = false; @@ -97,14 +98,16 @@ public class InfusionRitual implements Inventory { time = 0; markDirty(); } - + public void tick() { if (isDirty) { configure(); isDirty = false; } - if (!isValid() || !hasRecipe()) return; - if (!checkRecipe()) return; + if (!isValid() || !hasRecipe()) + return; + if (!checkRecipe()) + return; progress++; if (progress == time) { input.removeStack(0); @@ -114,7 +117,7 @@ public class InfusionRitual implements Inventory { } stop(); } else { - ServerWorld world = (ServerWorld) this.world; + ServerLevel world = (ServerLevel) this.world; BlockPos target = worldPos.up(); double tx = target.getX() + 0.5; double ty = target.getY() + 0.5; @@ -126,31 +129,33 @@ public class InfusionRitual implements Inventory { double sx = start.getX() + 0.5; double sy = start.getY() + 1.25; double sz = start.getZ() + 0.5; - world.spawnParticles(new InfusionParticleType(stack), sx, sy, sz, 0, tx - sx, ty - sy, tz - sz, 0.5); + world.sendParticles(new InfusionParticleType(stack), sx, sy, sz, 0, tx - sx, ty - sy, tz - sz, 0.5); } } } - + } - + @Override public boolean isValid(int slot, ItemStack stack) { return isValid(); } - + public boolean isValid() { - if (world == null || world.isClient || worldPos == null || input == null) return false; + if (world == null || world.isClientSide || worldPos == null || input == null) + return false; for (PedestalBlockEntity catalyst : catalysts) { - if (catalyst == null) return false; + if (catalyst == null) + return false; } return true; } - + public boolean hasRecipe() { return hasRecipe; } - public void setLocation(World world, BlockPos pos) { + public void setLocation(Level world, BlockPos pos) { this.world = world; this.worldPos = pos; this.isDirty = true; @@ -158,7 +163,8 @@ public class InfusionRitual implements Inventory { @Override public void clear() { - if (!isValid()) return; + if (!isValid()) + return; input.clear(); for (PedestalBlockEntity catalyst : catalysts) { catalyst.clear(); @@ -177,7 +183,8 @@ public class InfusionRitual implements Inventory { @Override public ItemStack getStack(int slot) { - if (slot > 8) return ItemStack.EMPTY; + if (slot > 8) + return ItemStack.EMPTY; if (slot == 0) { return input.getStack(0); } else { @@ -192,7 +199,8 @@ public class InfusionRitual implements Inventory { @Override public ItemStack removeStack(int slot) { - if (slot > 8) return ItemStack.EMPTY; + if (slot > 8) + return ItemStack.EMPTY; if (slot == 0) { return input.removeStack(0); } else { @@ -202,7 +210,8 @@ public class InfusionRitual implements Inventory { @Override public void setStack(int slot, ItemStack stack) { - if (slot > 8) return; + if (slot > 8) + return; if (slot == 0) { input.setStack(0, stack); } else { @@ -224,7 +233,7 @@ public class InfusionRitual implements Inventory { public boolean canPlayerUse(PlayerEntity player) { return true; } - + public void fromTag(CompoundTag tag) { if (tag.contains("recipe")) { hasRecipe = tag.getBoolean("recipe"); diff --git a/src/main/java/ru/betterend/tab/CreativeTabs.java b/src/main/java/ru/betterend/tab/CreativeTabs.java index 1ee8eb5d..518925f7 100644 --- a/src/main/java/ru/betterend/tab/CreativeTabs.java +++ b/src/main/java/ru/betterend/tab/CreativeTabs.java @@ -1,16 +1,16 @@ package ru.betterend.tab; import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import ru.betterend.BetterEnd; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndItems; public class CreativeTabs { - public static final ItemGroup TAB_BLOCKS; - public static final ItemGroup TAB_ITEMS; + public static final CreativeModeTab TAB_BLOCKS; + public static final CreativeModeTab TAB_ITEMS; static { TAB_BLOCKS = FabricItemGroupBuilder.create(BetterEnd.makeID("end_blocks")) diff --git a/src/main/java/ru/betterend/util/BlocksHelper.java b/src/main/java/ru/betterend/util/BlocksHelper.java index fe2601ab..094ef837 100644 --- a/src/main/java/ru/betterend/util/BlocksHelper.java +++ b/src/main/java/ru/betterend/util/BlocksHelper.java @@ -9,20 +9,20 @@ import java.util.Set; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FallingBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FallingBlock; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.Property; -import net.minecraft.tag.BlockTags; +import net.minecraft.tags.BlockTags; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3i; -import net.minecraft.world.WorldAccess; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.LevelAccessor; import ru.betterend.blocks.BlueVineBlock; import ru.betterend.blocks.basis.DoublePlantBlock; import ru.betterend.blocks.basis.FurBlock; @@ -34,7 +34,7 @@ import ru.betterend.registry.EndTags; public class BlocksHelper { public static final BooleanProperty ROOTS = BooleanProperty.of("roots"); private static final Map COLOR_BY_BLOCK = Maps.newHashMap(); - + public static final int FLAG_UPDATE_BLOCK = 1; public static final int FLAG_SEND_CLIENT_CHANGES = 2; public static final int FLAG_NO_RERENDER = 4; @@ -45,97 +45,92 @@ public class BlocksHelper { public static final int SET_OBSERV = FLAG_UPDATE_BLOCK | FLAG_SEND_CLIENT_CHANGES; public static final Direction[] HORIZONTAL = makeHorizontal(); public static final Direction[] DIRECTIONS = Direction.values(); - - private static final Mutable POS = new Mutable(); - protected static final BlockState AIR = Blocks.AIR.getDefaultState(); - protected static final BlockState WATER = Blocks.WATER.getDefaultState(); - private static final Vec3i[] OFFSETS = new Vec3i[] { - new Vec3i(-1, -1, -1), new Vec3i(-1, -1, 0), new Vec3i(-1, -1, 1), - new Vec3i(-1, 0, -1), new Vec3i(-1, 0, 0), new Vec3i(-1, 0, 1), - new Vec3i(-1, 1, -1), new Vec3i(-1, 1, 0), new Vec3i(-1, 1, 1), + private static final MutableBlockPos POS = new MutableBlockPos(); + protected static final BlockState AIR = Blocks.AIR.defaultBlockState(); + protected static final BlockState WATER = Blocks.WATER.defaultBlockState(); - new Vec3i(0, -1, -1), new Vec3i(0, -1, 0), new Vec3i(0, -1, 1), - new Vec3i(0, 0, -1), new Vec3i(0, 0, 0), new Vec3i(0, 0, 1), - new Vec3i(0, 1, -1), new Vec3i(0, 1, 0), new Vec3i(0, 1, 1), + private static final Vec3i[] OFFSETS = new Vec3i[] { new Vec3i(-1, -1, -1), new Vec3i(-1, -1, 0), + new Vec3i(-1, -1, 1), new Vec3i(-1, 0, -1), new Vec3i(-1, 0, 0), new Vec3i(-1, 0, 1), new Vec3i(-1, 1, -1), + new Vec3i(-1, 1, 0), new Vec3i(-1, 1, 1), + + new Vec3i(0, -1, -1), new Vec3i(0, -1, 0), new Vec3i(0, -1, 1), new Vec3i(0, 0, -1), new Vec3i(0, 0, 0), + new Vec3i(0, 0, 1), new Vec3i(0, 1, -1), new Vec3i(0, 1, 0), new Vec3i(0, 1, 1), + + new Vec3i(1, -1, -1), new Vec3i(1, -1, 0), new Vec3i(1, -1, 1), new Vec3i(1, 0, -1), new Vec3i(1, 0, 0), + new Vec3i(1, 0, 1), new Vec3i(1, 1, -1), new Vec3i(1, 1, 0), new Vec3i(1, 1, 1) }; - new Vec3i(1, -1, -1), new Vec3i(1, -1, 0), new Vec3i(1, -1, 1), - new Vec3i(1, 0, -1), new Vec3i(1, 0, 0), new Vec3i(1, 0, 1), - new Vec3i(1, 1, -1), new Vec3i(1, 1, 0), new Vec3i(1, 1, 1) - }; - public static void addBlockColor(Block block, int color) { COLOR_BY_BLOCK.put(block, color); } - + public static int getBlockColor(Block block) { return COLOR_BY_BLOCK.getOrDefault(block, 0xFF000000); } - public static void setWithoutUpdate(WorldAccess world, BlockPos pos, BlockState state) { - world.setBlockState(pos, state, SET_SILENT); - } - - public static void setWithoutUpdate(WorldAccess world, BlockPos pos, Block block) { - world.setBlockState(pos, block.getDefaultState(), SET_SILENT); - } - - public static void setWithUpdate(WorldAccess world, BlockPos pos, BlockState state) { - world.setBlockState(pos, state, SET_OBSERV); - } - - public static void setWithUpdate(WorldAccess world, BlockPos pos, Block block) { - world.setBlockState(pos, block.getDefaultState(), SET_OBSERV); + public static void setWithoutUpdate(LevelAccessor world, BlockPos pos, BlockState state) { + world.setBlockAndUpdate(pos, state, SET_SILENT); } - public static int upRay(WorldAccess world, BlockPos pos, int maxDist) { + public static void setWithoutUpdate(LevelAccessor world, BlockPos pos, Block block) { + world.setBlockAndUpdate(pos, block.defaultBlockState(), SET_SILENT); + } + + public static void setWithUpdate(LevelAccessor world, BlockPos pos, BlockState state) { + world.setBlockAndUpdate(pos, state, SET_OBSERV); + } + + public static void setWithUpdate(LevelAccessor world, BlockPos pos, Block block) { + world.setBlockAndUpdate(pos, block.defaultBlockState(), SET_OBSERV); + } + + public static int upRay(LevelAccessor world, BlockPos pos, int maxDist) { int length = 0; for (int j = 1; j < maxDist && (world.isAir(pos.up(j))); j++) length++; return length; } - public static int downRay(WorldAccess world, BlockPos pos, int maxDist) { + public static int downRay(LevelAccessor world, BlockPos pos, int maxDist) { int length = 0; for (int j = 1; j < maxDist && (world.isAir(pos.down(j))); j++) length++; return length; } - - public static int downRayRep(WorldAccess world, BlockPos pos, int maxDist) { + + public static int downRayRep(LevelAccessor world, BlockPos pos, int maxDist) { POS.set(pos); - for (int j = 1; j < maxDist && (world.getBlockState(POS)).getMaterial().isReplaceable(); j++) - { + for (int j = 1; j < maxDist && (world.getBlockState(POS)).getMaterial().isReplaceable(); j++) { POS.setY(POS.getY() - 1); } return pos.getY() - POS.getY(); } - - public static int raycastSqr(WorldAccess world, BlockPos pos, int dx, int dy, int dz, int maxDist) { + + public static int raycastSqr(LevelAccessor world, BlockPos pos, int dx, int dy, int dz, int maxDist) { POS.set(pos); - for (int j = 1; j < maxDist && (world.getBlockState(POS)).getMaterial().isReplaceable(); j++) - { + for (int j = 1; j < maxDist && (world.getBlockState(POS)).getMaterial().isReplaceable(); j++) { POS.move(dx, dy, dz); } return (int) pos.getSquaredDistance(POS); } - public static BlockState rotateHorizontal(BlockState state, BlockRotation rotation, Property facing) { - return state.with(facing, rotation.rotate(state.get(facing))); + public static BlockState rotateHorizontal(BlockState state, Rotation rotation, Property facing) { + return state.with(facing, rotation.rotate(state.getValue(facing))); } public static BlockState mirrorHorizontal(BlockState state, BlockMirror mirror, Property facing) { - return state.rotate(mirror.getRotation(state.get(facing))); + return state.rotate(mirror.getRotation(state.getValue(facing))); } - public static int getLengthDown(WorldAccess world, BlockPos pos, Block block) { + public static int getLengthDown(LevelAccessor world, BlockPos pos, Block block) { int count = 1; while (world.getBlockState(pos.down(count)).getBlock() == block) count++; return count; } - public static void cover(WorldAccess world, BlockPos center, Block ground, BlockState cover, int radius, Random random) { + public static void cover(LevelAccessor world, BlockPos center, Block ground, BlockState cover, int radius, + Random random) { HashSet points = new HashSet(); HashSet points2 = new HashSet(); if (world.getBlockState(center).getBlock() == ground) { @@ -147,7 +142,7 @@ public class BlocksHelper { BlockPos pos = iterator.next(); for (Vec3i offset : OFFSETS) { if (random.nextBoolean()) { - BlockPos pos2 = pos.add(offset); + BlockPos pos2 = pos.offset(offset); if (random.nextBoolean() && world.getBlockState(pos2).getBlock() == ground && !points.contains(pos2)) points2.add(pos2); @@ -164,8 +159,8 @@ public class BlocksHelper { } } } - - public static void fixBlocks(WorldAccess world, BlockPos start, BlockPos end) { + + public static void fixBlocks(LevelAccessor world, BlockPos start, BlockPos end) { BlockState state; Set doubleCheck = Sets.newHashSet(); for (int x = start.getX(); x <= end.getX(); x++) { @@ -175,7 +170,7 @@ public class BlocksHelper { for (int y = start.getY(); y <= end.getY(); y++) { POS.setY(y); state = world.getBlockState(POS); - + if (state.getBlock() instanceof FurBlock) { doubleCheck.add(POS.toImmutable()); } @@ -207,19 +202,17 @@ public class BlocksHelper { break; } } - } - else if (state.isOf(EndBlocks.SMARAGDANT_CRYSTAL)) { + } else if (state.is(EndBlocks.SMARAGDANT_CRYSTAL)) { POS.setY(POS.getY() - 1); if (world.isAir(POS)) { POS.setY(POS.getY() + 1); - while (state.isOf(EndBlocks.SMARAGDANT_CRYSTAL)) { + while (state.is(EndBlocks.SMARAGDANT_CRYSTAL)) { setWithoutUpdate(world, POS, AIR); POS.setY(POS.getY() + 1); state = world.getBlockState(POS); } } - } - else if (state.getBlock() instanceof StalactiteBlock) { + } else if (state.getBlock() instanceof StalactiteBlock) { if (!state.canPlaceAt(world, POS)) { if (world.getBlockState(POS.up()).getBlock() instanceof StalactiteBlock) { while (state.getBlock() instanceof StalactiteBlock) { @@ -227,8 +220,7 @@ public class BlocksHelper { POS.setY(POS.getY() + 1); state = world.getBlockState(POS); } - } - else { + } else { while (state.getBlock() instanceof StalactiteBlock) { setWithoutUpdate(world, POS, AIR); POS.setY(POS.getY() - 1); @@ -236,15 +228,13 @@ public class BlocksHelper { } } } - } - else if (state.isOf(EndBlocks.CAVE_PUMPKIN)) { - if (!world.getBlockState(POS.up()).isOf(EndBlocks.CAVE_PUMPKIN_SEED)) { + } else if (state.is(EndBlocks.CAVE_PUMPKIN)) { + if (!world.getBlockState(POS.up()).is(EndBlocks.CAVE_PUMPKIN_SEED)) { setWithoutUpdate(world, POS, AIR); } - } - else if (!state.canPlaceAt(world, POS)) { + } else if (!state.canPlaceAt(world, POS)) { // Chorus - if (state.isOf(Blocks.CHORUS_PLANT)) { + if (state.is(Blocks.CHORUS_PLANT)) { Set ends = Sets.newHashSet(); Set add = Sets.newHashSet(); ends.add(POS.toImmutable()); @@ -253,15 +243,17 @@ public class BlocksHelper { ends.forEach((pos) -> { setWithoutUpdate(world, pos, AIR); for (Direction dir : HORIZONTAL) { - BlockPos p = pos.offset(dir); + BlockPos p = pos.relative(dir); BlockState st = world.getBlockState(p); - if ((st.isOf(Blocks.CHORUS_PLANT) || st.isOf(Blocks.CHORUS_FLOWER)) && !st.canPlaceAt(world, p)) { + if ((st.is(Blocks.CHORUS_PLANT) || st.is(Blocks.CHORUS_FLOWER)) + && !st.canPlaceAt(world, p)) { add.add(p); } } BlockPos p = pos.up(); BlockState st = world.getBlockState(p); - if ((st.isOf(Blocks.CHORUS_PLANT) || st.isOf(Blocks.CHORUS_FLOWER)) && !st.canPlaceAt(world, p)) { + if ((st.is(Blocks.CHORUS_PLANT) || st.is(Blocks.CHORUS_FLOWER)) + && !st.canPlaceAt(world, p)) { add.add(p); } }); @@ -286,14 +278,13 @@ public class BlocksHelper { int ray = downRayRep(world, POS.toImmutable(), 64); if (ray > 32) { - BlocksHelper.setWithoutUpdate(world, POS, Blocks.END_STONE.getDefaultState()); + BlocksHelper.setWithoutUpdate(world, POS, Blocks.END_STONE.defaultBlockState()); if (world.getRandom().nextBoolean()) { POS.setY(POS.getY() - 1); state = world.getBlockState(POS); - BlocksHelper.setWithoutUpdate(world, POS, Blocks.END_STONE.getDefaultState()); + BlocksHelper.setWithoutUpdate(world, POS, Blocks.END_STONE.defaultBlockState()); } - } - else { + } else { POS.setY(y); BlockState replacement = AIR; for (Direction dir : HORIZONTAL) { @@ -312,7 +303,8 @@ public class BlocksHelper { else { // Blue Vine if (state.getBlock() instanceof BlueVineBlock) { - while (state.isOf(EndBlocks.BLUE_VINE) || state.isOf(EndBlocks.BLUE_VINE_LANTERN) || state.isOf(EndBlocks.BLUE_VINE_FUR)) { + while (state.is(EndBlocks.BLUE_VINE) || state.is(EndBlocks.BLUE_VINE_LANTERN) + || state.is(EndBlocks.BLUE_VINE_FUR)) { BlocksHelper.setWithoutUpdate(world, POS, AIR); POS.setY(POS.getY() + 1); state = world.getBlockState(POS); @@ -333,34 +325,34 @@ public class BlocksHelper { } } } - + doubleCheck.forEach((pos) -> { if (!world.getBlockState(pos).canPlaceAt(world, pos)) { BlocksHelper.setWithoutUpdate(world, pos, AIR); } }); } - + private static BlockState getAirOrFluid(BlockState state) { return state.getFluidState().isEmpty() ? AIR : state.getFluidState().getBlockState(); } - + public static boolean isEndNylium(Block block) { return block.isIn(BlockTags.NYLIUM) && block.isIn(EndTags.END_GROUND); } - + public static boolean isEndNylium(BlockState state) { return isEndNylium(state.getBlock()); } - + public static Direction[] makeHorizontal() { return new Direction[] { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST }; } - + public static Direction randomHorizontal(Random random) { return HORIZONTAL[random.nextInt(4)]; } - + public static Direction randomDirection(Random random) { return DIRECTIONS[random.nextInt(6)]; } diff --git a/src/main/java/ru/betterend/util/BonemealUtil.java b/src/main/java/ru/betterend/util/BonemealUtil.java index 035f26c2..cbf685ec 100644 --- a/src/main/java/ru/betterend/util/BonemealUtil.java +++ b/src/main/java/ru/betterend/util/BonemealUtil.java @@ -7,68 +7,68 @@ import java.util.Random; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import net.minecraft.block.Block; -import net.minecraft.util.Identifier; +import net.minecraft.world.level.block.Block; +import net.minecraft.resources.ResourceLocation; import ru.betterend.registry.EndBiomes; import ru.betterend.registry.EndBlocks; import ru.betterend.world.biome.EndBiome; public class BonemealUtil { - private static final Map> GRASS_BIOMES = Maps.newHashMap(); + private static final Map> GRASS_BIOMES = Maps.newHashMap(); private static final Map GRASS_TYPES = Maps.newHashMap(); - + public static void init() { addBonemealGrass(EndBlocks.END_MOSS, EndBlocks.CREEPING_MOSS); addBonemealGrass(EndBlocks.END_MOSS, EndBlocks.UMBRELLA_MOSS); addBonemealGrass(EndBlocks.END_MYCELIUM, EndBlocks.CREEPING_MOSS); addBonemealGrass(EndBlocks.END_MYCELIUM, EndBlocks.UMBRELLA_MOSS); - + addBonemealGrass(EndBlocks.CAVE_MOSS, EndBlocks.CAVE_GRASS); addBonemealGrass(EndBlocks.CHORUS_NYLIUM, EndBlocks.CHORUS_GRASS); addBonemealGrass(EndBlocks.CRYSTAL_MOSS, EndBlocks.CRYSTAL_GRASS); addBonemealGrass(EndBlocks.SHADOW_GRASS, EndBlocks.SHADOW_PLANT); addBonemealGrass(EndBlocks.PINK_MOSS, EndBlocks.BUSHY_GRASS); addBonemealGrass(EndBlocks.AMBER_MOSS, EndBlocks.AMBER_GRASS); - + addBonemealGrass(EndBlocks.JUNGLE_MOSS, EndBlocks.JUNGLE_GRASS); addBonemealGrass(EndBlocks.JUNGLE_MOSS, EndBlocks.TWISTED_UMBRELLA_MOSS); addBonemealGrass(EndBlocks.JUNGLE_MOSS, EndBlocks.SMALL_JELLYSHROOM, 0.1F); - + addBonemealGrass(EndBiomes.GLOWING_GRASSLANDS, EndBlocks.END_MOSS, EndBlocks.BLOOMING_COOKSONIA); addBonemealGrass(EndBiomes.GLOWING_GRASSLANDS, EndBlocks.END_MOSS, EndBlocks.VAIOLUSH_FERN); addBonemealGrass(EndBiomes.GLOWING_GRASSLANDS, EndBlocks.END_MOSS, EndBlocks.FRACTURN); addBonemealGrass(EndBiomes.GLOWING_GRASSLANDS, EndBlocks.END_MOSS, EndBlocks.SALTEAGO); - + addBonemealGrass(EndBiomes.GLOWING_GRASSLANDS, EndBlocks.END_MOSS, EndBlocks.CREEPING_MOSS, 0.1F); addBonemealGrass(EndBiomes.GLOWING_GRASSLANDS, EndBlocks.END_MOSS, EndBlocks.UMBRELLA_MOSS, 0.1F); addBonemealGrass(EndBiomes.GLOWING_GRASSLANDS, EndBlocks.END_MOSS, EndBlocks.TWISTED_UMBRELLA_MOSS, 0.1F); - + addBonemealGrass(EndBlocks.RUTISCUS, EndBlocks.ORANGO); addBonemealGrass(EndBlocks.RUTISCUS, EndBlocks.AERIDIUM, 0.2F); addBonemealGrass(EndBlocks.RUTISCUS, EndBlocks.LUTEBUS, 0.2F); addBonemealGrass(EndBlocks.RUTISCUS, EndBlocks.LAMELLARIUM); - + addBonemealGrass(EndBiomes.LANTERN_WOODS, EndBlocks.RUTISCUS, EndBlocks.AERIDIUM, 0.2F); addBonemealGrass(EndBiomes.LANTERN_WOODS, EndBlocks.RUTISCUS, EndBlocks.LAMELLARIUM); addBonemealGrass(EndBiomes.LANTERN_WOODS, EndBlocks.RUTISCUS, EndBlocks.BOLUX_MUSHROOM, 0.05F); - + addBonemealGrass(EndBlocks.SANGNUM, EndBlocks.GLOBULAGUS); addBonemealGrass(EndBlocks.SANGNUM, EndBlocks.CLAWFERN); addBonemealGrass(EndBlocks.SANGNUM, EndBlocks.SMALL_AMARANITA_MUSHROOM, 0.1F); - + addBonemealGrass(EndBlocks.MOSSY_DRAGON_BONE, EndBlocks.GLOBULAGUS); addBonemealGrass(EndBlocks.MOSSY_DRAGON_BONE, EndBlocks.CLAWFERN); addBonemealGrass(EndBlocks.MOSSY_DRAGON_BONE, EndBlocks.SMALL_AMARANITA_MUSHROOM, 0.1F); - + addBonemealGrass(EndBlocks.MOSSY_OBSIDIAN, EndBlocks.GLOBULAGUS); addBonemealGrass(EndBlocks.MOSSY_OBSIDIAN, EndBlocks.CLAWFERN); addBonemealGrass(EndBlocks.MOSSY_OBSIDIAN, EndBlocks.SMALL_AMARANITA_MUSHROOM, 0.1F); } - + public static void addBonemealGrass(Block terrain, Block plant) { addBonemealGrass(terrain, plant, 1F); } - + public static void addBonemealGrass(Block terrain, Block plant, float chance) { GrassList list = GRASS_TYPES.get(terrain); if (list == null) { @@ -77,11 +77,11 @@ public class BonemealUtil { } list.addGrass(plant, chance); } - + public static void addBonemealGrass(EndBiome biome, Block terrain, Block plant) { addBonemealGrass(biome, terrain, plant, 1F); } - + public static void addBonemealGrass(EndBiome biome, Block terrain, Block plant, float chance) { Map map = GRASS_BIOMES.get(biome.getID()); if (map == null) { @@ -95,8 +95,8 @@ public class BonemealUtil { } list.addGrass(plant, chance); } - - public static Block getGrass(Identifier biomeID, Block terrain, Random random) { + + public static Block getGrass(ResourceLocation biomeID, Block terrain, Random random) { Map map = GRASS_BIOMES.get(biomeID); GrassList list = null; if (map != null) { @@ -104,44 +104,43 @@ public class BonemealUtil { if (list == null) { list = GRASS_TYPES.get(terrain); } - } - else { + } else { list = GRASS_TYPES.get(terrain); } return list == null ? null : list.getGrass(random); } - + private static final class GrassInfo { final Block grass; float chance; - + public GrassInfo(Block grass, float chance) { this.grass = grass; this.chance = chance; } - + public float addChance(float chance) { this.chance += chance; return this.chance; } } - + private static final class GrassList { final List list = Lists.newArrayList(); float maxChance = 0; - + public void addGrass(Block grass, float chance) { GrassInfo info = new GrassInfo(grass, chance); maxChance = info.addChance(maxChance); list.add(info); } - + public Block getGrass(Random random) { if (maxChance == 0 || list.isEmpty()) { return null; } float chance = random.nextFloat() * maxChance; - for (GrassInfo info: list) { + for (GrassInfo info : list) { if (chance <= info.chance) { return info.grass; } diff --git a/src/main/java/ru/betterend/util/ColorUtil.java b/src/main/java/ru/betterend/util/ColorUtil.java index 83ff6882..17c6f39b 100644 --- a/src/main/java/ru/betterend/util/ColorUtil.java +++ b/src/main/java/ru/betterend/util/ColorUtil.java @@ -12,47 +12,44 @@ import net.fabricmc.api.Environment; import net.fabricmc.fabric.impl.client.indigo.renderer.helper.ColorHelper; import net.minecraft.client.MinecraftClient; import net.minecraft.client.texture.NativeImage; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; import net.minecraft.resource.Resource; import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.registry.Registry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; @Environment(EnvType.CLIENT) public class ColorUtil { - + private static float[] floatBuffer = new float[4]; - + public static int[] toIntArray(int color) { - return new int[] { - (color >> 24) & 255, - (color >> 16) & 255, - (color >> 8) & 255, - color & 255 - }; + return new int[] { (color >> 24) & 255, (color >> 16) & 255, (color >> 8) & 255, color & 255 }; } - + public static float[] toFloatArray(int color) { floatBuffer[0] = ((color >> 16 & 255) / 255.0F); floatBuffer[1] = ((color >> 8 & 255) / 255.0F); floatBuffer[2] = ((color & 255) / 255.0F); floatBuffer[3] = ((color >> 24 & 255) / 255.0F); - + return floatBuffer; } - + public static float[] RGBtoHSB(int r, int g, int b, float[] hsbvals) { float hue, saturation, brightness; if (hsbvals == null) { hsbvals = floatBuffer; } int cmax = (r > g) ? r : g; - if (b > cmax) cmax = b; + if (b > cmax) + cmax = b; int cmin = (r < g) ? r : g; - if (b < cmin) cmin = b; + if (b < cmin) + cmin = b; brightness = ((float) cmax) / 255.0F; if (cmax != 0) @@ -80,14 +77,14 @@ public class ColorUtil { hsbvals[2] = brightness; return hsbvals; } - + public static int HSBtoRGB(float hue, float saturation, float brightness) { int r = 0, g = 0, b = 0; if (saturation == 0) { r = g = b = (int) (brightness * 255.0F + 0.5F); } else { - float h = (hue - (float)Math.floor(hue)) * 6.0F; - float f = h - (float)java.lang.Math.floor(h); + float h = (hue - (float) Math.floor(hue)) * 6.0F; + float f = h - (float) java.lang.Math.floor(h); float p = brightness * (1.0F - saturation); float q = brightness * (1.0F - saturation * f); float t = brightness * (1.0F - (saturation * (1.0F - f))); @@ -126,41 +123,43 @@ public class ColorUtil { } return 0xFF000000 | (r << 16) | (g << 8) | (b << 0); } - + public static int parseHex(String hexColor) { int len = hexColor.length(); if (len < 6 || len > 8 || len % 2 > 0) { return -1; } - + int color, shift; - if(len == 6) { - color = 0xFF000000; shift = 16; + if (len == 6) { + color = 0xFF000000; + shift = 16; } else { - color = 0; shift = 24; + color = 0; + shift = 24; } - + try { String[] splited = hexColor.split("(?<=\\G.{2})"); for (String digit : splited) { color |= Integer.valueOf(digit, 16) << shift; shift -= 8; } - } catch(NumberFormatException ex) { + } catch (NumberFormatException ex) { BetterEnd.LOGGER.catching(ex); return -1; } - + return color; } - + public static int toABGR(int color) { int r = (color >> 16) & 255; int g = (color >> 8) & 255; int b = color & 255; return 0xFF000000 | b << 16 | g << 8 | r; } - + public static int ABGRtoARGB(int color) { int a = (color >> 24) & 255; int b = (color >> 16) & 255; @@ -168,18 +167,18 @@ public class ColorUtil { int r = color & 255; return a << 24 | r << 16 | g << 8 | b; } - + public static int colorBrigtness(int color, float val) { RGBtoHSB((color >> 16) & 255, (color >> 8) & 255, color & 255, floatBuffer); floatBuffer[2] += val / 10.0F; - floatBuffer[2] = MathHelper.clamp(floatBuffer[2], 0.0F, 1.0F); + floatBuffer[2] = Mth.clamp(floatBuffer[2], 0.0F, 1.0F); return HSBtoRGB(floatBuffer[0], floatBuffer[1], floatBuffer[2]); } - + public static int applyTint(int color, int tint) { return colorBrigtness(ColorHelper.multiplyColor(color, tint), 1.5F); } - + public static int colorDistance(int color1, int color2) { int r1 = (color1 >> 16) & 255; int g1 = (color1 >> 8) & 255; @@ -189,20 +188,21 @@ public class ColorUtil { int b2 = color2 & 255; return MHelper.pow2(r1 - r2) + MHelper.pow2(g1 - g2) + MHelper.pow2(b1 - b2); } - - private static Map colorPalette = Maps.newHashMap(); - + + private static Map colorPalette = Maps.newHashMap(); + public static int extractColor(Item item) { - Identifier id = Registry.ITEM.getId(item); - if (id.equals(Registry.ITEM.getDefaultId())) return -1; + ResourceLocation id = Registry.ITEM.getId(item); + if (id.equals(Registry.ITEM.getDefaultId())) + return -1; if (colorPalette.containsKey(id)) { return colorPalette.get(id); } - Identifier texture; + ResourceLocation texture; if (item instanceof BlockItem) { - texture = new Identifier(id.getNamespace(), "textures/block/" + id.getPath() + ".png"); + texture = new ResourceLocation(id.getNamespace(), "textures/block/" + id.getPath() + ".png"); } else { - texture = new Identifier(id.getNamespace(), "textures/item/" + id.getPath() + ".png"); + texture = new ResourceLocation(id.getNamespace(), "textures/item/" + id.getPath() + ".png"); } NativeImage image = loadImage(texture, 16, 16); List colors = new ArrayList<>(); @@ -215,27 +215,28 @@ public class ColorUtil { } } image.close(); - - if (colors.size() == 0) return -1; - + + if (colors.size() == 0) + return -1; + ColorExtractor extractor = new ColorExtractor(colors); int color = extractor.analize(); colorPalette.put(id, color); - + return color; } - - public static NativeImage loadImage(Identifier image, int w, int h) { + + public static NativeImage loadImage(ResourceLocation image, int w, int h) { MinecraftClient minecraft = MinecraftClient.getInstance(); ResourceManager resourceManager = minecraft.getResourceManager(); if (resourceManager.containsResource(image)) { try (Resource resource = resourceManager.getResource(image)) { - return NativeImage.read(resource.getInputStream()); + return NativeImage.read(resource.getInputStream()); } catch (IOException e) { BetterEnd.LOGGER.warning("Can't load texture image: {}. Will be created empty image.", image); BetterEnd.LOGGER.warning("Cause: {}.", e.getMessage()); } - } + } return new NativeImage(w, h, false); } } \ No newline at end of file diff --git a/src/main/java/ru/betterend/util/FeaturesHelper.java b/src/main/java/ru/betterend/util/FeaturesHelper.java index c43e0d9c..806f8325 100644 --- a/src/main/java/ru/betterend/util/FeaturesHelper.java +++ b/src/main/java/ru/betterend/util/FeaturesHelper.java @@ -8,7 +8,7 @@ import java.util.function.Supplier; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredStructureFeature; @@ -23,9 +23,11 @@ public class FeaturesHelper { biomeRegistry.forEach((biome) -> { if (biome.getCategory() == Biome.Category.THEEND && !INJECTED.contains(biome)) { GenerationSettingsAccessor accessor = (GenerationSettingsAccessor) biome.getGenerationSettings(); - List>> structures = Lists.newArrayList(accessor.beGetStructures()); + List>> structures = Lists + .newArrayList(accessor.beGetStructures()); List>>> preFeatures = accessor.beGetFeatures(); - List>>> features = new ArrayList>>>(preFeatures.size()); + List>>> features = new ArrayList>>>( + preFeatures.size()); preFeatures.forEach((list) -> { features.add(Lists.newArrayList(list)); }); @@ -37,6 +39,6 @@ public class FeaturesHelper { accessor.beSetStructures(structures); INJECTED.add(biome); } - }); + }); } } \ No newline at end of file diff --git a/src/main/java/ru/betterend/util/ItemUtil.java b/src/main/java/ru/betterend/util/ItemUtil.java index 16ab37c8..030a47a0 100644 --- a/src/main/java/ru/betterend/util/ItemUtil.java +++ b/src/main/java/ru/betterend/util/ItemUtil.java @@ -5,15 +5,15 @@ import org.jetbrains.annotations.Nullable; import com.google.gson.JsonObject; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Identifier; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.JsonHelper; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; public class ItemUtil { - + public static String toStackString(@NotNull ItemStack stack) { try { if (stack == null) { @@ -26,7 +26,7 @@ public class ItemUtil { } return ""; } - + @Nullable public static ItemStack fromStackString(String stackString) { if (stackString == null || stackString.equals("")) { @@ -34,15 +34,16 @@ public class ItemUtil { } try { String[] parts = stackString.split(":"); - if (parts.length < 2) return null; + if (parts.length < 2) + return null; if (parts.length == 2) { - Identifier itemId = new Identifier(stackString); + ResourceLocation itemId = new ResourceLocation(stackString); Item item = Registry.ITEM.getOrEmpty(itemId).orElseThrow(() -> { return new IllegalStateException("Output item " + itemId + " does not exists!"); }); return new ItemStack(item); } - Identifier itemId = new Identifier(parts[0], parts[1]); + ResourceLocation itemId = new ResourceLocation(parts[0], parts[1]); Item item = Registry.ITEM.getOrEmpty(itemId).orElseThrow(() -> { return new IllegalStateException("Output item " + itemId + " does not exists!"); }); @@ -52,14 +53,14 @@ public class ItemUtil { } return null; } - + @Nullable public static ItemStack fromJsonRecipe(JsonObject recipe) { try { if (!recipe.has("item")) { throw new IllegalStateException("Invalid JsonObject. Entry 'item' does not exists!"); } - Identifier itemId = new Identifier(JsonHelper.getString(recipe, "item")); + ResourceLocation itemId = new ResourceLocation(JsonHelper.getString(recipe, "item")); Item item = Registry.ITEM.getOrEmpty(itemId).orElseThrow(() -> { return new IllegalStateException("Output item " + itemId + " does not exists!"); }); diff --git a/src/main/java/ru/betterend/util/LootTableUtil.java b/src/main/java/ru/betterend/util/LootTableUtil.java index 76400df1..163cec76 100644 --- a/src/main/java/ru/betterend/util/LootTableUtil.java +++ b/src/main/java/ru/betterend/util/LootTableUtil.java @@ -2,15 +2,15 @@ package ru.betterend.util; import net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder; import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback; -import net.minecraft.item.Items; +import net.minecraft.world.item.Items; import net.minecraft.loot.UniformLootTableRange; import net.minecraft.loot.condition.RandomChanceLootCondition; import net.minecraft.loot.entry.ItemEntry; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import ru.betterend.registry.EndItems; public class LootTableUtil { - private static final Identifier END_CITY_TREASURE_ID = new Identifier("chests/end_city_treasure"); + private static final ResourceLocation END_CITY_TREASURE_ID = new ResourceLocation("chests/end_city_treasure"); public static void init() { LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, supplier, setter) -> { diff --git a/src/main/java/ru/betterend/util/RecipeHelper.java b/src/main/java/ru/betterend/util/RecipeHelper.java index a95a372c..61bdbb13 100644 --- a/src/main/java/ru/betterend/util/RecipeHelper.java +++ b/src/main/java/ru/betterend/util/RecipeHelper.java @@ -1,18 +1,18 @@ package ru.betterend.util; -import net.minecraft.block.Block; -import net.minecraft.item.ItemConvertible; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.item.ItemConvertible; +import net.minecraft.core.Registry; public class RecipeHelper { public static boolean exists(ItemConvertible item) { if (item instanceof Block) { - return Registry.BLOCK.getId((Block) item) != Registry.BLOCK.getDefaultId(); + return Registry.BLOCK.getKey((Block) item) != Registry.BLOCK.getDefaultId(); } else { return Registry.ITEM.getId(item.asItem()) != Registry.ITEM.getDefaultId(); } } - + public static boolean exists(ItemConvertible... items) { for (ItemConvertible item : items) { if (!exists(item)) { diff --git a/src/main/java/ru/betterend/util/SpawnHelper.java b/src/main/java/ru/betterend/util/SpawnHelper.java index a3d9ba15..fccf56c7 100644 --- a/src/main/java/ru/betterend/util/SpawnHelper.java +++ b/src/main/java/ru/betterend/util/SpawnHelper.java @@ -1,21 +1,21 @@ package ru.betterend.util; import net.fabricmc.fabric.mixin.object.builder.SpawnRestrictionAccessor; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnRestriction.Location; -import net.minecraft.entity.SpawnRestriction.SpawnPredicate; -import net.minecraft.entity.mob.MobEntity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.SpawnRestriction.Location; +import net.minecraft.world.entity.SpawnRestriction.SpawnPredicate; +import net.minecraft.world.entity.mob.MobEntity; import net.minecraft.world.Heightmap.Type; public class SpawnHelper { public static void restrictionAir(EntityType entity, SpawnPredicate predicate) { SpawnRestrictionAccessor.callRegister(entity, Location.NO_RESTRICTIONS, Type.MOTION_BLOCKING, predicate); } - + public static void restrictionLand(EntityType entity, SpawnPredicate predicate) { SpawnRestrictionAccessor.callRegister(entity, Location.ON_GROUND, Type.MOTION_BLOCKING, predicate); } - + public static void restrictionWater(EntityType entity, SpawnPredicate predicate) { SpawnRestrictionAccessor.callRegister(entity, Location.IN_WATER, Type.MOTION_BLOCKING, predicate); } diff --git a/src/main/java/ru/betterend/util/SplineHelper.java b/src/main/java/ru/betterend/util/SplineHelper.java index b5e15f59..e5e66ef0 100644 --- a/src/main/java/ru/betterend/util/SplineHelper.java +++ b/src/main/java/ru/betterend/util/SplineHelper.java @@ -7,11 +7,11 @@ import java.util.function.Function; import com.google.common.collect.Lists; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.MathHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.util.Mth; import net.minecraft.world.StructureWorldAccess; import ru.betterend.util.sdf.SDF; import ru.betterend.util.sdf.operator.SDFUnion; @@ -24,15 +24,15 @@ public class SplineHelper { int count = points - 1; for (int i = 1; i < count; i++) { float delta = (float) i / (float) count; - float x = MathHelper.lerp(delta, x1, x2); - float y = MathHelper.lerp(delta, y1, y2); - float z = MathHelper.lerp(delta, z1, z2); + float x = Mth.lerp(delta, x1, x2); + float y = Mth.lerp(delta, y1, y2); + float z = Mth.lerp(delta, z1, z2); spline.add(new Vector3f(x, y, z)); } spline.add(new Vector3f(x2, y2, z2)); return spline; } - + public static List smoothSpline(List spline, int segmentPoints) { List result = Lists.newArrayList(); Vector3f start = spline.get(0); @@ -40,7 +40,7 @@ public class SplineHelper { Vector3f end = spline.get(i); for (int j = 0; j < segmentPoints; j++) { float delta = (float) j / segmentPoints; - delta = 0.5F - 0.5F * MathHelper.cos(delta * 3.14159F); + delta = 0.5F - 0.5F * Mth.cos(delta * 3.14159F); result.add(lerp(start, end, delta)); } start = end; @@ -48,14 +48,14 @@ public class SplineHelper { result.add(start); return result; } - + private static Vector3f lerp(Vector3f start, Vector3f end, float delta) { - float x = MathHelper.lerp(delta, start.getX(), end.getX()); - float y = MathHelper.lerp(delta, start.getY(), end.getY()); - float z = MathHelper.lerp(delta, start.getZ(), end.getZ()); + float x = Mth.lerp(delta, start.getX(), end.getX()); + float y = Mth.lerp(delta, start.getY(), end.getY()); + float z = Mth.lerp(delta, start.getZ(), end.getZ()); return new Vector3f(x, y, z); } - + public static void offsetParts(List spline, Random random, float dx, float dy, float dz) { int count = spline.size(); for (int i = 1; i < count; i++) { @@ -66,7 +66,7 @@ public class SplineHelper { pos.set(x, y, z); } } - + public static void powerOffset(List spline, float distance, float power) { int count = spline.size(); float max = count + 1; @@ -77,8 +77,9 @@ public class SplineHelper { pos.set(pos.getX(), y, pos.getZ()); } } - - public static SDF buildSDF(List spline, float radius1, float radius2, Function placerFunction) { + + public static SDF buildSDF(List spline, float radius1, float radius2, + Function placerFunction) { int count = spline.size(); float max = count - 2; SDF result = null; @@ -86,18 +87,17 @@ public class SplineHelper { for (int i = 1; i < count; i++) { Vector3f pos = spline.get(i); float delta = (float) (i - 1) / max; - SDF line = new SDFLine() - .setRadius(MathHelper.lerp(delta, radius1, radius2)) - .setStart(start.getX(), start.getY(), start.getZ()) - .setEnd(pos.getX(), pos.getY(), pos.getZ()) + SDF line = new SDFLine().setRadius(Mth.lerp(delta, radius1, radius2)) + .setStart(start.getX(), start.getY(), start.getZ()).setEnd(pos.getX(), pos.getY(), pos.getZ()) .setBlock(placerFunction); result = result == null ? line : new SDFUnion().setSourceA(result).setSourceB(line); start = pos; } return result; } - - public static SDF buildSDF(List spline, Function radiusFunction, Function placerFunction) { + + public static SDF buildSDF(List spline, Function radiusFunction, + Function placerFunction) { int count = spline.size(); float max = count - 2; SDF result = null; @@ -105,18 +105,17 @@ public class SplineHelper { for (int i = 1; i < count; i++) { Vector3f pos = spline.get(i); float delta = (float) (i - 1) / max; - SDF line = new SDFLine() - .setRadius(radiusFunction.apply(delta)) - .setStart(start.getX(), start.getY(), start.getZ()) - .setEnd(pos.getX(), pos.getY(), pos.getZ()) + SDF line = new SDFLine().setRadius(radiusFunction.apply(delta)) + .setStart(start.getX(), start.getY(), start.getZ()).setEnd(pos.getX(), pos.getY(), pos.getZ()) .setBlock(placerFunction); result = result == null ? line : new SDFUnion().setSourceA(result).setSourceB(line); start = pos; } return result; } - - public static boolean fillSpline(List spline, StructureWorldAccess world, BlockState state, BlockPos pos, Function replace) { + + public static boolean fillSpline(List spline, StructureWorldAccess world, BlockState state, BlockPos pos, + Function replace) { Vector3f startPos = spline.get(0); for (int i = 1; i < spline.size(); i++) { Vector3f endPos = spline.get(i); @@ -125,11 +124,12 @@ public class SplineHelper { } startPos = endPos; } - + return true; } - - public static void fillSplineForce(List spline, StructureWorldAccess world, BlockState state, BlockPos pos, Function replace) { + + public static void fillSplineForce(List spline, StructureWorldAccess world, BlockState state, + BlockPos pos, Function replace) { Vector3f startPos = spline.get(0); for (int i = 1; i < spline.size(); i++) { Vector3f endPos = spline.get(i); @@ -137,8 +137,9 @@ public class SplineHelper { startPos = endPos; } } - - public static boolean fillLine(Vector3f start, Vector3f end, StructureWorldAccess world, BlockState state, BlockPos pos, Function replace) { + + public static boolean fillLine(Vector3f start, Vector3f end, StructureWorldAccess world, BlockState state, + BlockPos pos, Function replace) { float dx = end.getX() - start.getX(); float dy = end.getY() - start.getY(); float dz = end.getZ() - start.getZ(); @@ -151,9 +152,9 @@ public class SplineHelper { float y = start.getY(); float z = start.getZ(); boolean down = Math.abs(dy) > 0.2; - + BlockState bState; - Mutable bPos = new Mutable(); + MutableBlockPos bPos = new MutableBlockPos(); for (int i = 0; i < count; i++) { bPos.set(x + pos.getX(), y + pos.getY(), z + pos.getZ()); bState = world.getBlockState(bPos); @@ -164,8 +165,7 @@ public class SplineHelper { if (down && bState.equals(state) || replace.apply(bState)) { BlocksHelper.setWithoutUpdate(world, bPos, state); } - } - else { + } else { return false; } x += dx; @@ -182,13 +182,13 @@ public class SplineHelper { BlocksHelper.setWithoutUpdate(world, bPos, state); } return true; - } - else { + } else { return false; } } - - public static void fillLineForce(Vector3f start, Vector3f end, StructureWorldAccess world, BlockState state, BlockPos pos, Function replace) { + + public static void fillLineForce(Vector3f start, Vector3f end, StructureWorldAccess world, BlockState state, + BlockPos pos, Function replace) { float dx = end.getX() - start.getX(); float dy = end.getY() - start.getY(); float dz = end.getZ() - start.getZ(); @@ -201,9 +201,9 @@ public class SplineHelper { float y = start.getY(); float z = start.getZ(); boolean down = Math.abs(dy) > 0.2; - + BlockState bState; - Mutable bPos = new Mutable(); + MutableBlockPos bPos = new MutableBlockPos(); for (int i = 0; i < count; i++) { bPos.set(x + pos.getX(), y + pos.getY(), z + pos.getZ()); bState = world.getBlockState(bPos); @@ -230,11 +230,12 @@ public class SplineHelper { } } } - - public static boolean canGenerate(List spline, float scale, BlockPos start, StructureWorldAccess world, Function canReplace) { + + public static boolean canGenerate(List spline, float scale, BlockPos start, StructureWorldAccess world, + Function canReplace) { int count = spline.size(); Vector3f vec = spline.get(0); - Mutable mut = new Mutable(); + MutableBlockPos mut = new MutableBlockPos(); float x1 = start.getX() + vec.getX() * scale; float y1 = start.getY() + vec.getY() * scale; float z1 = start.getZ() + vec.getZ() * scale; @@ -243,29 +244,31 @@ public class SplineHelper { float x2 = start.getX() + vec.getX() * scale; float y2 = start.getY() + vec.getY() * scale; float z2 = start.getZ() + vec.getZ() * scale; - + for (float py = y1; py < y2; py += 3) { - if (py - start.getY() < 10) continue; + if (py - start.getY() < 10) + continue; float lerp = (py - y1) / (y2 - y1); - float x = MathHelper.lerp(lerp, x1, x2); - float z = MathHelper.lerp(lerp, z1, z2); + float x = Mth.lerp(lerp, x1, x2); + float z = Mth.lerp(lerp, z1, z2); mut.set(x, py, z); if (!canReplace.apply(world.getBlockState(mut))) { return false; } } - + x1 = x2; y1 = y2; z1 = z2; } return true; } - - public static boolean canGenerate(List spline, BlockPos start, StructureWorldAccess world, Function canReplace) { + + public static boolean canGenerate(List spline, BlockPos start, StructureWorldAccess world, + Function canReplace) { int count = spline.size(); Vector3f vec = spline.get(0); - Mutable mut = new Mutable(); + MutableBlockPos mut = new MutableBlockPos(); float x1 = start.getX() + vec.getX(); float y1 = start.getY() + vec.getY(); float z1 = start.getZ() + vec.getZ(); @@ -274,25 +277,26 @@ public class SplineHelper { float x2 = start.getX() + vec.getX(); float y2 = start.getY() + vec.getY(); float z2 = start.getZ() + vec.getZ(); - + for (float py = y1; py < y2; py += 3) { - if (py - start.getY() < 10) continue; + if (py - start.getY() < 10) + continue; float lerp = (py - y1) / (y2 - y1); - float x = MathHelper.lerp(lerp, x1, x2); - float z = MathHelper.lerp(lerp, z1, z2); + float x = Mth.lerp(lerp, x1, x2); + float z = Mth.lerp(lerp, z1, z2); mut.set(x, py, z); if (!canReplace.apply(world.getBlockState(mut))) { return false; } } - + x1 = x2; y1 = y2; z1 = z2; } return true; } - + public static Vector3f getPos(List spline, float index) { int i = (int) index; int last = spline.size() - 1; @@ -302,14 +306,14 @@ public class SplineHelper { float delta = index - i; Vector3f p1 = spline.get(i); Vector3f p2 = spline.get(i + 1); - float x = MathHelper.lerp(delta, p1.getX(), p2.getX()); - float y = MathHelper.lerp(delta, p1.getY(), p2.getY()); - float z = MathHelper.lerp(delta, p1.getZ(), p2.getZ()); + float x = Mth.lerp(delta, p1.getX(), p2.getX()); + float y = Mth.lerp(delta, p1.getY(), p2.getY()); + float z = Mth.lerp(delta, p1.getZ(), p2.getZ()); return new Vector3f(x, y, z); } - + public static void rotateSpline(List spline, float angle) { - for (Vector3f v: spline) { + for (Vector3f v : spline) { float sin = (float) Math.sin(angle); float cos = (float) Math.cos(angle); float x = v.getX() * cos + v.getZ() * sin; @@ -317,27 +321,27 @@ public class SplineHelper { v.set(x, v.getY(), z); } } - + public static List copySpline(List spline) { List result = new ArrayList(spline.size()); - for (Vector3f v: spline) { + for (Vector3f v : spline) { result.add(new Vector3f(v.getX(), v.getY(), v.getZ())); } return result; } - + public static void scale(List spline, float scale) { scale(spline, scale, scale, scale); } - + public static void scale(List spline, float x, float y, float z) { - for (Vector3f v: spline) { + for (Vector3f v : spline) { v.set(v.getX() * x, v.getY() * y, v.getZ() * z); } } - + public static void offset(List spline, Vector3f offset) { - for (Vector3f v: spline) { + for (Vector3f v : spline) { v.set(offset.getX() + v.getX(), offset.getY() + v.getY(), offset.getZ() + v.getZ()); } } diff --git a/src/main/java/ru/betterend/util/StructureHelper.java b/src/main/java/ru/betterend/util/StructureHelper.java index 39879c5d..ec249958 100644 --- a/src/main/java/ru/betterend/util/StructureHelper.java +++ b/src/main/java/ru/betterend/util/StructureHelper.java @@ -11,39 +11,38 @@ import java.util.zip.ZipFile; import com.google.common.collect.Sets; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtIo; import net.minecraft.structure.Structure; import net.minecraft.structure.StructurePlacementData; -import net.minecraft.tag.BlockTags; +import net.minecraft.tags.BlockTags; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.Identifier; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndTags; public class StructureHelper { private static final Direction[] DIR = BlocksHelper.makeHorizontal(); - - public static Structure readStructure(Identifier resource) { + + public static Structure readStructure(ResourceLocation resource) { String ns = resource.getNamespace(); String nm = resource.getPath(); return readStructure("/data/" + ns + "/structures/" + nm + ".nbt"); } - + public static Structure readStructure(File datapack, String path) { if (datapack.isDirectory()) { return readStructure(datapack.toString() + "/" + path); - } - else if (datapack.isFile() && datapack.getName().endsWith(".zip")) { + } else if (datapack.isFile() && datapack.getName().endsWith(".zip")) { try { ZipFile zipFile = new ZipFile(datapack); Enumeration entries = zipFile.entries(); @@ -58,25 +57,23 @@ public class StructureHelper { System.out.format("\t %s - %d - %d\n", type, compressedSize, normalSize); } zipFile.close(); - } - catch (IOException e) { + } catch (IOException e) { e.printStackTrace(); } } return null; } - + public static Structure readStructure(String path) { try { InputStream inputstream = StructureHelper.class.getResourceAsStream(path); return readStructureFromStream(inputstream); - } - catch (IOException e) { + } catch (IOException e) { e.printStackTrace(); } return null; } - + private static Structure readStructureFromStream(InputStream stream) throws IOException { CompoundTag nbttagcompound = NbtIo.readCompressed(stream); @@ -85,22 +82,25 @@ public class StructureHelper { return template; } - - public static BlockPos offsetPos(BlockPos pos, Structure structure, BlockRotation rotation, BlockMirror mirror) { + + public static BlockPos offsetPos(BlockPos pos, Structure structure, Rotation rotation, BlockMirror mirror) { BlockPos offset = Structure.transformAround(structure.getSize(), mirror, rotation, BlockPos.ORIGIN); - return pos.add(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5); + return pos.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5); } - - public static void placeCenteredBottom(StructureWorldAccess world, BlockPos pos, Structure structure, BlockRotation rotation, BlockMirror mirror, Random random) { + + public static void placeCenteredBottom(StructureWorldAccess world, BlockPos pos, Structure structure, + Rotation rotation, BlockMirror mirror, Random random) { placeCenteredBottom(world, pos, structure, rotation, mirror, makeBox(pos), random); } - - public static void placeCenteredBottom(StructureWorldAccess world, BlockPos pos, Structure structure, BlockRotation rotation, BlockMirror mirror, BlockBox bounds, Random random) { + + public static void placeCenteredBottom(StructureWorldAccess world, BlockPos pos, Structure structure, + Rotation rotation, BlockMirror mirror, BlockBox bounds, Random random) { BlockPos offset = offsetPos(pos, structure, rotation, mirror); - StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds); + StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror) + .setBoundingBox(bounds); structure.place(world, offset, placementData, random); } - + private static BlockBox makeBox(BlockPos pos) { int sx = ((pos.getX() >> 4) << 4) - 16; int sz = ((pos.getZ() >> 4) << 4) - 16; @@ -108,28 +108,29 @@ public class StructureHelper { int ez = sz + 47; return BlockBox.create(sx, 0, sz, ex, 255, ez); } - - public static BlockBox getStructureBounds(BlockPos pos, Structure structure, BlockRotation rotation, BlockMirror mirror) { + + public static BlockBox getStructureBounds(BlockPos pos, Structure structure, Rotation rotation, + BlockMirror mirror) { BlockPos max = structure.getSize(); BlockPos min = Structure.transformAround(structure.getSize(), mirror, rotation, BlockPos.ORIGIN); max = max.subtract(min); return new BlockBox(min.add(pos), max.add(pos)); } - + public static BlockBox intersectBoxes(BlockBox box1, BlockBox box2) { int x1 = MHelper.max(box1.minX, box2.minX); int y1 = MHelper.max(box1.minY, box2.minY); int z1 = MHelper.max(box1.minZ, box2.minZ); - + int x2 = MHelper.min(box1.maxX, box2.maxX); int y2 = MHelper.min(box1.maxY, box2.maxY); int z2 = MHelper.min(box1.maxZ, box2.maxZ); - + return BlockBox.create(x1, y1, z1, x2, y2, z2); } - + public static void erode(StructureWorldAccess world, BlockBox bounds, int iterations, Random random) { - Mutable mut = new Mutable(); + MutableBlockPos mut = new MutableBlockPos(); boolean canDestruct = true; for (int i = 0; i < iterations; i++) { for (int x = bounds.minX; x <= bounds.maxX; x++) { @@ -139,7 +140,8 @@ public class StructureHelper { for (int y = bounds.maxY; y >= bounds.minY; y--) { mut.setY(y); BlockState state = world.getBlockState(mut); - if (canDestruct && state.isOf(EndBlocks.FLAVOLITE_RUNED_ETERNAL) && random.nextInt(8) == 0 && world.isAir(mut.down(2))) { + if (canDestruct && state.is(EndBlocks.FLAVOLITE_RUNED_ETERNAL) && random.nextInt(8) == 0 + && world.isAir(mut.down(2))) { int r = MHelper.randRange(1, 4, random); int cx = mut.getX(); int cy = mut.getY(); @@ -162,7 +164,8 @@ public class StructureHelper { int dz = pz - cz; dz *= dz; mut.setZ(pz); - if (dx + dy + dz <= r && world.getBlockState(mut).isOf(EndBlocks.FLAVOLITE_RUNED_ETERNAL)) { + if (dx + dy + dz <= r + && world.getBlockState(mut).is(EndBlocks.FLAVOLITE_RUNED_ETERNAL)) { BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); } } @@ -173,14 +176,13 @@ public class StructureHelper { mut.setZ(cz); canDestruct = false; continue; - } - else if (ignore(state)) { + } else if (ignore(state)) { continue; } if (!state.isAir() && random.nextBoolean()) { shuffle(random); - for (Direction dir: DIR) { - if (world.isAir(mut.offset(dir)) && world.isAir(mut.down().offset(dir))) { + for (Direction dir : DIR) { + if (world.isAir(mut.offset(dir)) && world.isAir(mut.below().offset(dir))) { BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); mut.move(dir).move(Direction.DOWN); for (int py = mut.getY(); y >= bounds.minY - 10; y--) { @@ -194,8 +196,8 @@ public class StructureHelper { } } break; - } - else if (random.nextInt(8) == 0 && !world.getBlockState(mut.up()).isOf(EndBlocks.ETERNAL_PEDESTAL)) { + } else if (random.nextInt(8) == 0 + && !world.getBlockState(mut.up()).is(EndBlocks.ETERNAL_PEDESTAL)) { BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); } } @@ -209,7 +211,7 @@ public class StructureHelper { for (int y = bounds.maxY; y >= bounds.minY; y--) { mut.setY(y); BlockState state = world.getBlockState(mut); - if (!ignore(state) && world.isAir(mut.down())) { + if (!ignore(state) && world.isAir(mut.below())) { BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); for (int py = mut.getY(); py >= bounds.minY - 10; py--) { mut.setY(py - 1); @@ -226,8 +228,8 @@ public class StructureHelper { } public static void erodeIntense(StructureWorldAccess world, BlockBox bounds, Random random) { - Mutable mut = new Mutable(); - Mutable mut2 = new Mutable(); + MutableBlockPos mut = new MutableBlockPos(); + MutableBlockPos mut2 = new MutableBlockPos(); int minY = bounds.minY - 10; for (int x = bounds.minX; x <= bounds.maxX; x++) { mut.setX(x); @@ -251,8 +253,7 @@ public class StructureHelper { BlocksHelper.setWithoutUpdate(world, mut2, state); } } - } - else if (random.nextInt(8) == 0) { + } else if (random.nextInt(8) == 0) { BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); } } @@ -262,23 +263,23 @@ public class StructureHelper { drop(world, bounds); } - + private static boolean isTerrainNear(StructureWorldAccess world, BlockPos pos) { - for (Direction dir: BlocksHelper.DIRECTIONS) { - if (world.getBlockState(pos.offset(dir)).isIn(EndTags.GEN_TERRAIN)) { + for (Direction dir : BlocksHelper.DIRECTIONS) { + if (world.getBlockState(pos.relative(dir)).isIn(EndTags.GEN_TERRAIN)) { return true; } } return false; } - + private static void drop(StructureWorldAccess world, BlockBox bounds) { - Mutable mut = new Mutable(); - + MutableBlockPos mut = new MutableBlockPos(); + Set blocks = Sets.newHashSet(); Set edge = Sets.newHashSet(); Set add = Sets.newHashSet(); - + for (int x = bounds.minX; x <= bounds.maxX; x++) { mut.setX(x); for (int z = bounds.minZ; z <= bounds.maxZ; z++) { @@ -292,14 +293,14 @@ public class StructureHelper { } } } - + if (edge.isEmpty()) { return; } - + while (!edge.isEmpty()) { - for (BlockPos center: edge) { - for (Direction dir: BlocksHelper.DIRECTIONS) { + for (BlockPos center : edge) { + for (Direction dir : BlocksHelper.DIRECTIONS) { BlockState state = world.getBlockState(center); if (state.isFullCube(world, center)) { mut.set(center).move(dir); @@ -312,13 +313,13 @@ public class StructureHelper { } } } - + blocks.addAll(edge); edge.clear(); edge.addAll(add); add.clear(); } - + int minY = bounds.minY - 10; for (int x = bounds.minX; x <= bounds.maxX; x++) { mut.setX(x); @@ -343,17 +344,12 @@ public class StructureHelper { } private static boolean ignore(BlockState state) { - return state.getMaterial().isReplaceable() - || !state.getFluidState().isEmpty() - || state.isIn(EndTags.END_GROUND) - || state.isOf(EndBlocks.ETERNAL_PEDESTAL) - || state.isOf(EndBlocks.FLAVOLITE_RUNED_ETERNAL) - || state.isIn(BlockTags.LOGS) - || state.isIn(BlockTags.LEAVES) - || state.getMaterial().equals(Material.PLANT) - || state.getMaterial().equals(Material.LEAVES); + return state.getMaterial().isReplaceable() || !state.getFluidState().isEmpty() || state.isIn(EndTags.END_GROUND) + || state.is(EndBlocks.ETERNAL_PEDESTAL) || state.is(EndBlocks.FLAVOLITE_RUNED_ETERNAL) + || state.isIn(BlockTags.LOGS) || state.isIn(BlockTags.LEAVES) + || state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.LEAVES); } - + private static void shuffle(Random random) { for (int i = 0; i < 4; i++) { int j = random.nextInt(4); @@ -362,9 +358,9 @@ public class StructureHelper { DIR[j] = d; } } - + public static void cover(StructureWorldAccess world, BlockBox bounds, Random random) { - Mutable mut = new Mutable(); + MutableBlockPos mut = new MutableBlockPos(); for (int x = bounds.minX; x <= bounds.maxX; x++) { mut.setX(x); for (int z = bounds.minZ; z <= bounds.maxZ; z++) { diff --git a/src/main/java/ru/betterend/util/TagHelper.java b/src/main/java/ru/betterend/util/TagHelper.java index 1cec51dd..5710e020 100644 --- a/src/main/java/ru/betterend/util/TagHelper.java +++ b/src/main/java/ru/betterend/util/TagHelper.java @@ -6,70 +6,70 @@ import java.util.Set; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemConvertible; -import net.minecraft.tag.Tag; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemConvertible; +import net.minecraft.tags.Tag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; public class TagHelper { - private static final Map> TAGS_BLOCK = Maps.newHashMap(); - private static final Map> TAGS_ITEM = Maps.newHashMap(); - + private static final Map> TAGS_BLOCK = Maps.newHashMap(); + private static final Map> TAGS_ITEM = Maps.newHashMap(); + public static void addTag(Tag.Identified tag, Block... blocks) { - Identifier tagID = tag.getId(); - Set set = TAGS_BLOCK.get(tagID); + ResourceLocation tagID = tag.getId(); + Set set = TAGS_BLOCK.get(tagID); if (set == null) { set = Sets.newHashSet(); TAGS_BLOCK.put(tagID, set); } - for (Block block: blocks) { - Identifier id = Registry.BLOCK.getId(block); + for (Block block : blocks) { + ResourceLocation id = Registry.BLOCK.getKey(block); if (id != Registry.BLOCK.getDefaultId()) { set.add(id); } } } - + public static void addTag(Tag.Identified tag, ItemConvertible... items) { - Identifier tagID = tag.getId(); - Set set = TAGS_ITEM.get(tagID); + ResourceLocation tagID = tag.getId(); + Set set = TAGS_ITEM.get(tagID); if (set == null) { set = Sets.newHashSet(); TAGS_ITEM.put(tagID, set); } - for (ItemConvertible item: items) { - Identifier id = Registry.ITEM.getId(item.asItem()); + for (ItemConvertible item : items) { + ResourceLocation id = Registry.ITEM.getId(item.asItem()); if (id != Registry.ITEM.getDefaultId()) { set.add(id); } } } - + @SafeVarargs public static void addTags(ItemConvertible item, Tag.Identified... tags) { - for (Tag.Identified tag: tags) { + for (Tag.Identified tag : tags) { addTag(tag, item); } } - + @SafeVarargs public static void addTags(Block block, Tag.Identified... tags) { - for (Tag.Identified tag: tags) { + for (Tag.Identified tag : tags) { addTag(tag, block); } } - - public static Tag.Builder apply(Tag.Builder builder, Set ids) { + + public static Tag.Builder apply(Tag.Builder builder, Set ids) { ids.forEach((value) -> { builder.add(value, "Better End Code"); }); return builder; } - - public static void apply(String entry, Map tagsMap) { - Map> endTags = null; + + public static void apply(String entry, Map tagsMap) { + Map> endTags = null; if (entry.equals("block")) { endTags = TAGS_BLOCK; } else if (entry.equals("item")) { diff --git a/src/main/java/ru/betterend/util/TranslationHelper.java b/src/main/java/ru/betterend/util/TranslationHelper.java index bc13490f..1911dff5 100644 --- a/src/main/java/ru/betterend/util/TranslationHelper.java +++ b/src/main/java/ru/betterend/util/TranslationHelper.java @@ -9,8 +9,8 @@ import com.google.common.collect.Lists; import com.google.gson.Gson; import com.google.gson.JsonObject; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import ru.betterend.BetterEnd; import ru.betterend.registry.EndBiomes; import ru.betterend.registry.EndItems; @@ -19,15 +19,15 @@ public class TranslationHelper { public static void printMissingNames() { List missingNamesEn = Lists.newArrayList(); List missingNamesRu = Lists.newArrayList(); - + Gson gson = new Gson(); InputStream streamEn = BetterEnd.class.getResourceAsStream("/assets/betterend/lang/en_us.json"); InputStream streamRu = BetterEnd.class.getResourceAsStream("/assets/betterend/lang/ru_ru.json"); JsonObject translationEn = gson.fromJson(new InputStreamReader(streamEn), JsonObject.class); JsonObject translationRu = gson.fromJson(new InputStreamReader(streamRu), JsonObject.class); - + Registry.BLOCK.forEach((block) -> { - if (Registry.BLOCK.getId(block).getNamespace().equals(BetterEnd.MOD_ID)) { + if (Registry.BLOCK.getKey(block).getNamespace().equals(BetterEnd.MOD_ID)) { String name = block.getName().getString(); if (!translationEn.has(name)) { missingNamesEn.add(name); @@ -37,7 +37,7 @@ public class TranslationHelper { } } }); - + EndItems.getModItems().forEach((item) -> { String name = item.getName().getString(); if (!translationEn.has(name)) { @@ -47,7 +47,7 @@ public class TranslationHelper { missingNamesRu.add(name); } }); - + EndBiomes.getModBiomes().forEach((endBiome) -> { if (endBiome.getID().getNamespace().equals(BetterEnd.MOD_ID)) { String name = "biome." + BetterEnd.MOD_ID + "." + endBiome.getID().getPath(); @@ -59,9 +59,9 @@ public class TranslationHelper { } } }); - + Registry.ENTITY_TYPE.forEach((entity) -> { - Identifier id = Registry.ENTITY_TYPE.getId(entity); + ResourceLocation id = Registry.ENTITY_TYPE.getId(entity); if (id.getNamespace().equals(BetterEnd.MOD_ID)) { String name = "entity." + BetterEnd.MOD_ID + "." + id.getPath(); if (!translationEn.has(name)) { @@ -72,12 +72,12 @@ public class TranslationHelper { } } }); - + if (!missingNamesEn.isEmpty() || !missingNamesRu.isEmpty()) { - + System.out.println("========================================"); System.out.println(" MISSING NAMES LIST"); - + if (!missingNamesEn.isEmpty()) { Collections.sort(missingNamesEn); System.out.println("========================================"); @@ -87,7 +87,7 @@ public class TranslationHelper { System.out.println(" \"" + name + "\": \"" + fastTranslateEn(name) + "\","); }); } - + if (!missingNamesRu.isEmpty()) { Collections.sort(missingNamesRu); System.out.println("========================================"); @@ -97,11 +97,11 @@ public class TranslationHelper { System.out.println(" \"" + name + "\": \"\","); }); } - + System.out.println("========================================"); } } - + public static String fastTranslateEn(String text) { String[] words = text.substring(text.lastIndexOf('.') + 1).split("_"); StringBuilder builder = new StringBuilder(); diff --git a/src/main/java/ru/betterend/util/WorldDataUtil.java b/src/main/java/ru/betterend/util/WorldDataUtil.java index e881ba09..5c99bcab 100644 --- a/src/main/java/ru/betterend/util/WorldDataUtil.java +++ b/src/main/java/ru/betterend/util/WorldDataUtil.java @@ -10,34 +10,32 @@ import ru.betterend.BetterEnd; public class WorldDataUtil { private static CompoundTag root; private static File saveFile; - + public static void load(File file) { saveFile = file; if (file.exists()) { try { root = NbtIo.readCompressed(file); - } - catch (IOException e) { - BetterEnd.LOGGER.error("World data loading failed", e); + } catch (IOException e) { + BetterEnd.LOGGER.error("Level data loading failed", e); root = new CompoundTag(); } return; } root = new CompoundTag(); } - + public static CompoundTag getRootTag() { return root; } - + public static CompoundTag getCompoundTag(String path) { String[] parts = path.split("\\."); CompoundTag tag = root; - for (String part: parts) { + for (String part : parts) { if (tag.contains(part)) { tag = tag.getCompound(part); - } - else { + } else { CompoundTag t = new CompoundTag(); tag.put(part, t); tag = t; @@ -45,13 +43,12 @@ public class WorldDataUtil { } return tag; } - + public static void saveFile() { try { NbtIo.writeCompressed(root, saveFile); - } - catch (IOException e) { - BetterEnd.LOGGER.error("World data saving failed", e); + } catch (IOException e) { + BetterEnd.LOGGER.error("Level data saving failed", e); } } } diff --git a/src/main/java/ru/betterend/util/sdf/PosInfo.java b/src/main/java/ru/betterend/util/sdf/PosInfo.java index bf5483b8..8594141f 100644 --- a/src/main/java/ru/betterend/util/sdf/PosInfo.java +++ b/src/main/java/ru/betterend/util/sdf/PosInfo.java @@ -2,33 +2,33 @@ package ru.betterend.util.sdf; import java.util.Map; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; public class PosInfo implements Comparable { - private static final BlockState AIR = Blocks.AIR.getDefaultState(); + private static final BlockState AIR = Blocks.AIR.defaultBlockState(); private final Map blocks; private final Map add; private final BlockPos pos; private BlockState state; - + public static PosInfo create(Map blocks, Map add, BlockPos pos) { return new PosInfo(blocks, add, pos); } - + private PosInfo(Map blocks, Map add, BlockPos pos) { this.blocks = blocks; this.add = add; this.pos = pos; blocks.put(pos, this); } - + public BlockState getState() { return state; } - + public BlockState getState(BlockPos pos) { PosInfo info = blocks.get(pos); if (info == null) { @@ -37,48 +37,48 @@ public class PosInfo implements Comparable { } return info.getState(); } - + public void setState(BlockState state) { this.state = state; } - + public void setState(BlockPos pos, BlockState state) { PosInfo info = blocks.get(pos); if (info != null) { info.setState(state); } } - + public BlockState getState(Direction dir) { - PosInfo info = blocks.get(pos.offset(dir)); + PosInfo info = blocks.get(pos.relative(dir)); if (info == null) { - info = add.get(pos.offset(dir)); + info = add.get(pos.relative(dir)); return info == null ? AIR : info.getState(); } return info.getState(); } - + public BlockState getState(Direction dir, int distance) { - PosInfo info = blocks.get(pos.offset(dir, distance)); + PosInfo info = blocks.get(pos.relative(dir, distance)); if (info == null) { return AIR; } return info.getState(); } - + public BlockState getStateUp() { return getState(Direction.UP); } - + public BlockState getStateDown() { return getState(Direction.DOWN); } - + @Override public int hashCode() { return pos.hashCode(); } - + @Override public boolean equals(Object obj) { if (!(obj instanceof PosInfo)) { @@ -95,7 +95,7 @@ public class PosInfo implements Comparable { public BlockPos getPos() { return pos; } - + public void setBlockPos(BlockPos pos, BlockState state) { PosInfo info = new PosInfo(blocks, add, pos); info.state = state; diff --git a/src/main/java/ru/betterend/util/sdf/SDF.java b/src/main/java/ru/betterend/util/sdf/SDF.java index 74aff385..a75ff615 100644 --- a/src/main/java/ru/betterend/util/sdf/SDF.java +++ b/src/main/java/ru/betterend/util/sdf/SDF.java @@ -11,11 +11,11 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.util.math.Box; -import net.minecraft.util.math.Direction; +import net.minecraft.core.Direction; import net.minecraft.world.ServerWorldAccess; import ru.betterend.util.BlocksHelper; import ru.betterend.world.structures.StructureWorld; @@ -27,19 +27,19 @@ public abstract class SDF { }; public abstract float getDistance(float x, float y, float z); - + public abstract BlockState getBlockState(BlockPos pos); - + public SDF addPostProcess(Function postProcess) { this.postProcesses.add(postProcess); return this; } - + public SDF setReplaceFunction(Function canReplace) { this.canReplace = canReplace; return this; } - + public void fillRecursive(ServerWorldAccess world, BlockPos start) { Map mapWorld = Maps.newHashMap(); Map addInfo = Maps.newHashMap(); @@ -48,15 +48,15 @@ public abstract class SDF { Set add = Sets.newHashSet(); ends.add(new BlockPos(0, 0, 0)); boolean run = true; - - Mutable bPos = new Mutable(); - + + MutableBlockPos bPos = new MutableBlockPos(); + while (run) { - for (BlockPos center: ends) { - for (Direction dir: Direction.values()) { + for (BlockPos center : ends) { + for (Direction dir : Direction.values()) { bPos.set(center).move(dir); BlockPos wpos = bPos.add(start); - + if (!blocks.contains(bPos) && canReplace.apply(world.getBlockState(wpos))) { if (this.getDistance(bPos.getX(), bPos.getY(), bPos.getZ()) < 0) { BlockState state = getBlockState(wpos); @@ -66,15 +66,15 @@ public abstract class SDF { } } } - + blocks.addAll(ends); ends.clear(); ends.addAll(add); add.clear(); - + run &= !ends.isEmpty(); } - + List infos = new ArrayList(mapWorld.values()); if (infos.size() > 0) { Collections.sort(infos); @@ -102,12 +102,12 @@ public abstract class SDF { }); } } - + public void fillArea(ServerWorldAccess world, BlockPos center, Box box) { Map mapWorld = Maps.newHashMap(); Map addInfo = Maps.newHashMap(); - - Mutable mut = new Mutable(); + + MutableBlockPos mut = new MutableBlockPos(); for (int y = (int) box.minY; y <= box.maxY; y++) { mut.setY(y); for (int x = (int) box.minX; x <= box.maxX; x++) { @@ -123,7 +123,7 @@ public abstract class SDF { } } } - + List infos = new ArrayList(mapWorld.values()); if (infos.size() > 0) { Collections.sort(infos); @@ -151,7 +151,7 @@ public abstract class SDF { }); } } - + public void fillRecursiveIgnore(ServerWorldAccess world, BlockPos start, Function ignore) { Map mapWorld = Maps.newHashMap(); Map addInfo = Maps.newHashMap(); @@ -160,12 +160,12 @@ public abstract class SDF { Set add = Sets.newHashSet(); ends.add(new BlockPos(0, 0, 0)); boolean run = true; - - Mutable bPos = new Mutable(); - + + MutableBlockPos bPos = new MutableBlockPos(); + while (run) { - for (BlockPos center: ends) { - for (Direction dir: Direction.values()) { + for (BlockPos center : ends) { + for (Direction dir : Direction.values()) { bPos.set(center).move(dir); BlockPos wpos = bPos.add(start); BlockState state = world.getBlockState(wpos); @@ -178,15 +178,15 @@ public abstract class SDF { } } } - + blocks.addAll(ends); ends.clear(); ends.addAll(add); add.clear(); - + run &= !ends.isEmpty(); } - + List infos = new ArrayList(mapWorld.values()); if (infos.size() > 0) { Collections.sort(infos); @@ -214,7 +214,7 @@ public abstract class SDF { }); } } - + public void fillRecursive(StructureWorld world, BlockPos start) { Map mapWorld = Maps.newHashMap(); Map addInfo = Maps.newHashMap(); @@ -223,15 +223,15 @@ public abstract class SDF { Set add = Sets.newHashSet(); ends.add(new BlockPos(0, 0, 0)); boolean run = true; - - Mutable bPos = new Mutable(); - + + MutableBlockPos bPos = new MutableBlockPos(); + while (run) { - for (BlockPos center: ends) { - for (Direction dir: Direction.values()) { + for (BlockPos center : ends) { + for (Direction dir : Direction.values()) { bPos.set(center).move(dir); BlockPos wpos = bPos.add(start); - + if (!blocks.contains(bPos)) { if (this.getDistance(bPos.getX(), bPos.getY(), bPos.getZ()) < 0) { BlockState state = getBlockState(wpos); @@ -241,15 +241,15 @@ public abstract class SDF { } } } - + blocks.addAll(ends); ends.clear(); ends.addAll(add); add.clear(); - + run &= !ends.isEmpty(); } - + List infos = new ArrayList(mapWorld.values()); Collections.sort(infos); postProcesses.forEach((postProcess) -> { @@ -260,7 +260,7 @@ public abstract class SDF { infos.forEach((info) -> { world.setBlock(info.getPos(), info.getState()); }); - + infos.clear(); infos.addAll(addInfo.values()); Collections.sort(infos); @@ -273,19 +273,19 @@ public abstract class SDF { world.setBlock(info.getPos(), info.getState()); }); } - + public Set getPositions(ServerWorldAccess world, BlockPos start) { Set blocks = Sets.newHashSet(); Set ends = Sets.newHashSet(); Set add = Sets.newHashSet(); ends.add(new BlockPos(0, 0, 0)); boolean run = true; - - Mutable bPos = new Mutable(); - + + MutableBlockPos bPos = new MutableBlockPos(); + while (run) { - for (BlockPos center: ends) { - for (Direction dir: Direction.values()) { + for (BlockPos center : ends) { + for (Direction dir : Direction.values()) { bPos.set(center).move(dir); BlockPos wpos = bPos.add(start); BlockState state = world.getBlockState(wpos); @@ -296,15 +296,15 @@ public abstract class SDF { } } } - + ends.forEach((end) -> blocks.add(end.add(start))); ends.clear(); ends.addAll(add); add.clear(); - + run &= !ends.isEmpty(); } - + return blocks; } } diff --git a/src/main/java/ru/betterend/util/sdf/operator/SDFBinary.java b/src/main/java/ru/betterend/util/sdf/operator/SDFBinary.java index 4c8fd72f..167de382 100644 --- a/src/main/java/ru/betterend/util/sdf/operator/SDFBinary.java +++ b/src/main/java/ru/betterend/util/sdf/operator/SDFBinary.java @@ -1,28 +1,28 @@ package ru.betterend.util.sdf.operator; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; import ru.betterend.util.sdf.SDF; public abstract class SDFBinary extends SDF { protected SDF sourceA; protected SDF sourceB; protected boolean firstValue; - + public SDFBinary setSourceA(SDF sourceA) { this.sourceA = sourceA; return this; } - + public SDFBinary setSourceB(SDF sourceB) { this.sourceB = sourceB; return this; } - + protected void selectValue(float a, float b) { firstValue = a < b; } - + @Override public BlockState getBlockState(BlockPos pos) { if (firstValue) { diff --git a/src/main/java/ru/betterend/util/sdf/operator/SDFHeightmap.java b/src/main/java/ru/betterend/util/sdf/operator/SDFHeightmap.java index c0129ba5..a82b50e4 100644 --- a/src/main/java/ru/betterend/util/sdf/operator/SDFHeightmap.java +++ b/src/main/java/ru/betterend/util/sdf/operator/SDFHeightmap.java @@ -1,7 +1,7 @@ package ru.betterend.util.sdf.operator; import net.minecraft.client.texture.NativeImage; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; public class SDFHeightmap extends SDFDisplacement { private float intensity = 1F; @@ -11,18 +11,18 @@ public class SDFHeightmap extends SDFDisplacement { private float scale; private float cos = 1; private float sin = 0; - + public SDFHeightmap() { setFunction((pos) -> { if (map == null) { return 0F; } - float px = MathHelper.clamp(pos.getX() * scale + offsetX, 0, map.getWidth() - 2); - float pz = MathHelper.clamp(pos.getZ() * scale + offsetZ, 0, map.getHeight() - 2); + float px = Mth.clamp(pos.getX() * scale + offsetX, 0, map.getWidth() - 2); + float pz = Mth.clamp(pos.getZ() * scale + offsetZ, 0, map.getHeight() - 2); float dx = (px * cos - pz * sin); float dz = (pz * cos + px * sin); - int x1 = MathHelper.floor(dx); - int z1 = MathHelper.floor(dz); + int x1 = Mth.floor(dx); + int z1 = Mth.floor(dz); int x2 = x1 + 1; int z2 = z1 + 1; dx = dx - x1; @@ -31,12 +31,12 @@ public class SDFHeightmap extends SDFDisplacement { float b = (map.getPixelColor(x2, z1) & 255) / 255F; float c = (map.getPixelColor(x1, z2) & 255) / 255F; float d = (map.getPixelColor(x2, z2) & 255) / 255F; - a = MathHelper.lerp(dx, a, b); - b = MathHelper.lerp(dx, c, d); - return -MathHelper.lerp(dz, a, b) * intensity; + a = Mth.lerp(dx, a, b); + b = Mth.lerp(dx, c, d); + return -Mth.lerp(dz, a, b) * intensity; }); } - + public SDFHeightmap setMap(NativeImage map) { this.map = map; offsetX = map.getWidth() * 0.5F; @@ -44,18 +44,18 @@ public class SDFHeightmap extends SDFDisplacement { scale = map.getWidth(); return this; } - + public SDFHeightmap setAngle(float angle) { - sin = MathHelper.sin(angle); - cos = MathHelper.cos(angle); + sin = Mth.sin(angle); + cos = Mth.cos(angle); return this; } - + public SDFHeightmap setScale(float scale) { this.scale = map.getWidth() * scale; return this; } - + public SDFHeightmap setIntensity(float intensity) { this.intensity = intensity; return this; diff --git a/src/main/java/ru/betterend/util/sdf/operator/SDFRadialNoiseMap.java b/src/main/java/ru/betterend/util/sdf/operator/SDFRadialNoiseMap.java index eeeb6918..b428973d 100644 --- a/src/main/java/ru/betterend/util/sdf/operator/SDFRadialNoiseMap.java +++ b/src/main/java/ru/betterend/util/sdf/operator/SDFRadialNoiseMap.java @@ -1,19 +1,19 @@ package ru.betterend.util.sdf.operator; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import ru.betterend.noise.OpenSimplexNoise; import ru.betterend.util.MHelper; public class SDFRadialNoiseMap extends SDFDisplacement { - private static final float SIN = MathHelper.sin(0.5F); - private static final float COS = MathHelper.cos(0.5F); - + private static final float SIN = Mth.sin(0.5F); + private static final float COS = Mth.cos(0.5F); + private OpenSimplexNoise noise; private float intensity = 1F; private float radius = 1F; private short offsetX; private short offsetZ; - + public SDFRadialNoiseMap() { setFunction((pos) -> { if (intensity == 0) { @@ -25,33 +25,34 @@ public class SDFRadialNoiseMap extends SDFDisplacement { if (distance > 1) { return 0F; } - distance = 1 - MathHelper.sqrt(distance); + distance = 1 - Mth.sqrt(distance); float nx = px * COS - pz * SIN; float nz = pz * COS + px * SIN; distance *= getNoise(nx * 0.75 + offsetX, nz * 0.75 + offsetZ); return distance * intensity; }); } - + private float getNoise(double x, double z) { - return (float) noise.eval(x, z) + (float) noise.eval(x * 3 + 1000, z * 3) * 0.5F + (float) noise.eval(x * 9 + 1000, z * 9) * 0.2F; + return (float) noise.eval(x, z) + (float) noise.eval(x * 3 + 1000, z * 3) * 0.5F + + (float) noise.eval(x * 9 + 1000, z * 9) * 0.2F; } - + public SDFRadialNoiseMap setSeed(long seed) { noise = new OpenSimplexNoise(seed); return this; } - + public SDFRadialNoiseMap setIntensity(float intensity) { this.intensity = intensity; return this; } - + public SDFRadialNoiseMap setRadius(float radius) { this.radius = radius; return this; } - + public SDFRadialNoiseMap setOffset(int x, int z) { offsetX = (short) (x & 32767); offsetZ = (short) (z & 32767); diff --git a/src/main/java/ru/betterend/util/sdf/operator/SDFSmoothIntersection.java b/src/main/java/ru/betterend/util/sdf/operator/SDFSmoothIntersection.java index d8643d64..e9aa513c 100644 --- a/src/main/java/ru/betterend/util/sdf/operator/SDFSmoothIntersection.java +++ b/src/main/java/ru/betterend/util/sdf/operator/SDFSmoothIntersection.java @@ -1,6 +1,6 @@ package ru.betterend.util.sdf.operator; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; public class SDFSmoothIntersection extends SDFBinary { private float radius; @@ -9,13 +9,13 @@ public class SDFSmoothIntersection extends SDFBinary { this.radius = radius; return this; } - + @Override public float getDistance(float x, float y, float z) { float a = this.sourceA.getDistance(x, y, z); float b = this.sourceB.getDistance(x, y, z); this.selectValue(a, b); - float h = MathHelper.clamp(0.5F - 0.5F * (b - a) / radius, 0F, 1F); - return MathHelper.lerp(h, b, a) + radius * h * (1F - h); + float h = Mth.clamp(0.5F - 0.5F * (b - a) / radius, 0F, 1F); + return Mth.lerp(h, b, a) + radius * h * (1F - h); } } diff --git a/src/main/java/ru/betterend/util/sdf/operator/SDFSmoothSubtraction.java b/src/main/java/ru/betterend/util/sdf/operator/SDFSmoothSubtraction.java index 2f24c1b6..98ba21c1 100644 --- a/src/main/java/ru/betterend/util/sdf/operator/SDFSmoothSubtraction.java +++ b/src/main/java/ru/betterend/util/sdf/operator/SDFSmoothSubtraction.java @@ -1,6 +1,6 @@ package ru.betterend.util.sdf.operator; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; public class SDFSmoothSubtraction extends SDFBinary { private float radius; @@ -9,13 +9,13 @@ public class SDFSmoothSubtraction extends SDFBinary { this.radius = radius; return this; } - + @Override public float getDistance(float x, float y, float z) { float a = this.sourceA.getDistance(x, y, z); float b = this.sourceB.getDistance(x, y, z); this.selectValue(a, b); - float h = MathHelper.clamp(0.5F - 0.5F * (b + a) / radius, 0F, 1F); - return MathHelper.lerp(h, b, -a) + radius * h * (1F - h); + float h = Mth.clamp(0.5F - 0.5F * (b + a) / radius, 0F, 1F); + return Mth.lerp(h, b, -a) + radius * h * (1F - h); } } diff --git a/src/main/java/ru/betterend/util/sdf/operator/SDFSmoothUnion.java b/src/main/java/ru/betterend/util/sdf/operator/SDFSmoothUnion.java index 417edc0a..103156fc 100644 --- a/src/main/java/ru/betterend/util/sdf/operator/SDFSmoothUnion.java +++ b/src/main/java/ru/betterend/util/sdf/operator/SDFSmoothUnion.java @@ -1,6 +1,6 @@ package ru.betterend.util.sdf.operator; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; public class SDFSmoothUnion extends SDFBinary { private float radius; @@ -15,7 +15,7 @@ public class SDFSmoothUnion extends SDFBinary { float a = this.sourceA.getDistance(x, y, z); float b = this.sourceB.getDistance(x, y, z); this.selectValue(a, b); - float h = MathHelper.clamp(0.5F + 0.5F * (b - a) / radius, 0F, 1F); - return MathHelper.lerp(h, b, a) - radius * h * (1F - h); + float h = Mth.clamp(0.5F + 0.5F * (b - a) / radius, 0F, 1F); + return Mth.lerp(h, b, a) - radius * h * (1F - h); } } diff --git a/src/main/java/ru/betterend/util/sdf/operator/SDFUnary.java b/src/main/java/ru/betterend/util/sdf/operator/SDFUnary.java index 83ea8cc4..29286ad5 100644 --- a/src/main/java/ru/betterend/util/sdf/operator/SDFUnary.java +++ b/src/main/java/ru/betterend/util/sdf/operator/SDFUnary.java @@ -1,17 +1,17 @@ package ru.betterend.util.sdf.operator; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; import ru.betterend.util.sdf.SDF; public abstract class SDFUnary extends SDF { protected SDF source; - + public SDFUnary setSource(SDF source) { this.source = source; return this; } - + @Override public BlockState getBlockState(BlockPos pos) { return source.getBlockState(pos); diff --git a/src/main/java/ru/betterend/util/sdf/primitive/SDFCappedCone.java b/src/main/java/ru/betterend/util/sdf/primitive/SDFCappedCone.java index 206a54de..580c6dfb 100644 --- a/src/main/java/ru/betterend/util/sdf/primitive/SDFCappedCone.java +++ b/src/main/java/ru/betterend/util/sdf/primitive/SDFCappedCone.java @@ -1,23 +1,23 @@ package ru.betterend.util.sdf.primitive; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import ru.betterend.util.MHelper; public class SDFCappedCone extends SDFPrimitive { private float radius1; private float radius2; private float height; - + public SDFCappedCone setRadius1(float radius) { this.radius1 = radius; return this; } - + public SDFCappedCone setRadius2(float radius) { this.radius2 = radius; return this; } - + public SDFCappedCone setHeight(float height) { this.height = height; return this; @@ -30,7 +30,8 @@ public class SDFCappedCone extends SDFPrimitive { float k2y = 2 * height; float cax = qx - MHelper.min(qx, (y < 0F) ? radius1 : radius2); float cay = Math.abs(y) - height; - float mlt = MathHelper.clamp(MHelper.dot(radius2 - qx, height - y, k2x, k2y) / MHelper.dot(k2x, k2y, k2x, k2y), 0F, 1F); + float mlt = Mth.clamp(MHelper.dot(radius2 - qx, height - y, k2x, k2y) / MHelper.dot(k2x, k2y, k2x, k2y), 0F, + 1F); float cbx = qx - radius2 + k2x * mlt; float cby = y - height + k2y * mlt; float s = (cbx < 0F && cay < 0F) ? -1F : 1F; diff --git a/src/main/java/ru/betterend/util/sdf/primitive/SDFCapsule.java b/src/main/java/ru/betterend/util/sdf/primitive/SDFCapsule.java index 404b9e24..4242d18f 100644 --- a/src/main/java/ru/betterend/util/sdf/primitive/SDFCapsule.java +++ b/src/main/java/ru/betterend/util/sdf/primitive/SDFCapsule.java @@ -1,24 +1,24 @@ package ru.betterend.util.sdf.primitive; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import ru.betterend.util.MHelper; public class SDFCapsule extends SDFPrimitive { private float radius; private float height; - + public SDFCapsule setRadius(float radius) { this.radius = radius; return this; } - + public SDFCapsule setHeight(float height) { this.height = height; return this; } - + @Override public float getDistance(float x, float y, float z) { - return MHelper.length(x, y - MathHelper.clamp(y, 0, height), z) - radius; + return MHelper.length(x, y - Mth.clamp(y, 0, height), z) - radius; } } diff --git a/src/main/java/ru/betterend/util/sdf/primitive/SDFLine.java b/src/main/java/ru/betterend/util/sdf/primitive/SDFLine.java index 15d46396..e35fc302 100644 --- a/src/main/java/ru/betterend/util/sdf/primitive/SDFLine.java +++ b/src/main/java/ru/betterend/util/sdf/primitive/SDFLine.java @@ -1,6 +1,6 @@ package ru.betterend.util.sdf.primitive; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import ru.betterend.util.MHelper; public class SDFLine extends SDFPrimitive { @@ -11,19 +11,19 @@ public class SDFLine extends SDFPrimitive { private float x2; private float y2; private float z2; - + public SDFLine setRadius(float radius) { this.radius = radius; return this; } - + public SDFLine setStart(float x, float y, float z) { this.x1 = x; this.y1 = y; this.z1 = z; return this; } - + public SDFLine setEnd(float x, float y, float z) { this.x2 = x; this.y2 = y; @@ -43,7 +43,7 @@ public class SDFLine extends SDFPrimitive { float dpb = MHelper.dot(pax, pay, paz, bax, bay, baz); float dbb = MHelper.dot(bax, bay, baz, bax, bay, baz); - float h = MathHelper.clamp(dpb / dbb, 0F, 1F); + float h = Mth.clamp(dpb / dbb, 0F, 1F); return MHelper.length(pax - bax * h, pay - bay * h, paz - baz * h) - radius; } } diff --git a/src/main/java/ru/betterend/util/sdf/primitive/SDFPie.java b/src/main/java/ru/betterend/util/sdf/primitive/SDFPie.java index 4e728bb1..3fdb2dcf 100644 --- a/src/main/java/ru/betterend/util/sdf/primitive/SDFPie.java +++ b/src/main/java/ru/betterend/util/sdf/primitive/SDFPie.java @@ -1,31 +1,31 @@ package ru.betterend.util.sdf.primitive; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import ru.betterend.util.MHelper; public class SDFPie extends SDFPrimitive { private float sin; private float cos; private float radius; - + public SDFPie setAngle(float angle) { this.sin = (float) Math.sin(angle); this.cos = (float) Math.cos(angle); return this; } - + public SDFPie setRadius(float radius) { this.radius = radius; return this; } - + @Override public float getDistance(float x, float y, float z) { float px = Math.abs(x); - float l = MHelper.length(px, y, z) - radius; - float m = MHelper.dot(px, z, sin, cos); - m = MathHelper.clamp(m, 0, radius); + float l = MHelper.length(px, y, z) - radius; + float m = MHelper.dot(px, z, sin, cos); + m = Mth.clamp(m, 0, radius); m = MHelper.length(px - sin * m, z - cos * m); - return MHelper.max(l, m * (float) Math.signum(cos * px - sin * z)); + return MHelper.max(l, m * (float) Math.signum(cos * px - sin * z)); } } diff --git a/src/main/java/ru/betterend/util/sdf/primitive/SDFPrimitive.java b/src/main/java/ru/betterend/util/sdf/primitive/SDFPrimitive.java index 5f8cf461..7ee719bf 100644 --- a/src/main/java/ru/betterend/util/sdf/primitive/SDFPrimitive.java +++ b/src/main/java/ru/betterend/util/sdf/primitive/SDFPrimitive.java @@ -2,38 +2,40 @@ package ru.betterend.util.sdf.primitive; import java.util.function.Function; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; import ru.betterend.util.sdf.SDF; public abstract class SDFPrimitive extends SDF { protected Function placerFunction; - + public SDFPrimitive setBlock(Function placerFunction) { this.placerFunction = placerFunction; return this; } - + public SDFPrimitive setBlock(BlockState state) { this.placerFunction = (pos) -> { return state; }; return this; } - + public SDFPrimitive setBlock(Block block) { this.placerFunction = (pos) -> { - return block.getDefaultState(); + return block.defaultBlockState(); }; return this; } - + public BlockState getBlockState(BlockPos pos) { return placerFunction.apply(pos); } - - /*public abstract CompoundTag toNBT(CompoundTag root) { - - }*/ + + /* + * public abstract CompoundTag toNBT(CompoundTag root) { + * + * } + */ } diff --git a/src/main/java/ru/betterend/world/biome/BiomeDefinition.java b/src/main/java/ru/betterend/world/biome/BiomeDefinition.java index 49475736..c3c96e88 100644 --- a/src/main/java/ru/betterend/world/biome/BiomeDefinition.java +++ b/src/main/java/ru/betterend/world/biome/BiomeDefinition.java @@ -4,18 +4,18 @@ import java.util.List; import com.google.common.collect.Lists; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import net.minecraft.client.sound.MusicType; -import net.minecraft.entity.EntityType; -import net.minecraft.particle.ParticleEffect; +import net.minecraft.world.entity.EntityType; +import net.minecraft.core.particles.ParticleOptions; import net.minecraft.sound.BiomeAdditionsSound; import net.minecraft.sound.BiomeMoodSound; import net.minecraft.sound.MusicSound; import net.minecraft.sound.SoundEvent; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.registry.Registry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import net.minecraft.core.Registry; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome.Category; import net.minecraft.world.biome.Biome.Precipitation; @@ -44,7 +44,7 @@ import ru.betterend.world.surface.SurfaceBuilders; public class BiomeDefinition { private static final int DEF_FOLIAGE = MHelper.color(197, 210, 112); - + private final List> structures = Lists.newArrayList(); private final List features = Lists.newArrayList(); private final List carvers = Lists.newArrayList(); @@ -65,62 +65,60 @@ public class BiomeDefinition { private float fogDensity = 1F; private float depth = 0.1F; - private final Identifier id; + private final ResourceLocation id; private float genChance = 1F; private boolean hasCaves = true; private boolean isCaveBiome = false; - + private ConfiguredSurfaceBuilder surface; public BiomeDefinition(String name) { this.id = BetterEnd.makeID(name); } - + public BiomeDefinition setCaveBiome() { isCaveBiome = true; return this; } - + public BiomeDefinition setSurface(Block block) { - setSurface(SurfaceBuilder.DEFAULT.withConfig(new TernarySurfaceConfig( - block.getDefaultState(), - Blocks.END_STONE.getDefaultState(), - Blocks.END_STONE.getDefaultState() - ))); + setSurface(SurfaceBuilder.DEFAULT.withConfig(new TernarySurfaceConfig(block.defaultBlockState(), + Blocks.END_STONE.defaultBlockState(), Blocks.END_STONE.defaultBlockState()))); return this; } - + public BiomeDefinition setSurface(Block block1, Block block2) { - setSurface(DoubleBlockSurfaceBuilder.register("be_" + id.getPath() + "_surface").setBlock1(block1).setBlock2(block2).configured()); + setSurface(DoubleBlockSurfaceBuilder.register("be_" + id.getPath() + "_surface").setBlock1(block1) + .setBlock2(block2).configured()); return this; } - + public BiomeDefinition setSurface(ConfiguredSurfaceBuilder builder) { this.surface = builder; return this; } - + public BiomeDefinition setSurface(SurfaceBuilder builder) { return setSurface(builder.withConfig(SurfaceBuilders.DEFAULT_END_CONFIG)); } - public BiomeDefinition setParticles(ParticleEffect particle, float probability) { + public BiomeDefinition setParticles(ParticleOptions particle, float probability) { this.particleConfig = new BiomeParticleConfig(particle, probability); return this; } - + public BiomeDefinition setGenChance(float genChance) { this.genChance = genChance; return this; } - + public BiomeDefinition setDepth(float depth) { this.depth = depth; return this; } public BiomeDefinition addMobSpawn(EntityType type, int weight, int minGroupSize, int maxGroupSize) { - Identifier eID = Registry.ENTITY_TYPE.getId(type); + ResourceLocation eID = Registry.ENTITY_TYPE.getId(type); if (eID != Registry.ENTITY_TYPE.getDefaultId()) { SpawnInfo info = new SpawnInfo(); info.type = type; @@ -131,7 +129,7 @@ public class BiomeDefinition { } return this; } - + public BiomeDefinition addMobSpawn(SpawnEntry entry) { spawns.add(entry); return this; @@ -141,12 +139,12 @@ public class BiomeDefinition { structures.add(feature); return this; } - + public BiomeDefinition addStructureFeature(EndStructureFeature feature) { structures.add(feature.getFeatureConfigured()); return this; } - + public BiomeDefinition addFeature(EndFeature feature) { FeatureInfo info = new FeatureInfo(); info.featureStep = feature.getFeatureStep(); @@ -162,11 +160,11 @@ public class BiomeDefinition { features.add(info); return this; } - + private int getColor(int r, int g, int b) { - r = MathHelper.clamp(r, 0, 255); - g = MathHelper.clamp(g, 0, 255); - b = MathHelper.clamp(b, 0, 255); + r = Mth.clamp(r, 0, 255); + g = Mth.clamp(g, 0, 255); + b = Mth.clamp(b, 0, 255); return MHelper.color(r, g, b); } @@ -189,21 +187,21 @@ public class BiomeDefinition { this.waterFogColor = getColor(r, g, b); return this; } - + public BiomeDefinition setWaterAndFogColor(int r, int g, int b) { return setWaterColor(r, g, b).setWaterFogColor(r, g, b); } - + public BiomeDefinition setFoliageColor(int r, int g, int b) { this.foliageColor = getColor(r, g, b); return this; } - + public BiomeDefinition setGrassColor(int r, int g, int b) { this.grassColor = getColor(r, g, b); return this; } - + public BiomeDefinition setPlantsColor(int r, int g, int b) { return this.setFoliageColor(r, g, b).setGrassColor(r, g, b); } @@ -227,7 +225,7 @@ public class BiomeDefinition { this.music = music; return this; } - + public BiomeDefinition setCaves(boolean hasCaves) { this.hasCaves = hasCaves; return this; @@ -239,9 +237,10 @@ public class BiomeDefinition { Builder effects = new Builder(); mobs.forEach((spawn) -> { - spawnSettings.spawn(spawn.type.getSpawnGroup(), new SpawnSettings.SpawnEntry(spawn.type, spawn.weight, spawn.minGroupSize, spawn.maxGroupSize)); + spawnSettings.spawn(spawn.type.getSpawnGroup(), + new SpawnSettings.SpawnEntry(spawn.type, spawn.weight, spawn.minGroupSize, spawn.maxGroupSize)); }); - + spawns.forEach((entry) -> { spawnSettings.spawn(entry.type.getSpawnGroup(), entry); }); @@ -252,24 +251,22 @@ public class BiomeDefinition { features.forEach((info) -> generationSettings.feature(info.featureStep, info.feature)); carvers.forEach((info) -> generationSettings.carver(info.carverStep, info.carver)); - effects.skyColor(0).waterColor(waterColor).waterFogColor(waterFogColor).fogColor(fogColor).foliageColor(foliageColor).grassColor(grassColor); - if (loop != null) effects.loopSound(loop); - if (mood != null) effects.moodSound(mood); - if (additions != null) effects.additionsSound(additions); - if (particleConfig != null) effects.particleConfig(particleConfig); + effects.skyColor(0).waterColor(waterColor).waterFogColor(waterFogColor).fogColor(fogColor) + .foliageColor(foliageColor).grassColor(grassColor); + if (loop != null) + effects.loopSound(loop); + if (mood != null) + effects.moodSound(mood); + if (additions != null) + effects.additionsSound(additions); + if (particleConfig != null) + effects.particleConfig(particleConfig); effects.music(music != null ? new MusicSound(music, 600, 2400, true) : MusicType.END); - return new Biome.Builder() - .precipitation(Precipitation.NONE) - .category(isCaveBiome ? Category.NONE : Category.THEEND) - .depth(depth) - .scale(0.2F) - .temperature(2.0F) - .downfall(0.0F) - .effects(effects.build()) - .spawnSettings(spawnSettings.build()) - .generationSettings(generationSettings.build()) - .build(); + return new Biome.Builder().precipitation(Precipitation.NONE) + .category(isCaveBiome ? Category.NONE : Category.THEEND).depth(depth).scale(0.2F).temperature(2.0F) + .downfall(0.0F).effects(effects.build()).spawnSettings(spawnSettings.build()) + .generationSettings(generationSettings.build()).build(); } private static final class SpawnInfo { @@ -283,16 +280,16 @@ public class BiomeDefinition { Feature featureStep; ConfiguredFeature feature; } - + private static final class CarverInfo { Carver carverStep; ConfiguredCarver carver; } - public Identifier getID() { + public ResourceLocation getID() { return id; } - + public float getFodDensity() { return fogDensity; } diff --git a/src/main/java/ru/betterend/world/biome/EndBiome.java b/src/main/java/ru/betterend/world/biome/EndBiome.java index 7b1a5f02..b01d89f0 100644 --- a/src/main/java/ru/betterend/world/biome/EndBiome.java +++ b/src/main/java/ru/betterend/world/biome/EndBiome.java @@ -8,8 +8,8 @@ import com.google.common.collect.Lists; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.Registry; import net.minecraft.world.biome.Biome; import ru.betterend.config.Configs; import ru.betterend.util.JsonFactory; @@ -23,7 +23,7 @@ public class EndBiome { protected List subbiomes = Lists.newArrayList(); protected final Biome biome; - protected final Identifier mcID; + protected final ResourceLocation mcID; protected EndBiome edge; protected int edgeSize; @@ -50,7 +50,7 @@ public class EndBiome { this.edgeSize = Configs.BIOME_CONFIG.getInt(mcID, "edge_size", 32); } - public EndBiome(Identifier id, Biome biome, float fogDensity, float genChance, boolean hasCaves) { + public EndBiome(ResourceLocation id, Biome biome, float fogDensity, float genChance, boolean hasCaves) { this.mcID = id; this.readStructureList(); this.biome = biome; @@ -82,7 +82,7 @@ public class EndBiome { biome.biomeParent = this; subbiomes.add(biome); } - + public boolean containsSubBiome(EndBiome biome) { return subbiomes.contains(biome); } @@ -130,14 +130,14 @@ public class EndBiome { return mcID.toString(); } - public Identifier getID() { + public ResourceLocation getID() { return mcID; } public float getFogDensity() { return fogDensity; } - + protected void readStructureList() { String ns = mcID.getNamespace(); String nm = mcID.getPath(); @@ -162,11 +162,11 @@ public class EndBiome { } } } - + public EndFeature getStructuresFeature() { return structuresFeature; } - + public Biome getActualBiome() { return this.actualBiome; } @@ -174,15 +174,15 @@ public class EndBiome { public float getGenChance() { return this.genChance; } - + public float getGenChanceImmutable() { return this.genChanceUnmutable; } - + public boolean hasCaves() { return hasCaves; } - + public void updateActualBiomes(Registry biomeRegistry) { subbiomes.forEach((sub) -> { if (sub != this) { @@ -194,7 +194,7 @@ public class EndBiome { } this.actualBiome = biomeRegistry.get(mcID); } - + @Override public boolean equals(Object obj) { if (obj == this) { @@ -203,7 +203,7 @@ public class EndBiome { EndBiome biome = (EndBiome) obj; return biome == null ? false : biome.mcID.equals(mcID); } - + @Override public int hashCode() { return mcID.hashCode(); diff --git a/src/main/java/ru/betterend/world/biome/air/BiomeIceStarfield.java b/src/main/java/ru/betterend/world/biome/air/BiomeIceStarfield.java index a9b42808..9e2424c9 100644 --- a/src/main/java/ru/betterend/world/biome/air/BiomeIceStarfield.java +++ b/src/main/java/ru/betterend/world/biome/air/BiomeIceStarfield.java @@ -1,6 +1,6 @@ package ru.betterend.world.biome.air; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.EntityType; import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndParticles; import ru.betterend.registry.EndStructures; @@ -9,15 +9,9 @@ import ru.betterend.world.biome.EndBiome; public class BiomeIceStarfield extends EndBiome { public BiomeIceStarfield() { - super(new BiomeDefinition("ice_starfield") - .setFogColor(224, 245, 254) - .setFogDensity(2.2F) - .setFoliageColor(193, 244, 244) - .setGenChance(0.25F) - .setParticles(EndParticles.SNOWFLAKE, 0.002F) - .addStructureFeature(EndStructures.GIANT_ICE_STAR) - .addFeature(EndFeatures.ICE_STAR) - .addFeature(EndFeatures.ICE_STAR_SMALL) - .addMobSpawn(EntityType.ENDERMAN, 20, 1, 4)); + super(new BiomeDefinition("ice_starfield").setFogColor(224, 245, 254).setFogDensity(2.2F) + .setFoliageColor(193, 244, 244).setGenChance(0.25F).setParticles(EndParticles.SNOWFLAKE, 0.002F) + .addStructureFeature(EndStructures.GIANT_ICE_STAR).addFeature(EndFeatures.ICE_STAR) + .addFeature(EndFeatures.ICE_STAR_SMALL).addMobSpawn(EntityType.ENDERMAN, 20, 1, 4)); } } diff --git a/src/main/java/ru/betterend/world/biome/cave/EndCaveBiome.java b/src/main/java/ru/betterend/world/biome/cave/EndCaveBiome.java index dd2cab46..dff525fe 100644 --- a/src/main/java/ru/betterend/world/biome/cave/EndCaveBiome.java +++ b/src/main/java/ru/betterend/world/biome/cave/EndCaveBiome.java @@ -2,9 +2,9 @@ package ru.betterend.world.biome.cave; import java.util.Random; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.util.collection.WeightedList; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.gen.feature.Feature; import ru.betterend.registry.EndBiomes; import ru.betterend.world.biome.BiomeDefinition; @@ -15,44 +15,42 @@ import ru.betterend.world.features.terrain.caves.CaveChunkPopulatorFeature; public class EndCaveBiome extends EndBiome { private WeightedList> floorFeatures = new WeightedList>(); private WeightedList> ceilFeatures = new WeightedList>(); - + public EndCaveBiome(BiomeDefinition definition) { super(makeDef(definition)); } - + private static BiomeDefinition makeDef(BiomeDefinition definition) { - EndFeature feature = EndFeature.makeChunkFeature( - definition.getID().getPath() + "_cave_populator", - new CaveChunkPopulatorFeature(() -> (EndCaveBiome) EndBiomes.getBiome(definition.getID())) - ); + EndFeature feature = EndFeature.makeChunkFeature(definition.getID().getPath() + "_cave_populator", + new CaveChunkPopulatorFeature(() -> (EndCaveBiome) EndBiomes.getBiome(definition.getID()))); definition.addFeature(feature).setCaveBiome(); return definition; } - + public void addFloorFeature(Feature feature, int weight) { floorFeatures.add(feature, weight); } - + public void addCeilFeature(Feature feature, int weight) { ceilFeatures.add(feature, weight); } - + public Feature getFloorFeature(Random random) { return floorFeatures.isEmpty() ? null : floorFeatures.pickRandom(random); } - + public Feature getCeilFeature(Random random) { return ceilFeatures.isEmpty() ? null : ceilFeatures.pickRandom(random); } - + public float getFloorDensity() { return 0; } - + public float getCeilDensity() { return 0; } - + public BlockState getCeil(BlockPos pos) { return null; } diff --git a/src/main/java/ru/betterend/world/biome/cave/LushAuroraCaveBiome.java b/src/main/java/ru/betterend/world/biome/cave/LushAuroraCaveBiome.java index 4271d50a..5e8ddcb4 100644 --- a/src/main/java/ru/betterend/world/biome/cave/LushAuroraCaveBiome.java +++ b/src/main/java/ru/betterend/world/biome/cave/LushAuroraCaveBiome.java @@ -1,7 +1,7 @@ package ru.betterend.world.biome.cave; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; import ru.betterend.blocks.BlockProperties; import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.registry.EndBlocks; @@ -12,39 +12,34 @@ import ru.betterend.world.biome.BiomeDefinition; public class LushAuroraCaveBiome extends EndCaveBiome { public LushAuroraCaveBiome() { - super(new BiomeDefinition("lush_aurora_cave") - .setFogColor(150, 30, 68) - .setFogDensity(2.0F) - .setPlantsColor(108, 25, 46) - .setWaterAndFogColor(186, 77, 237) - .setMusic(EndSounds.MUSIC_FOREST) - .setParticles(EndParticles.GLOWING_SPHERE, 0.001F) - .setSurface(EndBlocks.CAVE_MOSS)); - + super(new BiomeDefinition("lush_aurora_cave").setFogColor(150, 30, 68).setFogDensity(2.0F) + .setPlantsColor(108, 25, 46).setWaterAndFogColor(186, 77, 237).setMusic(EndSounds.MUSIC_FOREST) + .setParticles(EndParticles.GLOWING_SPHERE, 0.001F).setSurface(EndBlocks.CAVE_MOSS)); + this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL, 1); this.addFloorFeature(EndFeatures.CAVE_BUSH, 5); this.addFloorFeature(EndFeatures.CAVE_GRASS, 40); this.addFloorFeature(EndFeatures.END_STONE_STALAGMITE_CAVEMOSS, 5); - + this.addCeilFeature(EndFeatures.CAVE_BUSH, 1); this.addCeilFeature(EndFeatures.CAVE_PUMPKIN, 1); this.addCeilFeature(EndFeatures.RUBINEA, 3); this.addCeilFeature(EndFeatures.MAGNULA, 1); this.addCeilFeature(EndFeatures.END_STONE_STALACTITE_CAVEMOSS, 10); } - + @Override public float getFloorDensity() { return 0.2F; } - + @Override public float getCeilDensity() { return 0.1F; } - + @Override public BlockState getCeil(BlockPos pos) { - return EndBlocks.CAVE_MOSS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP); + return EndBlocks.CAVE_MOSS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP); } } diff --git a/src/main/java/ru/betterend/world/biome/land/AmberLandBiome.java b/src/main/java/ru/betterend/world/biome/land/AmberLandBiome.java index 768ba362..086e1a03 100644 --- a/src/main/java/ru/betterend/world/biome/land/AmberLandBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/AmberLandBiome.java @@ -1,6 +1,6 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.EntityType; import net.minecraft.world.gen.feature.ConfiguredStructureFeatures; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndEntities; @@ -12,27 +12,15 @@ import ru.betterend.world.biome.EndBiome; public class AmberLandBiome extends EndBiome { public AmberLandBiome() { - super(new BiomeDefinition("amber_land") - .setFogColor(255, 184, 71) - .setFogDensity(2.0F) - .setPlantsColor(219, 115, 38) - .setWaterAndFogColor(145, 108, 72) - .setMusic(EndSounds.MUSIC_FOREST) - .setParticles(EndParticles.AMBER_SPHERE, 0.001F) - .setSurface(EndBlocks.AMBER_MOSS) - .addFeature(EndFeatures.AMBER_ORE) - .addFeature(EndFeatures.END_LAKE_RARE) - .addFeature(EndFeatures.HELIX_TREE) - .addFeature(EndFeatures.LANCELEAF) - .addFeature(EndFeatures.GLOW_PILLAR) - .addFeature(EndFeatures.AMBER_GRASS) - .addFeature(EndFeatures.AMBER_ROOT) - .addFeature(EndFeatures.BULB_MOSS) - .addFeature(EndFeatures.BULB_MOSS_WOOD) - .addFeature(EndFeatures.CHARNIA_ORANGE) - .addFeature(EndFeatures.CHARNIA_RED) - .addStructureFeature(ConfiguredStructureFeatures.END_CITY) - .addMobSpawn(EntityType.ENDERMAN, 50, 1, 4) - .addMobSpawn(EndEntities.END_SLIME, 30, 1, 2)); + super(new BiomeDefinition("amber_land").setFogColor(255, 184, 71).setFogDensity(2.0F) + .setPlantsColor(219, 115, 38).setWaterAndFogColor(145, 108, 72).setMusic(EndSounds.MUSIC_FOREST) + .setParticles(EndParticles.AMBER_SPHERE, 0.001F).setSurface(EndBlocks.AMBER_MOSS) + .addFeature(EndFeatures.AMBER_ORE).addFeature(EndFeatures.END_LAKE_RARE) + .addFeature(EndFeatures.HELIX_TREE).addFeature(EndFeatures.LANCELEAF) + .addFeature(EndFeatures.GLOW_PILLAR).addFeature(EndFeatures.AMBER_GRASS) + .addFeature(EndFeatures.AMBER_ROOT).addFeature(EndFeatures.BULB_MOSS) + .addFeature(EndFeatures.BULB_MOSS_WOOD).addFeature(EndFeatures.CHARNIA_ORANGE) + .addFeature(EndFeatures.CHARNIA_RED).addStructureFeature(ConfiguredStructureFeatures.END_CITY) + .addMobSpawn(EntityType.ENDERMAN, 50, 1, 4).addMobSpawn(EndEntities.END_SLIME, 30, 1, 2)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/BlossomingSpiresBiome.java b/src/main/java/ru/betterend/world/biome/land/BlossomingSpiresBiome.java index 92c95867..546443bb 100644 --- a/src/main/java/ru/betterend/world/biome/land/BlossomingSpiresBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/BlossomingSpiresBiome.java @@ -1,6 +1,6 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.EntityType; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndEntities; import ru.betterend.registry.EndFeatures; @@ -10,26 +10,14 @@ import ru.betterend.world.biome.EndBiome; public class BlossomingSpiresBiome extends EndBiome { public BlossomingSpiresBiome() { - super(new BiomeDefinition("blossoming_spires") - .setFogColor(241, 146, 229) - .setFogDensity(1.7F) - .setPlantsColor(122, 45, 122) - .setCaves(false) - .setSurface(EndBlocks.PINK_MOSS) - .setMusic(EndSounds.MUSIC_FOREST) - .setLoop(EndSounds.AMBIENT_BLOSSOMING_SPIRES) - .addFeature(EndFeatures.SPIRE) - .addFeature(EndFeatures.FLOATING_SPIRE) - .addFeature(EndFeatures.TENANEA) - .addFeature(EndFeatures.TENANEA_BUSH) - .addFeature(EndFeatures.BULB_VINE) - .addFeature(EndFeatures.BUSHY_GRASS) - .addFeature(EndFeatures.BUSHY_GRASS_WG) - .addFeature(EndFeatures.BLOSSOM_BERRY) - .addFeature(EndFeatures.TWISTED_MOSS) - .addFeature(EndFeatures.TWISTED_MOSS_WOOD) - .addFeature(EndFeatures.SILK_MOTH_NEST) - .addMobSpawn(EntityType.ENDERMAN, 50, 1, 4) - .addMobSpawn(EndEntities.SILK_MOTH, 5, 1, 2)); + super(new BiomeDefinition("blossoming_spires").setFogColor(241, 146, 229).setFogDensity(1.7F) + .setPlantsColor(122, 45, 122).setCaves(false).setSurface(EndBlocks.PINK_MOSS) + .setMusic(EndSounds.MUSIC_FOREST).setLoop(EndSounds.AMBIENT_BLOSSOMING_SPIRES) + .addFeature(EndFeatures.SPIRE).addFeature(EndFeatures.FLOATING_SPIRE).addFeature(EndFeatures.TENANEA) + .addFeature(EndFeatures.TENANEA_BUSH).addFeature(EndFeatures.BULB_VINE) + .addFeature(EndFeatures.BUSHY_GRASS).addFeature(EndFeatures.BUSHY_GRASS_WG) + .addFeature(EndFeatures.BLOSSOM_BERRY).addFeature(EndFeatures.TWISTED_MOSS) + .addFeature(EndFeatures.TWISTED_MOSS_WOOD).addFeature(EndFeatures.SILK_MOTH_NEST) + .addMobSpawn(EntityType.ENDERMAN, 50, 1, 4).addMobSpawn(EndEntities.SILK_MOTH, 5, 1, 2)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/ChorusForestBiome.java b/src/main/java/ru/betterend/world/biome/land/ChorusForestBiome.java index fb55b03a..a63f1eba 100644 --- a/src/main/java/ru/betterend/world/biome/land/ChorusForestBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/ChorusForestBiome.java @@ -1,7 +1,7 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; -import net.minecraft.particle.ParticleTypes; +import net.minecraft.world.entity.EntityType; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.world.gen.GenerationStep.Feature; import net.minecraft.world.gen.feature.ConfiguredFeatures; import net.minecraft.world.gen.feature.ConfiguredStructureFeatures; @@ -14,30 +14,18 @@ import ru.betterend.world.biome.EndBiome; public class ChorusForestBiome extends EndBiome { public ChorusForestBiome() { - super(new BiomeDefinition("chorus_forest") - .setFogColor(87, 26, 87) - .setFogDensity(1.5F) - .setPlantsColor(122, 45, 122) - .setWaterAndFogColor(73, 30, 73) - .setSurface(EndBlocks.CHORUS_NYLIUM) - .setParticles(ParticleTypes.PORTAL, 0.01F) - .setLoop(EndSounds.AMBIENT_CHORUS_FOREST) - .setMusic(EndSounds.MUSIC_DARK) - .addFeature(EndFeatures.VIOLECITE_LAYER) - .addFeature(EndFeatures.END_LAKE_RARE) - .addFeature(EndFeatures.PYTHADENDRON_TREE) - .addFeature(EndFeatures.PYTHADENDRON_BUSH) - .addFeature(EndFeatures.PURPLE_POLYPORE) + super(new BiomeDefinition("chorus_forest").setFogColor(87, 26, 87).setFogDensity(1.5F) + .setPlantsColor(122, 45, 122).setWaterAndFogColor(73, 30, 73).setSurface(EndBlocks.CHORUS_NYLIUM) + .setParticles(ParticleTypes.PORTAL, 0.01F).setLoop(EndSounds.AMBIENT_CHORUS_FOREST) + .setMusic(EndSounds.MUSIC_DARK).addFeature(EndFeatures.VIOLECITE_LAYER) + .addFeature(EndFeatures.END_LAKE_RARE).addFeature(EndFeatures.PYTHADENDRON_TREE) + .addFeature(EndFeatures.PYTHADENDRON_BUSH).addFeature(EndFeatures.PURPLE_POLYPORE) .addFeature(Feature.VEGETAL_DECORATION, ConfiguredFeatures.CHORUS_PLANT) .addFeature(Feature.VEGETAL_DECORATION, ConfiguredFeatures.CHORUS_PLANT) - .addFeature(EndFeatures.CHORUS_GRASS) - .addFeature(EndFeatures.CHORUS_MUSHROOM) - .addFeature(EndFeatures.TAIL_MOSS) - .addFeature(EndFeatures.TAIL_MOSS_WOOD) - .addFeature(EndFeatures.CHARNIA_PURPLE) - .addFeature(EndFeatures.CHARNIA_RED_RARE) - .addStructureFeature(ConfiguredStructureFeatures.END_CITY) - .addMobSpawn(EndEntities.END_SLIME, 5, 1, 2) + .addFeature(EndFeatures.CHORUS_GRASS).addFeature(EndFeatures.CHORUS_MUSHROOM) + .addFeature(EndFeatures.TAIL_MOSS).addFeature(EndFeatures.TAIL_MOSS_WOOD) + .addFeature(EndFeatures.CHARNIA_PURPLE).addFeature(EndFeatures.CHARNIA_RED_RARE) + .addStructureFeature(ConfiguredStructureFeatures.END_CITY).addMobSpawn(EndEntities.END_SLIME, 5, 1, 2) .addMobSpawn(EntityType.ENDERMAN, 50, 1, 4)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/CrystalMountainsBiome.java b/src/main/java/ru/betterend/world/biome/land/CrystalMountainsBiome.java index d5c1d1d6..06fcc42e 100644 --- a/src/main/java/ru/betterend/world/biome/land/CrystalMountainsBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/CrystalMountainsBiome.java @@ -1,6 +1,6 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.EntityType; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndSounds; @@ -10,13 +10,9 @@ import ru.betterend.world.biome.EndBiome; public class CrystalMountainsBiome extends EndBiome { public CrystalMountainsBiome() { - super(new BiomeDefinition("crystal_mountains") - .setPlantsColor(255, 133, 211) - .setSurface(EndBlocks.CRYSTAL_MOSS) - .setMusic(EndSounds.MUSIC_OPENSPACE) - .addStructureFeature(EndStructures.MOUNTAIN) - .addFeature(EndFeatures.ROUND_CAVE) - .addFeature(EndFeatures.CRYSTAL_GRASS) + super(new BiomeDefinition("crystal_mountains").setPlantsColor(255, 133, 211).setSurface(EndBlocks.CRYSTAL_MOSS) + .setMusic(EndSounds.MUSIC_OPENSPACE).addStructureFeature(EndStructures.MOUNTAIN) + .addFeature(EndFeatures.ROUND_CAVE).addFeature(EndFeatures.CRYSTAL_GRASS) .addMobSpawn(EntityType.ENDERMAN, 50, 1, 2)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/DragonGraveyardsBiome.java b/src/main/java/ru/betterend/world/biome/land/DragonGraveyardsBiome.java index a0f5f500..4ac95163 100644 --- a/src/main/java/ru/betterend/world/biome/land/DragonGraveyardsBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/DragonGraveyardsBiome.java @@ -1,6 +1,6 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.EntityType; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndParticles; @@ -10,24 +10,14 @@ import ru.betterend.world.biome.EndBiome; public class DragonGraveyardsBiome extends EndBiome { public DragonGraveyardsBiome() { - super(new BiomeDefinition("dragon_graveyards") - .setGenChance(0.1F) - .setFogColor(244, 46, 79) - .setFogDensity(1.3F) - .setParticles(EndParticles.FIREFLY, 0.0007F) - .setMusic(EndSounds.MUSIC_OPENSPACE) - .setLoop(EndSounds.AMBIENT_GLOWING_GRASSLANDS) - .setSurface(EndBlocks.SANGNUM) - .setWaterAndFogColor(203, 59, 167) - .setPlantsColor(244, 46, 79) - .addFeature(EndFeatures.OBSIDIAN_PILLAR_BASEMENT) - .addFeature(EndFeatures.FALLEN_PILLAR) - .addFeature(EndFeatures.OBSIDIAN_BOULDER) - .addFeature(EndFeatures.GIGANTIC_AMARANITA) - .addFeature(EndFeatures.LARGE_AMARANITA) - .addFeature(EndFeatures.SMALL_AMARANITA) - .addFeature(EndFeatures.GLOBULAGUS) - .addFeature(EndFeatures.CLAWFERN) + super(new BiomeDefinition("dragon_graveyards").setGenChance(0.1F).setFogColor(244, 46, 79).setFogDensity(1.3F) + .setParticles(EndParticles.FIREFLY, 0.0007F).setMusic(EndSounds.MUSIC_OPENSPACE) + .setLoop(EndSounds.AMBIENT_GLOWING_GRASSLANDS).setSurface(EndBlocks.SANGNUM) + .setWaterAndFogColor(203, 59, 167).setPlantsColor(244, 46, 79) + .addFeature(EndFeatures.OBSIDIAN_PILLAR_BASEMENT).addFeature(EndFeatures.FALLEN_PILLAR) + .addFeature(EndFeatures.OBSIDIAN_BOULDER).addFeature(EndFeatures.GIGANTIC_AMARANITA) + .addFeature(EndFeatures.LARGE_AMARANITA).addFeature(EndFeatures.SMALL_AMARANITA) + .addFeature(EndFeatures.GLOBULAGUS).addFeature(EndFeatures.CLAWFERN) .addMobSpawn(EntityType.ENDERMAN, 50, 1, 2)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/DryShrublandBiome.java b/src/main/java/ru/betterend/world/biome/land/DryShrublandBiome.java index 97715260..4e1b32c1 100644 --- a/src/main/java/ru/betterend/world/biome/land/DryShrublandBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/DryShrublandBiome.java @@ -1,6 +1,6 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.EntityType; import net.minecraft.world.gen.feature.ConfiguredStructureFeatures; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndFeatures; @@ -10,18 +10,10 @@ import ru.betterend.world.biome.EndBiome; public class DryShrublandBiome extends EndBiome { public DryShrublandBiome() { - super(new BiomeDefinition("dry_shrubland") - .setFogColor(132, 35, 13) - .setFogDensity(1.2F) - .setWaterAndFogColor(113, 88, 53) - .setPlantsColor(237, 122, 66) - .setSurface(EndBlocks.RUTISCUS) - .setMusic(EndSounds.MUSIC_OPENSPACE) - .addFeature(EndFeatures.ORANGO) - .addFeature(EndFeatures.AERIDIUM) - .addFeature(EndFeatures.LUTEBUS) - .addFeature(EndFeatures.LAMELLARIUM) - .addStructureFeature(ConfiguredStructureFeatures.END_CITY) - .addMobSpawn(EntityType.ENDERMAN, 50, 1, 2)); + super(new BiomeDefinition("dry_shrubland").setFogColor(132, 35, 13).setFogDensity(1.2F) + .setWaterAndFogColor(113, 88, 53).setPlantsColor(237, 122, 66).setSurface(EndBlocks.RUTISCUS) + .setMusic(EndSounds.MUSIC_OPENSPACE).addFeature(EndFeatures.ORANGO).addFeature(EndFeatures.AERIDIUM) + .addFeature(EndFeatures.LUTEBUS).addFeature(EndFeatures.LAMELLARIUM) + .addStructureFeature(ConfiguredStructureFeatures.END_CITY).addMobSpawn(EntityType.ENDERMAN, 50, 1, 2)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/DustWastelandsBiome.java b/src/main/java/ru/betterend/world/biome/land/DustWastelandsBiome.java index 8e26f57a..db5b761b 100644 --- a/src/main/java/ru/betterend/world/biome/land/DustWastelandsBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/DustWastelandsBiome.java @@ -1,7 +1,7 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; -import net.minecraft.particle.ParticleTypes; +import net.minecraft.world.entity.EntityType; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.world.gen.feature.ConfiguredStructureFeatures; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndSounds; @@ -10,15 +10,10 @@ import ru.betterend.world.biome.EndBiome; public class DustWastelandsBiome extends EndBiome { public DustWastelandsBiome() { - super(new BiomeDefinition("dust_wastelands") - .setFogColor(226, 239, 168) - .setFogDensity(2) - .setWaterAndFogColor(192, 180, 131) - .setSurface(EndBlocks.ENDSTONE_DUST) - .setParticles(ParticleTypes.WHITE_ASH, 0.01F) - .setLoop(EndSounds.AMBIENT_DUST_WASTELANDS) - .setMusic(EndSounds.MUSIC_OPENSPACE) - .addStructureFeature(ConfiguredStructureFeatures.END_CITY) + super(new BiomeDefinition("dust_wastelands").setFogColor(226, 239, 168).setFogDensity(2) + .setWaterAndFogColor(192, 180, 131).setSurface(EndBlocks.ENDSTONE_DUST) + .setParticles(ParticleTypes.WHITE_ASH, 0.01F).setLoop(EndSounds.AMBIENT_DUST_WASTELANDS) + .setMusic(EndSounds.MUSIC_OPENSPACE).addStructureFeature(ConfiguredStructureFeatures.END_CITY) .addMobSpawn(EntityType.ENDERMAN, 50, 1, 2)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/FoggyMushroomlandBiome.java b/src/main/java/ru/betterend/world/biome/land/FoggyMushroomlandBiome.java index 76f2623c..d599bb94 100644 --- a/src/main/java/ru/betterend/world/biome/land/FoggyMushroomlandBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/FoggyMushroomlandBiome.java @@ -1,6 +1,6 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.EntityType; import net.minecraft.world.gen.feature.ConfiguredStructureFeatures; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndEntities; @@ -13,35 +13,20 @@ import ru.betterend.world.biome.EndBiome; public class FoggyMushroomlandBiome extends EndBiome { public FoggyMushroomlandBiome() { - super(new BiomeDefinition("foggy_mushroomland") - .setPlantsColor(73, 210, 209) - .setFogColor(41, 122, 173) - .setFogDensity(3) - .setWaterAndFogColor(119, 227, 250) + super(new BiomeDefinition("foggy_mushroomland").setPlantsColor(73, 210, 209).setFogColor(41, 122, 173) + .setFogDensity(3).setWaterAndFogColor(119, 227, 250) .setSurface(EndBlocks.END_MOSS, EndBlocks.END_MYCELIUM) - .setParticles(EndParticles.GLOWING_SPHERE, 0.001F) - .setLoop(EndSounds.AMBIENT_FOGGY_MUSHROOMLAND) - .setMusic(EndSounds.MUSIC_FOREST) - .addStructureFeature(EndStructures.GIANT_MOSSY_GLOWSHROOM) - .addFeature(EndFeatures.END_LAKE) - .addFeature(EndFeatures.MOSSY_GLOWSHROOM) - .addFeature(EndFeatures.BLUE_VINE) - .addFeature(EndFeatures.UMBRELLA_MOSS) - .addFeature(EndFeatures.CREEPING_MOSS) - .addFeature(EndFeatures.DENSE_VINE) - .addFeature(EndFeatures.PEARLBERRY) - .addFeature(EndFeatures.CYAN_MOSS) - .addFeature(EndFeatures.CYAN_MOSS_WOOD) - .addFeature(EndFeatures.END_LILY) - .addFeature(EndFeatures.BUBBLE_CORAL) - .addFeature(EndFeatures.CHARNIA_CYAN) - .addFeature(EndFeatures.CHARNIA_LIGHT_BLUE) - .addFeature(EndFeatures.CHARNIA_RED_RARE) - .addStructureFeature(ConfiguredStructureFeatures.END_CITY) - .addMobSpawn(EndEntities.DRAGONFLY, 80, 2, 5) - .addMobSpawn(EndEntities.END_FISH, 20, 2, 5) - .addMobSpawn(EndEntities.CUBOZOA, 10, 3, 8) - .addMobSpawn(EndEntities.END_SLIME, 10, 1, 2) - .addMobSpawn(EntityType.ENDERMAN, 10, 1, 2)); + .setParticles(EndParticles.GLOWING_SPHERE, 0.001F).setLoop(EndSounds.AMBIENT_FOGGY_MUSHROOMLAND) + .setMusic(EndSounds.MUSIC_FOREST).addStructureFeature(EndStructures.GIANT_MOSSY_GLOWSHROOM) + .addFeature(EndFeatures.END_LAKE).addFeature(EndFeatures.MOSSY_GLOWSHROOM) + .addFeature(EndFeatures.BLUE_VINE).addFeature(EndFeatures.UMBRELLA_MOSS) + .addFeature(EndFeatures.CREEPING_MOSS).addFeature(EndFeatures.DENSE_VINE) + .addFeature(EndFeatures.PEARLBERRY).addFeature(EndFeatures.CYAN_MOSS) + .addFeature(EndFeatures.CYAN_MOSS_WOOD).addFeature(EndFeatures.END_LILY) + .addFeature(EndFeatures.BUBBLE_CORAL).addFeature(EndFeatures.CHARNIA_CYAN) + .addFeature(EndFeatures.CHARNIA_LIGHT_BLUE).addFeature(EndFeatures.CHARNIA_RED_RARE) + .addStructureFeature(ConfiguredStructureFeatures.END_CITY).addMobSpawn(EndEntities.DRAGONFLY, 80, 2, 5) + .addMobSpawn(EndEntities.END_FISH, 20, 2, 5).addMobSpawn(EndEntities.CUBOZOA, 10, 3, 8) + .addMobSpawn(EndEntities.END_SLIME, 10, 1, 2).addMobSpawn(EntityType.ENDERMAN, 10, 1, 2)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/GlowingGrasslandsBiome.java b/src/main/java/ru/betterend/world/biome/land/GlowingGrasslandsBiome.java index df39d84a..79f29743 100644 --- a/src/main/java/ru/betterend/world/biome/land/GlowingGrasslandsBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/GlowingGrasslandsBiome.java @@ -1,6 +1,6 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.EntityType; import net.minecraft.world.gen.feature.ConfiguredStructureFeatures; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndFeatures; @@ -11,29 +11,16 @@ import ru.betterend.world.biome.EndBiome; public class GlowingGrasslandsBiome extends EndBiome { public GlowingGrasslandsBiome() { - super(new BiomeDefinition("glowing_grasslands") - .setFogColor(99, 228, 247) - .setFogDensity(1.3F) - .setParticles(EndParticles.FIREFLY, 0.001F) - .setMusic(EndSounds.MUSIC_OPENSPACE) - .setLoop(EndSounds.AMBIENT_GLOWING_GRASSLANDS) - .setSurface(EndBlocks.END_MOSS) - .setWaterAndFogColor(92, 250, 230) - .setPlantsColor(73, 210, 209) - .addFeature(EndFeatures.END_LAKE_RARE) - .addFeature(EndFeatures.LUMECORN) - .addFeature(EndFeatures.BLOOMING_COOKSONIA) - .addFeature(EndFeatures.SALTEAGO) - .addFeature(EndFeatures.VAIOLUSH_FERN) - .addFeature(EndFeatures.FRACTURN) - .addFeature(EndFeatures.UMBRELLA_MOSS_RARE) - .addFeature(EndFeatures.CREEPING_MOSS_RARE) - .addFeature(EndFeatures.TWISTED_UMBRELLA_MOSS_RARE) - .addFeature(EndFeatures.CHARNIA_CYAN) - .addFeature(EndFeatures.CHARNIA_GREEN) - .addFeature(EndFeatures.CHARNIA_LIGHT_BLUE) - .addFeature(EndFeatures.CHARNIA_RED_RARE) - .addStructureFeature(ConfiguredStructureFeatures.END_CITY) + super(new BiomeDefinition("glowing_grasslands").setFogColor(99, 228, 247).setFogDensity(1.3F) + .setParticles(EndParticles.FIREFLY, 0.001F).setMusic(EndSounds.MUSIC_OPENSPACE) + .setLoop(EndSounds.AMBIENT_GLOWING_GRASSLANDS).setSurface(EndBlocks.END_MOSS) + .setWaterAndFogColor(92, 250, 230).setPlantsColor(73, 210, 209).addFeature(EndFeatures.END_LAKE_RARE) + .addFeature(EndFeatures.LUMECORN).addFeature(EndFeatures.BLOOMING_COOKSONIA) + .addFeature(EndFeatures.SALTEAGO).addFeature(EndFeatures.VAIOLUSH_FERN).addFeature(EndFeatures.FRACTURN) + .addFeature(EndFeatures.UMBRELLA_MOSS_RARE).addFeature(EndFeatures.CREEPING_MOSS_RARE) + .addFeature(EndFeatures.TWISTED_UMBRELLA_MOSS_RARE).addFeature(EndFeatures.CHARNIA_CYAN) + .addFeature(EndFeatures.CHARNIA_GREEN).addFeature(EndFeatures.CHARNIA_LIGHT_BLUE) + .addFeature(EndFeatures.CHARNIA_RED_RARE).addStructureFeature(ConfiguredStructureFeatures.END_CITY) .addMobSpawn(EntityType.ENDERMAN, 50, 1, 2)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/LanternWoodsBiome.java b/src/main/java/ru/betterend/world/biome/land/LanternWoodsBiome.java index cad741a0..e888b454 100644 --- a/src/main/java/ru/betterend/world/biome/land/LanternWoodsBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/LanternWoodsBiome.java @@ -1,6 +1,6 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.EntityType; import net.minecraft.world.gen.feature.ConfiguredStructureFeatures; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndFeatures; @@ -11,29 +11,15 @@ import ru.betterend.world.biome.EndBiome; public class LanternWoodsBiome extends EndBiome { public LanternWoodsBiome() { - super(new BiomeDefinition("lantern_woods") - .setFogColor(189, 82, 70) - .setFogDensity(1.1F) - .setWaterAndFogColor(171, 234, 226) - .setPlantsColor(254, 85, 57) - .setSurface(EndBlocks.RUTISCUS) - .setMusic(EndSounds.MUSIC_FOREST) - .setParticles(EndParticles.GLOWING_SPHERE, 0.001F) - .addFeature(EndFeatures.END_LAKE_NORMAL) - .addFeature(EndFeatures.FLAMAEA) - .addFeature(EndFeatures.LUCERNIA) - .addFeature(EndFeatures.LUCERNIA_BUSH) - .addFeature(EndFeatures.FILALUX) - .addFeature(EndFeatures.AERIDIUM) - .addFeature(EndFeatures.LAMELLARIUM) - .addFeature(EndFeatures.BOLUX_MUSHROOM) - .addFeature(EndFeatures.AURANT_POLYPORE) - .addFeature(EndFeatures.POND_ANEMONE) - .addFeature(EndFeatures.CHARNIA_ORANGE) - .addFeature(EndFeatures.CHARNIA_RED) - .addFeature(EndFeatures.RUSCUS) - .addFeature(EndFeatures.RUSCUS_WOOD) - .addStructureFeature(ConfiguredStructureFeatures.END_CITY) - .addMobSpawn(EntityType.ENDERMAN, 50, 1, 2)); + super(new BiomeDefinition("lantern_woods").setFogColor(189, 82, 70).setFogDensity(1.1F) + .setWaterAndFogColor(171, 234, 226).setPlantsColor(254, 85, 57).setSurface(EndBlocks.RUTISCUS) + .setMusic(EndSounds.MUSIC_FOREST).setParticles(EndParticles.GLOWING_SPHERE, 0.001F) + .addFeature(EndFeatures.END_LAKE_NORMAL).addFeature(EndFeatures.FLAMAEA) + .addFeature(EndFeatures.LUCERNIA).addFeature(EndFeatures.LUCERNIA_BUSH).addFeature(EndFeatures.FILALUX) + .addFeature(EndFeatures.AERIDIUM).addFeature(EndFeatures.LAMELLARIUM) + .addFeature(EndFeatures.BOLUX_MUSHROOM).addFeature(EndFeatures.AURANT_POLYPORE) + .addFeature(EndFeatures.POND_ANEMONE).addFeature(EndFeatures.CHARNIA_ORANGE) + .addFeature(EndFeatures.CHARNIA_RED).addFeature(EndFeatures.RUSCUS).addFeature(EndFeatures.RUSCUS_WOOD) + .addStructureFeature(ConfiguredStructureFeatures.END_CITY).addMobSpawn(EntityType.ENDERMAN, 50, 1, 2)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/MegalakeBiome.java b/src/main/java/ru/betterend/world/biome/land/MegalakeBiome.java index 4c275a1b..ad87875c 100644 --- a/src/main/java/ru/betterend/world/biome/land/MegalakeBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/MegalakeBiome.java @@ -1,6 +1,6 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.EntityType; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndEntities; import ru.betterend.registry.EndFeatures; @@ -11,31 +11,17 @@ import ru.betterend.world.biome.EndBiome; public class MegalakeBiome extends EndBiome { public MegalakeBiome() { - super(new BiomeDefinition("megalake") - .setPlantsColor(73, 210, 209) - .setFogColor(178, 209, 248) - .setWaterAndFogColor(96, 163, 255) - .setFogDensity(1.75F) - .setMusic(EndSounds.MUSIC_WATER) - .setLoop(EndSounds.AMBIENT_MEGALAKE) - .setSurface(EndBlocks.END_MOSS, EndBlocks.ENDSTONE_DUST) - .setDepth(0F) - .addStructureFeature(EndStructures.MEGALAKE) - .addFeature(EndFeatures.END_LOTUS) - .addFeature(EndFeatures.END_LOTUS_LEAF) - .addFeature(EndFeatures.BUBBLE_CORAL_RARE) - .addFeature(EndFeatures.END_LILY_RARE) - .addFeature(EndFeatures.UMBRELLA_MOSS) - .addFeature(EndFeatures.CREEPING_MOSS) - .addFeature(EndFeatures.PEARLBERRY) - .addFeature(EndFeatures.CHARNIA_CYAN) - .addFeature(EndFeatures.CHARNIA_LIGHT_BLUE) - .addFeature(EndFeatures.CHARNIA_RED_RARE) - .addFeature(EndFeatures.MENGER_SPONGE) - .addMobSpawn(EndEntities.DRAGONFLY, 50, 1, 3) - .addMobSpawn(EndEntities.END_FISH, 50, 3, 8) - .addMobSpawn(EndEntities.CUBOZOA, 50, 3, 8) - .addMobSpawn(EndEntities.END_SLIME, 5, 1, 2) + super(new BiomeDefinition("megalake").setPlantsColor(73, 210, 209).setFogColor(178, 209, 248) + .setWaterAndFogColor(96, 163, 255).setFogDensity(1.75F).setMusic(EndSounds.MUSIC_WATER) + .setLoop(EndSounds.AMBIENT_MEGALAKE).setSurface(EndBlocks.END_MOSS, EndBlocks.ENDSTONE_DUST) + .setDepth(0F).addStructureFeature(EndStructures.MEGALAKE).addFeature(EndFeatures.END_LOTUS) + .addFeature(EndFeatures.END_LOTUS_LEAF).addFeature(EndFeatures.BUBBLE_CORAL_RARE) + .addFeature(EndFeatures.END_LILY_RARE).addFeature(EndFeatures.UMBRELLA_MOSS) + .addFeature(EndFeatures.CREEPING_MOSS).addFeature(EndFeatures.PEARLBERRY) + .addFeature(EndFeatures.CHARNIA_CYAN).addFeature(EndFeatures.CHARNIA_LIGHT_BLUE) + .addFeature(EndFeatures.CHARNIA_RED_RARE).addFeature(EndFeatures.MENGER_SPONGE) + .addMobSpawn(EndEntities.DRAGONFLY, 50, 1, 3).addMobSpawn(EndEntities.END_FISH, 50, 3, 8) + .addMobSpawn(EndEntities.CUBOZOA, 50, 3, 8).addMobSpawn(EndEntities.END_SLIME, 5, 1, 2) .addMobSpawn(EntityType.ENDERMAN, 10, 1, 2)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/MegalakeGroveBiome.java b/src/main/java/ru/betterend/world/biome/land/MegalakeGroveBiome.java index 2ff13bbf..3380f1da 100644 --- a/src/main/java/ru/betterend/world/biome/land/MegalakeGroveBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/MegalakeGroveBiome.java @@ -1,6 +1,6 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.EntityType; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndEntities; import ru.betterend.registry.EndFeatures; @@ -12,33 +12,18 @@ import ru.betterend.world.biome.EndBiome; public class MegalakeGroveBiome extends EndBiome { public MegalakeGroveBiome() { - super(new BiomeDefinition("megalake_grove") - .setPlantsColor(73, 210, 209) - .setFogColor(178, 209, 248) - .setWaterAndFogColor(96, 163, 255) - .setFogDensity(2.0F) - .setParticles(EndParticles.GLOWING_SPHERE, 0.001F) - .setMusic(EndSounds.MUSIC_WATER) - .setLoop(EndSounds.AMBIENT_MEGALAKE_GROVE) - .setSurface(EndBlocks.END_MOSS) - .setDepth(0F) - .addStructureFeature(EndStructures.MEGALAKE_SMALL) - .addFeature(EndFeatures.LACUGROVE) - .addFeature(EndFeatures.END_LOTUS) - .addFeature(EndFeatures.END_LOTUS_LEAF) - .addFeature(EndFeatures.BUBBLE_CORAL_RARE) - .addFeature(EndFeatures.END_LILY_RARE) - .addFeature(EndFeatures.UMBRELLA_MOSS) - .addFeature(EndFeatures.PEARLBERRY) - .addFeature(EndFeatures.CREEPING_MOSS) - .addFeature(EndFeatures.CHARNIA_CYAN) - .addFeature(EndFeatures.CHARNIA_LIGHT_BLUE) - .addFeature(EndFeatures.CHARNIA_RED_RARE) - .addFeature(EndFeatures.MENGER_SPONGE) - .addMobSpawn(EndEntities.DRAGONFLY, 20, 1, 3) - .addMobSpawn(EndEntities.END_FISH, 20, 3, 8) - .addMobSpawn(EndEntities.CUBOZOA, 50, 3, 8) - .addMobSpawn(EndEntities.END_SLIME, 5, 1, 2) + super(new BiomeDefinition("megalake_grove").setPlantsColor(73, 210, 209).setFogColor(178, 209, 248) + .setWaterAndFogColor(96, 163, 255).setFogDensity(2.0F).setParticles(EndParticles.GLOWING_SPHERE, 0.001F) + .setMusic(EndSounds.MUSIC_WATER).setLoop(EndSounds.AMBIENT_MEGALAKE_GROVE) + .setSurface(EndBlocks.END_MOSS).setDepth(0F).addStructureFeature(EndStructures.MEGALAKE_SMALL) + .addFeature(EndFeatures.LACUGROVE).addFeature(EndFeatures.END_LOTUS) + .addFeature(EndFeatures.END_LOTUS_LEAF).addFeature(EndFeatures.BUBBLE_CORAL_RARE) + .addFeature(EndFeatures.END_LILY_RARE).addFeature(EndFeatures.UMBRELLA_MOSS) + .addFeature(EndFeatures.PEARLBERRY).addFeature(EndFeatures.CREEPING_MOSS) + .addFeature(EndFeatures.CHARNIA_CYAN).addFeature(EndFeatures.CHARNIA_LIGHT_BLUE) + .addFeature(EndFeatures.CHARNIA_RED_RARE).addFeature(EndFeatures.MENGER_SPONGE) + .addMobSpawn(EndEntities.DRAGONFLY, 20, 1, 3).addMobSpawn(EndEntities.END_FISH, 20, 3, 8) + .addMobSpawn(EndEntities.CUBOZOA, 50, 3, 8).addMobSpawn(EndEntities.END_SLIME, 5, 1, 2) .addMobSpawn(EntityType.ENDERMAN, 10, 1, 2)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/NeonOasisBiome.java b/src/main/java/ru/betterend/world/biome/land/NeonOasisBiome.java index bc49f6f8..705b18a2 100644 --- a/src/main/java/ru/betterend/world/biome/land/NeonOasisBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/NeonOasisBiome.java @@ -1,7 +1,7 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; -import net.minecraft.particle.ParticleTypes; +import net.minecraft.world.entity.EntityType; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.world.gen.feature.ConfiguredStructureFeatures; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndFeatures; @@ -11,17 +11,10 @@ import ru.betterend.world.biome.EndBiome; public class NeonOasisBiome extends EndBiome { public NeonOasisBiome() { - super(new BiomeDefinition("neon_oasis") - .setGenChance(0.5F) - .setFogColor(226, 239, 168) - .setFogDensity(2) - .setWaterAndFogColor(192, 180, 131) - .setSurface(EndBlocks.ENDSTONE_DUST, EndBlocks.END_MOSS) - .setParticles(ParticleTypes.WHITE_ASH, 0.01F) - .setLoop(EndSounds.AMBIENT_DUST_WASTELANDS) - .setMusic(EndSounds.MUSIC_OPENSPACE) - .addFeature(EndFeatures.NEON_CACTUS) - .addStructureFeature(ConfiguredStructureFeatures.END_CITY) - .addMobSpawn(EntityType.ENDERMAN, 50, 1, 2)); + super(new BiomeDefinition("neon_oasis").setGenChance(0.5F).setFogColor(226, 239, 168).setFogDensity(2) + .setWaterAndFogColor(192, 180, 131).setSurface(EndBlocks.ENDSTONE_DUST, EndBlocks.END_MOSS) + .setParticles(ParticleTypes.WHITE_ASH, 0.01F).setLoop(EndSounds.AMBIENT_DUST_WASTELANDS) + .setMusic(EndSounds.MUSIC_OPENSPACE).addFeature(EndFeatures.NEON_CACTUS) + .addStructureFeature(ConfiguredStructureFeatures.END_CITY).addMobSpawn(EntityType.ENDERMAN, 50, 1, 2)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/PaintedMountainsBiome.java b/src/main/java/ru/betterend/world/biome/land/PaintedMountainsBiome.java index a25f388e..b158608c 100644 --- a/src/main/java/ru/betterend/world/biome/land/PaintedMountainsBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/PaintedMountainsBiome.java @@ -1,7 +1,7 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; -import net.minecraft.particle.ParticleTypes; +import net.minecraft.world.entity.EntityType; +import net.minecraft.core.particles.ParticleTypes; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndSounds; import ru.betterend.registry.EndStructures; @@ -10,16 +10,10 @@ import ru.betterend.world.biome.EndBiome; public class PaintedMountainsBiome extends EndBiome { public PaintedMountainsBiome() { - super(new BiomeDefinition("painted_mountains") - .setFogColor(226, 239, 168) - .setFogDensity(2) - .setCaves(false) - .setWaterAndFogColor(192, 180, 131) - .setMusic(EndSounds.MUSIC_OPENSPACE) - .setLoop(EndSounds.AMBIENT_DUST_WASTELANDS) - .setSurface(EndBlocks.ENDSTONE_DUST) - .setParticles(ParticleTypes.WHITE_ASH, 0.01F) - .addStructureFeature(EndStructures.PAINTED_MOUNTAIN) + super(new BiomeDefinition("painted_mountains").setFogColor(226, 239, 168).setFogDensity(2).setCaves(false) + .setWaterAndFogColor(192, 180, 131).setMusic(EndSounds.MUSIC_OPENSPACE) + .setLoop(EndSounds.AMBIENT_DUST_WASTELANDS).setSurface(EndBlocks.ENDSTONE_DUST) + .setParticles(ParticleTypes.WHITE_ASH, 0.01F).addStructureFeature(EndStructures.PAINTED_MOUNTAIN) .addMobSpawn(EntityType.ENDERMAN, 50, 1, 2)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/ShadowForestBiome.java b/src/main/java/ru/betterend/world/biome/land/ShadowForestBiome.java index ba4e7bed..59547453 100644 --- a/src/main/java/ru/betterend/world/biome/land/ShadowForestBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/ShadowForestBiome.java @@ -1,7 +1,7 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; -import net.minecraft.particle.ParticleTypes; +import net.minecraft.world.entity.EntityType; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.world.gen.feature.ConfiguredStructureFeatures; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndEntities; @@ -12,32 +12,18 @@ import ru.betterend.world.biome.EndBiome; public class ShadowForestBiome extends EndBiome { public ShadowForestBiome() { - super(new BiomeDefinition("shadow_forest") - .setFogColor(0, 0, 0) - .setFogDensity(2.5F) - .setPlantsColor(45, 45, 45) - .setWaterAndFogColor(42, 45, 80) - .setSurface(EndBlocks.SHADOW_GRASS) - .setParticles(ParticleTypes.MYCELIUM, 0.01F) - .setLoop(EndSounds.AMBIENT_CHORUS_FOREST) - .setMusic(EndSounds.MUSIC_DARK) - .addFeature(EndFeatures.VIOLECITE_LAYER) - .addFeature(EndFeatures.END_LAKE_RARE) - .addFeature(EndFeatures.DRAGON_TREE) - .addFeature(EndFeatures.DRAGON_TREE_BUSH) - .addFeature(EndFeatures.SHADOW_PLANT) - .addFeature(EndFeatures.MURKWEED) - .addFeature(EndFeatures.NEEDLEGRASS) - .addFeature(EndFeatures.SHADOW_BERRY) - .addFeature(EndFeatures.TWISTED_VINE) - .addFeature(EndFeatures.PURPLE_POLYPORE) - .addFeature(EndFeatures.TAIL_MOSS) - .addFeature(EndFeatures.TAIL_MOSS_WOOD) - .addFeature(EndFeatures.CHARNIA_PURPLE) - .addFeature(EndFeatures.CHARNIA_RED_RARE) - .addStructureFeature(ConfiguredStructureFeatures.END_CITY) - .addMobSpawn(EndEntities.SHADOW_WALKER, 80, 2, 4) - .addMobSpawn(EntityType.ENDERMAN, 40, 1, 4) + super(new BiomeDefinition("shadow_forest").setFogColor(0, 0, 0).setFogDensity(2.5F).setPlantsColor(45, 45, 45) + .setWaterAndFogColor(42, 45, 80).setSurface(EndBlocks.SHADOW_GRASS) + .setParticles(ParticleTypes.MYCELIUM, 0.01F).setLoop(EndSounds.AMBIENT_CHORUS_FOREST) + .setMusic(EndSounds.MUSIC_DARK).addFeature(EndFeatures.VIOLECITE_LAYER) + .addFeature(EndFeatures.END_LAKE_RARE).addFeature(EndFeatures.DRAGON_TREE) + .addFeature(EndFeatures.DRAGON_TREE_BUSH).addFeature(EndFeatures.SHADOW_PLANT) + .addFeature(EndFeatures.MURKWEED).addFeature(EndFeatures.NEEDLEGRASS) + .addFeature(EndFeatures.SHADOW_BERRY).addFeature(EndFeatures.TWISTED_VINE) + .addFeature(EndFeatures.PURPLE_POLYPORE).addFeature(EndFeatures.TAIL_MOSS) + .addFeature(EndFeatures.TAIL_MOSS_WOOD).addFeature(EndFeatures.CHARNIA_PURPLE) + .addFeature(EndFeatures.CHARNIA_RED_RARE).addStructureFeature(ConfiguredStructureFeatures.END_CITY) + .addMobSpawn(EndEntities.SHADOW_WALKER, 80, 2, 4).addMobSpawn(EntityType.ENDERMAN, 40, 1, 4) .addMobSpawn(EntityType.PHANTOM, 1, 1, 2)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/SulphurSpringsBiome.java b/src/main/java/ru/betterend/world/biome/land/SulphurSpringsBiome.java index 12888729..161efd76 100644 --- a/src/main/java/ru/betterend/world/biome/land/SulphurSpringsBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/SulphurSpringsBiome.java @@ -1,6 +1,6 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.EntityType; import ru.betterend.registry.EndEntities; import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndParticles; @@ -11,27 +11,15 @@ import ru.betterend.world.surface.SurfaceBuilders; public class SulphurSpringsBiome extends EndBiome { public SulphurSpringsBiome() { - super(new BiomeDefinition("sulphur_springs") - .setSurface(SurfaceBuilders.SULPHURIC_SURFACE) - .setMusic(EndSounds.MUSIC_OPENSPACE) - .setLoop(EndSounds.AMBIENT_SULPHUR_SPRINGS) - .setWaterColor(25, 90, 157) - .setWaterFogColor(30, 65, 61) - .setFogColor(207, 194, 62) - .setFogDensity(1.5F) - .setCaves(false) - .setDepth(0F) - .setParticles(EndParticles.SULPHUR_PARTICLE, 0.001F) - .addFeature(EndFeatures.GEYSER) - .addFeature(EndFeatures.SURFACE_VENT) - .addFeature(EndFeatures.SULPHURIC_LAKE) - .addFeature(EndFeatures.SULPHURIC_CAVE) - .addFeature(EndFeatures.HYDRALUX) - .addFeature(EndFeatures.CHARNIA_GREEN) - .addFeature(EndFeatures.CHARNIA_ORANGE) - .addFeature(EndFeatures.CHARNIA_RED_RARE) - .addMobSpawn(EndEntities.END_FISH, 50, 3, 8) - .addMobSpawn(EndEntities.CUBOZOA, 50, 3, 8) + super(new BiomeDefinition("sulphur_springs").setSurface(SurfaceBuilders.SULPHURIC_SURFACE) + .setMusic(EndSounds.MUSIC_OPENSPACE).setLoop(EndSounds.AMBIENT_SULPHUR_SPRINGS) + .setWaterColor(25, 90, 157).setWaterFogColor(30, 65, 61).setFogColor(207, 194, 62).setFogDensity(1.5F) + .setCaves(false).setDepth(0F).setParticles(EndParticles.SULPHUR_PARTICLE, 0.001F) + .addFeature(EndFeatures.GEYSER).addFeature(EndFeatures.SURFACE_VENT) + .addFeature(EndFeatures.SULPHURIC_LAKE).addFeature(EndFeatures.SULPHURIC_CAVE) + .addFeature(EndFeatures.HYDRALUX).addFeature(EndFeatures.CHARNIA_GREEN) + .addFeature(EndFeatures.CHARNIA_ORANGE).addFeature(EndFeatures.CHARNIA_RED_RARE) + .addMobSpawn(EndEntities.END_FISH, 50, 3, 8).addMobSpawn(EndEntities.CUBOZOA, 50, 3, 8) .addMobSpawn(EntityType.ENDERMAN, 50, 1, 4)); } } diff --git a/src/main/java/ru/betterend/world/biome/land/UmbrellaJungleBiome.java b/src/main/java/ru/betterend/world/biome/land/UmbrellaJungleBiome.java index e14e62cd..2ded7681 100644 --- a/src/main/java/ru/betterend/world/biome/land/UmbrellaJungleBiome.java +++ b/src/main/java/ru/betterend/world/biome/land/UmbrellaJungleBiome.java @@ -1,6 +1,6 @@ package ru.betterend.world.biome.land; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.EntityType; import net.minecraft.world.gen.feature.ConfiguredStructureFeatures; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndFeatures; @@ -11,33 +11,18 @@ import ru.betterend.world.biome.EndBiome; public class UmbrellaJungleBiome extends EndBiome { public UmbrellaJungleBiome() { - super(new BiomeDefinition("umbrella_jungle") - .setFogColor(87, 223, 221) - .setWaterAndFogColor(119, 198, 253) - .setFoliageColor(27, 183, 194) - .setFogDensity(2.3F) - .setParticles(EndParticles.JUNGLE_SPORE, 0.001F) - .setMusic(EndSounds.MUSIC_FOREST) - .setLoop(EndSounds.AMBIENT_UMBRELLA_JUNGLE) - .setSurface(EndBlocks.JUNGLE_MOSS) - .addFeature(EndFeatures.END_LAKE) - .addFeature(EndFeatures.UMBRELLA_TREE) - .addFeature(EndFeatures.JELLYSHROOM) - .addFeature(EndFeatures.TWISTED_UMBRELLA_MOSS) - .addFeature(EndFeatures.SMALL_JELLYSHROOM_FLOOR) - .addFeature(EndFeatures.JUNGLE_GRASS) - .addFeature(EndFeatures.CYAN_MOSS) - .addFeature(EndFeatures.CYAN_MOSS_WOOD) - .addFeature(EndFeatures.JUNGLE_FERN_WOOD) - .addFeature(EndFeatures.SMALL_JELLYSHROOM_WALL) - .addFeature(EndFeatures.SMALL_JELLYSHROOM_WOOD) - .addFeature(EndFeatures.SMALL_JELLYSHROOM_CEIL) - .addFeature(EndFeatures.JUNGLE_VINE) - .addFeature(EndFeatures.CHARNIA_CYAN) - .addFeature(EndFeatures.CHARNIA_GREEN) - .addFeature(EndFeatures.CHARNIA_LIGHT_BLUE) - .addFeature(EndFeatures.CHARNIA_RED_RARE) - .addStructureFeature(ConfiguredStructureFeatures.END_CITY) - .addMobSpawn(EntityType.ENDERMAN, 50, 1, 2)); + super(new BiomeDefinition("umbrella_jungle").setFogColor(87, 223, 221).setWaterAndFogColor(119, 198, 253) + .setFoliageColor(27, 183, 194).setFogDensity(2.3F).setParticles(EndParticles.JUNGLE_SPORE, 0.001F) + .setMusic(EndSounds.MUSIC_FOREST).setLoop(EndSounds.AMBIENT_UMBRELLA_JUNGLE) + .setSurface(EndBlocks.JUNGLE_MOSS).addFeature(EndFeatures.END_LAKE) + .addFeature(EndFeatures.UMBRELLA_TREE).addFeature(EndFeatures.JELLYSHROOM) + .addFeature(EndFeatures.TWISTED_UMBRELLA_MOSS).addFeature(EndFeatures.SMALL_JELLYSHROOM_FLOOR) + .addFeature(EndFeatures.JUNGLE_GRASS).addFeature(EndFeatures.CYAN_MOSS) + .addFeature(EndFeatures.CYAN_MOSS_WOOD).addFeature(EndFeatures.JUNGLE_FERN_WOOD) + .addFeature(EndFeatures.SMALL_JELLYSHROOM_WALL).addFeature(EndFeatures.SMALL_JELLYSHROOM_WOOD) + .addFeature(EndFeatures.SMALL_JELLYSHROOM_CEIL).addFeature(EndFeatures.JUNGLE_VINE) + .addFeature(EndFeatures.CHARNIA_CYAN).addFeature(EndFeatures.CHARNIA_GREEN) + .addFeature(EndFeatures.CHARNIA_LIGHT_BLUE).addFeature(EndFeatures.CHARNIA_RED_RARE) + .addStructureFeature(ConfiguredStructureFeatures.END_CITY).addMobSpawn(EntityType.ENDERMAN, 50, 1, 2)); } } \ No newline at end of file diff --git a/src/main/java/ru/betterend/world/features/BiomeIslandFeature.java b/src/main/java/ru/betterend/world/features/BiomeIslandFeature.java index e203909d..ad97e5c2 100644 --- a/src/main/java/ru/betterend/world/features/BiomeIslandFeature.java +++ b/src/main/java/ru/betterend/world/features/BiomeIslandFeature.java @@ -2,10 +2,10 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.chunk.ChunkGenerator; @@ -20,15 +20,16 @@ import ru.betterend.util.sdf.operator.SDFTranslate; import ru.betterend.util.sdf.primitive.SDFCappedCone; public class BiomeIslandFeature extends DefaultFeature { - private static final Mutable CENTER = new Mutable(); + private static final MutableBlockPos CENTER = new MutableBlockPos(); private static final SDF ISLAND; private static OpenSimplexNoise simplexNoise = new OpenSimplexNoise(412L); - private static BlockState topBlock = Blocks.GRASS_BLOCK.getDefaultState(); - private static BlockState underBlock = Blocks.DIRT.getDefaultState(); + private static BlockState topBlock = Blocks.GRASS_BLOCK.defaultBlockState(); + private static BlockState underBlock = Blocks.DIRT.defaultBlockState(); @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { Biome biome = world.getBiome(pos); SurfaceConfig surfaceConfig = biome.getGenerationSettings().getSurfaceConfig(); BlockState topMaterial = surfaceConfig.getTopMaterial(); @@ -40,14 +41,16 @@ public class BiomeIslandFeature extends DefaultFeature { underBlock = surfaceConfig.getUnderMaterial(); simplexNoise = new OpenSimplexNoise(world.getSeed()); CENTER.set(pos); - ISLAND.fillRecursive(world, pos.down()); + ISLAND.fillRecursive(world, pos.below()); return true; } private static SDF createSDFIsland() { SDF sdfCone = new SDFCappedCone().setRadius1(0).setRadius2(6).setHeight(4).setBlock(pos -> { - if (pos.getY() > CENTER.getY()) return AIR; - if (pos.getY() == CENTER.getY()) return topBlock; + if (pos.getY() > CENTER.getY()) + return AIR; + if (pos.getY() == CENTER.getY()) + return topBlock; return underBlock; }); sdfCone = new SDFTranslate().setTranslate(0, -2, 0).setSource(sdfCone); @@ -55,11 +58,12 @@ public class BiomeIslandFeature extends DefaultFeature { float deltaX = Math.abs(pos.getX()); float deltaY = Math.abs(pos.getY()); float deltaZ = Math.abs(pos.getZ()); - if (deltaY < 2.0f && (deltaX < 3.0f || deltaZ < 3.0F)) return 0.0f; - return (float) simplexNoise.eval(CENTER.getX() + pos.getX(), - CENTER.getY() + pos.getY(), CENTER.getZ() + pos.getZ()); - }).setSource(sdfCone).setReplaceFunction(state -> BlocksHelper.isFluid(state) || - state.getMaterial().isReplaceable()); + if (deltaY < 2.0f && (deltaX < 3.0f || deltaZ < 3.0F)) + return 0.0f; + return (float) simplexNoise.eval(CENTER.getX() + pos.getX(), CENTER.getY() + pos.getY(), + CENTER.getZ() + pos.getZ()); + }).setSource(sdfCone) + .setReplaceFunction(state -> BlocksHelper.isFluid(state) || state.getMaterial().isReplaceable()); return sdfCone; } diff --git a/src/main/java/ru/betterend/world/features/BlueVineFeature.java b/src/main/java/ru/betterend/world/features/BlueVineFeature.java index 06883bf3..861cc1e2 100644 --- a/src/main/java/ru/betterend/world/features/BlueVineFeature.java +++ b/src/main/java/ru/betterend/world/features/BlueVineFeature.java @@ -2,7 +2,7 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.basis.EndPlantWithAgeBlock; import ru.betterend.registry.EndBlocks; @@ -11,14 +11,16 @@ import ru.betterend.util.MHelper; public class BlueVineFeature extends ScatterFeature { private boolean small; - + public BlueVineFeature() { super(5); } @Override - public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) { - float d = MHelper.length(center.getX() - blockPos.getX(), center.getZ() - blockPos.getZ()) / radius * 0.6F + random.nextFloat() * 0.4F; + public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, + float radius) { + float d = MHelper.length(center.getX() - blockPos.getX(), center.getZ() - blockPos.getZ()) / radius * 0.6F + + random.nextFloat() * 0.4F; small = d > 0.5F; return EndBlocks.BLUE_VINE_SEED.canPlaceAt(AIR, world, blockPos); } @@ -26,9 +28,9 @@ public class BlueVineFeature extends ScatterFeature { @Override public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) { if (small) { - BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.BLUE_VINE_SEED.getDefaultState().with(EndPlantWithAgeBlock.AGE, random.nextInt(4))); - } - else { + BlocksHelper.setWithoutUpdate(world, blockPos, + EndBlocks.BLUE_VINE_SEED.defaultBlockState().with(EndPlantWithAgeBlock.AGE, random.nextInt(4))); + } else { EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.BLUE_VINE_SEED); seed.growAdult(world, random, blockPos); } diff --git a/src/main/java/ru/betterend/world/features/CavePlantFeature.java b/src/main/java/ru/betterend/world/features/CavePlantFeature.java index 59c8a8a7..e3e21ded 100644 --- a/src/main/java/ru/betterend/world/features/CavePlantFeature.java +++ b/src/main/java/ru/betterend/world/features/CavePlantFeature.java @@ -2,21 +2,22 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.Block; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.util.BlocksHelper; public class CavePlantFeature extends FullHeightScatterFeature { private final Block plant; - + public CavePlantFeature(Block plant, int radius) { super(radius); this.plant = plant; } @Override - public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) { + public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, + float radius) { return plant.canPlaceAt(world.getBlockState(blockPos), world, blockPos); } diff --git a/src/main/java/ru/betterend/world/features/CavePumpkinFeature.java b/src/main/java/ru/betterend/world/features/CavePumpkinFeature.java index de23780c..65c5aef3 100644 --- a/src/main/java/ru/betterend/world/features/CavePumpkinFeature.java +++ b/src/main/java/ru/betterend/world/features/CavePumpkinFeature.java @@ -2,7 +2,7 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -13,17 +13,21 @@ import ru.betterend.util.BlocksHelper; public class CavePumpkinFeature extends DefaultFeature { @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.up()).isIn(EndTags.GEN_TERRAIN) || !world.isAir(pos) || !world.isAir(pos.down())) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.up()).isIn(EndTags.GEN_TERRAIN) || !world.isAir(pos) + || !world.isAir(pos.below())) { return false; } - + int age = random.nextInt(4); - BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.CAVE_PUMPKIN_SEED.getDefaultState().with(BlockProperties.AGE, age)); + BlocksHelper.setWithoutUpdate(world, pos, + EndBlocks.CAVE_PUMPKIN_SEED.defaultBlockState().with(BlockProperties.AGE, age)); if (age > 1) { - BlocksHelper.setWithoutUpdate(world, pos.down(), EndBlocks.CAVE_PUMPKIN.getDefaultState().with(BlockProperties.SMALL, age < 3)); + BlocksHelper.setWithoutUpdate(world, pos.below(), + EndBlocks.CAVE_PUMPKIN.defaultBlockState().with(BlockProperties.SMALL, age < 3)); } - + return true; } } diff --git a/src/main/java/ru/betterend/world/features/CharniaFeature.java b/src/main/java/ru/betterend/world/features/CharniaFeature.java index 14102c4f..57636909 100644 --- a/src/main/java/ru/betterend/world/features/CharniaFeature.java +++ b/src/main/java/ru/betterend/world/features/CharniaFeature.java @@ -1,12 +1,12 @@ package ru.betterend.world.features; -import net.minecraft.block.Block; +import net.minecraft.world.level.block.Block; public class CharniaFeature extends UnderwaterPlantFeature { public CharniaFeature(Block plant) { super(plant, 6); } - + @Override protected int getChance() { return 3; diff --git a/src/main/java/ru/betterend/world/features/CrashedShipFeature.java b/src/main/java/ru/betterend/world/features/CrashedShipFeature.java index 12f17db3..0b474328 100644 --- a/src/main/java/ru/betterend/world/features/CrashedShipFeature.java +++ b/src/main/java/ru/betterend/world/features/CrashedShipFeature.java @@ -2,9 +2,9 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; import net.minecraft.structure.Structure; import net.minecraft.structure.Structure.StructureBlockInfo; import net.minecraft.structure.StructurePlacementData; @@ -12,10 +12,10 @@ import net.minecraft.structure.processor.BlockIgnoreStructureProcessor; import net.minecraft.structure.processor.StructureProcessor; import net.minecraft.structure.processor.StructureProcessorType; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.Identifier; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.WorldView; import net.minecraft.world.gen.chunk.ChunkGenerator; @@ -33,7 +33,8 @@ public class CrashedShipFeature extends NBTStructureFeature { @Override protected Structure getStructure(StructureWorldAccess world, BlockPos pos, Random random) { if (structure == null) { - structure = world.toServerWorld().getStructureManager().getStructureOrBlank(new Identifier("end_city/ship")); + structure = world.toServerWorld().getStructureManager() + .getStructureOrBlank(new ResourceLocation("end_city/ship")); if (structure == null) { structure = StructureHelper.readStructure(STRUCTURE_PATH); } @@ -48,12 +49,12 @@ public class CrashedShipFeature extends NBTStructureFeature { if (x * x + z * z < 3600) { return false; } - return pos.getY() > 5 && world.getBlockState(pos.down()).isIn(EndTags.GEN_TERRAIN); + return pos.getY() > 5 && world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN); } @Override - protected BlockRotation getRotation(StructureWorldAccess world, BlockPos pos, Random random) { - return BlockRotation.random(random); + protected Rotation getRotation(StructureWorldAccess world, BlockPos pos, Random random) { + return Rotation.random(random); } @Override @@ -72,48 +73,53 @@ public class CrashedShipFeature extends NBTStructureFeature { protected TerrainMerge getTerrainMerge(StructureWorldAccess world, BlockPos pos, Random random) { return TerrainMerge.NONE; } - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, + DefaultFeatureConfig featureConfig) { center = new BlockPos(((center.getX() >> 4) << 4) | 8, 128, ((center.getZ() >> 4) << 4) | 8); center = getGround(world, center); BlockBox bounds = makeBox(center); - + if (!canSpawn(world, center, random)) { return false; } - + Structure structure = getStructure(world, center, random); - BlockRotation rotation = getRotation(world, center, random); + Rotation rotation = getRotation(world, center, random); BlockMirror mirror = getMirror(world, center, random); BlockPos offset = Structure.transformAround(structure.getSize(), mirror, rotation, BlockPos.ORIGIN); center = center.add(0, getYOffset(structure, world, center, random) + 0.5, 0); StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror); center = center.add(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5); - + BlockBox structB = structure.calculateBoundingBox(placementData, center); bounds = StructureHelper.intersectBoxes(bounds, structB); - + addStructureData(placementData); structure.place(world, center, placementData.setBoundingBox(bounds), random); - + StructureHelper.erodeIntense(world, bounds, random); - BlocksHelper.fixBlocks(world, new BlockPos(bounds.minX, bounds.minY, bounds.minZ), new BlockPos(bounds.maxX, bounds.maxY, bounds.maxZ)); - + BlocksHelper.fixBlocks(world, new BlockPos(bounds.minX, bounds.minY, bounds.minZ), + new BlockPos(bounds.maxX, bounds.maxY, bounds.maxZ)); + return true; } @Override protected void addStructureData(StructurePlacementData data) { - data.addProcessor(BlockIgnoreStructureProcessor.IGNORE_AIR_AND_STRUCTURE_BLOCKS).addProcessor(REPLACER).setIgnoreEntities(true); + data.addProcessor(BlockIgnoreStructureProcessor.IGNORE_AIR_AND_STRUCTURE_BLOCKS).addProcessor(REPLACER) + .setIgnoreEntities(true); } - + static { REPLACER = new StructureProcessor() { @Override - public StructureBlockInfo process(WorldView worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlacementData structurePlacementData) { + public StructureBlockInfo process(WorldView worldView, BlockPos pos, BlockPos blockPos, + StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, + StructurePlacementData structurePlacementData) { BlockState state = structureBlockInfo2.state; - if (state.isOf(Blocks.SPAWNER) || state.getMaterial().equals(Material.WOOL)) { + if (state.is(Blocks.SPAWNER) || state.getMaterial().equals(Material.WOOL)) { return new StructureBlockInfo(structureBlockInfo2.pos, AIR, null); } return structureBlockInfo2; diff --git a/src/main/java/ru/betterend/world/features/DefaultFeature.java b/src/main/java/ru/betterend/world/features/DefaultFeature.java index adf0ff64..1c9dd59e 100644 --- a/src/main/java/ru/betterend/world/features/DefaultFeature.java +++ b/src/main/java/ru/betterend/world/features/DefaultFeature.java @@ -1,8 +1,8 @@ package ru.betterend.world.features; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.BlockPos; import net.minecraft.world.Heightmap.Type; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -10,33 +10,33 @@ import net.minecraft.world.gen.feature.Feature; import ru.betterend.util.BlocksHelper; public abstract class DefaultFeature extends Feature { - protected static final BlockState AIR = Blocks.AIR.getDefaultState(); - protected static final BlockState WATER = Blocks.WATER.getDefaultState(); - + protected static final BlockState AIR = Blocks.AIR.defaultBlockState(); + protected static final BlockState WATER = Blocks.WATER.defaultBlockState(); + public DefaultFeature() { super(DefaultFeatureConfig.CODEC); } - + public static int getYOnSurface(StructureWorldAccess world, int x, int z) { return world.getTopY(Type.WORLD_SURFACE, x, z); } - + public static int getYOnSurfaceWG(StructureWorldAccess world, int x, int z) { return world.getTopY(Type.WORLD_SURFACE_WG, x, z); } - + public static BlockPos getPosOnSurface(StructureWorldAccess world, BlockPos pos) { return world.getTopPosition(Type.WORLD_SURFACE, pos); } - + public static BlockPos getPosOnSurfaceWG(StructureWorldAccess world, BlockPos pos) { return world.getTopPosition(Type.WORLD_SURFACE_WG, pos); } - + public static BlockPos getPosOnSurfaceRaycast(StructureWorldAccess world, BlockPos pos) { return getPosOnSurfaceRaycast(world, pos, 256); } - + public static BlockPos getPosOnSurfaceRaycast(StructureWorldAccess world, BlockPos pos, int dist) { int h = BlocksHelper.downRay(world, pos, dist); return pos.down(h); diff --git a/src/main/java/ru/betterend/world/features/DoublePlantFeature.java b/src/main/java/ru/betterend/world/features/DoublePlantFeature.java index 310ecf4b..7dcaba6c 100644 --- a/src/main/java/ru/betterend/world/features/DoublePlantFeature.java +++ b/src/main/java/ru/betterend/world/features/DoublePlantFeature.java @@ -2,9 +2,9 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.basis.DoublePlantBlock; import ru.betterend.util.BlocksHelper; @@ -14,29 +14,30 @@ public class DoublePlantFeature extends ScatterFeature { private final Block smallPlant; private final Block largePlant; private Block plant; - + public DoublePlantFeature(Block smallPlant, Block largePlant, int radius) { super(radius); this.smallPlant = smallPlant; this.largePlant = largePlant; } - + @Override - public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) { - float d = MHelper.length(center.getX() - blockPos.getX(), center.getZ() - blockPos.getZ()) / radius * 0.6F + random.nextFloat() * 0.4F; + public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, + float radius) { + float d = MHelper.length(center.getX() - blockPos.getX(), center.getZ() - blockPos.getZ()) / radius * 0.6F + + random.nextFloat() * 0.4F; plant = d < 0.5F ? largePlant : smallPlant; - return plant.canPlaceAt(plant.getDefaultState(), world, blockPos); + return plant.canPlaceAt(plant.defaultBlockState(), world, blockPos); } @Override public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) { if (plant instanceof DoublePlantBlock) { int rot = random.nextInt(4); - BlockState state = plant.getDefaultState().with(DoublePlantBlock.ROTATION, rot); + BlockState state = plant.defaultBlockState().with(DoublePlantBlock.ROTATION, rot); BlocksHelper.setWithoutUpdate(world, blockPos, state); BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(DoublePlantBlock.TOP, true)); - } - else { + } else { BlocksHelper.setWithoutUpdate(world, blockPos, plant); } } diff --git a/src/main/java/ru/betterend/world/features/EndFeature.java b/src/main/java/ru/betterend/world/features/EndFeature.java index b1891370..49a5755c 100644 --- a/src/main/java/ru/betterend/world/features/EndFeature.java +++ b/src/main/java/ru/betterend/world/features/EndFeature.java @@ -1,12 +1,12 @@ package ru.betterend.world.features; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; import net.minecraft.structure.rule.BlockMatchRuleTest; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.registry.BuiltinRegistries; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; import net.minecraft.world.gen.CountConfig; import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.decorator.ChanceDecoratorConfig; @@ -26,99 +26,116 @@ public class EndFeature { private Feature feature; private ConfiguredFeature featureConfigured; private GenerationStep.Feature featureStep; - - protected EndFeature() {} - - public EndFeature(Feature feature, ConfiguredFeature configuredFeature, GenerationStep.Feature featureStep) { + + protected EndFeature() { + } + + public EndFeature(Feature feature, ConfiguredFeature configuredFeature, + GenerationStep.Feature featureStep) { this.featureStep = featureStep; this.feature = feature; this.featureConfigured = configuredFeature; } - - public EndFeature(String name, Feature feature, GenerationStep.Feature featureStep, ConfiguredFeature configuredFeature) { - Identifier id = BetterEnd.makeID(name); + + public EndFeature(String name, Feature feature, GenerationStep.Feature featureStep, + ConfiguredFeature configuredFeature) { + ResourceLocation id = BetterEnd.makeID(name); this.featureStep = featureStep; this.feature = Registry.register(Registry.FEATURE, id, feature); this.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, configuredFeature); } - + public EndFeature(String name, Feature feature) { - Identifier id = BetterEnd.makeID(name); + ResourceLocation id = BetterEnd.makeID(name); this.featureStep = GenerationStep.Feature.VEGETAL_DECORATION; this.feature = Registry.register(Registry.FEATURE, id, feature); - this.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(100)))); + this.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, feature + .configure(FeatureConfig.DEFAULT).decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(100)))); } - + public EndFeature(String name, Feature feature, int density) { - Identifier id = BetterEnd.makeID(name); + ResourceLocation id = BetterEnd.makeID(name); this.featureStep = GenerationStep.Feature.VEGETAL_DECORATION; this.feature = Registry.register(Registry.FEATURE, id, feature); - this.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, feature.configure(FeatureConfig.DEFAULT).decorate(ConfiguredFeatures.Decorators.SQUARE_HEIGHTMAP).repeatRandomly(density)); + this.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, + feature.configure(FeatureConfig.DEFAULT).decorate(ConfiguredFeatures.Decorators.SQUARE_HEIGHTMAP) + .repeatRandomly(density)); } - + public static EndFeature makeRawGenFeature(String name, Feature feature, int chance) { - ConfiguredFeature configured = feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(chance))); + ConfiguredFeature configured = feature.configure(FeatureConfig.DEFAULT) + .decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(chance))); return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured); } - + public static EndFeature makeLakeFeature(String name, Feature feature, int chance) { - ConfiguredFeature configured = feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.WATER_LAKE.configure(new ChanceDecoratorConfig(chance))); + ConfiguredFeature configured = feature.configure(FeatureConfig.DEFAULT) + .decorate(Decorator.WATER_LAKE.configure(new ChanceDecoratorConfig(chance))); return new EndFeature(name, feature, GenerationStep.Feature.LAKES, configured); } - - public static EndFeature makeOreFeature(String name, Block blockOre, int veins, int veinSize, int offset, int minY, int maxY) { + + public static EndFeature makeOreFeature(String name, Block blockOre, int veins, int veinSize, int offset, int minY, + int maxY) { EndFeature newFeature = new EndFeature(); - OreFeatureConfig featureConfig = new OreFeatureConfig(new BlockMatchRuleTest(Blocks.END_STONE), blockOre.getDefaultState(), veinSize); + OreFeatureConfig featureConfig = new OreFeatureConfig(new BlockMatchRuleTest(Blocks.END_STONE), + blockOre.defaultBlockState(), veinSize); RangeDecoratorConfig rangeDecorator = new RangeDecoratorConfig(offset, minY, maxY); ConfiguredFeature oreFeature = Feature.ORE.configure(featureConfig) - .decorate(Decorator.RANGE.configure(rangeDecorator)) - .spreadHorizontally() - .repeat(veins); + .decorate(Decorator.RANGE.configure(rangeDecorator)).spreadHorizontally().repeat(veins); newFeature.feature = Feature.ORE; newFeature.featureStep = GenerationStep.Feature.UNDERGROUND_ORES; - newFeature.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, BetterEnd.makeID(name), oreFeature); - + newFeature.featureConfigured = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, BetterEnd.makeID(name), + oreFeature); + return newFeature; } - - public static EndFeature makeLayerFeature(String name, BlockState state, float radius, int minY, int maxY, int count) { + + public static EndFeature makeLayerFeature(String name, BlockState state, float radius, int minY, int maxY, + int count) { OreLayerFeature layer = new OreLayerFeature(state, radius, minY, maxY); - ConfiguredFeature configured = layer.configure(FeatureConfig.DEFAULT).decorate(Decorator.COUNT.configure(new CountConfig(count))); + ConfiguredFeature configured = layer.configure(FeatureConfig.DEFAULT) + .decorate(Decorator.COUNT.configure(new CountConfig(count))); return new EndFeature(name, layer, GenerationStep.Feature.UNDERGROUND_ORES, configured); } - + public static EndFeature makeLayerFeature(String name, Block block, float radius, int minY, int maxY, int count) { - OreLayerFeature layer = new OreLayerFeature(block.getDefaultState(), radius, minY, maxY); - ConfiguredFeature configured = layer.configure(FeatureConfig.DEFAULT).decorate(Decorator.COUNT.configure(new CountConfig(count))); + OreLayerFeature layer = new OreLayerFeature(block.defaultBlockState(), radius, minY, maxY); + ConfiguredFeature configured = layer.configure(FeatureConfig.DEFAULT) + .decorate(Decorator.COUNT.configure(new CountConfig(count))); return new EndFeature(name, layer, GenerationStep.Feature.UNDERGROUND_ORES, configured); } - - public static EndFeature makeLayerFeature(String name, StoneMaterial material, float radius, int minY, int maxY, int count) { - OreLayerFeature layer = new OreLayerFeature(material.stone.getDefaultState(), radius, minY, maxY); - ConfiguredFeature configured = layer.configure(FeatureConfig.DEFAULT).decorate(Decorator.COUNT.configure(new CountConfig(count))); + + public static EndFeature makeLayerFeature(String name, StoneMaterial material, float radius, int minY, int maxY, + int count) { + OreLayerFeature layer = new OreLayerFeature(material.stone.defaultBlockState(), radius, minY, maxY); + ConfiguredFeature configured = layer.configure(FeatureConfig.DEFAULT) + .decorate(Decorator.COUNT.configure(new CountConfig(count))); return new EndFeature(name, layer, GenerationStep.Feature.UNDERGROUND_ORES, configured); } - + public static EndFeature makeChunkFeature(String name, Feature feature) { - ConfiguredFeature configured = feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.COUNT.configure(new CountConfig(1))); + ConfiguredFeature configured = feature.configure(FeatureConfig.DEFAULT) + .decorate(Decorator.COUNT.configure(new CountConfig(1))); return new EndFeature(name, feature, GenerationStep.Feature.LOCAL_MODIFICATIONS, configured); } - + public static EndFeature makeChansedFeature(String name, Feature feature, int chance) { - ConfiguredFeature configured = feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(chance))); + ConfiguredFeature configured = feature.configure(FeatureConfig.DEFAULT) + .decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(chance))); return new EndFeature(name, feature, GenerationStep.Feature.SURFACE_STRUCTURES, configured); } - + public static EndFeature makeCountRawFeature(String name, Feature feature, int chance) { - ConfiguredFeature configured = feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.COUNT.configure(new CountConfig(chance))); + ConfiguredFeature configured = feature.configure(FeatureConfig.DEFAULT) + .decorate(Decorator.COUNT.configure(new CountConfig(chance))); return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured); } - + public static EndFeature makeFeatureConfigured(String name, Feature feature) { ConfiguredFeature configured = feature.configure(FeatureConfig.DEFAULT); return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured); } - + public Feature getFeature() { return feature; } diff --git a/src/main/java/ru/betterend/world/features/EndLilyFeature.java b/src/main/java/ru/betterend/world/features/EndLilyFeature.java index e2556204..a97d377a 100644 --- a/src/main/java/ru/betterend/world/features/EndLilyFeature.java +++ b/src/main/java/ru/betterend/world/features/EndLilyFeature.java @@ -2,7 +2,7 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.EndLilySeedBlock; import ru.betterend.registry.EndBlocks; @@ -17,7 +17,7 @@ public class EndLilyFeature extends UnderwaterPlantScatter { EndLilySeedBlock seed = (EndLilySeedBlock) EndBlocks.END_LILY_SEED; seed.grow(world, random, blockPos); } - + @Override protected int getChance() { return 15; diff --git a/src/main/java/ru/betterend/world/features/EndLotusFeature.java b/src/main/java/ru/betterend/world/features/EndLotusFeature.java index ffa327a4..3cf060e4 100644 --- a/src/main/java/ru/betterend/world/features/EndLotusFeature.java +++ b/src/main/java/ru/betterend/world/features/EndLotusFeature.java @@ -2,7 +2,7 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.EndLotusSeedBlock; import ru.betterend.registry.EndBlocks; @@ -17,7 +17,7 @@ public class EndLotusFeature extends UnderwaterPlantScatter { EndLotusSeedBlock seed = (EndLotusSeedBlock) EndBlocks.END_LOTUS_SEED; seed.grow(world, random, blockPos); } - + @Override protected int getChance() { return 15; diff --git a/src/main/java/ru/betterend/world/features/EndLotusLeafFeature.java b/src/main/java/ru/betterend/world/features/EndLotusLeafFeature.java index 5c12c62e..0264ccc4 100644 --- a/src/main/java/ru/betterend/world/features/EndLotusLeafFeature.java +++ b/src/main/java/ru/betterend/world/features/EndLotusLeafFeature.java @@ -2,11 +2,11 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.blocks.EndLotusLeafBlock; @@ -24,48 +24,51 @@ public class EndLotusLeafFeature extends ScatterFeature { generateLeaf(world, blockPos); } } - + @Override protected int getChance() { return 15; } - + @Override protected BlockPos getCenterGround(StructureWorldAccess world, BlockPos pos) { return getPosOnSurface(world, pos); } - + private void generateLeaf(StructureWorldAccess world, BlockPos pos) { - Mutable p = new Mutable(); - BlockState leaf = EndBlocks.END_LOTUS_LEAF.getDefaultState(); + MutableBlockPos p = new MutableBlockPos(); + BlockState leaf = EndBlocks.END_LOTUS_LEAF.defaultBlockState(); BlocksHelper.setWithoutUpdate(world, pos, leaf.with(EndLotusLeafBlock.SHAPE, TripleShape.BOTTOM)); - for (Direction move: BlocksHelper.HORIZONTAL) { - BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf.with(EndLotusLeafBlock.HORIZONTAL_FACING, move).with(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE)); + for (Direction move : BlocksHelper.HORIZONTAL) { + BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf + .with(EndLotusLeafBlock.HORIZONTAL_FACING, move).with(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE)); } - for (int i = 0; i < 4; i ++) { + for (int i = 0; i < 4; i++) { Direction d1 = BlocksHelper.HORIZONTAL[i]; Direction d2 = BlocksHelper.HORIZONTAL[(i + 1) & 3]; - BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2), leaf.with(EndLotusLeafBlock.HORIZONTAL_FACING, d1).with(EndLotusLeafBlock.SHAPE, TripleShape.TOP)); + BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2), + leaf.with(EndLotusLeafBlock.HORIZONTAL_FACING, d1).with(EndLotusLeafBlock.SHAPE, TripleShape.TOP)); } } - + private boolean canGenerate(StructureWorldAccess world, BlockPos pos) { - Mutable p = new Mutable(); + MutableBlockPos p = new MutableBlockPos(); p.setY(pos.getY()); int count = 0; - for (int x = -1; x < 2; x ++) { + for (int x = -1; x < 2; x++) { p.setX(pos.getX() + x); - for (int z = -1; z < 2; z ++) { + for (int z = -1; z < 2; z++) { p.setZ(pos.getZ() + z); - if (world.isAir(p) && world.getBlockState(p.down()).isOf(Blocks.WATER)) - count ++; + if (world.isAir(p) && world.getBlockState(p.below()).is(Blocks.WATER)) + count++; } } return count == 9; } @Override - public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) { - return world.isAir(blockPos) && world.getBlockState(blockPos.down()).isOf(Blocks.WATER); + public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, + float radius) { + return world.isAir(blockPos) && world.getBlockState(blockPos.below()).is(Blocks.WATER); } } diff --git a/src/main/java/ru/betterend/world/features/FilaluxFeature.java b/src/main/java/ru/betterend/world/features/FilaluxFeature.java index 394f0505..80b0505a 100644 --- a/src/main/java/ru/betterend/world/features/FilaluxFeature.java +++ b/src/main/java/ru/betterend/world/features/FilaluxFeature.java @@ -2,10 +2,10 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.BlockProperties; import ru.betterend.blocks.BlockProperties.TripleShape; @@ -20,11 +20,11 @@ public class FilaluxFeature extends SkyScatterFeature { @Override public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) { - BlockState vine = EndBlocks.FILALUX.getDefaultState(); - BlockState wings = EndBlocks.FILALUX_WINGS.getDefaultState(); + BlockState vine = EndBlocks.FILALUX.defaultBlockState(); + BlockState wings = EndBlocks.FILALUX_WINGS.defaultBlockState(); BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.FILALUX_LANTERN); BlocksHelper.setWithoutUpdate(world, blockPos.up(), wings.with(Properties.FACING, Direction.UP)); - for (Direction dir: BlocksHelper.HORIZONTAL) { + for (Direction dir : BlocksHelper.HORIZONTAL) { BlocksHelper.setWithoutUpdate(world, blockPos.offset(dir), wings.with(Properties.FACING, dir)); } int length = MHelper.randRange(1, 3, random); diff --git a/src/main/java/ru/betterend/world/features/FullHeightScatterFeature.java b/src/main/java/ru/betterend/world/features/FullHeightScatterFeature.java index b5b112f9..a188df4c 100644 --- a/src/main/java/ru/betterend/world/features/FullHeightScatterFeature.java +++ b/src/main/java/ru/betterend/world/features/FullHeightScatterFeature.java @@ -2,8 +2,8 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.world.Heightmap; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; @@ -12,24 +12,26 @@ import ru.betterend.util.BlocksHelper; import ru.betterend.util.MHelper; public abstract class FullHeightScatterFeature extends DefaultFeature { - private static final Mutable POS = new Mutable(); + private static final MutableBlockPos POS = new MutableBlockPos(); private final int radius; - + public FullHeightScatterFeature(int radius) { this.radius = radius; } - - public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius); - + + public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, + float radius); + public abstract void generate(StructureWorldAccess world, Random random, BlockPos blockPos); - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, + DefaultFeatureConfig featureConfig) { int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, center.getX(), center.getZ()); int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY); for (int y = maxY; y > minY; y--) { POS.set(center.getX(), y, center.getZ()); - if (world.getBlockState(POS).isAir() && !world.getBlockState(POS.down()).isAir()) { + if (world.getBlockState(POS).isAir() && !world.getBlockState(POS.below()).isAir()) { float r = MHelper.randRange(radius * 0.5F, radius, random); int count = MHelper.floor(r * r * MHelper.randRange(1.5F, 3F, random)); for (int i = 0; i < count; i++) { @@ -37,12 +39,13 @@ public abstract class FullHeightScatterFeature extends DefaultFeature { float theta = random.nextFloat() * MHelper.PI2; float x = pr * (float) Math.cos(theta); float z = pr * (float) Math.sin(theta); - + POS.set(center.getX() + x, y + 5, center.getZ() + z); int down = BlocksHelper.downRay(world, POS, 16); - if (down > 10) continue; + if (down > 10) + continue; POS.setY(POS.getY() - down); - + if (canGenerate(world, random, center, POS, r)) { generate(world, random, POS); } diff --git a/src/main/java/ru/betterend/world/features/GlowPillarFeature.java b/src/main/java/ru/betterend/world/features/GlowPillarFeature.java index d64c9cbb..0afd2944 100644 --- a/src/main/java/ru/betterend/world/features/GlowPillarFeature.java +++ b/src/main/java/ru/betterend/world/features/GlowPillarFeature.java @@ -2,7 +2,7 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.basis.EndPlantWithAgeBlock; import ru.betterend.registry.EndBlocks; @@ -13,7 +13,8 @@ public class GlowPillarFeature extends ScatterFeature { } @Override - public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) { + public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, + float radius) { return EndBlocks.GLOWING_PILLAR_SEED.canPlaceAt(AIR, world, blockPos); } @@ -22,7 +23,7 @@ public class GlowPillarFeature extends ScatterFeature { EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.GLOWING_PILLAR_SEED); seed.growAdult(world, random, blockPos); } - + @Override protected int getChance() { return 10; diff --git a/src/main/java/ru/betterend/world/features/HydraluxFeature.java b/src/main/java/ru/betterend/world/features/HydraluxFeature.java index 3aad5755..3b27ddf7 100644 --- a/src/main/java/ru/betterend/world/features/HydraluxFeature.java +++ b/src/main/java/ru/betterend/world/features/HydraluxFeature.java @@ -2,7 +2,7 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.HydraluxSaplingBlock; import ru.betterend.registry.EndBlocks; @@ -17,7 +17,7 @@ public class HydraluxFeature extends UnderwaterPlantScatter { HydraluxSaplingBlock seed = (HydraluxSaplingBlock) EndBlocks.HYDRALUX_SAPLING; seed.grow(world, random, blockPos); } - + @Override protected int getChance() { return 15; diff --git a/src/main/java/ru/betterend/world/features/InvertedScatterFeature.java b/src/main/java/ru/betterend/world/features/InvertedScatterFeature.java index 895fdc5a..6f4b3dc0 100644 --- a/src/main/java/ru/betterend/world/features/InvertedScatterFeature.java +++ b/src/main/java/ru/betterend/world/features/InvertedScatterFeature.java @@ -2,8 +2,8 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.world.Heightmap; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; @@ -12,19 +12,21 @@ import ru.betterend.util.BlocksHelper; import ru.betterend.util.MHelper; public abstract class InvertedScatterFeature extends DefaultFeature { - private static final Mutable POS = new Mutable(); + private static final MutableBlockPos POS = new MutableBlockPos(); private final int radius; - + public InvertedScatterFeature(int radius) { this.radius = radius; } - - public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius); - + + public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, + float radius); + public abstract void generate(StructureWorldAccess world, Random random, BlockPos blockPos); - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, + DefaultFeatureConfig featureConfig) { int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE, center.getX(), center.getZ()); int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY); for (int y = maxY; y > minY; y--) { @@ -37,12 +39,13 @@ public abstract class InvertedScatterFeature extends DefaultFeature { float theta = random.nextFloat() * MHelper.PI2; float x = pr * (float) Math.cos(theta); float z = pr * (float) Math.sin(theta); - + POS.set(center.getX() + x, center.getY() - 7, center.getZ() + z); int up = BlocksHelper.upRay(world, POS, 16); - if (up > 14) continue; + if (up > 14) + continue; POS.setY(POS.getY() + up); - + if (canGenerate(world, random, center, POS, r)) { generate(world, random, POS); } diff --git a/src/main/java/ru/betterend/world/features/LanceleafFeature.java b/src/main/java/ru/betterend/world/features/LanceleafFeature.java index 97a63710..2223c3c1 100644 --- a/src/main/java/ru/betterend/world/features/LanceleafFeature.java +++ b/src/main/java/ru/betterend/world/features/LanceleafFeature.java @@ -2,7 +2,7 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.basis.EndPlantWithAgeBlock; import ru.betterend.registry.EndBlocks; @@ -13,7 +13,8 @@ public class LanceleafFeature extends ScatterFeature { } @Override - public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) { + public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, + float radius) { return EndBlocks.LANCELEAF_SEED.canPlaceAt(AIR, world, blockPos); } @@ -22,7 +23,7 @@ public class LanceleafFeature extends ScatterFeature { EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.LANCELEAF_SEED); seed.growAdult(world, random, blockPos); } - + @Override protected int getChance() { return 5; diff --git a/src/main/java/ru/betterend/world/features/ListFeature.java b/src/main/java/ru/betterend/world/features/ListFeature.java index 42dc6367..bc4dcf0c 100644 --- a/src/main/java/ru/betterend/world/features/ListFeature.java +++ b/src/main/java/ru/betterend/world/features/ListFeature.java @@ -6,8 +6,8 @@ import java.util.Random; import net.minecraft.structure.Structure; import net.minecraft.structure.StructurePlacementData; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.registry.EndTags; import ru.betterend.util.StructureHelper; @@ -15,11 +15,11 @@ import ru.betterend.util.StructureHelper; public class ListFeature extends NBTStructureFeature { private final List list; private StructureInfo selected; - + public ListFeature(List list) { this.list = list; } - + @Override protected Structure getStructure(StructureWorldAccess world, BlockPos pos, Random random) { selected = list.get(random.nextInt(list.size())); @@ -30,12 +30,12 @@ public class ListFeature extends NBTStructureFeature { protected boolean canSpawn(StructureWorldAccess world, BlockPos pos, Random random) { int cx = pos.getX() >> 4; int cz = pos.getZ() >> 4; - return ((cx + cz) & 1) == 0 && pos.getY() > 58 && world.getBlockState(pos.down()).isIn(EndTags.GEN_TERRAIN); + return ((cx + cz) & 1) == 0 && pos.getY() > 58 && world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN); } @Override - protected BlockRotation getRotation(StructureWorldAccess world, BlockPos pos, Random random) { - return BlockRotation.random(random); + protected Rotation getRotation(StructureWorldAccess world, BlockPos pos, Random random) { + return Rotation.random(random); } @Override @@ -52,23 +52,24 @@ public class ListFeature extends NBTStructureFeature { protected TerrainMerge getTerrainMerge(StructureWorldAccess world, BlockPos pos, Random random) { return selected.terrainMerge; } - + @Override - protected void addStructureData(StructurePlacementData data) {} - + protected void addStructureData(StructurePlacementData data) { + } + public static final class StructureInfo { public final TerrainMerge terrainMerge; public final String structurePath; public final int offsetY; - + private Structure structure; - + public StructureInfo(String structurePath, int offsetY, TerrainMerge terrainMerge) { this.terrainMerge = terrainMerge; this.structurePath = structurePath; this.offsetY = offsetY; } - + public Structure getStructure() { if (structure == null) { structure = StructureHelper.readStructure(structurePath); diff --git a/src/main/java/ru/betterend/world/features/MengerSpongeFeature.java b/src/main/java/ru/betterend/world/features/MengerSpongeFeature.java index 186fa664..3347ab66 100644 --- a/src/main/java/ru/betterend/world/features/MengerSpongeFeature.java +++ b/src/main/java/ru/betterend/world/features/MengerSpongeFeature.java @@ -3,16 +3,16 @@ package ru.betterend.world.features; import java.util.Random; import java.util.function.Function; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import ru.betterend.registry.EndBlocks; import ru.betterend.util.BlocksHelper; public class MengerSpongeFeature extends UnderwaterPlantScatter { private static final Function REPLACE; - + public MengerSpongeFeature(int radius) { super(radius); } @@ -21,7 +21,7 @@ public class MengerSpongeFeature extends UnderwaterPlantScatter { public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) { BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.MENGER_SPONGE_WET); if (random.nextBoolean()) { - for (Direction dir: BlocksHelper.DIRECTIONS) { + for (Direction dir : BlocksHelper.DIRECTIONS) { BlockPos pos = blockPos.offset(dir); if (REPLACE.apply(world.getBlockState(pos))) { BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.MENGER_SPONGE_WET); @@ -29,10 +29,10 @@ public class MengerSpongeFeature extends UnderwaterPlantScatter { } } } - + static { REPLACE = (state) -> { - if (state.isOf(EndBlocks.END_LOTUS_STEM)) { + if (state.is(EndBlocks.END_LOTUS_STEM)) { return false; } return !state.getFluidState().isEmpty() || state.getMaterial().isReplaceable(); diff --git a/src/main/java/ru/betterend/world/features/NBTStructureFeature.java b/src/main/java/ru/betterend/world/features/NBTStructureFeature.java index 2bb0dac0..a8ced4bf 100644 --- a/src/main/java/ru/betterend/world/features/NBTStructureFeature.java +++ b/src/main/java/ru/betterend/world/features/NBTStructureFeature.java @@ -4,19 +4,19 @@ import java.io.IOException; import java.io.InputStream; import java.util.Random; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtIo; import net.minecraft.server.MinecraftServer; import net.minecraft.structure.Structure; import net.minecraft.structure.StructurePlacementData; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.Identifier; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.chunk.ChunkGenerator; @@ -29,34 +29,33 @@ import ru.betterend.world.processors.DestructionStructureProcessor; public abstract class NBTStructureFeature extends DefaultFeature { protected static final DestructionStructureProcessor DESTRUCTION = new DestructionStructureProcessor(); - + protected abstract Structure getStructure(StructureWorldAccess world, BlockPos pos, Random random); - + protected abstract boolean canSpawn(StructureWorldAccess world, BlockPos pos, Random random); - - protected abstract BlockRotation getRotation(StructureWorldAccess world, BlockPos pos, Random random); - + + protected abstract Rotation getRotation(StructureWorldAccess world, BlockPos pos, Random random); + protected abstract BlockMirror getMirror(StructureWorldAccess world, BlockPos pos, Random random); - + protected abstract int getYOffset(Structure structure, StructureWorldAccess world, BlockPos pos, Random random); - + protected abstract TerrainMerge getTerrainMerge(StructureWorldAccess world, BlockPos pos, Random random); - + protected abstract void addStructureData(StructurePlacementData data); - + protected BlockPos getGround(StructureWorldAccess world, BlockPos center) { Biome biome = world.getBiome(center); - Identifier id = EndBiomes.getBiomeID(biome); + ResourceLocation id = EndBiomes.getBiomeID(biome); if (id.getNamespace().contains("moutain") || id.getNamespace().contains("lake")) { int y = getAverageY(world, center); return new BlockPos(center.getX(), y, center.getZ()); - } - else { + } else { int y = getAverageYWG(world, center); return new BlockPos(center.getX(), y, center.getZ()); } } - + protected int getAverageY(StructureWorldAccess world, BlockPos center) { int y = getYOnSurface(world, center.getX(), center.getZ()); y += getYOnSurface(world, center.getX() - 2, center.getZ() - 2); @@ -65,7 +64,7 @@ public abstract class NBTStructureFeature extends DefaultFeature { y += getYOnSurface(world, center.getX() + 2, center.getZ() + 2); return y / 5; } - + protected int getAverageYWG(StructureWorldAccess world, BlockPos center) { int y = getYOnSurfaceWG(world, center.getX(), center.getZ()); y += getYOnSurfaceWG(world, center.getX() - 2, center.getZ() - 2); @@ -74,49 +73,51 @@ public abstract class NBTStructureFeature extends DefaultFeature { y += getYOnSurfaceWG(world, center.getX() + 2, center.getZ() + 2); return y / 5; } - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, + DefaultFeatureConfig featureConfig) { center = new BlockPos(((center.getX() >> 4) << 4) | 8, 128, ((center.getZ() >> 4) << 4) | 8); center = getGround(world, center); - + if (!canSpawn(world, center, random)) { return false; } - + int posY = center.getY() + 1; Structure structure = getStructure(world, center, random); - BlockRotation rotation = getRotation(world, center, random); + Rotation rotation = getRotation(world, center, random); BlockMirror mirror = getMirror(world, center, random); BlockPos offset = Structure.transformAround(structure.getSize(), mirror, rotation, BlockPos.ORIGIN); center = center.add(0, getYOffset(structure, world, center, random) + 0.5, 0); - + BlockBox bounds = makeBox(center); - StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds); + StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror) + .setBoundingBox(bounds); addStructureData(placementData); center = center.add(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5); structure.place(world, center, placementData, random); - + TerrainMerge merge = getTerrainMerge(world, center, random); int x1 = center.getX(); int z1 = center.getZ(); int x2 = x1 + offset.getX(); int z2 = z1 + offset.getZ(); if (merge != TerrainMerge.NONE) { - Mutable mut = new Mutable(); - + MutableBlockPos mut = new MutableBlockPos(); + if (x2 < x1) { int a = x1; x1 = x2; x2 = a; } - + if (z2 < z1) { int a = z1; z1 = z2; z2 = a; } - + int surfMax = posY - 1; for (int x = x1; x <= x2; x++) { mut.setX(x); @@ -130,22 +131,21 @@ public abstract class NBTStructureFeature extends DefaultFeature { BlockState stateSt = world.getBlockState(mut); if (!stateSt.isIn(EndTags.GEN_TERRAIN)) { if (merge == TerrainMerge.SURFACE) { - SurfaceConfig config = world.getBiome(mut).getGenerationSettings().getSurfaceConfig(); + SurfaceConfig config = world.getBiome(mut).getGenerationSettings() + .getSurfaceConfig(); boolean isTop = mut.getY() == surfMax && state.getMaterial().blocksLight(); BlockState top = isTop ? config.getTopMaterial() : config.getUnderMaterial(); BlocksHelper.setWithoutUpdate(world, mut, top); - } - else { + } else { BlocksHelper.setWithoutUpdate(world, mut, state); } - } - else { + } else { if (stateSt.isIn(EndTags.END_GROUND) && state.getMaterial().blocksLight()) { if (merge == TerrainMerge.SURFACE) { - SurfaceConfig config = world.getBiome(mut).getGenerationSettings().getSurfaceConfig(); + SurfaceConfig config = world.getBiome(mut).getGenerationSettings() + .getSurfaceConfig(); BlocksHelper.setWithoutUpdate(world, mut, config.getUnderMaterial()); - } - else { + } else { BlocksHelper.setWithoutUpdate(world, mut, state); } } @@ -156,11 +156,12 @@ public abstract class NBTStructureFeature extends DefaultFeature { } } } - BlocksHelper.fixBlocks(world, new BlockPos(x1, center.getY(), z1), new BlockPos(x2, center.getY() + offset.getY(), z2)); - + BlocksHelper.fixBlocks(world, new BlockPos(x1, center.getY(), z1), + new BlockPos(x2, center.getY() + offset.getY(), z2)); + return true; } - + protected BlockBox makeBox(BlockPos pos) { int sx = ((pos.getX() >> 4) << 4) - 16; int sz = ((pos.getZ() >> 4) << 4) - 16; @@ -168,22 +169,22 @@ public abstract class NBTStructureFeature extends DefaultFeature { int ez = sz + 47; return BlockBox.create(sx, 0, sz, ex, 255, ez); } - - protected static Structure readStructure(Identifier resource) { + + protected static Structure readStructure(ResourceLocation resource) { String ns = resource.getNamespace(); String nm = resource.getPath(); try { - InputStream inputstream = MinecraftServer.class.getResourceAsStream("/data/" + ns + "/structures/" + nm + ".nbt"); + InputStream inputstream = MinecraftServer.class + .getResourceAsStream("/data/" + ns + "/structures/" + nm + ".nbt"); return readStructureFromStream(inputstream); - } - catch (IOException e) { + } catch (IOException e) { e.printStackTrace(); } return null; } - + private static Structure readStructureFromStream(InputStream stream) throws IOException { CompoundTag nbttagcompound = NbtIo.readCompressed(stream); @@ -192,20 +193,16 @@ public abstract class NBTStructureFeature extends DefaultFeature { return template; } - + public static enum TerrainMerge { - NONE, - SURFACE, - OBJECT; - + NONE, SURFACE, OBJECT; + public static TerrainMerge getFromString(String type) { if (type.equals("surface")) { return SURFACE; - } - else if (type.equals("object")) { + } else if (type.equals("object")) { return OBJECT; - } - else { + } else { return NONE; } } diff --git a/src/main/java/ru/betterend/world/features/NeonCactusFeature.java b/src/main/java/ru/betterend/world/features/NeonCactusFeature.java index f62ae4ab..c38a6ce4 100644 --- a/src/main/java/ru/betterend/world/features/NeonCactusFeature.java +++ b/src/main/java/ru/betterend/world/features/NeonCactusFeature.java @@ -3,9 +3,9 @@ package ru.betterend.world.features; import java.util.Random; import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -17,65 +17,61 @@ import ru.betterend.util.MHelper; public class NeonCactusFeature extends DefaultFeature { @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).isOf(EndBlocks.ENDSTONE_DUST)) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).is(EndBlocks.ENDSTONE_DUST)) { return false; } - + int h = MHelper.randRange(5, 20, random); - Mutable mut = new Mutable().set(pos); + MutableBlockPos mut = new MutableBlockPos().set(pos); Direction hor = BlocksHelper.randomHorizontal(random); for (int i = 0; i < h; i++) { if (!world.getBlockState(mut).getMaterial().isReplaceable()) { break; } int size = (h - i) >> 2; - BlocksHelper.setWithUpdate(world, mut, - EndBlocks.NEON_CACTUS.getDefaultState() - .with(BlockProperties.TRIPLE_SHAPE, getBySize(size)) - .with(Properties.FACING, Direction.UP) - ); + BlocksHelper.setWithUpdate(world, mut, EndBlocks.NEON_CACTUS.defaultBlockState() + .with(BlockProperties.TRIPLE_SHAPE, getBySize(size)).with(Properties.FACING, Direction.UP)); if (i > 2 && i < (h - 1) && random.nextBoolean()) { int length = h - i - MHelper.randRange(1, 2, random); if (length > 0) { Direction dir2 = hor; - hor = hor.rotateYClockwise(); + hor = hor.getClockWise(); int bsize = i > ((h << 1) / 3) ? 0 : size > 1 ? 1 : size; branch(world, mut.offset(dir2), dir2, random, length, bsize); } } mut.move(Direction.UP); } - + return true; } - + private void branch(StructureWorldAccess world, BlockPos pos, Direction dir, Random random, int length, int size) { int rotIndex = length >> 2; - Mutable mut = new Mutable().set(pos); + MutableBlockPos mut = new MutableBlockPos().set(pos); Direction hor = BlocksHelper.randomHorizontal(random); for (int i = 0; i < length; i++) { if (!world.getBlockState(mut).getMaterial().isReplaceable()) { return; } - BlocksHelper.setWithUpdate(world, mut, - EndBlocks.NEON_CACTUS.getDefaultState() - .with(BlockProperties.TRIPLE_SHAPE, getBySize(size)) - .with(Properties.FACING, dir) - ); + BlocksHelper.setWithUpdate(world, mut, EndBlocks.NEON_CACTUS.defaultBlockState() + .with(BlockProperties.TRIPLE_SHAPE, getBySize(size)).with(Properties.FACING, dir)); if (i == rotIndex) { dir = Direction.UP; - size --; + size--; } if (i > 1 && i < (length - 1) && random.nextBoolean()) { Direction dir2 = dir == Direction.UP ? hor : Direction.UP; - hor = hor.rotateYClockwise(); - branch(world, mut.offset(dir2), dir2, random, MHelper.randRange(length / 4, length / 2, random), size > 0 ? size - 1 : size); + hor = hor.getClockWise(); + branch(world, mut.offset(dir2), dir2, random, MHelper.randRange(length / 4, length / 2, random), + size > 0 ? size - 1 : size); } mut.move(dir); } } - + private TripleShape getBySize(int size) { return size < 1 ? TripleShape.TOP : size == 1 ? TripleShape.MIDDLE : TripleShape.BOTTOM; } diff --git a/src/main/java/ru/betterend/world/features/ScatterFeature.java b/src/main/java/ru/betterend/world/features/ScatterFeature.java index 56086199..eed12d70 100644 --- a/src/main/java/ru/betterend/world/features/ScatterFeature.java +++ b/src/main/java/ru/betterend/world/features/ScatterFeature.java @@ -2,8 +2,8 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -12,32 +12,32 @@ import ru.betterend.util.BlocksHelper; import ru.betterend.util.MHelper; public abstract class ScatterFeature extends DefaultFeature { - private static final Mutable POS = new Mutable(); + private static final MutableBlockPos POS = new MutableBlockPos(); private final int radius; - + public ScatterFeature(int radius) { this.radius = radius; } - - public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius); - + + public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, + float radius); + public abstract void generate(StructureWorldAccess world, Random random, BlockPos blockPos); - + protected BlockPos getCenterGround(StructureWorldAccess world, BlockPos pos) { return getPosOnSurfaceWG(world, pos); } - + protected boolean canSpawn(StructureWorldAccess world, BlockPos pos) { if (pos.getY() < 5) { return false; - } - else if (!world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) { + } else if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) { return false; } return true; } - - protected boolean getGroundPlant(StructureWorldAccess world, Mutable pos) { + + protected boolean getGroundPlant(StructureWorldAccess world, MutableBlockPos pos) { int down = BlocksHelper.downRay(world, pos, 16); if (down > Math.abs(getYOffset() * 2)) { return false; @@ -45,23 +45,24 @@ public abstract class ScatterFeature extends DefaultFeature { pos.setY(pos.getY() - down); return true; } - + protected int getYOffset() { return 5; } - + protected int getChance() { return 1; } - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, + DefaultFeatureConfig featureConfig) { center = getCenterGround(world, center); - + if (!canSpawn(world, center)) { return false; } - + float r = MHelper.randRange(radius * 0.5F, radius, random); int count = MHelper.floor(r * r * MHelper.randRange(1.5F, 3F, random)); for (int i = 0; i < count; i++) { @@ -69,13 +70,14 @@ public abstract class ScatterFeature extends DefaultFeature { float theta = random.nextFloat() * MHelper.PI2; float x = pr * (float) Math.cos(theta); float z = pr * (float) Math.sin(theta); - + POS.set(center.getX() + x, center.getY() + getYOffset(), center.getZ() + z); - if (getGroundPlant(world, POS) && canGenerate(world, random, center, POS, r) && (getChance() < 2 || random.nextInt(getChance()) == 0)) { + if (getGroundPlant(world, POS) && canGenerate(world, random, center, POS, r) + && (getChance() < 2 || random.nextInt(getChance()) == 0)) { generate(world, random, POS); } } - + return true; } } diff --git a/src/main/java/ru/betterend/world/features/SilkMothNestFeature.java b/src/main/java/ru/betterend/world/features/SilkMothNestFeature.java index a66d8862..ba270515 100644 --- a/src/main/java/ru/betterend/world/features/SilkMothNestFeature.java +++ b/src/main/java/ru/betterend/world/features/SilkMothNestFeature.java @@ -2,12 +2,12 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.state.property.Properties; -import net.minecraft.tag.BlockTags; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.tags.BlockTags; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.Heightmap; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; @@ -17,15 +17,15 @@ import ru.betterend.registry.EndBlocks; import ru.betterend.util.BlocksHelper; public class SilkMothNestFeature extends DefaultFeature { - private static final Mutable POS = new Mutable(); - + private static final MutableBlockPos POS = new MutableBlockPos(); + private boolean canGenerate(StructureWorldAccess world, BlockPos pos) { BlockState state = world.getBlockState(pos.up()); if (state.isIn(BlockTags.LEAVES) || state.isIn(BlockTags.LOGS)) { state = world.getBlockState(pos); - if ((state.isAir() || state.isOf(EndBlocks.TENANEA_OUTER_LEAVES)) && world.isAir(pos.down())) { - for (Direction dir: BlocksHelper.HORIZONTAL) { - if (world.getBlockState(pos.down().offset(dir)).getMaterial().blocksMovement()) { + if ((state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) && world.isAir(pos.below())) { + for (Direction dir : BlocksHelper.HORIZONTAL) { + if (world.getBlockState(pos.below().offset(dir)).getMaterial().blocksMovement()) { return false; } return true; @@ -34,9 +34,10 @@ public class SilkMothNestFeature extends DefaultFeature { } return false; } - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, + DefaultFeatureConfig featureConfig) { int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE, center.getX(), center.getZ()); int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY); POS.set(center); @@ -44,9 +45,11 @@ public class SilkMothNestFeature extends DefaultFeature { POS.setY(y); if (canGenerate(world, POS)) { Direction dir = BlocksHelper.randomHorizontal(random); - BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.getDefaultState().with(Properties.HORIZONTAL_FACING, dir).with(BlockProperties.ACTIVE, false)); + BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.defaultBlockState() + .with(Properties.HORIZONTAL_FACING, dir).with(BlockProperties.ACTIVE, false)); POS.setY(y - 1); - BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.getDefaultState().with(Properties.HORIZONTAL_FACING, dir)); + BlocksHelper.setWithoutUpdate(world, POS, + EndBlocks.SILK_MOTH_NEST.defaultBlockState().with(Properties.HORIZONTAL_FACING, dir)); return true; } } diff --git a/src/main/java/ru/betterend/world/features/SingleInvertedScatterFeature.java b/src/main/java/ru/betterend/world/features/SingleInvertedScatterFeature.java index 82316fd6..77a6bf04 100644 --- a/src/main/java/ru/betterend/world/features/SingleInvertedScatterFeature.java +++ b/src/main/java/ru/betterend/world/features/SingleInvertedScatterFeature.java @@ -2,29 +2,30 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.basis.AttachedBlock; import ru.betterend.util.BlocksHelper; public class SingleInvertedScatterFeature extends InvertedScatterFeature { private final Block block; - + public SingleInvertedScatterFeature(Block block, int radius) { super(radius); this.block = block; } @Override - public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) { + public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, + float radius) { if (!world.isAir(blockPos)) { return false; } - BlockState state = block.getDefaultState(); + BlockState state = block.defaultBlockState(); if (block instanceof AttachedBlock) { state = state.with(Properties.FACING, Direction.DOWN); } @@ -33,7 +34,7 @@ public class SingleInvertedScatterFeature extends InvertedScatterFeature { @Override public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) { - BlockState state = block.getDefaultState(); + BlockState state = block.defaultBlockState(); if (block instanceof AttachedBlock) { state = state.with(Properties.FACING, Direction.DOWN); } diff --git a/src/main/java/ru/betterend/world/features/SinglePlantFeature.java b/src/main/java/ru/betterend/world/features/SinglePlantFeature.java index 892c3da4..9218691b 100644 --- a/src/main/java/ru/betterend/world/features/SinglePlantFeature.java +++ b/src/main/java/ru/betterend/world/features/SinglePlantFeature.java @@ -2,9 +2,9 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.basis.DoublePlantBlock; import ru.betterend.blocks.basis.EndCropBlock; @@ -15,58 +15,56 @@ public class SinglePlantFeature extends ScatterFeature { private final Block plant; private final boolean rawHeightmap; private final int chance; - + public SinglePlantFeature(Block plant, int radius) { this(plant, radius, true, 1); } - + public SinglePlantFeature(Block plant, int radius, int chance) { this(plant, radius, true, chance); } - + public SinglePlantFeature(Block plant, int radius, boolean rawHeightmap) { this(plant, radius, rawHeightmap, 1); } - + public SinglePlantFeature(Block plant, int radius, boolean rawHeightmap, int chance) { super(radius); this.plant = plant; this.rawHeightmap = rawHeightmap; this.chance = chance; } - + protected int getChance() { return chance; } - + @Override protected BlockPos getCenterGround(StructureWorldAccess world, BlockPos pos) { return rawHeightmap ? getPosOnSurfaceWG(world, pos) : getPosOnSurface(world, pos); } - + @Override - public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) { - return plant.canPlaceAt(plant.getDefaultState(), world, blockPos); + public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, + float radius) { + return plant.canPlaceAt(plant.defaultBlockState(), world, blockPos); } @Override public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) { if (plant instanceof DoublePlantBlock) { int rot = random.nextInt(4); - BlockState state = plant.getDefaultState().with(DoublePlantBlock.ROTATION, rot); + BlockState state = plant.defaultBlockState().with(DoublePlantBlock.ROTATION, rot); BlocksHelper.setWithoutUpdate(world, blockPos, state); BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(DoublePlantBlock.TOP, true)); - } - else if (plant instanceof EndCropBlock) { - BlockState state = plant.getDefaultState().with(EndCropBlock.AGE, 3); + } else if (plant instanceof EndCropBlock) { + BlockState state = plant.defaultBlockState().with(EndCropBlock.AGE, 3); BlocksHelper.setWithoutUpdate(world, blockPos, state); - } - else if (plant instanceof EndPlantWithAgeBlock) { + } else if (plant instanceof EndPlantWithAgeBlock) { int age = random.nextInt(4); - BlockState state = plant.getDefaultState().with(EndPlantWithAgeBlock.AGE, age); + BlockState state = plant.defaultBlockState().with(EndPlantWithAgeBlock.AGE, age); BlocksHelper.setWithoutUpdate(world, blockPos, state); - } - else { + } else { BlocksHelper.setWithoutUpdate(world, blockPos, plant); } } diff --git a/src/main/java/ru/betterend/world/features/SkyScatterFeature.java b/src/main/java/ru/betterend/world/features/SkyScatterFeature.java index 97e5178a..090b8314 100644 --- a/src/main/java/ru/betterend/world/features/SkyScatterFeature.java +++ b/src/main/java/ru/betterend/world/features/SkyScatterFeature.java @@ -2,9 +2,9 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import ru.betterend.util.BlocksHelper; import ru.betterend.util.MHelper; @@ -13,41 +13,42 @@ public abstract class SkyScatterFeature extends ScatterFeature { public SkyScatterFeature(int radius) { super(radius); } - + @Override protected int getChance() { return 10; } @Override - public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) { + public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, + float radius) { if (!world.isAir(blockPos)) { return false; } - - for (Direction dir: BlocksHelper.HORIZONTAL) { + + for (Direction dir : BlocksHelper.HORIZONTAL) { if (!world.isAir(blockPos.offset(dir))) { return false; } } - + int maxD = getYOffset() + 2; int maxV = getYOffset() - 2; - + return BlocksHelper.upRay(world, blockPos, maxD) > maxV && BlocksHelper.downRay(world, blockPos, maxD) > maxV; } - + @Override protected boolean canSpawn(StructureWorldAccess world, BlockPos pos) { return true; } - + @Override protected BlockPos getCenterGround(StructureWorldAccess world, BlockPos pos) { return new BlockPos(pos.getX(), MHelper.randRange(32, 192, world.getRandom()), pos.getZ()); } - - protected boolean getGroundPlant(StructureWorldAccess world, Mutable pos) { + + protected boolean getGroundPlant(StructureWorldAccess world, MutableBlockPos pos) { pos.setY(pos.getY() + MHelper.randRange(-getYOffset(), getYOffset(), world.getRandom())); return true; } diff --git a/src/main/java/ru/betterend/world/features/UnderwaterPlantFeature.java b/src/main/java/ru/betterend/world/features/UnderwaterPlantFeature.java index 5013d22c..a62b4a5e 100644 --- a/src/main/java/ru/betterend/world/features/UnderwaterPlantFeature.java +++ b/src/main/java/ru/betterend/world/features/UnderwaterPlantFeature.java @@ -2,35 +2,35 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.basis.DoublePlantBlock; import ru.betterend.util.BlocksHelper; public class UnderwaterPlantFeature extends UnderwaterPlantScatter { private final Block plant; - + public UnderwaterPlantFeature(Block plant, int radius) { super(radius); this.plant = plant; } - + @Override - public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) { - return super.canSpawn(world, blockPos) && plant.canPlaceAt(plant.getDefaultState(), world, blockPos); + public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, + float radius) { + return super.canSpawn(world, blockPos) && plant.canPlaceAt(plant.defaultBlockState(), world, blockPos); } @Override public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) { if (plant instanceof DoublePlantBlock) { int rot = random.nextInt(4); - BlockState state = plant.getDefaultState().with(DoublePlantBlock.ROTATION, rot); + BlockState state = plant.defaultBlockState().with(DoublePlantBlock.ROTATION, rot); BlocksHelper.setWithoutUpdate(world, blockPos, state); BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(DoublePlantBlock.TOP, true)); - } - else { + } else { BlocksHelper.setWithoutUpdate(world, blockPos, plant); } } diff --git a/src/main/java/ru/betterend/world/features/UnderwaterPlantScatter.java b/src/main/java/ru/betterend/world/features/UnderwaterPlantScatter.java index 9af618c4..d38eb537 100644 --- a/src/main/java/ru/betterend/world/features/UnderwaterPlantScatter.java +++ b/src/main/java/ru/betterend/world/features/UnderwaterPlantScatter.java @@ -2,18 +2,18 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.world.StructureWorldAccess; public abstract class UnderwaterPlantScatter extends ScatterFeature { - private static final Mutable POS = new Mutable(); - + private static final MutableBlockPos POS = new MutableBlockPos(); + public UnderwaterPlantScatter(int radius) { super(radius); } - + @Override protected BlockPos getCenterGround(StructureWorldAccess world, BlockPos pos) { POS.setX(pos.getX()); @@ -21,33 +21,34 @@ public abstract class UnderwaterPlantScatter extends ScatterFeature { POS.setY(0); return getGround(world, POS).toImmutable(); } - + @Override - public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) { - return world.getBlockState(blockPos).isOf(Blocks.WATER); + public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, + float radius) { + return world.getBlockState(blockPos).is(Blocks.WATER); } - + @Override protected boolean canSpawn(StructureWorldAccess world, BlockPos pos) { - return world.getBlockState(pos).isOf(Blocks.WATER); + return world.getBlockState(pos).is(Blocks.WATER); } - + @Override - protected boolean getGroundPlant(StructureWorldAccess world, Mutable pos) { + protected boolean getGroundPlant(StructureWorldAccess world, MutableBlockPos pos) { return getGround(world, pos).getY() < 128; } - + @Override protected int getYOffset() { return -5; } - + @Override protected int getChance() { return 5; } - - private BlockPos getGround(StructureWorldAccess world, Mutable pos) { + + private BlockPos getGround(StructureWorldAccess world, MutableBlockPos pos) { while (pos.getY() < 128 && world.getFluidState(pos).isEmpty()) { pos.setY(pos.getY() + 1); } diff --git a/src/main/java/ru/betterend/world/features/VineFeature.java b/src/main/java/ru/betterend/world/features/VineFeature.java index 535ecd7c..ec3885b2 100644 --- a/src/main/java/ru/betterend/world/features/VineFeature.java +++ b/src/main/java/ru/betterend/world/features/VineFeature.java @@ -2,9 +2,9 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.BlockProperties; import ru.betterend.blocks.BlockProperties.TripleShape; @@ -15,7 +15,7 @@ public class VineFeature extends InvertedScatterFeature { private final Block vineBlock; private final int maxLength; private final boolean vine; - + public VineFeature(Block vineBlock, int maxLength) { super(6); this.vineBlock = vineBlock; @@ -24,7 +24,8 @@ public class VineFeature extends InvertedScatterFeature { } @Override - public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) { + public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, + float radius) { BlockState state = world.getBlockState(blockPos); return state.getMaterial().isReplaceable() && canPlaceBlock(state, world, blockPos); } @@ -43,28 +44,27 @@ public class VineFeature extends InvertedScatterFeature { BlocksHelper.setWithoutUpdate(world, blockPos.down(h), bottom); } } - + private boolean canPlaceBlock(BlockState state, StructureWorldAccess world, BlockPos blockPos) { if (vine) { return ((VineBlock) vineBlock).canGenerate(state, world, blockPos); - } - else { + } else { return vineBlock.canPlaceAt(state, world, blockPos); } } - + private BlockState getTopState() { - BlockState state = vineBlock.getDefaultState(); + BlockState state = vineBlock.defaultBlockState(); return vine ? state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP) : state; } - + private BlockState getMiggleState() { - BlockState state = vineBlock.getDefaultState(); + BlockState state = vineBlock.defaultBlockState(); return vine ? state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE) : state; } - + private BlockState getBottomState() { - BlockState state = vineBlock.getDefaultState(); + BlockState state = vineBlock.defaultBlockState(); return vine ? state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM) : state; } } diff --git a/src/main/java/ru/betterend/world/features/WallPlantFeature.java b/src/main/java/ru/betterend/world/features/WallPlantFeature.java index 7faadad5..24f252d8 100644 --- a/src/main/java/ru/betterend/world/features/WallPlantFeature.java +++ b/src/main/java/ru/betterend/world/features/WallPlantFeature.java @@ -2,11 +2,11 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.basis.AttachedBlock; import ru.betterend.blocks.basis.EndWallPlantBlock; @@ -14,7 +14,7 @@ import ru.betterend.util.BlocksHelper; public class WallPlantFeature extends WallScatterFeature { private final Block block; - + public WallPlantFeature(Block block, int radius) { super(radius); this.block = block; @@ -23,23 +23,21 @@ public class WallPlantFeature extends WallScatterFeature { @Override public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir) { if (block instanceof EndWallPlantBlock) { - BlockState state = block.getDefaultState().with(EndWallPlantBlock.FACING, dir); + BlockState state = block.defaultBlockState().with(EndWallPlantBlock.FACING, dir); + return block.canPlaceAt(state, world, pos); + } else if (block instanceof AttachedBlock) { + BlockState state = block.defaultBlockState().with(Properties.FACING, dir); return block.canPlaceAt(state, world, pos); } - else if (block instanceof AttachedBlock) { - BlockState state = block.getDefaultState().with(Properties.FACING, dir); - return block.canPlaceAt(state, world, pos); - } - return block.canPlaceAt(block.getDefaultState(), world, pos); + return block.canPlaceAt(block.defaultBlockState(), world, pos); } @Override public void generate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir) { - BlockState state = block.getDefaultState(); + BlockState state = block.defaultBlockState(); if (block instanceof EndWallPlantBlock) { state = state.with(EndWallPlantBlock.FACING, dir); - } - else if (block instanceof AttachedBlock) { + } else if (block instanceof AttachedBlock) { state = state.with(Properties.FACING, dir); } BlocksHelper.setWithoutUpdate(world, pos, state); diff --git a/src/main/java/ru/betterend/world/features/WallPlantOnLogFeature.java b/src/main/java/ru/betterend/world/features/WallPlantOnLogFeature.java index c00159f2..6fb1bb71 100644 --- a/src/main/java/ru/betterend/world/features/WallPlantOnLogFeature.java +++ b/src/main/java/ru/betterend/world/features/WallPlantOnLogFeature.java @@ -2,11 +2,11 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.tag.BlockTags; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.tags.BlockTags; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; public class WallPlantOnLogFeature extends WallPlantFeature { @@ -16,7 +16,7 @@ public class WallPlantOnLogFeature extends WallPlantFeature { @Override public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir) { - BlockPos blockPos = pos.offset(dir.getOpposite()); + BlockPos blockPos = pos.relative(dir.getOpposite()); BlockState blockState = world.getBlockState(blockPos); return blockState.isIn(BlockTags.LOGS); } diff --git a/src/main/java/ru/betterend/world/features/WallScatterFeature.java b/src/main/java/ru/betterend/world/features/WallScatterFeature.java index 38e63bf4..80f628ad 100644 --- a/src/main/java/ru/betterend/world/features/WallScatterFeature.java +++ b/src/main/java/ru/betterend/world/features/WallScatterFeature.java @@ -2,9 +2,9 @@ package ru.betterend.world.features; import java.util.Random; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.Heightmap; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; @@ -15,25 +15,26 @@ import ru.betterend.util.MHelper; public abstract class WallScatterFeature extends DefaultFeature { private static final Direction[] DIR = BlocksHelper.makeHorizontal(); private final int radius; - + public WallScatterFeature(int radius) { this.radius = radius; } - + public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir); - + public abstract void generate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir); - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, + DefaultFeatureConfig featureConfig) { int maxY = world.getTopY(Heightmap.Type.WORLD_SURFACE, center.getX(), center.getZ()); int minY = BlocksHelper.upRay(world, new BlockPos(center.getX(), 0, center.getZ()), maxY); if (maxY < 10 || maxY < minY) { return false; } int py = MHelper.randRange(minY, maxY, random); - - Mutable mut = new Mutable(); + + MutableBlockPos mut = new MutableBlockPos(); for (int x = -radius; x <= radius; x++) { mut.setX(center.getX() + x); for (int y = -radius; y <= radius; y++) { @@ -42,7 +43,7 @@ public abstract class WallScatterFeature extends DefaultFeature { mut.setZ(center.getZ() + z); if (random.nextInt(4) == 0 && world.isAir(mut)) { shuffle(random); - for (Direction dir: DIR) { + for (Direction dir : DIR) { if (canGenerate(world, random, mut, dir)) { generate(world, random, mut, dir); break; @@ -52,10 +53,10 @@ public abstract class WallScatterFeature extends DefaultFeature { } } } - + return true; } - + private void shuffle(Random random) { for (int i = 0; i < 4; i++) { int j = random.nextInt(4); diff --git a/src/main/java/ru/betterend/world/features/bushes/BushFeature.java b/src/main/java/ru/betterend/world/features/bushes/BushFeature.java index f06a4f4d..ad884473 100644 --- a/src/main/java/ru/betterend/world/features/bushes/BushFeature.java +++ b/src/main/java/ru/betterend/world/features/bushes/BushFeature.java @@ -3,12 +3,12 @@ package ru.betterend.world.features.bushes; import java.util.Random; import java.util.function.Function; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.Material; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.material.Material; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -28,31 +28,38 @@ public class BushFeature extends DefaultFeature { private static final Function REPLACE; private final Block leaves; private final Block stem; - + public BushFeature(Block leaves, Block stem) { this.leaves = leaves; this.stem = stem; } - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND) && !world.getBlockState(pos.up()).getBlock().isIn(EndTags.END_GROUND)) return false; - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND) + && !world.getBlockState(pos.up()).getBlock().isIn(EndTags.END_GROUND)) + return false; + float radius = MHelper.randRange(1.8F, 3.5F, random); OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt()); SDF sphere = new SDFSphere().setRadius(radius).setBlock(this.leaves); sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-2F, 2F, random); }).setSource(sphere); - sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere)); + sphere = new SDFDisplacement().setFunction((vec) -> { + return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; + }).setSource(sphere); + sphere = new SDFDisplacement().setFunction((vec) -> { + return MHelper.randRange(-2F, 2F, random); + }).setSource(sphere); + sphere = new SDFSubtraction().setSourceA(sphere) + .setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere)); sphere.setReplaceFunction(REPLACE); sphere.addPostProcess((info) -> { if (info.getState().getBlock() instanceof LeavesBlock) { int distance = info.getPos().getManhattanDistance(pos); if (distance < 7) { return info.getState().with(LeavesBlock.DISTANCE, distance); - } - else { + } else { return AIR; } } @@ -60,21 +67,20 @@ public class BushFeature extends DefaultFeature { }); sphere.fillRecursive(world, pos); BlocksHelper.setWithoutUpdate(world, pos, stem); - for (Direction d: Direction.values()) { - BlockPos p = pos.offset(d); + for (Direction d : Direction.values()) { + BlockPos p = pos.relative(d); if (world.isAir(p)) { if (leaves instanceof LeavesBlock) { - BlocksHelper.setWithoutUpdate(world, p, leaves.getDefaultState().with(LeavesBlock.DISTANCE, 1)); - } - else { - BlocksHelper.setWithoutUpdate(world, p, leaves.getDefaultState()); + BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState().with(LeavesBlock.DISTANCE, 1)); + } else { + BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState()); } } } - + return true; } - + static { REPLACE = (state) -> { if (state.getMaterial().equals(Material.PLANT)) { diff --git a/src/main/java/ru/betterend/world/features/bushes/BushWithOuterFeature.java b/src/main/java/ru/betterend/world/features/bushes/BushWithOuterFeature.java index 024fcbe3..03f54c15 100644 --- a/src/main/java/ru/betterend/world/features/bushes/BushWithOuterFeature.java +++ b/src/main/java/ru/betterend/world/features/bushes/BushWithOuterFeature.java @@ -3,13 +3,13 @@ package ru.betterend.world.features.bushes; import java.util.Random; import java.util.function.Function; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.material.Material; import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -31,32 +31,39 @@ public class BushWithOuterFeature extends DefaultFeature { private final Block outer_leaves; private final Block leaves; private final Block stem; - + public BushWithOuterFeature(Block leaves, Block outer_leaves, Block stem) { this.outer_leaves = outer_leaves; this.leaves = leaves; this.stem = stem; } - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND) && !world.getBlockState(pos.up()).getBlock().isIn(EndTags.END_GROUND)) return false; - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND) + && !world.getBlockState(pos.up()).getBlock().isIn(EndTags.END_GROUND)) + return false; + float radius = MHelper.randRange(1.8F, 3.5F, random); OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt()); SDF sphere = new SDFSphere().setRadius(radius).setBlock(this.leaves); sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-2F, 2F, random); }).setSource(sphere); - sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere)); + sphere = new SDFDisplacement().setFunction((vec) -> { + return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; + }).setSource(sphere); + sphere = new SDFDisplacement().setFunction((vec) -> { + return MHelper.randRange(-2F, 2F, random); + }).setSource(sphere); + sphere = new SDFSubtraction().setSourceA(sphere) + .setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere)); sphere.setReplaceFunction(REPLACE); sphere.addPostProcess((info) -> { if (info.getState().getBlock() instanceof LeavesBlock) { int distance = info.getPos().getManhattanDistance(pos); if (distance < 7) { return info.getState().with(LeavesBlock.DISTANCE, distance); - } - else { + } else { return AIR; } } @@ -64,9 +71,10 @@ public class BushWithOuterFeature extends DefaultFeature { }).addPostProcess((info) -> { if (info.getState().getBlock() instanceof LeavesBlock) { MHelper.shuffle(DIRECTIONS, random); - for (Direction dir: DIRECTIONS) { + for (Direction dir : DIRECTIONS) { if (info.getState(dir).isAir()) { - info.setBlockPos(info.getPos().offset(dir), outer_leaves.getDefaultState().with(Properties.FACING, dir)); + info.setBlockPos(info.getPos().offset(dir), + outer_leaves.defaultBlockState().with(Properties.FACING, dir)); } } } @@ -74,21 +82,20 @@ public class BushWithOuterFeature extends DefaultFeature { }); sphere.fillRecursive(world, pos); BlocksHelper.setWithoutUpdate(world, pos, stem); - for (Direction d: Direction.values()) { - BlockPos p = pos.offset(d); + for (Direction d : Direction.values()) { + BlockPos p = pos.relative(d); if (world.isAir(p)) { if (leaves instanceof LeavesBlock) { - BlocksHelper.setWithoutUpdate(world, p, leaves.getDefaultState().with(LeavesBlock.DISTANCE, 1)); - } - else { - BlocksHelper.setWithoutUpdate(world, p, leaves.getDefaultState()); + BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState().with(LeavesBlock.DISTANCE, 1)); + } else { + BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState()); } } } - + return true; } - + static { REPLACE = (state) -> { if (state.getMaterial().equals(Material.PLANT)) { diff --git a/src/main/java/ru/betterend/world/features/bushes/LargeAmaranitaFeature.java b/src/main/java/ru/betterend/world/features/bushes/LargeAmaranitaFeature.java index 09f5e5ff..cad1b8c7 100644 --- a/src/main/java/ru/betterend/world/features/bushes/LargeAmaranitaFeature.java +++ b/src/main/java/ru/betterend/world/features/bushes/LargeAmaranitaFeature.java @@ -2,10 +2,10 @@ package ru.betterend.world.features.bushes; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -19,10 +19,12 @@ import ru.betterend.world.features.DefaultFeature; public class LargeAmaranitaFeature extends DefaultFeature { @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false; - - Mutable mut = new Mutable().set(pos); + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)) + return false; + + MutableBlockPos mut = new MutableBlockPos().set(pos); int height = MHelper.randRange(2, 3, random); for (int i = 1; i < height; i++) { mut.setY(mut.getY() + 1); @@ -31,14 +33,16 @@ public class LargeAmaranitaFeature extends DefaultFeature { } } mut.set(pos); - - BlockState state = EndBlocks.LARGE_AMARANITA_MUSHROOM.getDefaultState(); + + BlockState state = EndBlocks.LARGE_AMARANITA_MUSHROOM.defaultBlockState(); BlocksHelper.setWithUpdate(world, mut, state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM)); if (height > 2) { - BlocksHelper.setWithUpdate(world, mut.move(Direction.UP), state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE)); + BlocksHelper.setWithUpdate(world, mut.move(Direction.UP), + state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE)); } - BlocksHelper.setWithUpdate(world, mut.move(Direction.UP), state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP)); - + BlocksHelper.setWithUpdate(world, mut.move(Direction.UP), + state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP)); + return true; } } diff --git a/src/main/java/ru/betterend/world/features/bushes/Lumecorn.java b/src/main/java/ru/betterend/world/features/bushes/Lumecorn.java index 81bad45d..0dc33584 100644 --- a/src/main/java/ru/betterend/world/features/bushes/Lumecorn.java +++ b/src/main/java/ru/betterend/world/features/bushes/Lumecorn.java @@ -2,10 +2,10 @@ package ru.betterend.world.features.bushes; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -19,11 +19,13 @@ import ru.betterend.world.features.DefaultFeature; public class Lumecorn extends DefaultFeature { @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false; - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)) + return false; + int height = MHelper.randRange(4, 7, random); - Mutable mut = new Mutable().set(pos); + MutableBlockPos mut = new MutableBlockPos().set(pos); for (int i = 1; i < height; i++) { mut.move(Direction.UP); if (!world.isAir(mut)) { @@ -31,24 +33,30 @@ public class Lumecorn extends DefaultFeature { } } mut.set(pos); - BlockState topMiddle = EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_TOP_MIDDLE); - BlockState middle = EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_MIDDLE); - BlockState bottom = EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_BOTTOM); - BlockState top = EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_TOP); + BlockState topMiddle = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, + LumecornShape.LIGHT_TOP_MIDDLE); + BlockState middle = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, + LumecornShape.LIGHT_MIDDLE); + BlockState bottom = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, + LumecornShape.LIGHT_BOTTOM); + BlockState top = EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.LIGHT_TOP); if (height == 4) { - BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL)); + BlocksHelper.setWithoutUpdate(world, mut, + EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL)); BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), bottom); BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), topMiddle); BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), top); return true; } if (random.nextBoolean()) { - BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL)); - } - else { - BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_BIG)); - BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), EndBlocks.LUMECORN.getDefaultState().with(LumecornBlock.SHAPE, LumecornShape.MIDDLE)); - height --; + BlocksHelper.setWithoutUpdate(world, mut, + EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL)); + } else { + BlocksHelper.setWithoutUpdate(world, mut, + EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.BOTTOM_BIG)); + BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), + EndBlocks.LUMECORN.defaultBlockState().with(LumecornBlock.SHAPE, LumecornShape.MIDDLE)); + height--; } BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), bottom); for (int i = 4; i < height; i++) { diff --git a/src/main/java/ru/betterend/world/features/bushes/TenaneaBushFeature.java b/src/main/java/ru/betterend/world/features/bushes/TenaneaBushFeature.java index 3f31e6d9..210fce3c 100644 --- a/src/main/java/ru/betterend/world/features/bushes/TenaneaBushFeature.java +++ b/src/main/java/ru/betterend/world/features/bushes/TenaneaBushFeature.java @@ -6,12 +6,12 @@ import java.util.function.Function; import com.google.common.collect.Lists; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.Material; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.material.Material; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -34,21 +34,29 @@ import ru.betterend.world.features.DefaultFeature; public class TenaneaBushFeature extends DefaultFeature { private static final Function REPLACE; private static final Direction[] DIRECTIONS = Direction.values(); - - public TenaneaBushFeature() {} - + + public TenaneaBushFeature() { + } + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false; - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)) + return false; + float radius = MHelper.randRange(1.8F, 3.5F, random); OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt()); - BlockState leaves = EndBlocks.TENANEA_LEAVES.getDefaultState(); + BlockState leaves = EndBlocks.TENANEA_LEAVES.defaultBlockState(); SDF sphere = new SDFSphere().setRadius(radius).setBlock(leaves); sphere = new SDFScale3D().setScale(1, 0.75F, 1).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-2F, 2F, random); }).setSource(sphere); - sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere)); + sphere = new SDFDisplacement().setFunction((vec) -> { + return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; + }).setSource(sphere); + sphere = new SDFDisplacement().setFunction((vec) -> { + return MHelper.randRange(-2F, 2F, random); + }).setSource(sphere); + sphere = new SDFSubtraction().setSourceA(sphere) + .setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere)); sphere.setReplaceFunction(REPLACE); List support = Lists.newArrayList(); sphere.addPostProcess((info) -> { @@ -56,52 +64,54 @@ public class TenaneaBushFeature extends DefaultFeature { int distance = info.getPos().getManhattanDistance(pos); if (distance < 7) { if (random.nextInt(4) == 0 && info.getStateDown().isAir()) { - BlockPos d = info.getPos().down(); + BlockPos d = info.getPos().below(); support.add(d); } - + MHelper.shuffle(DIRECTIONS, random); - for (Direction d: DIRECTIONS) { + for (Direction d : DIRECTIONS) { if (info.getState(d).isAir()) { - info.setBlockPos(info.getPos().offset(d), EndBlocks.TENANEA_OUTER_LEAVES.getDefaultState().with(FurBlock.FACING, d)); + info.setBlockPos(info.getPos().offset(d), + EndBlocks.TENANEA_OUTER_LEAVES.defaultBlockState().with(FurBlock.FACING, d)); } } - + return info.getState().with(LeavesBlock.DISTANCE, distance); - } - else { + } else { return AIR; } } return info.getState(); }); sphere.fillRecursive(world, pos); - BlockState stem = EndBlocks.TENANEA.bark.getDefaultState(); + BlockState stem = EndBlocks.TENANEA.bark.defaultBlockState(); BlocksHelper.setWithoutUpdate(world, pos, stem); - for (Direction d: Direction.values()) { - BlockPos p = pos.offset(d); + for (Direction d : Direction.values()) { + BlockPos p = pos.relative(d); if (world.isAir(p)) { BlocksHelper.setWithoutUpdate(world, p, leaves.with(LeavesBlock.DISTANCE, 1)); } } - - Mutable mut = new Mutable(); - BlockState top = EndBlocks.TENANEA_FLOWERS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP); - BlockState middle = EndBlocks.TENANEA_FLOWERS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE); - BlockState bottom = EndBlocks.TENANEA_FLOWERS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM); + + MutableBlockPos mut = new MutableBlockPos(); + BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, + TripleShape.TOP); + BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, + TripleShape.MIDDLE); + BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, + TripleShape.BOTTOM); support.forEach((bpos) -> { BlockState state = world.getBlockState(bpos); - if (state.isAir() || state.isOf(EndBlocks.TENANEA_OUTER_LEAVES)) { + if (state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) { int count = MHelper.randRange(3, 8, random); mut.set(bpos); - if (world.getBlockState(mut.up()).isOf(EndBlocks.TENANEA_LEAVES)) { + if (world.getBlockState(mut.up()).is(EndBlocks.TENANEA_LEAVES)) { BlocksHelper.setWithoutUpdate(world, mut, top); for (int i = 1; i < count; i++) { mut.setY(mut.getY() - 1); - if (world.isAir(mut.down())) { + if (world.isAir(mut.below())) { BlocksHelper.setWithoutUpdate(world, mut, middle); - } - else { + } else { break; } } @@ -109,10 +119,10 @@ public class TenaneaBushFeature extends DefaultFeature { } } }); - + return true; } - + static { REPLACE = (state) -> { if (state.getMaterial().equals(Material.PLANT)) { diff --git a/src/main/java/ru/betterend/world/features/terrain/BigAuroraCrystalFeature.java b/src/main/java/ru/betterend/world/features/terrain/BigAuroraCrystalFeature.java index 687eaf61..e7f7b7ba 100644 --- a/src/main/java/ru/betterend/world/features/terrain/BigAuroraCrystalFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/BigAuroraCrystalFeature.java @@ -2,9 +2,9 @@ package ru.betterend.world.features.terrain; import java.util.Random; -import net.minecraft.block.Material; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -19,30 +19,30 @@ import ru.betterend.world.features.DefaultFeature; public class BigAuroraCrystalFeature extends DefaultFeature { @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { int maxY = pos.getY() + BlocksHelper.upRay(world, pos, 16); int minY = pos.getY() - BlocksHelper.downRay(world, pos, 16); - + if (maxY - minY < 10) { return false; } - + int y = MHelper.randRange(minY, maxY, random); pos = new BlockPos(pos.getX(), y, pos.getZ()); - + int height = MHelper.randRange(5, 25, random); - SDF prism = new SDFHexPrism().setHeight(height).setRadius(MHelper.randRange(1.7F, 3F, random)).setBlock(EndBlocks.AURORA_CRYSTAL); + SDF prism = new SDFHexPrism().setHeight(height).setRadius(MHelper.randRange(1.7F, 3F, random)) + .setBlock(EndBlocks.AURORA_CRYSTAL); Vector3f vec = MHelper.randomHorizontal(random); prism = new SDFRotation().setRotation(vec, random.nextFloat()).setSource(prism); prism.setReplaceFunction((bState) -> { - return bState.getMaterial().isReplaceable() - || bState.isIn(EndTags.GEN_TERRAIN) - || bState.getMaterial().equals(Material.PLANT) - || bState.getMaterial().equals(Material.LEAVES); + return bState.getMaterial().isReplaceable() || bState.isIn(EndTags.GEN_TERRAIN) + || bState.getMaterial().equals(Material.PLANT) || bState.getMaterial().equals(Material.LEAVES); }); prism.fillRecursive(world, pos); BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.AURORA_CRYSTAL); - + return true; } } diff --git a/src/main/java/ru/betterend/world/features/terrain/EndLakeFeature.java b/src/main/java/ru/betterend/world/features/terrain/EndLakeFeature.java index 8c6bbed3..97d3e3b6 100644 --- a/src/main/java/ru/betterend/world/features/terrain/EndLakeFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/EndLakeFeature.java @@ -2,12 +2,12 @@ package ru.betterend.world.features.terrain; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; import net.minecraft.fluid.FluidState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -19,46 +19,52 @@ import ru.betterend.util.MHelper; import ru.betterend.world.features.DefaultFeature; public class EndLakeFeature extends DefaultFeature { - private static final BlockState END_STONE = Blocks.END_STONE.getDefaultState(); + private static final BlockState END_STONE = Blocks.END_STONE.defaultBlockState(); private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(15152); - private static final Mutable POS = new Mutable(); - + private static final MutableBlockPos POS = new MutableBlockPos(); + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, + DefaultFeatureConfig featureConfig) { double radius = MHelper.randRange(10.0, 20.0, random); double depth = radius * 0.5 * MHelper.randRange(0.8, 1.2, random); int dist = MHelper.floor(radius); int dist2 = MHelper.floor(radius * 1.5); int bott = MHelper.floor(depth); blockPos = getPosOnSurfaceWG(world, blockPos); - if (blockPos.getY() < 10) return false; - + if (blockPos.getY() < 10) + return false; + int waterLevel = blockPos.getY(); - + BlockPos pos = getPosOnSurfaceRaycast(world, blockPos.north(dist).up(10), 20); - if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false; + if (Math.abs(blockPos.getY() - pos.getY()) > 5) + return false; waterLevel = MHelper.min(pos.getY(), waterLevel); - + pos = getPosOnSurfaceRaycast(world, blockPos.south(dist).up(10), 20); - if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false; + if (Math.abs(blockPos.getY() - pos.getY()) > 5) + return false; waterLevel = MHelper.min(pos.getY(), waterLevel); - + pos = getPosOnSurfaceRaycast(world, blockPos.east(dist).up(10), 20); - if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false; + if (Math.abs(blockPos.getY() - pos.getY()) > 5) + return false; waterLevel = MHelper.min(pos.getY(), waterLevel); - + pos = getPosOnSurfaceRaycast(world, blockPos.west(dist).up(10), 20); - if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false; + if (Math.abs(blockPos.getY() - pos.getY()) > 5) + return false; waterLevel = MHelper.min(pos.getY(), waterLevel); BlockState state; - + int minX = blockPos.getX() - dist2; int maxX = blockPos.getX() + dist2; int minZ = blockPos.getZ() - dist2; int maxZ = blockPos.getZ() + dist2; int maskMinX = minX - 1; int maskMinZ = minZ - 1; - + boolean[][] mask = new boolean[maxX - minX + 3][maxZ - minZ + 3]; for (int x = minX; x <= maxX; x++) { POS.setX(x); @@ -84,7 +90,7 @@ public class EndLakeFeature extends DefaultFeature { } } } - + for (int x = minX; x <= maxX; x++) { POS.setX(x); int x2 = x - blockPos.getX(); @@ -104,7 +110,8 @@ public class EndLakeFeature extends DefaultFeature { size *= 0.8; add = 5; } - double r = (add * 1.8 + radius * (NOISE.eval(x * 0.2, y * 0.2, z * 0.2) * 0.25 + 0.75)) - 1.0 / size; + double r = (add * 1.8 + radius * (NOISE.eval(x * 0.2, y * 0.2, z * 0.2) * 0.25 + 0.75)) + - 1.0 / size; if (r > 0) { r *= r; if (x2 + z2 <= r) { @@ -112,26 +119,28 @@ public class EndLakeFeature extends DefaultFeature { if (state.isIn(EndTags.GEN_TERRAIN)) { BlocksHelper.setWithoutUpdate(world, POS, AIR); } - pos = POS.down(); + pos = POS.below(); if (world.getBlockState(pos).isIn(EndTags.GEN_TERRAIN)) { - state = world.getBiome(pos).getGenerationSettings().getSurfaceConfig().getTopMaterial(); + state = world.getBiome(pos).getGenerationSettings().getSurfaceConfig() + .getTopMaterial(); if (y > waterLevel + 1) BlocksHelper.setWithoutUpdate(world, pos, state); else if (y > waterLevel) - BlocksHelper.setWithoutUpdate(world, pos, random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.getDefaultState()); + BlocksHelper.setWithoutUpdate(world, pos, random.nextBoolean() ? state + : EndBlocks.ENDSTONE_DUST.defaultBlockState()); else - BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.ENDSTONE_DUST.getDefaultState()); + BlocksHelper.setWithoutUpdate(world, pos, + EndBlocks.ENDSTONE_DUST.defaultBlockState()); } } - } - else { + } else { break; } } } } } - + double aspect = ((double) radius / (double) depth); for (int x = blockPos.getX() - dist; x <= blockPos.getX() + dist; x++) { @@ -160,12 +169,13 @@ public class EndLakeFeature extends DefaultFeature { state = canReplace(state) ? (y < waterLevel ? WATER : AIR) : state; BlocksHelper.setWithoutUpdate(world, POS, state); } - pos = POS.down(); + pos = POS.below(); if (world.getBlockState(pos).getBlock().isIn(EndTags.GEN_TERRAIN)) { - BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.ENDSTONE_DUST.getDefaultState()); + BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.ENDSTONE_DUST.defaultBlockState()); } pos = POS.up(); - while (canReplace(state = world.getBlockState(pos)) && !state.isAir() && state.getFluidState().isEmpty()) { + while (canReplace(state = world.getBlockState(pos)) && !state.isAir() + && state.getFluidState().isEmpty()) { BlocksHelper.setWithoutUpdate(world, pos, pos.getY() < waterLevel ? WATER : AIR); pos = pos.up(); } @@ -174,30 +184,29 @@ public class EndLakeFeature extends DefaultFeature { else if (y < waterLevel && y2 + x2 + z2 <= rb) { if (world.isAir(POS.up())) { state = world.getBiome(POS).getGenerationSettings().getSurfaceConfig().getTopMaterial(); - BlocksHelper.setWithoutUpdate(world, POS, random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.getDefaultState()); - BlocksHelper.setWithoutUpdate(world, POS.down(), END_STONE); + BlocksHelper.setWithoutUpdate(world, POS, + random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.defaultBlockState()); + BlocksHelper.setWithoutUpdate(world, POS.below(), END_STONE); + } else { + BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.ENDSTONE_DUST.defaultBlockState()); + BlocksHelper.setWithoutUpdate(world, POS.below(), END_STONE); } - else { - BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.ENDSTONE_DUST.getDefaultState()); - BlocksHelper.setWithoutUpdate(world, POS.down(), END_STONE); - } - //} + // } } } } } } - - BlocksHelper.fixBlocks(world, new BlockPos(minX - 2, waterLevel - 2, minZ - 2), new BlockPos(maxX + 2, blockPos.getY() + 20, maxZ + 2)); - + + BlocksHelper.fixBlocks(world, new BlockPos(minX - 2, waterLevel - 2, minZ - 2), + new BlockPos(maxX + 2, blockPos.getY() + 20, maxZ + 2)); + return true; } - + private boolean canReplace(BlockState state) { - return state.getMaterial().isReplaceable() - || state.isIn(EndTags.GEN_TERRAIN) - || state.isOf(EndBlocks.ENDSTONE_DUST) - || state.getMaterial().equals(Material.PLANT) + return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN) + || state.is(EndBlocks.ENDSTONE_DUST) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.UNDERWATER_PLANT) || state.getMaterial().equals(Material.UNUSED_PLANT); } diff --git a/src/main/java/ru/betterend/world/features/terrain/FallenPillarFeature.java b/src/main/java/ru/betterend/world/features/terrain/FallenPillarFeature.java index a0cafa58..27402490 100644 --- a/src/main/java/ru/betterend/world/features/terrain/FallenPillarFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/FallenPillarFeature.java @@ -2,11 +2,11 @@ package ru.betterend.world.features.terrain; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -23,15 +23,18 @@ import ru.betterend.world.features.DefaultFeature; public class FallenPillarFeature extends DefaultFeature { @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16))); + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + pos = getPosOnSurface(world, + new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16))); if (!world.getBlockState(pos.down(5)).isIn(EndTags.GEN_TERRAIN)) { return false; } - + float height = MHelper.randRange(20F, 40F, random); float radius = MHelper.randRange(2F, 4F, random); - SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F).setBlock(Blocks.OBSIDIAN); + SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F) + .setBlock(Blocks.OBSIDIAN); pillar = new SDFTranslate().setTranslate(0, radius * 0.5F - 2, 0).setSource(pillar); OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong()); pillar = new SDFDisplacement().setFunction((vec) -> { @@ -40,17 +43,18 @@ public class FallenPillarFeature extends DefaultFeature { Vector3f vec = MHelper.randomHorizontal(random); float angle = (float) random.nextGaussian() * 0.05F + (float) Math.PI; pillar = new SDFRotation().setRotation(vec, angle).setSource(pillar); - - BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.getDefaultState(); + + BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.defaultBlockState(); pillar.addPostProcess((info) -> { if (info.getStateUp().isAir() && random.nextFloat() > 0.1F) { return mossy; } return info.getState(); }).setReplaceFunction((state) -> { - return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT); + return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN) + || state.getMaterial().equals(Material.PLANT); }).fillRecursive(world, pos); - + return true; } } diff --git a/src/main/java/ru/betterend/world/features/terrain/FloatingSpireFeature.java b/src/main/java/ru/betterend/world/features/terrain/FloatingSpireFeature.java index 390e5c09..dde3dc7c 100644 --- a/src/main/java/ru/betterend/world/features/terrain/FloatingSpireFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/FloatingSpireFeature.java @@ -5,9 +5,9 @@ import java.util.Random; import com.google.common.collect.Lists; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -21,14 +21,16 @@ import ru.betterend.util.sdf.primitive.SDFSphere; public class FloatingSpireFeature extends SpireFeature { @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { int minY = getYOnSurface(world, pos.getX(), pos.getZ()); - int y = minY > 57 ? MHelper.floor(MHelper.randRange(minY, minY * 2, random) * 0.5F + 32) : MHelper.randRange(64, 192, random); + int y = minY > 57 ? MHelper.floor(MHelper.randRange(minY, minY * 2, random) * 0.5F + 32) + : MHelper.randRange(64, 192, random); pos = new BlockPos(pos.getX(), y, pos.getZ()); - + SDF sdf = new SDFSphere().setRadius(MHelper.randRange(2, 3, random)).setBlock(Blocks.END_STONE); int count = MHelper.randRange(3, 5, random); - + for (int i = 0; i < count; i++) { float rMin = (i * 1.3F) + 2.5F; sdf = addSegment(sdf, MHelper.randRange(rMin, rMin + 1.5F, random), random); @@ -37,10 +39,11 @@ public class FloatingSpireFeature extends SpireFeature { float rMin = (i * 1.3F) + 2.5F; sdf = addSegment(sdf, MHelper.randRange(rMin, rMin + 1.5F, random), random); } - + OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong()); sdf = new SDFDisplacement().setFunction((vec) -> { - return (float) (Math.abs(noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1)) * 3F + Math.abs(noise.eval(vec.getX() * 0.3, vec.getY() * 0.3 + 100, vec.getZ() * 0.3)) * 1.3F); + return (float) (Math.abs(noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1)) * 3F + + Math.abs(noise.eval(vec.getX() * 0.3, vec.getY() * 0.3 + 100, vec.getZ() * 0.3)) * 1.3F); }).setSource(sdf); final BlockPos center = pos; List support = Lists.newArrayList(); @@ -50,20 +53,19 @@ public class FloatingSpireFeature extends SpireFeature { support.add(info.getPos().up()); } return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceConfig().getTopMaterial(); - } - else if (info.getState(Direction.UP, 3).isAir()) { + } else if (info.getState(Direction.UP, 3).isAir()) { return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceConfig().getUnderMaterial(); } return info.getState(); }); sdf.fillRecursive(world, center); - + support.forEach((bpos) -> { if (EndBiomes.getFromBiome(world.getBiome(bpos)) == EndBiomes.BLOSSOMING_SPIRES) { EndFeatures.TENANEA_BUSH.getFeature().generate(world, chunkGenerator, random, bpos, null); } }); - + return true; } } diff --git a/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java b/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java index 7334d517..04899d98 100644 --- a/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java @@ -3,15 +3,15 @@ package ru.betterend.world.features.terrain; import java.util.Random; import java.util.function.Function; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.HorizontalFacingBlock; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.HorizontalFacingBlock; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.MathHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -43,23 +43,24 @@ public class GeyserFeature extends DefaultFeature { protected static final Function REPLACE2; private static final Function IGNORE; private static final Direction[] HORIZONTAL = BlocksHelper.makeHorizontal(); - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { pos = getPosOnSurfaceWG(world, pos); - + if (pos.getY() < 10) { return false; } - - Mutable bpos = new Mutable().set(pos); + + MutableBlockPos bpos = new MutableBlockPos().set(pos); bpos.setY(bpos.getY() - 1); BlockState state = world.getBlockState(bpos); while (state.isIn(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) { bpos.setY(bpos.getY() - 1); state = world.getBlockState(bpos); } - + if (pos.getY() - bpos.getY() < 25) { return false; } @@ -67,18 +68,21 @@ public class GeyserFeature extends DefaultFeature { int halfHeight = MHelper.randRange(10, 20, random); float radius1 = halfHeight * 0.5F; float radius2 = halfHeight * 0.1F + 0.5F; - SDF sdf = new SDFCappedCone().setHeight(halfHeight).setRadius1(radius1).setRadius2(radius2).setBlock(EndBlocks.SULPHURIC_ROCK.stone); + SDF sdf = new SDFCappedCone().setHeight(halfHeight).setRadius1(radius1).setRadius2(radius2) + .setBlock(EndBlocks.SULPHURIC_ROCK.stone); sdf = new SDFTranslate().setTranslate(0, halfHeight - 3, 0).setSource(sdf); int count = halfHeight; for (int i = 0; i < count; i++) { int py = i << 1; float delta = (float) i / (float) (count - 1); - float radius = MathHelper.lerp(delta, radius1, radius2) * 1.3F; + float radius = Mth.lerp(delta, radius1, radius2) * 1.3F; - SDF bowl = new SDFCappedCone().setHeight(radius).setRadius1(0).setRadius2(radius).setBlock(EndBlocks.SULPHURIC_ROCK.stone); + SDF bowl = new SDFCappedCone().setHeight(radius).setRadius1(0).setRadius2(radius) + .setBlock(EndBlocks.SULPHURIC_ROCK.stone); - SDF brimstone = new SDFCappedCone().setHeight(radius).setRadius1(0).setRadius2(radius).setBlock(EndBlocks.BRIMSTONE); + SDF brimstone = new SDFCappedCone().setHeight(radius).setRadius1(0).setRadius2(radius) + .setBlock(EndBlocks.BRIMSTONE); brimstone = new SDFTranslate().setTranslate(0, 2F, 0).setSource(brimstone); bowl = new SDFSubtraction().setSourceA(bowl).setSourceB(brimstone); bowl = new SDFUnion().setSourceA(brimstone).setSourceB(bowl); @@ -156,7 +160,7 @@ public class GeyserFeature extends DefaultFeature { }).setSource(cave).setReplaceFunction(REPLACE1).fillRecursiveIgnore(world, pos, IGNORE); BlocksHelper.setWithoutUpdate(world, pos, WATER); - Mutable mut = new Mutable().set(pos); + MutableBlockPos mut = new MutableBlockPos().set(pos); count = getYOnSurface(world, pos.getX(), pos.getZ()) - pos.getY(); for (int i = 0; i < count; i++) { BlocksHelper.setWithoutUpdate(world, mut, WATER); @@ -167,7 +171,8 @@ public class GeyserFeature extends DefaultFeature { } for (int i = 0; i < 150; i++) { - mut.set(pos).move(MHelper.floor(random.nextGaussian() * 4 + 0.5), -halfHeight - 10, MHelper.floor(random.nextGaussian() * 4 + 0.5)); + mut.set(pos).move(MHelper.floor(random.nextGaussian() * 4 + 0.5), -halfHeight - 10, + MHelper.floor(random.nextGaussian() * 4 + 0.5)); float distRaw = MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ()); int dist = MHelper.floor(6 - distRaw) + random.nextInt(2); if (dist >= 0) { @@ -176,24 +181,26 @@ public class GeyserFeature extends DefaultFeature { mut.setY(mut.getY() - 1); state = world.getBlockState(mut); } - if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).isOf(EndBlocks.HYDROTHERMAL_VENT)) { + if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).is(EndBlocks.HYDROTHERMAL_VENT)) { for (int j = 0; j <= dist; j++) { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone); MHelper.shuffle(HORIZONTAL, random); for (Direction dir : HORIZONTAL) { BlockPos p = mut.offset(dir); - if (random.nextBoolean() && world.getBlockState(p).isOf(Blocks.WATER)) { - BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.getDefaultState().with(HorizontalFacingBlock.FACING, dir)); + if (random.nextBoolean() && world.getBlockState(p).is(Blocks.WATER)) { + BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.defaultBlockState() + .with(HorizontalFacingBlock.FACING, dir)); } } mut.setY(mut.getY() + 1); } - state = EndBlocks.HYDROTHERMAL_VENT.getDefaultState().with(HydrothermalVentBlock.ACTIVATED, distRaw < 2); + state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().with(HydrothermalVentBlock.ACTIVATED, + distRaw < 2); BlocksHelper.setWithoutUpdate(world, mut, state); mut.setY(mut.getY() + 1); state = world.getBlockState(mut); - while (state.isOf(Blocks.WATER)) { - BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.getDefaultState()); + while (state.is(Blocks.WATER)) { + BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.defaultBlockState()); mut.setY(mut.getY() + 1); state = world.getBlockState(mut); } @@ -202,12 +209,13 @@ public class GeyserFeature extends DefaultFeature { } for (int i = 0; i < 10; i++) { - mut.set(pos).move(MHelper.floor(random.nextGaussian() * 0.7 + 0.5), -halfHeight - 10, MHelper.floor(random.nextGaussian() * 0.7 + 0.5)); + mut.set(pos).move(MHelper.floor(random.nextGaussian() * 0.7 + 0.5), -halfHeight - 10, + MHelper.floor(random.nextGaussian() * 0.7 + 0.5)); float distRaw = MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ()); int dist = MHelper.floor(6 - distRaw) + random.nextInt(2); if (dist >= 0) { state = world.getBlockState(mut); - while (state.isOf(Blocks.WATER)) { + while (state.is(Blocks.WATER)) { mut.setY(mut.getY() - 1); state = world.getBlockState(mut); } @@ -216,12 +224,13 @@ public class GeyserFeature extends DefaultFeature { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone); mut.setY(mut.getY() + 1); } - state = EndBlocks.HYDROTHERMAL_VENT.getDefaultState().with(HydrothermalVentBlock.ACTIVATED, distRaw < 2); + state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().with(HydrothermalVentBlock.ACTIVATED, + distRaw < 2); BlocksHelper.setWithoutUpdate(world, mut, state); mut.setY(mut.getY() + 1); state = world.getBlockState(mut); - while (state.isOf(Blocks.WATER)) { - BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.getDefaultState()); + while (state.is(Blocks.WATER)) { + BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.defaultBlockState()); mut.setY(mut.getY() + 1); state = world.getBlockState(mut); } @@ -232,20 +241,21 @@ public class GeyserFeature extends DefaultFeature { EndFeatures.SULPHURIC_LAKE.getFeature().generate(world, chunkGenerator, random, pos, null); double distance = radius1 * 1.7; - BlockPos start = pos.add(-distance, -halfHeight - 15 - distance, -distance); - BlockPos end = pos.add(distance, -halfHeight - 5 + distance, distance); + BlockPos start = pos.offset(-distance, -halfHeight - 15 - distance, -distance); + BlockPos end = pos.offset(distance, -halfHeight - 5 + distance, distance); BlocksHelper.fixBlocks(world, start, end); return true; } - + static { REPLACE1 = (state) -> { return state.isAir() || (state.isIn(EndTags.GEN_TERRAIN)); }; - + REPLACE2 = (state) -> { - if (state.isIn(EndTags.GEN_TERRAIN) || state.isOf(EndBlocks.HYDROTHERMAL_VENT) || state.isOf(EndBlocks.SULPHUR_CRYSTAL)) { + if (state.isIn(EndTags.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT) + || state.is(EndBlocks.SULPHUR_CRYSTAL)) { return true; } if (state.getMaterial().equals(Material.PLANT)) { @@ -253,9 +263,10 @@ public class GeyserFeature extends DefaultFeature { } return state.getMaterial().isReplaceable(); }; - + IGNORE = (state) -> { - return state.isOf(Blocks.WATER) || state.isOf(Blocks.CAVE_AIR) || state.isOf(EndBlocks.SULPHURIC_ROCK.stone) || state.isOf(EndBlocks.BRIMSTONE); + return state.is(Blocks.WATER) || state.is(Blocks.CAVE_AIR) || state.is(EndBlocks.SULPHURIC_ROCK.stone) + || state.is(EndBlocks.BRIMSTONE); }; } } diff --git a/src/main/java/ru/betterend/world/features/terrain/IceStarFeature.java b/src/main/java/ru/betterend/world/features/terrain/IceStarFeature.java index b7bb5f52..52f6def7 100644 --- a/src/main/java/ru/betterend/world/features/terrain/IceStarFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/IceStarFeature.java @@ -4,9 +4,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -24,64 +24,64 @@ public class IceStarFeature extends DefaultFeature { private final float maxSize; private final int minCount; private final int maxCount; - + public IceStarFeature(float minSize, float maxSize, int minCount, int maxCount) { this.minSize = minSize; this.maxSize = maxSize; this.minCount = minCount; this.maxCount = maxCount; } - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { float size = MHelper.randRange(minSize, maxSize, random); int count = MHelper.randRange(minCount, maxCount, random); List points = getFibonacciPoints(count); SDF sdf = null; - SDF spike = new SDFCappedCone().setRadius1(3 + (size - 5) * 0.2F).setRadius2(0).setHeight(size).setBlock(EndBlocks.DENSE_SNOW); + SDF spike = new SDFCappedCone().setRadius1(3 + (size - 5) * 0.2F).setRadius2(0).setHeight(size) + .setBlock(EndBlocks.DENSE_SNOW); spike = new SDFTranslate().setTranslate(0, size - 0.5F, 0).setSource(spike); - for (Vector3f point: points) { + for (Vector3f point : points) { SDF rotated = spike; point = MHelper.normalize(point); float angle = MHelper.angle(Vector3f.POSITIVE_Y, point); if (angle > 0.01F && angle < 3.14F) { Vector3f axis = MHelper.normalize(MHelper.cross(Vector3f.POSITIVE_Y, point)); rotated = new SDFRotation().setRotation(axis, angle).setSource(spike); - } - else if (angle > 1) { + } else if (angle > 1) { rotated = new SDFRotation().setRotation(Vector3f.POSITIVE_Y, (float) Math.PI).setSource(spike); } sdf = (sdf == null) ? rotated : new SDFUnion().setSourceA(sdf).setSourceB(rotated); } - + int x1 = (pos.getX() >> 4) << 4; int z1 = (pos.getZ() >> 4) << 4; pos = new BlockPos(x1 + random.nextInt(16), MHelper.randRange(32, 128, random), z1 + random.nextInt(16)); - + final float ancientRadius = size * 0.7F; final float denseRadius = size * 0.9F; final float iceRadius = size < 7 ? size * 5 : size * 1.3F; final float randScale = size * 0.3F; - + final BlockPos center = pos; - final BlockState ice = EndBlocks.EMERALD_ICE.getDefaultState(); - final BlockState dense = EndBlocks.DENSE_EMERALD_ICE.getDefaultState(); - final BlockState ancient = EndBlocks.ANCIENT_EMERALD_ICE.getDefaultState(); + final BlockState ice = EndBlocks.EMERALD_ICE.defaultBlockState(); + final BlockState dense = EndBlocks.DENSE_EMERALD_ICE.defaultBlockState(); + final BlockState ancient = EndBlocks.ANCIENT_EMERALD_ICE.defaultBlockState(); final SDF sdfCopy = sdf; - + sdf.addPostProcess((info) -> { BlockPos bpos = info.getPos(); float px = bpos.getX() - center.getX(); float py = bpos.getY() - center.getY(); float pz = bpos.getZ() - center.getZ(); - float distance = MHelper.length(px, py, pz) + sdfCopy.getDistance(px, py, pz) * 0.4F + random.nextFloat() * randScale; + float distance = MHelper.length(px, py, pz) + sdfCopy.getDistance(px, py, pz) * 0.4F + + random.nextFloat() * randScale; if (distance < ancientRadius) { return ancient; - } - else if (distance < denseRadius) { + } else if (distance < denseRadius) { return dense; - } - else if (distance < iceRadius) { + } else if (distance < iceRadius) { return ice; } return info.getState(); diff --git a/src/main/java/ru/betterend/world/features/terrain/ObsidianBoulderFeature.java b/src/main/java/ru/betterend/world/features/terrain/ObsidianBoulderFeature.java index 9d00ec71..0cc228d1 100644 --- a/src/main/java/ru/betterend/world/features/terrain/ObsidianBoulderFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/ObsidianBoulderFeature.java @@ -2,10 +2,10 @@ package ru.betterend.world.features.terrain; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -21,26 +21,29 @@ import ru.betterend.world.features.DefaultFeature; public class ObsidianBoulderFeature extends DefaultFeature { @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16))); - if (!world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + pos = getPosOnSurface(world, + new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16))); + if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) { return false; } - + int count = MHelper.randRange(1, 5, random); for (int i = 0; i < count; i++) { - BlockPos p = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16) - 8, pos.getY(), pos.getZ() + random.nextInt(16) - 8)); + BlockPos p = getPosOnSurface(world, + new BlockPos(pos.getX() + random.nextInt(16) - 8, pos.getY(), pos.getZ() + random.nextInt(16) - 8)); makeBoulder(world, p, random); } - + return true; } - + private void makeBoulder(StructureWorldAccess world, BlockPos pos, Random random) { - if (!world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) { + if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) { return; } - + float radius = MHelper.randRange(1F, 5F, random); SDF sphere = new SDFSphere().setRadius(radius).setBlock(Blocks.OBSIDIAN); float sx = MHelper.randRange(0.7F, 1.3F, random); @@ -51,15 +54,16 @@ public class ObsidianBoulderFeature extends DefaultFeature { sphere = new SDFDisplacement().setFunction((vec) -> { return (float) (noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 1.5F); }).setSource(sphere); - - BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.getDefaultState(); + + BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.defaultBlockState(); sphere.addPostProcess((info) -> { if (info.getStateUp().isAir() && random.nextFloat() > 0.1F) { return mossy; } return info.getState(); }).setReplaceFunction((state) -> { - return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT); + return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN) + || state.getMaterial().equals(Material.PLANT); }).fillRecursive(world, pos); } } diff --git a/src/main/java/ru/betterend/world/features/terrain/ObsidianPillarBasementFeature.java b/src/main/java/ru/betterend/world/features/terrain/ObsidianPillarBasementFeature.java index 00948443..75fc5f22 100644 --- a/src/main/java/ru/betterend/world/features/terrain/ObsidianPillarBasementFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/ObsidianPillarBasementFeature.java @@ -2,11 +2,11 @@ package ru.betterend.world.features.terrain; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -25,15 +25,18 @@ import ru.betterend.world.features.DefaultFeature; public class ObsidianPillarBasementFeature extends DefaultFeature { @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16))); + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + pos = getPosOnSurface(world, + new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16))); if (!world.getBlockState(pos.down(5)).isIn(EndTags.GEN_TERRAIN)) { return false; } - + float height = MHelper.randRange(10F, 35F, random); float radius = MHelper.randRange(2F, 5F, random); - SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F).setBlock(Blocks.OBSIDIAN); + SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F) + .setBlock(Blocks.OBSIDIAN); pillar = new SDFTranslate().setTranslate(0, height * 0.5F - 3, 0).setSource(pillar); SDF cut = new SDFFlatland().setBlock(Blocks.OBSIDIAN); OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong()); @@ -48,17 +51,18 @@ public class ObsidianPillarBasementFeature extends DefaultFeature { vec = MHelper.randomHorizontal(random); angle = random.nextFloat() * 0.2F; pillar = new SDFRotation().setRotation(vec, angle).setSource(pillar); - - BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.getDefaultState(); + + BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.defaultBlockState(); pillar.addPostProcess((info) -> { if (info.getStateUp().isAir() && random.nextFloat() > 0.1F) { return mossy; } return info.getState(); }).setReplaceFunction((state) -> { - return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT); + return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN) + || state.getMaterial().equals(Material.PLANT); }).fillRecursive(world, pos); - + return true; } } diff --git a/src/main/java/ru/betterend/world/features/terrain/OreLayerFeature.java b/src/main/java/ru/betterend/world/features/terrain/OreLayerFeature.java index d1d1b37f..36766726 100644 --- a/src/main/java/ru/betterend/world/features/terrain/OreLayerFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/OreLayerFeature.java @@ -2,9 +2,9 @@ package ru.betterend.world.features.terrain; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -20,32 +20,33 @@ public class OreLayerFeature extends DefaultFeature { private static final SDFSphere SPHERE; private static final SDFCoordModify NOISE; private static final SDF FUNCTION; - + private final BlockState state; private final float radius; private final int minY; private final int maxY; private OpenSimplexNoise noise; - + public OreLayerFeature(BlockState state, float radius, int minY, int maxY) { this.state = state; this.radius = radius; this.minY = minY; this.maxY = maxY; } - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { float radius = this.radius * 0.5F; int r = MHelper.floor(radius + 1); int posX = MHelper.randRange(Math.max(r - 16, 0), Math.min(31 - r, 15), random) + pos.getX(); int posZ = MHelper.randRange(Math.max(r - 16, 0), Math.min(31 - r, 15), random) + pos.getZ(); int posY = MHelper.randRange(minY, maxY, random); - + if (noise == null) { noise = new OpenSimplexNoise(world.getSeed()); } - + SPHERE.setRadius(radius).setBlock(state); NOISE.setFunction((vec) -> { double x = (vec.getX() + pos.getX()) * 0.1; @@ -56,18 +57,18 @@ public class OreLayerFeature extends DefaultFeature { FUNCTION.fillRecursive(world, new BlockPos(posX, posY, posZ)); return true; } - + static { SPHERE = new SDFSphere(); NOISE = new SDFCoordModify(); - + SDF body = SPHERE; body = new SDFScale3D().setScale(1, 0.2F, 1).setSource(body); body = NOISE.setSource(body); body.setReplaceFunction((state) -> { - return state.isOf(Blocks.END_STONE); + return state.is(Blocks.END_STONE); }); - + FUNCTION = body; } } diff --git a/src/main/java/ru/betterend/world/features/terrain/SingleBlockFeature.java b/src/main/java/ru/betterend/world/features/terrain/SingleBlockFeature.java index fd9396ac..a13e5821 100644 --- a/src/main/java/ru/betterend/world/features/terrain/SingleBlockFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/SingleBlockFeature.java @@ -2,10 +2,10 @@ package ru.betterend.world.features.terrain; import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -15,24 +15,25 @@ import ru.betterend.world.features.DefaultFeature; public class SingleBlockFeature extends DefaultFeature { private final Block block; - + public SingleBlockFeature(Block block) { this.block = block; } - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).isIn(EndTags.GEN_TERRAIN)) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN)) { return false; } - - BlockState state = block.getDefaultState(); + + BlockState state = block.defaultBlockState(); if (block.getStateManager().getProperty("waterlogged") != null) { boolean waterlogged = !world.getFluidState(pos).isEmpty(); state = state.with(Properties.WATERLOGGED, waterlogged); } BlocksHelper.setWithoutUpdate(world, pos, state); - + return true; } } diff --git a/src/main/java/ru/betterend/world/features/terrain/SmaragdantCrystalFeature.java b/src/main/java/ru/betterend/world/features/terrain/SmaragdantCrystalFeature.java index ef652d54..466bd242 100644 --- a/src/main/java/ru/betterend/world/features/terrain/SmaragdantCrystalFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/SmaragdantCrystalFeature.java @@ -2,10 +2,10 @@ package ru.betterend.world.features.terrain; import java.util.Random; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -17,25 +17,28 @@ import ru.betterend.world.features.DefaultFeature; public class SmaragdantCrystalFeature extends DefaultFeature { @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).isIn(EndTags.GEN_TERRAIN)) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN)) { return false; } - - Mutable mut = new Mutable(); + + MutableBlockPos mut = new MutableBlockPos(); int count = MHelper.randRange(15, 30, random); - BlockState crystal = EndBlocks.SMARAGDANT_CRYSTAL.getDefaultState(); - BlockState shard = EndBlocks.SMARAGDANT_CRYSTAL_SHARD.getDefaultState(); + BlockState crystal = EndBlocks.SMARAGDANT_CRYSTAL.defaultBlockState(); + BlockState shard = EndBlocks.SMARAGDANT_CRYSTAL_SHARD.defaultBlockState(); for (int i = 0; i < count; i++) { - mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5, MHelper.floor(random.nextGaussian() * 2 + 0.5)); - int dist = MHelper.floor(1.5F - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(3); + mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5, + MHelper.floor(random.nextGaussian() * 2 + 0.5)); + int dist = MHelper.floor(1.5F - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + + random.nextInt(3); if (dist > 0) { BlockState state = world.getBlockState(mut); for (int n = 0; n < 10 && state.isAir(); n++) { mut.setY(mut.getY() - 1); state = world.getBlockState(mut); } - if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).isOf(crystal.getBlock())) { + if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).is(crystal.getBlock())) { for (int j = 0; j <= dist; j++) { BlocksHelper.setWithoutUpdate(world, mut, crystal); mut.setY(mut.getY() + 1); @@ -45,7 +48,7 @@ public class SmaragdantCrystalFeature extends DefaultFeature { } } } - + return true; } } diff --git a/src/main/java/ru/betterend/world/features/terrain/SpireFeature.java b/src/main/java/ru/betterend/world/features/terrain/SpireFeature.java index f0518d81..6f6824ab 100644 --- a/src/main/java/ru/betterend/world/features/terrain/SpireFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/SpireFeature.java @@ -6,12 +6,12 @@ import java.util.function.Function; import com.google.common.collect.Lists; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.Material; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.material.Material; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -29,14 +29,16 @@ import ru.betterend.world.features.DefaultFeature; public class SpireFeature extends DefaultFeature { protected static final Function REPLACE; - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { pos = getPosOnSurfaceWG(world, pos); - if (pos.getY() < 10 || !world.getBlockState(pos.down(3)).isIn(EndTags.GEN_TERRAIN) || !world.getBlockState(pos.down(6)).isIn(EndTags.GEN_TERRAIN)) { + if (pos.getY() < 10 || !world.getBlockState(pos.down(3)).isIn(EndTags.GEN_TERRAIN) + || !world.getBlockState(pos.down(6)).isIn(EndTags.GEN_TERRAIN)) { return false; } - + SDF sdf = new SDFSphere().setRadius(MHelper.randRange(2, 3, random)).setBlock(Blocks.END_STONE); int count = MHelper.randRange(3, 7, random); for (int i = 0; i < count; i++) { @@ -45,7 +47,8 @@ public class SpireFeature extends DefaultFeature { } OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong()); sdf = new SDFDisplacement().setFunction((vec) -> { - return (float) (Math.abs(noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1)) * 3F + Math.abs(noise.eval(vec.getX() * 0.3, vec.getY() * 0.3 + 100, vec.getZ() * 0.3)) * 1.3F); + return (float) (Math.abs(noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1)) * 3F + + Math.abs(noise.eval(vec.getX() * 0.3, vec.getY() * 0.3 + 100, vec.getZ() * 0.3)) * 1.3F); }).setSource(sdf); final BlockPos center = pos; List support = Lists.newArrayList(); @@ -55,13 +58,12 @@ public class SpireFeature extends DefaultFeature { support.add(info.getPos().up()); } return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceConfig().getTopMaterial(); - } - else if (info.getState(Direction.UP, 3).isAir()) { + } else if (info.getState(Direction.UP, 3).isAir()) { return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceConfig().getUnderMaterial(); } return info.getState(); }).fillRecursive(world, center); - + support.forEach((bpos) -> { if (EndBiomes.getFromBiome(world.getBiome(bpos)) == EndBiomes.BLOSSOMING_SPIRES) { EndFeatures.TENANEA_BUSH.getFeature().generate(world, chunkGenerator, random, bpos, null); @@ -70,13 +72,14 @@ public class SpireFeature extends DefaultFeature { return true; } - + protected SDF addSegment(SDF sdf, float radius, Random random) { SDF sphere = new SDFSphere().setRadius(radius).setBlock(Blocks.END_STONE); - SDF offseted = new SDFTranslate().setTranslate(0, radius + random.nextFloat() * 0.25F * radius, 0).setSource(sdf); + SDF offseted = new SDFTranslate().setTranslate(0, radius + random.nextFloat() * 0.25F * radius, 0) + .setSource(sdf); return new SDFSmoothUnion().setRadius(radius * 0.5F).setSourceA(sphere).setSourceB(offseted); } - + static { REPLACE = (state) -> { if (state.isIn(EndTags.END_GROUND)) { diff --git a/src/main/java/ru/betterend/world/features/terrain/StalactiteFeature.java b/src/main/java/ru/betterend/world/features/terrain/StalactiteFeature.java index 0b1f708f..6c54c59c 100644 --- a/src/main/java/ru/betterend/world/features/terrain/StalactiteFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/StalactiteFeature.java @@ -2,12 +2,12 @@ package ru.betterend.world.features.terrain; import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.MathHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.util.Mth; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -20,24 +20,25 @@ public class StalactiteFeature extends DefaultFeature { private final boolean ceiling; private final Block[] ground; private final Block block; - + public StalactiteFeature(boolean ceiling, Block block, Block... ground) { this.ceiling = ceiling; this.ground = ground; this.block = block; } - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!isGround(world.getBlockState(ceiling ? pos.up() : pos.down()).getBlock())) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!isGround(world.getBlockState(ceiling ? pos.up() : pos.below()).getBlock())) { return false; } - - Mutable mut = new Mutable().set(pos); + + MutableBlockPos mut = new MutableBlockPos().set(pos); int height = random.nextInt(16); int dir = ceiling ? -1 : 1; boolean stalagnate = false; - + for (int i = 1; i <= height; i++) { mut.setY(pos.getY() + i * dir); BlockState state = world.getBlockState(mut); @@ -47,21 +48,23 @@ public class StalactiteFeature extends DefaultFeature { break; } } - + if (!stalagnate && height > 7) { height = random.nextInt(8); } - + float center = height * 0.5F; for (int i = 0; i < height; i++) { mut.setY(pos.getY() + i * dir); - int size = stalagnate ? MathHelper.clamp((int) (MathHelper.abs(i - center) + 1), 1, 7) : height - i - 1; + int size = stalagnate ? Mth.clamp((int) (Mth.abs(i - center) + 1), 1, 7) : height - i - 1; boolean waterlogged = !world.getFluidState(mut).isEmpty(); - BlockState base = block.getDefaultState().with(StalactiteBlock.SIZE, size).with(Properties.WATERLOGGED, waterlogged); - BlockState state = stalagnate ? base.with(StalactiteBlock.IS_FLOOR, dir > 0 ? i < center : i > center) : base.with(StalactiteBlock.IS_FLOOR, dir > 0); + BlockState base = block.defaultBlockState().with(StalactiteBlock.SIZE, size).with(Properties.WATERLOGGED, + waterlogged); + BlockState state = stalagnate ? base.with(StalactiteBlock.IS_FLOOR, dir > 0 ? i < center : i > center) + : base.with(StalactiteBlock.IS_FLOOR, dir > 0); BlocksHelper.setWithoutUpdate(world, mut, state); } - + return true; } diff --git a/src/main/java/ru/betterend/world/features/terrain/SulphurHillFeature.java b/src/main/java/ru/betterend/world/features/terrain/SulphurHillFeature.java index 73728a0f..16ebab6f 100644 --- a/src/main/java/ru/betterend/world/features/terrain/SulphurHillFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/SulphurHillFeature.java @@ -2,11 +2,11 @@ package ru.betterend.world.features.terrain; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -19,12 +19,13 @@ import ru.betterend.world.features.DefaultFeature; public class SulphurHillFeature extends DefaultFeature { @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { pos = getPosOnSurfaceWG(world, pos); if (pos.getY() < 57 || pos.getY() > 70) { return false; } - + int count = MHelper.randRange(5, 13, random); OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong()); for (int i = 0; i < count; i++) { @@ -38,14 +39,14 @@ public class SulphurHillFeature extends DefaultFeature { } return true; } - + private void makeCircle(StructureWorldAccess world, BlockPos pos, OpenSimplexNoise noise, Random random) { int radius = MHelper.randRange(5, 9, random); int min = -radius - 3; int max = radius + 4; - Mutable mut = new Mutable(); - BlockState rock = EndBlocks.SULPHURIC_ROCK.stone.getDefaultState(); - BlockState brimstone = EndBlocks.BRIMSTONE.getDefaultState().with(BlockProperties.ACTIVE, true); + MutableBlockPos mut = new MutableBlockPos(); + BlockState rock = EndBlocks.SULPHURIC_ROCK.stone.defaultBlockState(); + BlockState brimstone = EndBlocks.BRIMSTONE.defaultBlockState().with(BlockProperties.ACTIVE, true); for (int x = min; x < max; x++) { int x2 = x * x; int px = pos.getX() + x; @@ -60,7 +61,7 @@ public class SulphurHillFeature extends DefaultFeature { int d = x2 + z2; mut.setY(pos.getY()); BlockState state = world.getBlockState(mut); - if (state.getMaterial().isReplaceable() || state.isOf(EndBlocks.HYDROTHERMAL_VENT)) { + if (state.getMaterial().isReplaceable() || state.is(EndBlocks.HYDROTHERMAL_VENT)) { if (d < r2 * r2) { BlocksHelper.setWithoutUpdate(world, mut, Blocks.WATER); mut.move(Direction.DOWN); @@ -76,8 +77,7 @@ public class SulphurHillFeature extends DefaultFeature { BlocksHelper.setWithoutUpdate(world, mut, rock); mut.move(Direction.DOWN); } - } - else if (d < r1 * r1) { + } else if (d < r1 * r1) { BlocksHelper.setWithoutUpdate(world, mut, brimstone); mut.move(Direction.DOWN); state = world.getBlockState(mut); diff --git a/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java b/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java index 36686fb3..6fc09489 100644 --- a/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java @@ -5,13 +5,13 @@ import java.util.Set; import com.google.common.collect.Sets; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.HorizontalFacingBlock; -import net.minecraft.block.Material; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.HorizontalFacingBlock; +import net.minecraft.world.level.material.Material; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.Heightmap; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; @@ -26,20 +26,21 @@ import ru.betterend.util.MHelper; import ru.betterend.world.features.DefaultFeature; public class SulphuricCaveFeature extends DefaultFeature { - private static final BlockState CAVE_AIR = Blocks.CAVE_AIR.getDefaultState(); - private static final BlockState WATER = Blocks.WATER.getDefaultState(); + private static final BlockState CAVE_AIR = Blocks.CAVE_AIR.defaultBlockState(); + private static final BlockState WATER = Blocks.WATER.defaultBlockState(); private static final Direction[] HORIZONTAL = BlocksHelper.makeHorizontal(); - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { int radius = MHelper.randRange(10, 30, random); - + int top = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ()); - Mutable bpos = new Mutable(); + MutableBlockPos bpos = new MutableBlockPos(); bpos.setX(pos.getX()); bpos.setZ(pos.getZ()); bpos.setY(top - 1); - + BlockState state = world.getBlockState(bpos); while (!state.isIn(EndTags.GEN_TERRAIN) && bpos.getY() > 5) { bpos.setY(bpos.getY() - 1); @@ -49,34 +50,34 @@ public class SulphuricCaveFeature extends DefaultFeature { return false; } top = (int) (bpos.getY() - (radius * 1.3F + 5)); - + while (state.isIn(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) { bpos.setY(bpos.getY() - 1); state = world.getBlockState(bpos); } int bottom = (int) (bpos.getY() + radius * 1.3F + 5); - + if (top <= bottom) { return false; } - - Mutable mut = new Mutable(); + + MutableBlockPos mut = new MutableBlockPos(); pos = new BlockPos(pos.getX(), MHelper.randRange(bottom, top, random), pos.getZ()); - + OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, pos.getX(), pos.getZ())); - + int x1 = pos.getX() - radius - 5; int z1 = pos.getZ() - radius - 5; int x2 = pos.getX() + radius + 5; int z2 = pos.getZ() + radius + 5; int y1 = MHelper.floor(pos.getY() - (radius + 5) / 1.6); int y2 = MHelper.floor(pos.getY() + (radius + 5) / 1.6); - + double hr = radius * 0.75; double nr = radius * 0.25; - + Set brimstone = Sets.newHashSet(); - BlockState rock = EndBlocks.SULPHURIC_ROCK.stone.getDefaultState(); + BlockState rock = EndBlocks.SULPHURIC_ROCK.stone.defaultBlockState(); int waterLevel = pos.getY() + MHelper.randRange(MHelper.floor(radius * 0.8), radius, random); for (int x = x1; x <= x2; x++) { int xsq = x - pos.getX(); @@ -99,15 +100,14 @@ public class SulphuricCaveFeature extends DefaultFeature { if (isReplaceable(state)) { BlocksHelper.setWithoutUpdate(world, mut, y < waterLevel ? WATER : CAVE_AIR); } - } - else if (dist < r2 * r2) { + } else if (dist < r2 * r2) { state = world.getBlockState(mut); - if (state.isIn(EndTags.GEN_TERRAIN) || state.isOf(Blocks.AIR)) { - double v = noise.eval(x * 0.1, y * 0.1, z * 0.1) + noise.eval(x * 0.03, y * 0.03, z * 0.03) * 0.5; + if (state.isIn(EndTags.GEN_TERRAIN) || state.is(Blocks.AIR)) { + double v = noise.eval(x * 0.1, y * 0.1, z * 0.1) + + noise.eval(x * 0.03, y * 0.03, z * 0.03) * 0.5; if (v > 0.4) { brimstone.add(mut.toImmutable()); - } - else { + } else { BlocksHelper.setWithoutUpdate(world, mut, rock); } } @@ -118,26 +118,30 @@ public class SulphuricCaveFeature extends DefaultFeature { brimstone.forEach((blockPos) -> { placeBrimstone(world, blockPos, random); }); - + if (random.nextInt(4) == 0) { int count = MHelper.randRange(5, 20, random); for (int i = 0; i < count; i++) { - mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 0, MHelper.floor(random.nextGaussian() * 2 + 0.5)); - int dist = MHelper.floor(3 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(2); + mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 0, + MHelper.floor(random.nextGaussian() * 2 + 0.5)); + int dist = MHelper.floor(3 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + + random.nextInt(2); if (dist > 0) { state = world.getBlockState(mut); while (!state.getFluidState().isEmpty() || state.getMaterial().equals(Material.UNDERWATER_PLANT)) { mut.setY(mut.getY() - 1); state = world.getBlockState(mut); } - if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).isOf(EndBlocks.HYDROTHERMAL_VENT)) { + if (state.isIn(EndTags.GEN_TERRAIN) + && !world.getBlockState(mut.up()).is(EndBlocks.HYDROTHERMAL_VENT)) { for (int j = 0; j <= dist; j++) { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone); MHelper.shuffle(HORIZONTAL, random); - for (Direction dir: HORIZONTAL) { + for (Direction dir : HORIZONTAL) { BlockPos p = mut.offset(dir); - if (random.nextBoolean() && world.getBlockState(p).isOf(Blocks.WATER)) { - BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.getDefaultState().with(HorizontalFacingBlock.FACING, dir)); + if (random.nextBoolean() && world.getBlockState(p).is(Blocks.WATER)) { + BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.defaultBlockState() + .with(HorizontalFacingBlock.FACING, dir)); } } mut.setY(mut.getY() + 1); @@ -145,9 +149,10 @@ public class SulphuricCaveFeature extends DefaultFeature { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.HYDROTHERMAL_VENT); mut.setY(mut.getY() + 1); state = world.getBlockState(mut); - while (state.isOf(Blocks.WATER)) { - BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.getDefaultState()); - world.getBlockTickScheduler().schedule(mut, EndBlocks.VENT_BUBBLE_COLUMN, MHelper.randRange(8, 32, random)); + while (state.is(Blocks.WATER)) { + BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.defaultBlockState()); + world.getBlockTickScheduler().schedule(mut, EndBlocks.VENT_BUBBLE_COLUMN, + MHelper.randRange(8, 32, random)); mut.setY(mut.getY() + 1); state = world.getBlockState(mut); } @@ -155,47 +160,42 @@ public class SulphuricCaveFeature extends DefaultFeature { } } } - + BlocksHelper.fixBlocks(world, new BlockPos(x1, y1, z1), new BlockPos(x2, y2, z2)); - + return true; } - + private boolean isReplaceable(BlockState state) { - return state.isIn(EndTags.GEN_TERRAIN) - || state.isOf(EndBlocks.HYDROTHERMAL_VENT) - || state.isOf(EndBlocks.VENT_BUBBLE_COLUMN) - || state.isOf(EndBlocks.SULPHUR_CRYSTAL) - || state.getMaterial().isReplaceable() - || state.getMaterial().equals(Material.PLANT) - || state.getMaterial().equals(Material.UNDERWATER_PLANT) - || state.getMaterial().equals(Material.LEAVES); + return state.isIn(EndTags.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT) + || state.is(EndBlocks.VENT_BUBBLE_COLUMN) || state.is(EndBlocks.SULPHUR_CRYSTAL) + || state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT) + || state.getMaterial().equals(Material.UNDERWATER_PLANT) || state.getMaterial().equals(Material.LEAVES); } - + private void placeBrimstone(StructureWorldAccess world, BlockPos pos, Random random) { BlockState state = getBrimstone(world, pos); BlocksHelper.setWithoutUpdate(world, pos, state); - if (state.get(BlockProperties.ACTIVE)) { + if (state.getValue(BlockProperties.ACTIVE)) { makeShards(world, pos, random); } } - + private BlockState getBrimstone(StructureWorldAccess world, BlockPos pos) { - for (Direction dir: BlocksHelper.DIRECTIONS) { - if (world.getBlockState(pos.offset(dir)).isOf(Blocks.WATER)) { - return EndBlocks.BRIMSTONE.getDefaultState().with(BlockProperties.ACTIVE, true); + for (Direction dir : BlocksHelper.DIRECTIONS) { + if (world.getBlockState(pos.relative(dir)).is(Blocks.WATER)) { + return EndBlocks.BRIMSTONE.defaultBlockState().with(BlockProperties.ACTIVE, true); } } - return EndBlocks.BRIMSTONE.getDefaultState(); + return EndBlocks.BRIMSTONE.defaultBlockState(); } - + private void makeShards(StructureWorldAccess world, BlockPos pos, Random random) { - for (Direction dir: BlocksHelper.DIRECTIONS) { + for (Direction dir : BlocksHelper.DIRECTIONS) { BlockPos side; - if (random.nextInt(16) == 0 && world.getBlockState((side = pos.offset(dir))).isOf(Blocks.WATER)) { - BlockState state = EndBlocks.SULPHUR_CRYSTAL.getDefaultState() - .with(SulphurCrystalBlock.WATERLOGGED, true) - .with(SulphurCrystalBlock.FACING, dir) + if (random.nextInt(16) == 0 && world.getBlockState((side = pos.relative(dir))).is(Blocks.WATER)) { + BlockState state = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState() + .with(SulphurCrystalBlock.WATERLOGGED, true).with(SulphurCrystalBlock.FACING, dir) .with(SulphurCrystalBlock.AGE, random.nextInt(3)); BlocksHelper.setWithoutUpdate(world, side, state); } diff --git a/src/main/java/ru/betterend/world/features/terrain/SulphuricLakeFeature.java b/src/main/java/ru/betterend/world/features/terrain/SulphuricLakeFeature.java index bd388e81..9428fe66 100644 --- a/src/main/java/ru/betterend/world/features/terrain/SulphuricLakeFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/SulphuricLakeFeature.java @@ -5,12 +5,12 @@ import java.util.Set; import com.google.common.collect.Sets; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; import net.minecraft.fluid.Fluids; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -25,24 +25,25 @@ import ru.betterend.world.features.DefaultFeature; public class SulphuricLakeFeature extends DefaultFeature { private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(15152); - private static final Mutable POS = new Mutable(); - + private static final MutableBlockPos POS = new MutableBlockPos(); + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, + DefaultFeatureConfig featureConfig) { blockPos = getPosOnSurfaceWG(world, blockPos); - + if (blockPos.getY() < 57) { return false; } - + double radius = MHelper.randRange(10.0, 20.0, random); int dist2 = MHelper.floor(radius * 1.5); - + int minX = blockPos.getX() - dist2; int maxX = blockPos.getX() + dist2; int minZ = blockPos.getZ() - dist2; int maxZ = blockPos.getZ() + dist2; - + Set brimstone = Sets.newHashSet(); for (int x = minX; x <= maxX; x++) { POS.setX(x); @@ -64,36 +65,33 @@ public class SulphuricLakeFeature extends DefaultFeature { if (random.nextInt(8) > 0) { brimstone.add(POS.toImmutable()); if (random.nextBoolean()) { - brimstone.add(POS.down()); + brimstone.add(POS.below()); if (random.nextBoolean()) { brimstone.add(POS.down(2)); } } - } - else { + } else { if (!isAbsoluteBorder(world, POS)) { BlocksHelper.setWithoutUpdate(world, POS, Blocks.WATER); world.getFluidTickScheduler().schedule(POS, Fluids.WATER, 0); - brimstone.add(POS.down()); + brimstone.add(POS.below()); if (random.nextBoolean()) { brimstone.add(POS.down(2)); if (random.nextBoolean()) { brimstone.add(POS.down(3)); } } - } - else { + } else { brimstone.add(POS.toImmutable()); if (random.nextBoolean()) { - brimstone.add(POS.down()); + brimstone.add(POS.below()); } } } - } - else { + } else { BlocksHelper.setWithoutUpdate(world, POS, Blocks.WATER); brimstone.remove(POS); - for (Direction dir: BlocksHelper.HORIZONTAL) { + for (Direction dir : BlocksHelper.HORIZONTAL) { BlockPos offseted = POS.offset(dir); if (world.getBlockState(offseted).isIn(EndTags.GEN_TERRAIN)) { brimstone.add(offseted); @@ -102,14 +100,14 @@ public class SulphuricLakeFeature extends DefaultFeature { if (isDeepWater(world, POS)) { BlocksHelper.setWithoutUpdate(world, POS.move(Direction.DOWN), Blocks.WATER); brimstone.remove(POS); - for (Direction dir: BlocksHelper.HORIZONTAL) { + for (Direction dir : BlocksHelper.HORIZONTAL) { BlockPos offseted = POS.offset(dir); if (world.getBlockState(offseted).isIn(EndTags.GEN_TERRAIN)) { brimstone.add(offseted); } } } - brimstone.add(POS.down()); + brimstone.add(POS.below()); if (random.nextBoolean()) { brimstone.add(POS.down(2)); if (random.nextBoolean()) { @@ -118,13 +116,12 @@ public class SulphuricLakeFeature extends DefaultFeature { } } } - } - else if (dist < r2) { + } else if (dist < r2) { POS.setY(getYOnSurface(world, x, z) - 1); if (world.getBlockState(POS).isIn(EndTags.GEN_TERRAIN)) { brimstone.add(POS.toImmutable()); if (random.nextBoolean()) { - brimstone.add(POS.down()); + brimstone.add(POS.below()); if (random.nextBoolean()) { brimstone.add(POS.down(2)); } @@ -133,37 +130,37 @@ public class SulphuricLakeFeature extends DefaultFeature { } } } - + brimstone.forEach((bpos) -> { placeBrimstone(world, bpos, random); }); - + return true; } - + private boolean isBorder(StructureWorldAccess world, BlockPos pos) { int y = pos.getY() + 1; - for (Direction dir: BlocksHelper.DIRECTIONS) { + for (Direction dir : BlocksHelper.DIRECTIONS) { if (getYOnSurface(world, pos.getX() + dir.getOffsetX(), pos.getZ() + dir.getOffsetZ()) < y) { return true; } } return false; } - + private boolean isAbsoluteBorder(StructureWorldAccess world, BlockPos pos) { int y = pos.getY() - 2; - for (Direction dir: BlocksHelper.DIRECTIONS) { + for (Direction dir : BlocksHelper.DIRECTIONS) { if (getYOnSurface(world, pos.getX() + dir.getOffsetX() * 3, pos.getZ() + dir.getOffsetZ() * 3) < y) { return true; } } return false; } - + private boolean isDeepWater(StructureWorldAccess world, BlockPos pos) { int y = pos.getY() + 1; - for (Direction dir: BlocksHelper.DIRECTIONS) { + for (Direction dir : BlocksHelper.DIRECTIONS) { if (getYOnSurface(world, pos.getX() + dir.getOffsetX(), pos.getZ() + dir.getOffsetZ()) < y || getYOnSurface(world, pos.getX() + dir.getOffsetX() * 2, pos.getZ() + dir.getOffsetZ() * 2) < y || getYOnSurface(world, pos.getX() + dir.getOffsetX() * 3, pos.getZ() + dir.getOffsetZ() * 3) < y) { @@ -172,31 +169,30 @@ public class SulphuricLakeFeature extends DefaultFeature { } return true; } - + private void placeBrimstone(StructureWorldAccess world, BlockPos pos, Random random) { BlockState state = getBrimstone(world, pos); BlocksHelper.setWithoutUpdate(world, pos, state); - if (state.get(BlockProperties.ACTIVE)) { + if (state.getValue(BlockProperties.ACTIVE)) { makeShards(world, pos, random); } } - + private BlockState getBrimstone(StructureWorldAccess world, BlockPos pos) { - for (Direction dir: BlocksHelper.DIRECTIONS) { - if (world.getBlockState(pos.offset(dir)).isOf(Blocks.WATER)) { - return EndBlocks.BRIMSTONE.getDefaultState().with(BlockProperties.ACTIVE, true); + for (Direction dir : BlocksHelper.DIRECTIONS) { + if (world.getBlockState(pos.relative(dir)).is(Blocks.WATER)) { + return EndBlocks.BRIMSTONE.defaultBlockState().with(BlockProperties.ACTIVE, true); } } - return EndBlocks.BRIMSTONE.getDefaultState(); + return EndBlocks.BRIMSTONE.defaultBlockState(); } - + private void makeShards(StructureWorldAccess world, BlockPos pos, Random random) { - for (Direction dir: BlocksHelper.DIRECTIONS) { + for (Direction dir : BlocksHelper.DIRECTIONS) { BlockPos side; - if (random.nextInt(16) == 0 && world.getBlockState((side = pos.offset(dir))).isOf(Blocks.WATER)) { - BlockState state = EndBlocks.SULPHUR_CRYSTAL.getDefaultState() - .with(SulphurCrystalBlock.WATERLOGGED, true) - .with(SulphurCrystalBlock.FACING, dir) + if (random.nextInt(16) == 0 && world.getBlockState((side = pos.relative(dir))).is(Blocks.WATER)) { + BlockState state = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState() + .with(SulphurCrystalBlock.WATERLOGGED, true).with(SulphurCrystalBlock.FACING, dir) .with(SulphurCrystalBlock.AGE, random.nextInt(3)); BlocksHelper.setWithoutUpdate(world, side, state); } diff --git a/src/main/java/ru/betterend/world/features/terrain/SurfaceVentFeature.java b/src/main/java/ru/betterend/world/features/terrain/SurfaceVentFeature.java index ab53b52f..92148073 100644 --- a/src/main/java/ru/betterend/world/features/terrain/SurfaceVentFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/SurfaceVentFeature.java @@ -2,9 +2,9 @@ package ru.betterend.world.features.terrain; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -17,25 +17,30 @@ import ru.betterend.world.features.DefaultFeature; public class SurfaceVentFeature extends DefaultFeature { @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16))); + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + pos = getPosOnSurface(world, + new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16))); if (!world.getBlockState(pos.down(3)).isIn(EndTags.GEN_TERRAIN)) { return false; } - - Mutable mut = new Mutable(); + + MutableBlockPos mut = new MutableBlockPos(); int count = MHelper.randRange(15, 30, random); - BlockState vent = EndBlocks.HYDROTHERMAL_VENT.getDefaultState().with(HydrothermalVentBlock.WATERLOGGED, false); + BlockState vent = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().with(HydrothermalVentBlock.WATERLOGGED, + false); for (int i = 0; i < count; i++) { - mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5, MHelper.floor(random.nextGaussian() * 2 + 0.5)); - int dist = MHelper.floor(2 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(2); + mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5, + MHelper.floor(random.nextGaussian() * 2 + 0.5)); + int dist = MHelper.floor(2 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + + random.nextInt(2); if (dist > 0) { BlockState state = world.getBlockState(mut); for (int n = 0; n < 10 && state.isAir(); n++) { mut.setY(mut.getY() - 1); state = world.getBlockState(mut); } - if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).isOf(EndBlocks.HYDROTHERMAL_VENT)) { + if (state.isIn(EndTags.GEN_TERRAIN) && !world.getBlockState(mut.up()).is(EndBlocks.HYDROTHERMAL_VENT)) { for (int j = 0; j <= dist; j++) { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone); mut.setY(mut.getY() + 1); @@ -44,7 +49,7 @@ public class SurfaceVentFeature extends DefaultFeature { } } } - + return true; } } diff --git a/src/main/java/ru/betterend/world/features/terrain/caves/CaveChunkPopulatorFeature.java b/src/main/java/ru/betterend/world/features/terrain/caves/CaveChunkPopulatorFeature.java index cbd1f55a..261828c0 100644 --- a/src/main/java/ru/betterend/world/features/terrain/caves/CaveChunkPopulatorFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/caves/CaveChunkPopulatorFeature.java @@ -6,10 +6,10 @@ import java.util.function.Supplier; import com.google.common.collect.Sets; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.gen.chunk.ChunkGenerator; @@ -22,19 +22,20 @@ import ru.betterend.world.features.DefaultFeature; public class CaveChunkPopulatorFeature extends DefaultFeature { private Supplier supplier; - + public CaveChunkPopulatorFeature(Supplier biome) { this.supplier = biome; } - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { Set floorPositions = Sets.newHashSet(); Set ceilPositions = Sets.newHashSet(); int sx = (pos.getX() >> 4) << 4; int sz = (pos.getZ() >> 4) << 4; - Mutable min = new Mutable().set(pos); - Mutable max = new Mutable().set(pos); + MutableBlockPos min = new MutableBlockPos().set(pos); + MutableBlockPos max = new MutableBlockPos().set(pos); fillSets(sx, sz, world.getChunk(pos), floorPositions, ceilPositions, min, max); EndCaveBiome biome = supplier.get(); BlockState surfaceBlock = biome.getBiome().getGenerationSettings().getSurfaceConfig().getTopMaterial(); @@ -43,11 +44,12 @@ public class CaveChunkPopulatorFeature extends DefaultFeature { BlocksHelper.fixBlocks(world, min, max); return true; } - - protected void fillSets(int sx, int sz, Chunk chunk, Set floorPositions, Set ceilPositions, Mutable min, Mutable max) { - Mutable mut = new Mutable(); - Mutable mut2 = new Mutable(); - Mutable mut3 = new Mutable(); + + protected void fillSets(int sx, int sz, Chunk chunk, Set floorPositions, Set ceilPositions, + MutableBlockPos min, MutableBlockPos max) { + MutableBlockPos mut = new MutableBlockPos(); + MutableBlockPos mut2 = new MutableBlockPos(); + MutableBlockPos mut3 = new MutableBlockPos(); for (int x = 0; x < 16; x++) { mut.setX(x); mut2.setX(x); @@ -59,13 +61,12 @@ public class CaveChunkPopulatorFeature extends DefaultFeature { mut.setY(y); BlockState top = chunk.getBlockState(mut); BlockState bottom = chunk.getBlockState(mut2); - if (top.isAir() && (bottom.isIn(EndTags.GEN_TERRAIN) || bottom.isOf(Blocks.STONE))) { + if (top.isAir() && (bottom.isIn(EndTags.GEN_TERRAIN) || bottom.is(Blocks.STONE))) { mut3.set(mut2).move(sx, 0, sz); floorPositions.add(mut3.toImmutable()); updateMin(mut3, min); updateMax(mut3, max); - } - else if (bottom.isAir() && (top.isIn(EndTags.GEN_TERRAIN)|| top.isOf(Blocks.STONE))) { + } else if (bottom.isAir() && (top.isIn(EndTags.GEN_TERRAIN) || top.is(Blocks.STONE))) { mut3.set(mut).move(sx, 0, sz); ceilPositions.add(mut3.toImmutable()); updateMin(mut3, min); @@ -76,8 +77,8 @@ public class CaveChunkPopulatorFeature extends DefaultFeature { } } } - - private void updateMin(BlockPos pos, Mutable min) { + + private void updateMin(BlockPos pos, MutableBlockPos min) { if (pos.getX() < min.getX()) { min.setX(pos.getX()); } @@ -88,8 +89,8 @@ public class CaveChunkPopulatorFeature extends DefaultFeature { min.setZ(pos.getZ()); } } - - private void updateMax(BlockPos pos, Mutable max) { + + private void updateMax(BlockPos pos, MutableBlockPos max) { if (pos.getX() > max.getX()) { max.setX(pos.getX()); } @@ -100,8 +101,9 @@ public class CaveChunkPopulatorFeature extends DefaultFeature { max.setZ(pos.getZ()); } } - - protected void placeFloor(StructureWorldAccess world, EndCaveBiome biome, Set floorPositions, Random random, BlockState surfaceBlock) { + + protected void placeFloor(StructureWorldAccess world, EndCaveBiome biome, Set floorPositions, + Random random, BlockState surfaceBlock) { float density = biome.getFloorDensity(); floorPositions.forEach((pos) -> { BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock); @@ -113,8 +115,9 @@ public class CaveChunkPopulatorFeature extends DefaultFeature { } }); } - - protected void placeCeil(StructureWorldAccess world, EndCaveBiome biome, Set ceilPositions, Random random) { + + protected void placeCeil(StructureWorldAccess world, EndCaveBiome biome, Set ceilPositions, + Random random) { float density = biome.getCeilDensity(); ceilPositions.forEach((pos) -> { BlockState ceilBlock = biome.getCeil(pos); @@ -124,7 +127,7 @@ public class CaveChunkPopulatorFeature extends DefaultFeature { if (density > 0 && random.nextFloat() <= density) { Feature feature = biome.getCeilFeature(random); if (feature != null) { - feature.generate(world, null, random, pos.down(), null); + feature.generate(world, null, random, pos.below(), null); } } }); diff --git a/src/main/java/ru/betterend/world/features/terrain/caves/EndCaveFeature.java b/src/main/java/ru/betterend/world/features/terrain/caves/EndCaveFeature.java index ad2b088a..5faf8e26 100644 --- a/src/main/java/ru/betterend/world/features/terrain/caves/EndCaveFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/caves/EndCaveFeature.java @@ -5,11 +5,11 @@ import java.util.Set; import com.google.common.collect.Sets; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.Heightmap; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.biome.Biome; @@ -27,27 +27,29 @@ import ru.betterend.world.features.DefaultFeature; import ru.betterend.world.generator.GeneratorOptions; public abstract class EndCaveFeature extends DefaultFeature { - protected static final BlockState CAVE_AIR = Blocks.CAVE_AIR.getDefaultState(); - protected static final BlockState END_STONE = Blocks.END_STONE.getDefaultState(); - protected static final BlockState WATER = Blocks.WATER.getDefaultState(); - + protected static final BlockState CAVE_AIR = Blocks.CAVE_AIR.defaultBlockState(); + protected static final BlockState END_STONE = Blocks.END_STONE.defaultBlockState(); + protected static final BlockState WATER = Blocks.WATER.defaultBlockState(); + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!(GeneratorOptions.useNewGenerator() && GeneratorOptions.noRingVoid()) || pos.getX() * pos.getX() + pos.getZ() * pos.getZ() <= 22500) { + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!(GeneratorOptions.useNewGenerator() && GeneratorOptions.noRingVoid()) + || pos.getX() * pos.getX() + pos.getZ() * pos.getZ() <= 22500) { return false; } - + if (biomeMissingCaves(world, pos)) { return false; } - + int radius = MHelper.randRange(10, 30, random); BlockPos center = findPos(world, pos, radius, random); - + if (center == null) { return false; } - + EndCaveBiome biome = EndBiomes.getCaveBiome(random); Set caveBlocks = generate(world, center, radius, random); if (!caveBlocks.isEmpty()) { @@ -55,7 +57,7 @@ public abstract class EndCaveFeature extends DefaultFeature { setBiomes(world, biome, caveBlocks); Set floorPositions = Sets.newHashSet(); Set ceilPositions = Sets.newHashSet(); - Mutable mut = new Mutable(); + MutableBlockPos mut = new MutableBlockPos(); caveBlocks.forEach((bpos) -> { mut.set(bpos); if (world.getBlockState(mut).getMaterial().isReplaceable()) { @@ -75,13 +77,14 @@ public abstract class EndCaveFeature extends DefaultFeature { } fixBlocks(world, caveBlocks); } - + return true; } - + protected abstract Set generate(StructureWorldAccess world, BlockPos center, int radius, Random random); - - protected void placeFloor(StructureWorldAccess world, EndCaveBiome biome, Set floorPositions, Random random, BlockState surfaceBlock) { + + protected void placeFloor(StructureWorldAccess world, EndCaveBiome biome, Set floorPositions, + Random random, BlockState surfaceBlock) { float density = biome.getFloorDensity(); floorPositions.forEach((pos) -> { BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock); @@ -93,8 +96,9 @@ public abstract class EndCaveFeature extends DefaultFeature { } }); } - - protected void placeCeil(StructureWorldAccess world, EndCaveBiome biome, Set ceilPositions, Random random) { + + protected void placeCeil(StructureWorldAccess world, EndCaveBiome biome, Set ceilPositions, + Random random) { float density = biome.getCeilDensity(); ceilPositions.forEach((pos) -> { BlockState ceilBlock = biome.getCeil(pos); @@ -104,30 +108,30 @@ public abstract class EndCaveFeature extends DefaultFeature { if (density > 0 && random.nextFloat() <= density) { Feature feature = biome.getCeilFeature(random); if (feature != null) { - feature.generate(world, null, random, pos.down(), null); + feature.generate(world, null, random, pos.below(), null); } } }); } - + protected void setBiomes(StructureWorldAccess world, EndCaveBiome biome, Set blocks) { blocks.forEach((pos) -> setBiome(world, pos, biome)); } - + private void setBiome(StructureWorldAccess world, BlockPos pos, EndCaveBiome biome) { IBiomeArray array = (IBiomeArray) world.getChunk(pos).getBiomeArray(); if (array != null) { array.setBiome(biome.getActualBiome(), pos); } } - + private BlockPos findPos(StructureWorldAccess world, BlockPos pos, int radius, Random random) { int top = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ()); - Mutable bpos = new Mutable(); + MutableBlockPos bpos = new MutableBlockPos(); bpos.setX(pos.getX()); bpos.setZ(pos.getZ()); bpos.setY(top - 1); - + BlockState state = world.getBlockState(bpos); while (!state.isIn(EndTags.GEN_TERRAIN) && bpos.getY() > 5) { bpos.setY(bpos.getY() - 1); @@ -137,24 +141,24 @@ public abstract class EndCaveFeature extends DefaultFeature { return null; } top = (int) (bpos.getY() - (radius * 1.3F + 5)); - + while (state.isIn(EndTags.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) { bpos.setY(bpos.getY() - 1); state = world.getBlockState(bpos); } int bottom = (int) (bpos.getY() + radius * 1.3F + 5); - + if (top <= bottom) { return null; } - + return new BlockPos(pos.getX(), MHelper.randRange(bottom, top, random), pos.getZ()); } - + private void fixBlocks(StructureWorldAccess world, Set caveBlocks) { BlockPos pos = caveBlocks.iterator().next(); - Mutable start = new Mutable().set(pos); - Mutable end = new Mutable().set(pos); + MutableBlockPos start = new MutableBlockPos().set(pos); + MutableBlockPos end = new MutableBlockPos().set(pos); caveBlocks.forEach((bpos) -> { if (bpos.getX() < start.getX()) { start.setX(bpos.getX()); @@ -162,14 +166,14 @@ public abstract class EndCaveFeature extends DefaultFeature { if (bpos.getX() > end.getX()) { end.setX(bpos.getX()); } - + if (bpos.getY() < start.getY()) { start.setY(bpos.getY()); } if (bpos.getY() > end.getY()) { end.setY(bpos.getY()); } - + if (bpos.getZ() < start.getZ()) { start.setZ(bpos.getZ()); } @@ -179,20 +183,20 @@ public abstract class EndCaveFeature extends DefaultFeature { }); BlocksHelper.fixBlocks(world, start.add(-5, -5, -5), end.add(5, 5, 5)); } - + protected boolean isWaterNear(StructureWorldAccess world, BlockPos pos) { - for (Direction dir: BlocksHelper.DIRECTIONS) { - if (!world.getFluidState(pos.offset(dir, 5)).isEmpty()) { + for (Direction dir : BlocksHelper.DIRECTIONS) { + if (!world.getFluidState(pos.relative(dir, 5)).isEmpty()) { return true; } } return false; } - + protected boolean biomeMissingCaves(StructureWorldAccess world, BlockPos pos) { for (int x = -2; x < 3; x++) { for (int z = -2; z < 3; z++) { - Biome biome = world.getBiome(pos.add(x << 4, 0, z << 4)); + Biome biome = world.getBiome(pos.offset(x << 4, 0, z << 4)); EndBiome endBiome = EndBiomes.getFromBiome(biome); if (!endBiome.hasCaves()) { return true; diff --git a/src/main/java/ru/betterend/world/features/terrain/caves/RoundCaveFeature.java b/src/main/java/ru/betterend/world/features/terrain/caves/RoundCaveFeature.java index 55636096..284528cf 100644 --- a/src/main/java/ru/betterend/world/features/terrain/caves/RoundCaveFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/caves/RoundCaveFeature.java @@ -5,10 +5,10 @@ import java.util.Set; import com.google.common.collect.Sets; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.world.StructureWorldAccess; import ru.betterend.noise.OpenSimplexNoise; import ru.betterend.registry.EndTags; @@ -19,19 +19,19 @@ public class RoundCaveFeature extends EndCaveFeature { @Override protected Set generate(StructureWorldAccess world, BlockPos center, int radius, Random random) { OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ())); - + int x1 = center.getX() - radius - 5; int z1 = center.getZ() - radius - 5; int x2 = center.getX() + radius + 5; int z2 = center.getZ() + radius + 5; int y1 = MHelper.floor(center.getY() - (radius + 5) / 1.6); int y2 = MHelper.floor(center.getY() + (radius + 5) / 1.6); - + double hr = radius * 0.75; double nr = radius * 0.25; - + BlockState state; - Mutable bpos = new Mutable(); + MutableBlockPos bpos = new MutableBlockPos(); Set blocks = Sets.newHashSet(); for (int x = x1; x <= x2; x++) { int xsq = x - center.getX(); @@ -53,13 +53,13 @@ public class RoundCaveFeature extends EndCaveFeature { if (isReplaceable(state) && !isWaterNear(world, bpos)) { BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR); blocks.add(bpos.toImmutable()); - + while (state.getMaterial().equals(Material.LEAVES)) { BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR); bpos.setY(bpos.getY() + 1); state = world.getBlockState(bpos); } - + bpos.setY(y - 1); while (state.getMaterial().equals(Material.LEAVES)) { BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR); @@ -71,14 +71,12 @@ public class RoundCaveFeature extends EndCaveFeature { } } } - + return blocks; } - + private boolean isReplaceable(BlockState state) { - return state.isIn(EndTags.GEN_TERRAIN) - || state.getMaterial().isReplaceable() - || state.getMaterial().equals(Material.PLANT) - || state.getMaterial().equals(Material.LEAVES); + return state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().isReplaceable() + || state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.LEAVES); } } diff --git a/src/main/java/ru/betterend/world/features/terrain/caves/TunelCaveFeature.java b/src/main/java/ru/betterend/world/features/terrain/caves/TunelCaveFeature.java index 72826f16..96789b66 100644 --- a/src/main/java/ru/betterend/world/features/terrain/caves/TunelCaveFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/caves/TunelCaveFeature.java @@ -5,12 +5,12 @@ import java.util.Random; import java.util.Set; import java.util.function.Function; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; import net.minecraft.world.StructureWorldAccess; import ru.betterend.registry.EndTags; import ru.betterend.util.BlocksHelper; @@ -19,36 +19,35 @@ import ru.betterend.util.sdf.SDF; public class TunelCaveFeature extends EndCaveFeature { private static final Function REPLACE; - + @Override protected Set generate(StructureWorldAccess world, BlockPos center, int radius, Random random) { - //OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ())); + // OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, + // center.getX(), center.getZ())); float rad = radius * 0.15F; - int min = MathHelper.ceil(rad) - 15; - int max = 31 - MathHelper.floor(rad); + int min = Mth.ceil(rad) - 15; + int max = 31 - Mth.floor(rad); List spline = SplineHelper.makeSpline(0, 0, 0, 0, 0, 0, radius / 3); spline = SplineHelper.smoothSpline(spline, 5); SplineHelper.offsetParts(spline, random, 5, radius * 0.4F, 5); - for (Vector3f vec: spline) { - float x = MathHelper.clamp(vec.getX(), min, max); - float y = MathHelper.clamp(vec.getY(), -radius, radius); - float z = MathHelper.clamp(vec.getZ(), min, max); + for (Vector3f vec : spline) { + float x = Mth.clamp(vec.getX(), min, max); + float y = Mth.clamp(vec.getY(), -radius, radius); + float z = Mth.clamp(vec.getZ(), min, max); vec.set(x, y, z); } - SDF sdf = SplineHelper.buildSDF(spline, rad, rad, (vec) -> Blocks.AIR.getDefaultState()); + SDF sdf = SplineHelper.buildSDF(spline, rad, rad, (vec) -> Blocks.AIR.defaultBlockState()); Set positions = sdf.setReplaceFunction(REPLACE).getPositions(world, center); - for (BlockPos p: positions) { + for (BlockPos p : positions) { BlocksHelper.setWithoutUpdate(world, p, CAVE_AIR); } return positions; } - + static { REPLACE = (state) -> { - return state.isIn(EndTags.GEN_TERRAIN) - || state.getMaterial().isReplaceable() - || state.getMaterial().equals(Material.PLANT) - || state.getMaterial().equals(Material.LEAVES); + return state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().isReplaceable() + || state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.LEAVES); }; } } diff --git a/src/main/java/ru/betterend/world/features/trees/DragonTreeFeature.java b/src/main/java/ru/betterend/world/features/trees/DragonTreeFeature.java index ad8f0951..bc404708 100644 --- a/src/main/java/ru/betterend/world/features/trees/DragonTreeFeature.java +++ b/src/main/java/ru/betterend/world/features/trees/DragonTreeFeature.java @@ -6,13 +6,13 @@ import java.util.function.Function; import com.google.common.collect.Lists; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -40,99 +40,108 @@ public class DragonTreeFeature extends DefaultFeature { private static final List SIDE1; private static final List SIDE2; private static final List ROOT; - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false; - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)) + return false; + float size = MHelper.randRange(10, 25, random); List spline = SplineHelper.makeSpline(0, 0, 0, 0, size, 0, 6); SplineHelper.offsetParts(spline, random, 1F, 0, 1F); - + if (!SplineHelper.canGenerate(spline, pos, world, REPLACE)) { return false; } BlocksHelper.setWithoutUpdate(world, pos, AIR); - + Vector3f last = SplineHelper.getPos(spline, 3.5F); OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong()); float radius = size * MHelper.randRange(0.5F, 0.7F, random); - makeCap(world, pos.add(last.getX(), last.getY(), last.getZ()), radius, random, noise); - + makeCap(world, pos.offset(last.getX(), last.getY(), last.getZ()), radius, random, noise); + last = spline.get(0); - makeRoots(world, pos.add(last.getX(), last.getY(), last.getZ()), radius, random); - + makeRoots(world, pos.offset(last.getX(), last.getY(), last.getZ()), radius, random); + radius = MHelper.randRange(1.2F, 2.3F, random); SDF function = SplineHelper.buildSDF(spline, radius, 1.2F, (bpos) -> { - return EndBlocks.DRAGON_TREE.bark.getDefaultState(); + return EndBlocks.DRAGON_TREE.bark.defaultBlockState(); }); - + function.setReplaceFunction(REPLACE); function.addPostProcess(POST); function.fillRecursiveIgnore(world, pos, IGNORE); - + return true; } - - private void makeCap(StructureWorldAccess world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) { + + private void makeCap(StructureWorldAccess world, BlockPos pos, float radius, Random random, + OpenSimplexNoise noise) { int count = (int) radius; int offset = (int) (BRANCH.get(BRANCH.size() - 1).getY() * radius); for (int i = 0; i < count; i++) { float angle = (float) i / (float) count * MHelper.PI2; float scale = radius * MHelper.randRange(0.85F, 1.15F, random); - + List branch = SplineHelper.copySpline(BRANCH); SplineHelper.rotateSpline(branch, angle); SplineHelper.scale(branch, scale); - SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.getDefaultState(), pos, REPLACE); - + SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.defaultBlockState(), pos, REPLACE); + branch = SplineHelper.copySpline(SIDE1); SplineHelper.rotateSpline(branch, angle); SplineHelper.scale(branch, scale); - SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.getDefaultState(), pos, REPLACE); - + SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.defaultBlockState(), pos, REPLACE); + branch = SplineHelper.copySpline(SIDE2); SplineHelper.rotateSpline(branch, angle); SplineHelper.scale(branch, scale); - SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.getDefaultState(), pos, REPLACE); + SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.defaultBlockState(), pos, REPLACE); } leavesBall(world, pos.up(offset), radius * 1.15F + 2, random, noise); } - + private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random) { int count = (int) (radius * 1.5F); for (int i = 0; i < count; i++) { float angle = (float) i / (float) count * MHelper.PI2; float scale = radius * MHelper.randRange(0.85F, 1.15F, random); - + List branch = SplineHelper.copySpline(ROOT); SplineHelper.rotateSpline(branch, angle); SplineHelper.scale(branch, scale); Vector3f last = branch.get(branch.size() - 1); - if (world.getBlockState(pos.add(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) { - SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.getDefaultState(), pos, REPLACE); + if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) { + SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.defaultBlockState(), pos, REPLACE); } } } - - private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) { - SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.DRAGON_TREE_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 6)); + + private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random, + OpenSimplexNoise noise) { + SDF sphere = new SDFSphere().setRadius(radius) + .setBlock(EndBlocks.DRAGON_TREE_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6)); SDF sub = new SDFScale().setScale(5).setSource(sphere); sub = new SDFTranslate().setTranslate(0, -radius * 5, 0).setSource(sub); sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub); sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 1.5F; }).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { return random.nextFloat() * 3F - 1.5F; }).setSource(sphere); - Mutable mut = new Mutable(); + sphere = new SDFDisplacement().setFunction((vec) -> { + return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 1.5F; + }).setSource(sphere); + sphere = new SDFDisplacement().setFunction((vec) -> { + return random.nextFloat() * 3F - 1.5F; + }).setSource(sphere); + MutableBlockPos mut = new MutableBlockPos(); sphere.addPostProcess((info) -> { if (random.nextInt(5) == 0) { - for (Direction dir: Direction.values()) { + for (Direction dir : Direction.values()) { BlockState state = info.getState(dir, 2); if (state.isAir()) { return info.getState(); } } - info.setState(EndBlocks.DRAGON_TREE.bark.getDefaultState()); + info.setState(EndBlocks.DRAGON_TREE.bark.defaultBlockState()); for (int x = -6; x < 7; x++) { int ax = Math.abs(x); mut.setX(x + info.getPos().getX()); @@ -146,7 +155,7 @@ public class DragonTreeFeature extends DefaultFeature { mut.setY(y + info.getPos().getY()); BlockState state = info.getState(mut); if (state.getBlock() instanceof LeavesBlock) { - int distance = state.get(LeavesBlock.DISTANCE); + int distance = state.getValue(LeavesBlock.DISTANCE); if (d < distance) { info.setState(mut, state.with(LeavesBlock.DISTANCE, d)); } @@ -159,16 +168,16 @@ public class DragonTreeFeature extends DefaultFeature { return info.getState(); }); sphere.fillRecursiveIgnore(world, pos, IGNORE); - - + if (radius > 5) { int count = (int) (radius * 2.5F); for (int i = 0; i < count; i++) { - BlockPos p = pos.add(random.nextGaussian() * 1, random.nextGaussian() * 1, random.nextGaussian() * 1); + BlockPos p = pos.offset(random.nextGaussian() * 1, random.nextGaussian() * 1, + random.nextGaussian() * 1); boolean place = true; - for (Direction d: Direction.values()) { + for (Direction d : Direction.values()) { BlockState state = world.getBlockState(p.offset(d)); - if (!EndBlocks.DRAGON_TREE.isTreeLog(state) && !state.isOf(EndBlocks.DRAGON_TREE_LEAVES)) { + if (!EndBlocks.DRAGON_TREE.isTreeLog(state) && !state.is(EndBlocks.DRAGON_TREE_LEAVES)) { place = false; break; } @@ -178,10 +187,10 @@ public class DragonTreeFeature extends DefaultFeature { } } } - + BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.DRAGON_TREE.bark); } - + static { REPLACE = (state) -> { if (state.isIn(EndTags.END_GROUND)) { @@ -195,45 +204,36 @@ public class DragonTreeFeature extends DefaultFeature { } return state.getMaterial().isReplaceable(); }; - + IGNORE = (state) -> { return EndBlocks.DRAGON_TREE.isTreeLog(state); }; - + POST = (info) -> { - if (EndBlocks.DRAGON_TREE.isTreeLog(info.getStateUp()) && EndBlocks.DRAGON_TREE.isTreeLog(info.getStateDown())) { - return EndBlocks.DRAGON_TREE.log.getDefaultState(); + if (EndBlocks.DRAGON_TREE.isTreeLog(info.getStateUp()) + && EndBlocks.DRAGON_TREE.isTreeLog(info.getStateDown())) { + return EndBlocks.DRAGON_TREE.log.defaultBlockState(); } return info.getState(); }; - - BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0), - new Vector3f(0.1F, 0.3F, 0), - new Vector3f(0.4F, 0.6F, 0), - new Vector3f(0.8F, 0.8F, 0), - new Vector3f(1, 1, 0)); - SIDE1 = Lists.newArrayList(new Vector3f(0.4F, 0.6F, 0), - new Vector3f(0.8F, 0.8F, 0), - new Vector3f(1, 1, 0)); + + BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0), new Vector3f(0.1F, 0.3F, 0), new Vector3f(0.4F, 0.6F, 0), + new Vector3f(0.8F, 0.8F, 0), new Vector3f(1, 1, 0)); + SIDE1 = Lists.newArrayList(new Vector3f(0.4F, 0.6F, 0), new Vector3f(0.8F, 0.8F, 0), new Vector3f(1, 1, 0)); SIDE2 = SplineHelper.copySpline(SIDE1); - + Vector3f offset1 = new Vector3f(-0.4F, -0.6F, 0); Vector3f offset2 = new Vector3f(0.4F, 0.6F, 0); - + SplineHelper.offset(SIDE1, offset1); SplineHelper.offset(SIDE2, offset1); SplineHelper.rotateSpline(SIDE1, 0.5F); SplineHelper.rotateSpline(SIDE2, -0.5F); SplineHelper.offset(SIDE1, offset2); SplineHelper.offset(SIDE2, offset2); - - ROOT = Lists.newArrayList( - new Vector3f(0F, 1F, 0), - new Vector3f(0.1F, 0.7F, 0), - new Vector3f(0.3F, 0.3F, 0), - new Vector3f(0.7F, 0.05F, 0), - new Vector3f(0.8F, -0.2F, 0) - ); + + ROOT = Lists.newArrayList(new Vector3f(0F, 1F, 0), new Vector3f(0.1F, 0.7F, 0), new Vector3f(0.3F, 0.3F, 0), + new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.2F, 0)); SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0)); } } diff --git a/src/main/java/ru/betterend/world/features/trees/GiganticAmaranitaFeature.java b/src/main/java/ru/betterend/world/features/trees/GiganticAmaranitaFeature.java index 01ffa490..de9113dc 100644 --- a/src/main/java/ru/betterend/world/features/trees/GiganticAmaranitaFeature.java +++ b/src/main/java/ru/betterend/world/features/trees/GiganticAmaranitaFeature.java @@ -4,15 +4,15 @@ import java.util.List; import java.util.Random; import java.util.function.Function; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Direction.Axis; -import net.minecraft.util.math.Direction.AxisDirection; -import net.minecraft.util.math.MathHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.util.Mth; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -30,43 +30,46 @@ public class GiganticAmaranitaFeature extends DefaultFeature { private static final Function REPLACE; private static final Function IGNORE; private static final Function POST; - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false; - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)) + return false; + float size = MHelper.randRange(5, 10, random); List spline = SplineHelper.makeSpline(0, 0, 0, 0, size, 0, 5); SplineHelper.offsetParts(spline, random, 0.7F, 0, 0.7F); - + if (!SplineHelper.canGenerate(spline, pos, world, REPLACE)) { return false; } BlocksHelper.setWithoutUpdate(world, pos, AIR); - - float radius = size * 0.17F;//MHelper.randRange(0.8F, 1.2F, random); + + float radius = size * 0.17F;// MHelper.randRange(0.8F, 1.2F, random); SDF function = SplineHelper.buildSDF(spline, radius, 0.2F, (bpos) -> { - return EndBlocks.AMARANITA_STEM.getDefaultState(); + return EndBlocks.AMARANITA_STEM.defaultBlockState(); }); - + Vector3f capPos = spline.get(spline.size() - 1); - makeHead(world, pos.add(capPos.getX() + 0.5F, capPos.getY() + 1.5F ,capPos.getZ() + 0.5F), MathHelper.floor(size / 1.6F)); - + makeHead(world, pos.offset(capPos.getX() + 0.5F, capPos.getY() + 1.5F, capPos.getZ() + 0.5F), + Mth.floor(size / 1.6F)); + function.setReplaceFunction(REPLACE); function.addPostProcess(POST); function.fillRecursiveIgnore(world, pos, IGNORE); - + for (int i = 0; i < 3; i++) { List copy = SplineHelper.copySpline(spline); SplineHelper.offsetParts(copy, random, 0.2F, 0, 0.2F); - SplineHelper.fillSplineForce(copy, world, EndBlocks.AMARANITA_HYPHAE.getDefaultState(), pos, REPLACE); + SplineHelper.fillSplineForce(copy, world, EndBlocks.AMARANITA_HYPHAE.defaultBlockState(), pos, REPLACE); } - + return true; } - + private void makeHead(StructureWorldAccess world, BlockPos pos, int radius) { - Mutable mut = new Mutable(); + MutableBlockPos mut = new MutableBlockPos(); if (radius < 2) { for (int i = -1; i < 2; i++) { mut.set(pos).move(Direction.NORTH, 2).move(Direction.EAST, i); @@ -95,12 +98,13 @@ public class GiganticAmaranitaFeature extends DefaultFeature { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_LANTERN); mut.move(Direction.DOWN); if (world.getBlockState(mut).getMaterial().isReplaceable()) { - BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.getDefaultState().with(AttachedBlock.FACING, Direction.DOWN)); + BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState() + .with(AttachedBlock.FACING, Direction.DOWN)); } } } } - + int h = radius + 1; for (int y = 0; y < h; y++) { mut.setY(pos.getY() + y + 1); @@ -114,7 +118,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature { } } } - + mut.setY(pos.getY() + h + 1); for (int x = -1; x < 2; x++) { mut.setX(pos.getX() + x); @@ -125,9 +129,8 @@ public class GiganticAmaranitaFeature extends DefaultFeature { } } } - } - else if (radius < 4) { - pos = pos.add(-1, 0, -1); + } else if (radius < 4) { + pos = pos.offset(-1, 0, -1); for (int i = -2; i < 2; i++) { mut.set(pos).move(Direction.NORTH, 2).move(Direction.WEST, i); if (world.getBlockState(mut).getMaterial().isReplaceable()) { @@ -158,18 +161,21 @@ public class GiganticAmaranitaFeature extends DefaultFeature { int distance = axis == Axis.X ? x < 0 ? -1 : 1 : z < 0 ? -1 : 1; BlockPos offseted = mut.offset(axis, distance); if (world.getBlockState(offseted).getMaterial().isReplaceable()) { - Direction dir = Direction.from(axis, distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE); - BlocksHelper.setWithoutUpdate(world, offseted, EndBlocks.AMARANITA_FUR.getDefaultState().with(AttachedBlock.FACING, dir)); + Direction dir = Direction.fromAxisAndDirection(axis, + distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE); + BlocksHelper.setWithoutUpdate(world, offseted, + EndBlocks.AMARANITA_FUR.defaultBlockState().with(AttachedBlock.FACING, dir)); } mut.move(Direction.DOWN); } if (world.getBlockState(mut).getMaterial().isReplaceable()) { - BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.getDefaultState().with(AttachedBlock.FACING, Direction.DOWN)); + BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState() + .with(AttachedBlock.FACING, Direction.DOWN)); } } } } - + int h = radius - 1; for (int y = 0; y < h; y++) { mut.setY(pos.getY() + y + 1); @@ -183,7 +189,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature { } } } - + mut.setY(pos.getY() + h + 1); for (int x = -1; x < 3; x++) { mut.setX(pos.getX() + x); @@ -194,8 +200,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature { } } } - } - else { + } else { for (int i = -2; i < 3; i++) { mut.set(pos).move(Direction.NORTH, 3).move(Direction.EAST, i); if (world.getBlockState(mut).getMaterial().isReplaceable()) { @@ -209,7 +214,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature { if (world.getBlockState(mut).getMaterial().isReplaceable()) { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE); } - + mut.set(pos).move(Direction.SOUTH, 3).move(Direction.EAST, i); if (world.getBlockState(mut).getMaterial().isReplaceable()) { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE); @@ -222,7 +227,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature { if (world.getBlockState(mut).getMaterial().isReplaceable()) { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE); } - + mut.set(pos).move(Direction.EAST, 3).move(Direction.NORTH, i); if (world.getBlockState(mut).getMaterial().isReplaceable()) { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE); @@ -235,7 +240,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature { if (world.getBlockState(mut).getMaterial().isReplaceable()) { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE); } - + mut.set(pos).move(Direction.WEST, 3).move(Direction.NORTH, i); if (world.getBlockState(mut).getMaterial().isReplaceable()) { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE); @@ -249,14 +254,15 @@ public class GiganticAmaranitaFeature extends DefaultFeature { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE); } } - + for (int i = 0; i < 4; i++) { - mut.set(pos).move(Direction.UP).move(BlocksHelper.HORIZONTAL[i], 3).move(BlocksHelper.HORIZONTAL[(i + 1) & 3], 3); + mut.set(pos).move(Direction.UP).move(BlocksHelper.HORIZONTAL[i], 3) + .move(BlocksHelper.HORIZONTAL[(i + 1) & 3], 3); if (world.getBlockState(mut).getMaterial().isReplaceable()) { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE); } } - + for (int x = -2; x < 3; x++) { for (int z = -2; z < 3; z++) { mut.set(pos).move(x, 0, z); @@ -269,18 +275,21 @@ public class GiganticAmaranitaFeature extends DefaultFeature { int distance = axis == Axis.X ? x < 0 ? -1 : 1 : z < 0 ? -1 : 1; BlockPos offseted = mut.offset(axis, distance); if (world.getBlockState(offseted).getMaterial().isReplaceable()) { - Direction dir = Direction.from(axis, distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE); - BlocksHelper.setWithoutUpdate(world, offseted, EndBlocks.AMARANITA_FUR.getDefaultState().with(AttachedBlock.FACING, dir)); + Direction dir = Direction.fromAxisAndDirection(axis, + distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE); + BlocksHelper.setWithoutUpdate(world, offseted, + EndBlocks.AMARANITA_FUR.defaultBlockState().with(AttachedBlock.FACING, dir)); } mut.move(Direction.DOWN); } if (world.getBlockState(mut).getMaterial().isReplaceable()) { - BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.getDefaultState().with(AttachedBlock.FACING, Direction.DOWN)); + BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState() + .with(AttachedBlock.FACING, Direction.DOWN)); } } } } - + for (int y = 0; y < 3; y++) { mut.setY(pos.getY() + y + 1); for (int x = -2; x < 3; x++) { @@ -293,7 +302,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature { } } } - + int h = radius + 1; for (int y = 4; y < h; y++) { mut.setY(pos.getY() + y); @@ -302,12 +311,13 @@ public class GiganticAmaranitaFeature extends DefaultFeature { for (int z = -2; z < 3; z++) { mut.setZ(pos.getZ() + z); if (y < 6) { - if (((x / 2) == 0 || (z / 2) == 0) && world.getBlockState(mut).getMaterial().isReplaceable()) { + if (((x / 2) == 0 || (z / 2) == 0) + && world.getBlockState(mut).getMaterial().isReplaceable()) { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_CAP); } - } - else { - if ((x == 0 || z == 0) && (Math.abs(x) < 2 && Math.abs(z) < 2) && world.getBlockState(mut).getMaterial().isReplaceable()) { + } else { + if ((x == 0 || z == 0) && (Math.abs(x) < 2 && Math.abs(z) < 2) + && world.getBlockState(mut).getMaterial().isReplaceable()) { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_CAP); } } @@ -316,7 +326,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature { } } } - + static { REPLACE = (state) -> { if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) { @@ -324,14 +334,14 @@ public class GiganticAmaranitaFeature extends DefaultFeature { } return state.getMaterial().isReplaceable(); }; - + IGNORE = (state) -> { return EndBlocks.DRAGON_TREE.isTreeLog(state); }; - + POST = (info) -> { - if (!info.getStateUp().isOf(EndBlocks.AMARANITA_STEM) || !info.getStateDown().isOf(EndBlocks.AMARANITA_STEM)) { - return EndBlocks.AMARANITA_HYPHAE.getDefaultState(); + if (!info.getStateUp().is(EndBlocks.AMARANITA_STEM) || !info.getStateDown().is(EndBlocks.AMARANITA_STEM)) { + return EndBlocks.AMARANITA_HYPHAE.defaultBlockState(); } return info.getState(); }; diff --git a/src/main/java/ru/betterend/world/features/trees/HelixTreeFeature.java b/src/main/java/ru/betterend/world/features/trees/HelixTreeFeature.java index d71004cf..3a0c9fcc 100644 --- a/src/main/java/ru/betterend/world/features/trees/HelixTreeFeature.java +++ b/src/main/java/ru/betterend/world/features/trees/HelixTreeFeature.java @@ -5,12 +5,12 @@ import java.util.List; import java.util.Random; import java.util.function.Function; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.util.math.Box; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -31,16 +31,18 @@ import ru.betterend.world.features.DefaultFeature; public class HelixTreeFeature extends DefaultFeature { private static final Function POST; - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false; + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)) + return false; BlocksHelper.setWithoutUpdate(world, pos, AIR); - + float angle = random.nextFloat() * MHelper.PI2; float radiusRange = MHelper.randRange(4.5F, 6F, random); float scale = MHelper.randRange(0.5F, 1F, random); - + float dx; float dz; List spline = new ArrayList(10); @@ -50,35 +52,40 @@ public class HelixTreeFeature extends DefaultFeature { dz = (float) Math.cos(i + angle) * radius; spline.add(new Vector3f(dx, i * 2, dz)); } - SDF sdf = SplineHelper.buildSDF(spline, 1.7F, 0.5F, (p) -> { return EndBlocks.HELIX_TREE.bark.getDefaultState(); }); + SDF sdf = SplineHelper.buildSDF(spline, 1.7F, 0.5F, (p) -> { + return EndBlocks.HELIX_TREE.bark.defaultBlockState(); + }); SDF rotated = new SDFRotation().setRotation(Vector3f.POSITIVE_Y, (float) Math.PI).setSource(sdf); sdf = new SDFUnion().setSourceA(rotated).setSourceB(sdf); - + Vector3f lastPoint = spline.get(spline.size() - 1); List spline2 = SplineHelper.makeSpline(0, 0, 0, 0, 20, 0, 5); - SDF stem = SplineHelper.buildSDF(spline2, 1.0F, 0.5F, (p) -> { return EndBlocks.HELIX_TREE.bark.getDefaultState(); }); + SDF stem = SplineHelper.buildSDF(spline2, 1.0F, 0.5F, (p) -> { + return EndBlocks.HELIX_TREE.bark.defaultBlockState(); + }); stem = new SDFTranslate().setTranslate(lastPoint.getX(), lastPoint.getY(), lastPoint.getZ()).setSource(stem); sdf = new SDFSmoothUnion().setRadius(3).setSourceA(sdf).setSourceB(stem); - + sdf = new SDFScale().setScale(scale).setSource(sdf); dx = 30 * scale; float dy1 = -20 * scale; float dy2 = 100 * scale; - sdf.addPostProcess(POST).fillArea(world, pos, new Box(pos.add(-dx, dy1, -dx), pos.add(dx, dy2, dx))); + sdf.addPostProcess(POST).fillArea(world, pos, new Box(pos.offset(-dx, dy1, -dx), pos.offset(dx, dy2, dx))); SplineHelper.scale(spline, scale); - SplineHelper.fillSplineForce(spline, world, EndBlocks.HELIX_TREE.bark.getDefaultState(), pos, (state) -> { + SplineHelper.fillSplineForce(spline, world, EndBlocks.HELIX_TREE.bark.defaultBlockState(), pos, (state) -> { return state.getMaterial().isReplaceable(); }); SplineHelper.rotateSpline(spline, (float) Math.PI); - SplineHelper.fillSplineForce(spline, world, EndBlocks.HELIX_TREE.bark.getDefaultState(), pos, (state) -> { + SplineHelper.fillSplineForce(spline, world, EndBlocks.HELIX_TREE.bark.defaultBlockState(), pos, (state) -> { return state.getMaterial().isReplaceable(); }); SplineHelper.scale(spline2, scale); - BlockPos leafStart = pos.add(lastPoint.getX() + 0.5, lastPoint.getY() + 0.5, lastPoint.getZ() + 0.5); - SplineHelper.fillSplineForce(spline2, world, EndBlocks.HELIX_TREE.log.getDefaultState(), leafStart, (state) -> { - return state.getMaterial().isReplaceable(); - }); - + BlockPos leafStart = pos.offset(lastPoint.getX() + 0.5, lastPoint.getY() + 0.5, lastPoint.getZ() + 0.5); + SplineHelper.fillSplineForce(spline2, world, EndBlocks.HELIX_TREE.log.defaultBlockState(), leafStart, + (state) -> { + return state.getMaterial().isReplaceable(); + }); + spline.clear(); float rad = MHelper.randRange(8F, 11F, random); int count = MHelper.randRange(20, 30, random); @@ -93,11 +100,11 @@ public class HelixTreeFeature extends DefaultFeature { dz = (float) Math.cos(i * 0.45F + angle) * radius; spline.add(new Vector3f(dx, i * scaleM, dz)); } - + Vector3f start = new Vector3f(); Vector3f end = new Vector3f(); lastPoint = spline.get(0); - BlockState leaf = EndBlocks.HELIX_TREE_LEAVES.getDefaultState(); + BlockState leaf = EndBlocks.HELIX_TREE_LEAVES.defaultBlockState(); for (int i = 1; i < spline.size(); i++) { Vector3f point = spline.get(i); int minY = MHelper.floor(lastPoint.getY()); @@ -106,8 +113,8 @@ public class HelixTreeFeature extends DefaultFeature { for (float py = minY; py <= maxY; py += 0.2F) { start.set(0, py, 0); float delta = (float) (py - minY) / div; - float px = MathHelper.lerp(delta, lastPoint.getX(), point.getX()); - float pz = MathHelper.lerp(delta, lastPoint.getZ(), point.getZ()); + float px = Mth.lerp(delta, lastPoint.getX(), point.getX()); + float pz = Mth.lerp(delta, lastPoint.getZ(), point.getZ()); end.set(px, py, pz); fillLine(start, end, world, leaf, leafStart, i / 2 - 1); float ax = Math.abs(px); @@ -115,8 +122,7 @@ public class HelixTreeFeature extends DefaultFeature { if (ax > az) { start.set(start.getX(), start.getY(), start.getZ() + az > 0 ? 1 : -1); end.set(end.getX(), end.getY(), end.getZ() + az > 0 ? 1 : -1); - } - else { + } else { start.set(start.getX() + ax > 0 ? 1 : -1, start.getY(), start.getZ()); end.set(end.getX() + ax > 0 ? 1 : -1, end.getY(), end.getZ()); } @@ -124,7 +130,7 @@ public class HelixTreeFeature extends DefaultFeature { } lastPoint = point; } - + leaf = leaf.with(HelixTreeLeavesBlock.COLOR, 7); leafStart = leafStart.add(0, lastPoint.getY(), 0); if (world.getBlockState(leafStart).isAir()) { @@ -133,16 +139,17 @@ public class HelixTreeFeature extends DefaultFeature { if (world.getBlockState(leafStart).isAir()) { BlocksHelper.setWithoutUpdate(world, leafStart, leaf); leafStart = leafStart.up(); - if (world.getBlockState(leafStart).isAir()) { - BlocksHelper.setWithoutUpdate(world, leafStart, leaf); - } + if (world.getBlockState(leafStart).isAir()) { + BlocksHelper.setWithoutUpdate(world, leafStart, leaf); + } } } - + return true; } - - private void fillLine(Vector3f start, Vector3f end, StructureWorldAccess world, BlockState state, BlockPos pos, int offset) { + + private void fillLine(Vector3f start, Vector3f end, StructureWorldAccess world, BlockState state, BlockPos pos, + int offset) { float dx = end.getX() - start.getX(); float dy = end.getY() - start.getY(); float dz = end.getZ() - start.getZ(); @@ -154,12 +161,12 @@ public class HelixTreeFeature extends DefaultFeature { float x = start.getX(); float y = start.getY(); float z = start.getZ(); - - Mutable bPos = new Mutable(); + + MutableBlockPos bPos = new MutableBlockPos(); for (int i = 0; i < count; i++) { bPos.set(x + pos.getX(), y + pos.getY(), z + pos.getZ()); int color = MHelper.floor((float) i / (float) count * 7F + 0.5F) + offset; - color = MathHelper.clamp(color, 0, 7); + color = Mth.clamp(color, 0, 7); if (world.getBlockState(bPos).getMaterial().isReplaceable()) { BlocksHelper.setWithoutUpdate(world, bPos, state.with(HelixTreeLeavesBlock.COLOR, color)); } @@ -172,11 +179,12 @@ public class HelixTreeFeature extends DefaultFeature { BlocksHelper.setWithoutUpdate(world, bPos, state.with(HelixTreeLeavesBlock.COLOR, 7)); } } - + static { POST = (info) -> { - if (EndBlocks.HELIX_TREE.isTreeLog(info.getStateUp()) && EndBlocks.HELIX_TREE.isTreeLog(info.getStateDown())) { - return EndBlocks.HELIX_TREE.log.getDefaultState(); + if (EndBlocks.HELIX_TREE.isTreeLog(info.getStateUp()) + && EndBlocks.HELIX_TREE.isTreeLog(info.getStateDown())) { + return EndBlocks.HELIX_TREE.log.defaultBlockState(); } return info.getState(); }; diff --git a/src/main/java/ru/betterend/world/features/trees/JellyshroomFeature.java b/src/main/java/ru/betterend/world/features/trees/JellyshroomFeature.java index 99912b1c..3b16470a 100644 --- a/src/main/java/ru/betterend/world/features/trees/JellyshroomFeature.java +++ b/src/main/java/ru/betterend/world/features/trees/JellyshroomFeature.java @@ -6,11 +6,11 @@ import java.util.function.Function; import com.google.common.collect.Lists; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -31,14 +31,16 @@ import ru.betterend.world.features.DefaultFeature; public class JellyshroomFeature extends DefaultFeature { private static final Function REPLACE; private static final List ROOT; - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false; - - BlockState bark = EndBlocks.JELLYSHROOM.bark.getDefaultState(); - BlockState membrane = EndBlocks.JELLYSHROOM_CAP_PURPLE.getDefaultState(); - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)) + return false; + + BlockState bark = EndBlocks.JELLYSHROOM.bark.defaultBlockState(); + BlockState membrane = EndBlocks.JELLYSHROOM_CAP_PURPLE.defaultBlockState(); + int height = MHelper.randRange(5, 8, random); float radius = height * MHelper.randRange(0.15F, 0.25F, random); List spline = SplineHelper.makeSpline(0, -1, 0, 0, height, 0, 3); @@ -46,7 +48,7 @@ public class JellyshroomFeature extends DefaultFeature { SDF sdf = SplineHelper.buildSDF(spline, radius, 0.8F, (bpos) -> { return bark; }); - + radius = height * MHelper.randRange(0.7F, 0.9F, random); if (radius < 1.5F) { radius = 1.5F; @@ -58,67 +60,63 @@ public class JellyshroomFeature extends DefaultFeature { sdf = new SDFSmoothUnion().setRadius(3F).setSourceA(sdf).setSourceB(cap); sdf.setReplaceFunction(REPLACE).addPostProcess((info) -> { if (EndBlocks.JELLYSHROOM.isTreeLog(info.getState())) { - if (EndBlocks.JELLYSHROOM.isTreeLog(info.getStateUp()) && EndBlocks.JELLYSHROOM.isTreeLog(info.getStateDown())) { - return EndBlocks.JELLYSHROOM.log.getDefaultState(); + if (EndBlocks.JELLYSHROOM.isTreeLog(info.getStateUp()) + && EndBlocks.JELLYSHROOM.isTreeLog(info.getStateDown())) { + return EndBlocks.JELLYSHROOM.log.defaultBlockState(); } - } - else if (info.getState().isOf(EndBlocks.JELLYSHROOM_CAP_PURPLE)) { + } else if (info.getState().is(EndBlocks.JELLYSHROOM_CAP_PURPLE)) { float dx = info.getPos().getX() - pos.getX() - last.getX(); float dz = info.getPos().getZ() - pos.getZ() - last.getZ(); float distance = MHelper.length(dx, dz) / membraneRadius * 7F; - int color = MathHelper.clamp(MHelper.floor(distance), 0, 7); + int color = Mth.clamp(MHelper.floor(distance), 0, 7); return info.getState().with(JellyshroomCapBlock.COLOR, color); } return info.getState(); }).fillRecursive(world, pos); radius = height * 0.5F; - makeRoots(world, pos.add(0, 2, 0), radius, random, bark); - + makeRoots(world, pos.offset(0, 2, 0), radius, random, bark); + return true; } - + private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random, BlockState wood) { int count = (int) (radius * 3.5F); for (int i = 0; i < count; i++) { float angle = (float) i / (float) count * MHelper.PI2; float scale = radius * MHelper.randRange(0.85F, 1.15F, random); - + List branch = SplineHelper.copySpline(ROOT); SplineHelper.rotateSpline(branch, angle); SplineHelper.scale(branch, scale); Vector3f last = branch.get(branch.size() - 1); - if (world.getBlockState(pos.add(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) { + if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) { SplineHelper.fillSpline(branch, world, wood, pos, REPLACE); } } } - + private SDF makeCap(float radius, Random random, BlockState cap) { SDF sphere = new SDFSphere().setRadius(radius).setBlock(cap); SDF sub = new SDFTranslate().setTranslate(0, -4, 0).setSource(sphere); sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub); sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere); sphere = new SDFTranslate().setTranslate(0, 1 - radius * 0.5F, 0).setSource(sphere); - + float angle = random.nextFloat() * MHelper.PI2; int count = (int) MHelper.randRange(radius * 0.5F, radius, random); if (count < 3) { count = 3; } sphere = new SDFFlatWave().setAngle(angle).setRaysCount(count).setIntensity(0.2F).setSource(sphere); - + return sphere; } - + static { - ROOT = Lists.newArrayList( - new Vector3f(0.1F, 0.70F, 0), - new Vector3f(0.3F, 0.30F, 0), - new Vector3f(0.7F, 0.05F, 0), - new Vector3f(0.8F, -0.20F, 0) - ); + ROOT = Lists.newArrayList(new Vector3f(0.1F, 0.70F, 0), new Vector3f(0.3F, 0.30F, 0), + new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.20F, 0)); SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0)); - + REPLACE = (state) -> { if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) { return true; diff --git a/src/main/java/ru/betterend/world/features/trees/LacugroveFeature.java b/src/main/java/ru/betterend/world/features/trees/LacugroveFeature.java index 79410baf..9ef75410 100644 --- a/src/main/java/ru/betterend/world/features/trees/LacugroveFeature.java +++ b/src/main/java/ru/betterend/world/features/trees/LacugroveFeature.java @@ -4,13 +4,13 @@ import java.util.List; import java.util.Random; import java.util.function.Function; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -32,39 +32,41 @@ public class LacugroveFeature extends DefaultFeature { private static final Function REPLACE; private static final Function IGNORE; private static final Function POST; - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) return false; - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) + return false; + float size = MHelper.randRange(15, 25, random); List spline = SplineHelper.makeSpline(0, 0, 0, 0, size, 0, 6); SplineHelper.offsetParts(spline, random, 1F, 0, 1F); - + if (!SplineHelper.canGenerate(spline, pos, world, REPLACE)) { return false; } - + OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong()); - + float radius = MHelper.randRange(6F, 8F, random); radius *= (size - 15F) / 20F + 1F; Vector3f center = spline.get(4); - leavesBall(world, pos.add(center.getX(), center.getY(), center.getZ()), radius, random, noise); - + leavesBall(world, pos.offset(center.getX(), center.getY(), center.getZ()), radius, random, noise); + radius = MHelper.randRange(1.2F, 1.8F, random); SDF function = SplineHelper.buildSDF(spline, radius, 0.7F, (bpos) -> { - return EndBlocks.LACUGROVE.bark.getDefaultState(); + return EndBlocks.LACUGROVE.bark.defaultBlockState(); }); - + function.setReplaceFunction(REPLACE); function.addPostProcess(POST); function.fillRecursive(world, pos); - + spline = spline.subList(4, 6); - SplineHelper.fillSpline(spline, world, EndBlocks.LACUGROVE.bark.getDefaultState(), pos, REPLACE); - - Mutable mut = new Mutable(); + SplineHelper.fillSpline(spline, world, EndBlocks.LACUGROVE.bark.defaultBlockState(), pos, REPLACE); + + MutableBlockPos mut = new MutableBlockPos(); int offset = random.nextInt(2); for (int i = 0; i < 100; i++) { double px = pos.getX() + MHelper.randRange(-5, 5, random); @@ -89,10 +91,11 @@ public class LacugroveFeature extends DefaultFeature { for (int y = top; y >= minY; y--) { mut.setY(y); BlockState state = world.getBlockState(mut); - if (state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT) || state.isIn(EndTags.END_GROUND)) { - BlocksHelper.setWithoutUpdate(world, mut, y == top ? EndBlocks.LACUGROVE.bark : EndBlocks.LACUGROVE.log); - } - else { + if (state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT) + || state.isIn(EndTags.END_GROUND)) { + BlocksHelper.setWithoutUpdate(world, mut, + y == top ? EndBlocks.LACUGROVE.bark : EndBlocks.LACUGROVE.log); + } else { break; } } @@ -100,25 +103,32 @@ public class LacugroveFeature extends DefaultFeature { } } } - + return true; } - - private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) { - SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.LACUGROVE_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 6)); - sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { return random.nextFloat() * 3F - 1.5F; }).setSource(sphere); - sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius - 2, 0).setSource(sphere)); - Mutable mut = new Mutable(); + + private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random, + OpenSimplexNoise noise) { + SDF sphere = new SDFSphere().setRadius(radius) + .setBlock(EndBlocks.LACUGROVE_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6)); + sphere = new SDFDisplacement().setFunction((vec) -> { + return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; + }).setSource(sphere); + sphere = new SDFDisplacement().setFunction((vec) -> { + return random.nextFloat() * 3F - 1.5F; + }).setSource(sphere); + sphere = new SDFSubtraction().setSourceA(sphere) + .setSourceB(new SDFTranslate().setTranslate(0, -radius - 2, 0).setSource(sphere)); + MutableBlockPos mut = new MutableBlockPos(); sphere.addPostProcess((info) -> { if (random.nextInt(5) == 0) { - for (Direction dir: Direction.values()) { + for (Direction dir : Direction.values()) { BlockState state = info.getState(dir, 2); if (state.isAir()) { return info.getState(); } } - info.setState(EndBlocks.LACUGROVE.bark.getDefaultState()); + info.setState(EndBlocks.LACUGROVE.bark.defaultBlockState()); for (int x = -6; x < 7; x++) { int ax = Math.abs(x); mut.setX(x + info.getPos().getX()); @@ -132,7 +142,7 @@ public class LacugroveFeature extends DefaultFeature { mut.setY(y + info.getPos().getY()); BlockState state = info.getState(mut); if (state.getBlock() instanceof LeavesBlock) { - int distance = state.get(LeavesBlock.DISTANCE); + int distance = state.getValue(LeavesBlock.DISTANCE); if (d < distance) { info.setState(mut, state.with(LeavesBlock.DISTANCE, d)); } @@ -145,15 +155,16 @@ public class LacugroveFeature extends DefaultFeature { return info.getState(); }); sphere.fillRecursiveIgnore(world, pos, IGNORE); - + if (radius > 5) { int count = (int) (radius * 2.5F); for (int i = 0; i < count; i++) { - BlockPos p = pos.add(random.nextGaussian() * 1, random.nextGaussian() * 1, random.nextGaussian() * 1); + BlockPos p = pos.offset(random.nextGaussian() * 1, random.nextGaussian() * 1, + random.nextGaussian() * 1); boolean place = true; - for (Direction d: Direction.values()) { + for (Direction d : Direction.values()) { BlockState state = world.getBlockState(p.offset(d)); - if (!EndBlocks.LACUGROVE.isTreeLog(state) && !state.isOf(EndBlocks.LACUGROVE_LEAVES)) { + if (!EndBlocks.LACUGROVE.isTreeLog(state) && !state.is(EndBlocks.LACUGROVE_LEAVES)) { place = false; break; } @@ -163,10 +174,10 @@ public class LacugroveFeature extends DefaultFeature { } } } - + BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.LACUGROVE.bark); } - + static { REPLACE = (state) -> { if (state.isIn(EndTags.END_GROUND)) { @@ -183,14 +194,15 @@ public class LacugroveFeature extends DefaultFeature { } return state.getMaterial().isReplaceable(); }; - + IGNORE = (state) -> { return EndBlocks.LACUGROVE.isTreeLog(state); }; - + POST = (info) -> { - if (EndBlocks.LACUGROVE.isTreeLog(info.getStateUp()) && EndBlocks.LACUGROVE.isTreeLog(info.getStateDown())) { - return EndBlocks.LACUGROVE.log.getDefaultState(); + if (EndBlocks.LACUGROVE.isTreeLog(info.getStateUp()) + && EndBlocks.LACUGROVE.isTreeLog(info.getStateDown())) { + return EndBlocks.LACUGROVE.log.defaultBlockState(); } return info.getState(); }; diff --git a/src/main/java/ru/betterend/world/features/trees/LucerniaFeature.java b/src/main/java/ru/betterend/world/features/trees/LucerniaFeature.java index 8a452bd7..c2eb554e 100644 --- a/src/main/java/ru/betterend/world/features/trees/LucerniaFeature.java +++ b/src/main/java/ru/betterend/world/features/trees/LucerniaFeature.java @@ -6,13 +6,13 @@ import java.util.function.Function; import com.google.common.collect.Lists; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -40,14 +40,16 @@ public class LucerniaFeature extends DefaultFeature { private static final Function IGNORE; private static final List SPLINE; private static final List ROOT; - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false; - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)) + return false; + float size = MHelper.randRange(12, 20, random); int count = (int) (size * 0.3F); - float var = MHelper.PI2 / (float) (count * 3); + float var = MHelper.PI2 / (float) (count * 3); float start = MHelper.randRange(0, MHelper.PI2, random); for (int i = 0; i < count; i++) { float angle = (float) i / (float) count * MHelper.PI2 + MHelper.randRange(0, var, random) + start; @@ -55,65 +57,74 @@ public class LucerniaFeature extends DefaultFeature { SplineHelper.rotateSpline(spline, angle); SplineHelper.scale(spline, size * MHelper.randRange(0.5F, 1F, random)); SplineHelper.offsetParts(spline, random, 1F, 0, 1F); - SplineHelper.fillSpline(spline, world, EndBlocks.LUCERNIA.bark.getDefaultState(), pos, REPLACE); + SplineHelper.fillSpline(spline, world, EndBlocks.LUCERNIA.bark.defaultBlockState(), pos, REPLACE); Vector3f last = spline.get(spline.size() - 1); float leavesRadius = (size * 0.13F + MHelper.randRange(0.8F, 1.5F, random)) * 1.4F; OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong()); - leavesBall(world, pos.add(last.getX(), last.getY(), last.getZ()), leavesRadius, random, noise, config != null); + leavesBall(world, pos.offset(last.getX(), last.getY(), last.getZ()), leavesRadius, random, noise, + config != null); } - - makeRoots(world, pos.add(0, MHelper.randRange(3, 5, random), 0), size * 0.35F, random); - + + makeRoots(world, pos.offset(0, MHelper.randRange(3, 5, random), 0), size * 0.35F, random); + return true; } - - private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise, boolean natural) { - SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.LUCERNIA_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 6)); + + private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random, + OpenSimplexNoise noise, boolean natural) { + SDF sphere = new SDFSphere().setRadius(radius) + .setBlock(EndBlocks.LUCERNIA_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6)); SDF sub = new SDFScale().setScale(5).setSource(sphere); sub = new SDFTranslate().setTranslate(0, -radius * 5, 0).setSource(sub); sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub); sphere = new SDFScale3D().setScale(1, 0.75F, 1).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 2F; }).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-1.5F, 1.5F, random); }).setSource(sphere); - - Mutable mut = new Mutable(); - for (Direction d1: BlocksHelper.HORIZONTAL) { + sphere = new SDFDisplacement().setFunction((vec) -> { + return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 2F; + }).setSource(sphere); + sphere = new SDFDisplacement().setFunction((vec) -> { + return MHelper.randRange(-1.5F, 1.5F, random); + }).setSource(sphere); + + MutableBlockPos mut = new MutableBlockPos(); + for (Direction d1 : BlocksHelper.HORIZONTAL) { BlockPos p = mut.set(pos).move(Direction.UP).move(d1).toImmutable(); - BlocksHelper.setWithoutUpdate(world, p, EndBlocks.LUCERNIA.bark.getDefaultState()); - for (Direction d2: BlocksHelper.HORIZONTAL) { + BlocksHelper.setWithoutUpdate(world, p, EndBlocks.LUCERNIA.bark.defaultBlockState()); + for (Direction d2 : BlocksHelper.HORIZONTAL) { mut.set(p).move(Direction.UP).move(d2); - BlocksHelper.setWithoutUpdate(world, p, EndBlocks.LUCERNIA.bark.getDefaultState()); + BlocksHelper.setWithoutUpdate(world, p, EndBlocks.LUCERNIA.bark.defaultBlockState()); } } - - BlockState top = EndBlocks.FILALUX.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP); - BlockState middle = EndBlocks.FILALUX.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE); - BlockState bottom = EndBlocks.FILALUX.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM); - BlockState outer = EndBlocks.LUCERNIA_OUTER_LEAVES.getDefaultState(); - + + BlockState top = EndBlocks.FILALUX.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP); + BlockState middle = EndBlocks.FILALUX.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, + TripleShape.MIDDLE); + BlockState bottom = EndBlocks.FILALUX.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, + TripleShape.BOTTOM); + BlockState outer = EndBlocks.LUCERNIA_OUTER_LEAVES.defaultBlockState(); + List support = Lists.newArrayList(); sphere.addPostProcess((info) -> { if (natural && random.nextInt(6) == 0 && info.getStateDown().isAir()) { - BlockPos d = info.getPos().down(); + BlockPos d = info.getPos().below(); support.add(d); } if (random.nextInt(15) == 0) { - for (Direction dir: Direction.values()) { + for (Direction dir : Direction.values()) { BlockState state = info.getState(dir, 2); if (state.isAir()) { return info.getState(); } } - info.setState(EndBlocks.LUCERNIA.bark.getDefaultState()); + info.setState(EndBlocks.LUCERNIA.bark.defaultBlockState()); } - + MHelper.shuffle(DIRECTIONS, random); - for (Direction d: DIRECTIONS) { + for (Direction d : DIRECTIONS) { if (info.getState(d).isAir()) { info.setBlockPos(info.getPos().offset(d), outer.with(FurBlock.FACING, d)); } } - + if (EndBlocks.LUCERNIA.isTreeLog(info.getState())) { for (int x = -6; x < 7; x++) { int ax = Math.abs(x); @@ -128,7 +139,7 @@ public class LucerniaFeature extends DefaultFeature { mut.setY(y + info.getPos().getY()); BlockState state = info.getState(mut); if (state.getBlock() instanceof LeavesBlock) { - int distance = state.get(LeavesBlock.DISTANCE); + int distance = state.getValue(LeavesBlock.DISTANCE); if (d < distance) { info.setState(mut, state.with(LeavesBlock.DISTANCE, d)); } @@ -142,20 +153,19 @@ public class LucerniaFeature extends DefaultFeature { }); sphere.fillRecursiveIgnore(world, pos, IGNORE); BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.LUCERNIA.bark); - + support.forEach((bpos) -> { BlockState state = world.getBlockState(bpos); - if (state.isAir() || state.isOf(EndBlocks.LUCERNIA_OUTER_LEAVES)) { + if (state.isAir() || state.is(EndBlocks.LUCERNIA_OUTER_LEAVES)) { int count = MHelper.randRange(3, 8, random); mut.set(bpos); - if (world.getBlockState(mut.up()).isOf(EndBlocks.LUCERNIA_LEAVES)) { + if (world.getBlockState(mut.up()).is(EndBlocks.LUCERNIA_LEAVES)) { BlocksHelper.setWithoutUpdate(world, mut, top); for (int i = 1; i < count; i++) { mut.setY(mut.getY() - 1); - if (world.isAir(mut.down())) { + if (world.isAir(mut.below())) { BlocksHelper.setWithoutUpdate(world, mut, middle); - } - else { + } else { break; } } @@ -164,23 +174,23 @@ public class LucerniaFeature extends DefaultFeature { } }); } - + private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random) { int count = (int) (radius * 1.5F); for (int i = 0; i < count; i++) { float angle = (float) i / (float) count * MHelper.PI2; float scale = radius * MHelper.randRange(0.85F, 1.15F, random); - + List branch = SplineHelper.copySpline(ROOT); SplineHelper.rotateSpline(branch, angle); SplineHelper.scale(branch, scale); Vector3f last = branch.get(branch.size() - 1); - if (world.getBlockState(pos.add(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) { - SplineHelper.fillSplineForce(branch, world, EndBlocks.LUCERNIA.bark.getDefaultState(), pos, REPLACE); + if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) { + SplineHelper.fillSplineForce(branch, world, EndBlocks.LUCERNIA.bark.defaultBlockState(), pos, REPLACE); } } } - + static { REPLACE = (state) -> { if (state.isIn(EndTags.END_GROUND)) { @@ -194,26 +204,17 @@ public class LucerniaFeature extends DefaultFeature { } return state.getMaterial().isReplaceable(); }; - + IGNORE = (state) -> { return EndBlocks.LUCERNIA.isTreeLog(state); }; - - SPLINE = Lists.newArrayList( - new Vector3f(0.00F, 0.00F, 0.00F), - new Vector3f(0.10F, 0.35F, 0.00F), - new Vector3f(0.20F, 0.50F, 0.00F), - new Vector3f(0.30F, 0.55F, 0.00F), - new Vector3f(0.42F, 0.70F, 0.00F), - new Vector3f(0.50F, 1.00F, 0.00F) - ); - - ROOT = Lists.newArrayList( - new Vector3f(0.1F, 0.70F, 0), - new Vector3f(0.3F, 0.30F, 0), - new Vector3f(0.7F, 0.05F, 0), - new Vector3f(0.8F, -0.20F, 0) - ); + + SPLINE = Lists.newArrayList(new Vector3f(0.00F, 0.00F, 0.00F), new Vector3f(0.10F, 0.35F, 0.00F), + new Vector3f(0.20F, 0.50F, 0.00F), new Vector3f(0.30F, 0.55F, 0.00F), new Vector3f(0.42F, 0.70F, 0.00F), + new Vector3f(0.50F, 1.00F, 0.00F)); + + ROOT = Lists.newArrayList(new Vector3f(0.1F, 0.70F, 0), new Vector3f(0.3F, 0.30F, 0), + new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.20F, 0)); SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0)); } } diff --git a/src/main/java/ru/betterend/world/features/trees/MossyGlowshroomFeature.java b/src/main/java/ru/betterend/world/features/trees/MossyGlowshroomFeature.java index 0a176f2d..499f4ee9 100644 --- a/src/main/java/ru/betterend/world/features/trees/MossyGlowshroomFeature.java +++ b/src/main/java/ru/betterend/world/features/trees/MossyGlowshroomFeature.java @@ -4,11 +4,11 @@ import java.util.List; import java.util.Random; import java.util.function.Function; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -41,122 +41,128 @@ public class MossyGlowshroomFeature extends DefaultFeature { private static final SDFBinary FUNCTION; private static final SDFTranslate HEAD_POS; private static final SDFFlatWave ROOTS_ROT; - + private static final SDFPrimitive CONE1; private static final SDFPrimitive CONE2; private static final SDFPrimitive CONE_GLOW; private static final SDFPrimitive ROOTS; - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) { - BlockState down = world.getBlockState(blockPos.down()); - if (!down.isOf(EndBlocks.END_MYCELIUM) && !down.isOf(EndBlocks.END_MOSS)) return false; - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, + DefaultFeatureConfig featureConfig) { + BlockState down = world.getBlockState(blockPos.below()); + if (!down.is(EndBlocks.END_MYCELIUM) && !down.is(EndBlocks.END_MOSS)) + return false; + CONE1.setBlock(EndBlocks.MOSSY_GLOWSHROOM_CAP); CONE2.setBlock(EndBlocks.MOSSY_GLOWSHROOM_CAP); CONE_GLOW.setBlock(EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE); ROOTS.setBlock(EndBlocks.MOSSY_GLOWSHROOM.bark); - + float height = MHelper.randRange(10F, 25F, random); int count = MHelper.floor(height / 4); List spline = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, count); SplineHelper.offsetParts(spline, random, 1F, 0, 1F); SDF sdf = SplineHelper.buildSDF(spline, 2.1F, 1.5F, (pos) -> { - return EndBlocks.MOSSY_GLOWSHROOM.log.getDefaultState(); + return EndBlocks.MOSSY_GLOWSHROOM.log.defaultBlockState(); }); Vector3f pos = spline.get(spline.size() - 1); float scale = MHelper.randRange(0.75F, 1.1F, random); - + if (!SplineHelper.canGenerate(spline, scale, blockPos, world, REPLACE)) { return false; } BlocksHelper.setWithoutUpdate(world, blockPos, AIR); - + CENTER.set(blockPos.getX(), 0, blockPos.getZ()); HEAD_POS.setTranslate(pos.getX(), pos.getY(), pos.getZ()); ROOTS_ROT.setAngle(random.nextFloat() * MHelper.PI2); FUNCTION.setSourceA(sdf); - - new SDFScale().setScale(scale) - .setSource(FUNCTION) - .setReplaceFunction(REPLACE) - .addPostProcess((info) -> { - if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getState())) { - if (random.nextBoolean() && info.getStateUp().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) { - info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.getDefaultState().with(MossyGlowshroomCapBlock.TRANSITION, true)); - return info.getState(); - } - else if (!EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateUp()) || !EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown())) { - info.setState(EndBlocks.MOSSY_GLOWSHROOM.bark.getDefaultState()); - return info.getState(); - } - } - else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) { - if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown().getBlock())) { - info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.getDefaultState().with(MossyGlowshroomCapBlock.TRANSITION, true)); - return info.getState(); - } - - info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.getDefaultState()); - return info.getState(); - } - else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) { - for (Direction dir: BlocksHelper.HORIZONTAL) { - if (info.getState(dir) == AIR) { - info.setBlockPos(info.getPos().offset(dir), EndBlocks.MOSSY_GLOWSHROOM_FUR.getDefaultState().with(FurBlock.FACING, dir)); - } - } - - if (info.getStateDown().getBlock() != EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) { - info.setBlockPos(info.getPos().down(), EndBlocks.MOSSY_GLOWSHROOM_FUR.getDefaultState().with(FurBlock.FACING, Direction.DOWN)); - } - } + + new SDFScale().setScale(scale).setSource(FUNCTION).setReplaceFunction(REPLACE).addPostProcess((info) -> { + if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getState())) { + if (random.nextBoolean() && info.getStateUp().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) { + info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState() + .with(MossyGlowshroomCapBlock.TRANSITION, true)); return info.getState(); - }) - .fillRecursive(world, blockPos); - + } else if (!EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateUp()) + || !EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown())) { + info.setState(EndBlocks.MOSSY_GLOWSHROOM.bark.defaultBlockState()); + return info.getState(); + } + } else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) { + if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown().getBlock())) { + info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState() + .with(MossyGlowshroomCapBlock.TRANSITION, true)); + return info.getState(); + } + + info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState()); + return info.getState(); + } else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) { + for (Direction dir : BlocksHelper.HORIZONTAL) { + if (info.getState(dir) == AIR) { + info.setBlockPos(info.getPos().offset(dir), + EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().with(FurBlock.FACING, dir)); + } + } + + if (info.getStateDown().getBlock() != EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) { + info.setBlockPos(info.getPos().below(), + EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().with(FurBlock.FACING, Direction.DOWN)); + } + } + return info.getState(); + }).fillRecursive(world, blockPos); + return true; } - + static { SDFCappedCone cone1 = new SDFCappedCone().setHeight(2.5F).setRadius1(1.5F).setRadius2(2.5F); SDFCappedCone cone2 = new SDFCappedCone().setHeight(3F).setRadius1(2.5F).setRadius2(13F); SDF posedCone2 = new SDFTranslate().setTranslate(0, 5, 0).setSource(cone2); - SDF posedCone3 = new SDFTranslate().setTranslate(0, 12F, 0).setSource(new SDFScale().setScale(2).setSource(cone2)); + SDF posedCone3 = new SDFTranslate().setTranslate(0, 12F, 0) + .setSource(new SDFScale().setScale(2).setSource(cone2)); SDF upCone = new SDFSubtraction().setSourceA(posedCone2).setSourceB(posedCone3); SDF wave = new SDFFlatWave().setRaysCount(12).setIntensity(1.3F).setSource(upCone); SDF cones = new SDFSmoothUnion().setRadius(3).setSourceA(cone1).setSourceB(wave); - + CONE1 = cone1; CONE2 = cone2; - + SDF innerCone = new SDFTranslate().setTranslate(0, 1.25F, 0).setSource(upCone); innerCone = new SDFScale3D().setScale(1.2F, 1F, 1.2F).setSource(innerCone); cones = new SDFUnion().setSourceA(cones).setSourceB(innerCone); - + SDF glowCone = new SDFCappedCone().setHeight(3F).setRadius1(2F).setRadius2(12.5F); CONE_GLOW = (SDFPrimitive) glowCone; glowCone = new SDFTranslate().setTranslate(0, 4.25F, 0).setSource(glowCone); glowCone = new SDFSubtraction().setSourceA(glowCone).setSourceB(posedCone3); - + cones = new SDFUnion().setSourceA(cones).setSourceB(glowCone); - + OpenSimplexNoise noise = new OpenSimplexNoise(1234); cones = new SDFCoordModify().setFunction((pos) -> { float dist = MHelper.length(pos.getX(), pos.getZ()); - float y = pos.getY() + (float) noise.eval(pos.getX() * 0.1 + CENTER.getX(), pos.getZ() * 0.1 + CENTER.getZ()) * dist * 0.3F - dist * 0.15F; + float y = pos.getY() + + (float) noise.eval(pos.getX() * 0.1 + CENTER.getX(), pos.getZ() * 0.1 + CENTER.getZ()) * dist + * 0.3F + - dist * 0.15F; pos.set(pos.getX(), y, pos.getZ()); }).setSource(cones); - - HEAD_POS = (SDFTranslate) new SDFTranslate().setSource(new SDFTranslate().setTranslate(0, 2.5F, 0).setSource(cones)); - + + HEAD_POS = (SDFTranslate) new SDFTranslate() + .setSource(new SDFTranslate().setTranslate(0, 2.5F, 0).setSource(cones)); + SDF roots = new SDFSphere().setRadius(4F); ROOTS = (SDFPrimitive) roots; roots = new SDFScale3D().setScale(1, 0.7F, 1).setSource(roots); ROOTS_ROT = (SDFFlatWave) new SDFFlatWave().setRaysCount(5).setIntensity(1.5F).setSource(roots); - - FUNCTION = new SDFSmoothUnion().setRadius(4).setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS_ROT)); - + + FUNCTION = new SDFSmoothUnion().setRadius(4) + .setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS_ROT)); + REPLACE = (state) -> { if (state.isIn(EndTags.END_GROUND)) { return true; diff --git a/src/main/java/ru/betterend/world/features/trees/PythadendronTreeFeature.java b/src/main/java/ru/betterend/world/features/trees/PythadendronTreeFeature.java index 5e946403..d3e9ddf0 100644 --- a/src/main/java/ru/betterend/world/features/trees/PythadendronTreeFeature.java +++ b/src/main/java/ru/betterend/world/features/trees/PythadendronTreeFeature.java @@ -4,13 +4,13 @@ import java.util.List; import java.util.Random; import java.util.function.Function; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -33,71 +33,78 @@ public class PythadendronTreeFeature extends DefaultFeature { private static final Function REPLACE; private static final Function IGNORE; private static final Function POST; - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (world.getBlockState(pos.down()).getBlock() != EndBlocks.CHORUS_NYLIUM) return false; + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (world.getBlockState(pos.below()).getBlock() != EndBlocks.CHORUS_NYLIUM) + return false; BlocksHelper.setWithoutUpdate(world, pos, AIR); - + float size = MHelper.randRange(10, 20, random); List spline = SplineHelper.makeSpline(0, 0, 0, 0, size, 0, 4); SplineHelper.offsetParts(spline, random, 0.7F, 0, 0.7F); Vector3f last = spline.get(spline.size() - 1); - + int depth = MHelper.floor((size - 10F) * 3F / 10F + 1F); float bsize = (10F - (size - 10F)) / 10F + 1.5F; - branch(last.getX(), last.getY(), last.getZ(), size * bsize, MHelper.randRange(0, MHelper.PI2, random), random, depth, world, pos); - + branch(last.getX(), last.getY(), last.getZ(), size * bsize, MHelper.randRange(0, MHelper.PI2, random), random, + depth, world, pos); + SDF function = SplineHelper.buildSDF(spline, 1.7F, 1.1F, (bpos) -> { - return EndBlocks.PYTHADENDRON.bark.getDefaultState(); + return EndBlocks.PYTHADENDRON.bark.defaultBlockState(); }); function.setReplaceFunction(REPLACE); function.addPostProcess(POST); function.fillRecursive(world, pos); - + return true; } - - private void branch(float x, float y, float z, float size, float angle, Random random, int depth, StructureWorldAccess world, BlockPos pos) { - if (depth == 0) return; - + + private void branch(float x, float y, float z, float size, float angle, Random random, int depth, + StructureWorldAccess world, BlockPos pos) { + if (depth == 0) + return; + float dx = (float) Math.cos(angle) * size * 0.15F; float dz = (float) Math.sin(angle) * size * 0.15F; - + float x1 = x + dx; float z1 = z + dz; float x2 = x - dx; float z2 = z - dz; - + List spline = SplineHelper.makeSpline(x, y, z, x1, y, z1, 5); SplineHelper.powerOffset(spline, size * MHelper.randRange(1.0F, 2.0F, random), 4); SplineHelper.offsetParts(spline, random, 0.3F, 0, 0.3F); Vector3f pos1 = spline.get(spline.size() - 1); - - boolean s1 = SplineHelper.fillSpline(spline, world, EndBlocks.PYTHADENDRON.bark.getDefaultState(), pos, REPLACE); - + + boolean s1 = SplineHelper.fillSpline(spline, world, EndBlocks.PYTHADENDRON.bark.defaultBlockState(), pos, + REPLACE); + spline = SplineHelper.makeSpline(x, y, z, x2, y, z2, 5); SplineHelper.powerOffset(spline, size * MHelper.randRange(1.0F, 2.0F, random), 4); SplineHelper.offsetParts(spline, random, 0.3F, 0, 0.3F); Vector3f pos2 = spline.get(spline.size() - 1); - - boolean s2 = SplineHelper.fillSpline(spline, world, EndBlocks.PYTHADENDRON.bark.getDefaultState(), pos, REPLACE); - + + boolean s2 = SplineHelper.fillSpline(spline, world, EndBlocks.PYTHADENDRON.bark.defaultBlockState(), pos, + REPLACE); + OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt()); if (depth < 3) { if (s1) { - leavesBall(world, pos.add(pos1.getX(), pos1.getY(), pos1.getZ()), random, noise); + leavesBall(world, pos.offset(pos1.getX(), pos1.getY(), pos1.getZ()), random, noise); } if (s2) { - leavesBall(world, pos.add(pos2.getX(), pos2.getY(), pos2.getZ()), random, noise); + leavesBall(world, pos.offset(pos2.getX(), pos2.getY(), pos2.getZ()), random, noise); } } - + float size1 = size * MHelper.randRange(0.75F, 0.95F, random); float size2 = size * MHelper.randRange(0.75F, 0.95F, random); float angle1 = angle + (float) Math.PI * 0.5F + MHelper.randRange(-0.1F, 0.1F, random); float angle2 = angle + (float) Math.PI * 0.5F + MHelper.randRange(-0.1F, 0.1F, random); - + if (s1) { branch(pos1.getX(), pos1.getY(), pos1.getZ(), size1, angle1, random, depth - 1, world, pos); } @@ -105,25 +112,31 @@ public class PythadendronTreeFeature extends DefaultFeature { branch(pos2.getX(), pos2.getY(), pos2.getZ(), size2, angle2, random, depth - 1, world, pos); } } - + private void leavesBall(StructureWorldAccess world, BlockPos pos, Random random, OpenSimplexNoise noise) { float radius = MHelper.randRange(4.5F, 6.5F, random); - - SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.PYTHADENDRON_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 6)); + + SDF sphere = new SDFSphere().setRadius(radius) + .setBlock(EndBlocks.PYTHADENDRON_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6)); sphere = new SDFScale3D().setScale(1, 0.6F, 1).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { return random.nextFloat() * 3F - 1.5F; }).setSource(sphere); - sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere)); - Mutable mut = new Mutable(); + sphere = new SDFDisplacement().setFunction((vec) -> { + return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; + }).setSource(sphere); + sphere = new SDFDisplacement().setFunction((vec) -> { + return random.nextFloat() * 3F - 1.5F; + }).setSource(sphere); + sphere = new SDFSubtraction().setSourceA(sphere) + .setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere)); + MutableBlockPos mut = new MutableBlockPos(); sphere.addPostProcess((info) -> { if (random.nextInt(5) == 0) { - for (Direction dir: Direction.values()) { + for (Direction dir : Direction.values()) { BlockState state = info.getState(dir, 2); if (state.isAir()) { return info.getState(); } } - info.setState(EndBlocks.PYTHADENDRON.bark.getDefaultState()); + info.setState(EndBlocks.PYTHADENDRON.bark.defaultBlockState()); for (int x = -6; x < 7; x++) { int ax = Math.abs(x); mut.setX(x + info.getPos().getX()); @@ -137,7 +150,7 @@ public class PythadendronTreeFeature extends DefaultFeature { mut.setY(y + info.getPos().getY()); BlockState state = info.getState(mut); if (state.getBlock() instanceof LeavesBlock) { - int distance = state.get(LeavesBlock.DISTANCE); + int distance = state.getValue(LeavesBlock.DISTANCE); if (d < distance) { info.setState(mut, state.with(LeavesBlock.DISTANCE, d)); } @@ -151,7 +164,7 @@ public class PythadendronTreeFeature extends DefaultFeature { }); sphere.fillRecursiveIgnore(world, pos, IGNORE); } - + static { REPLACE = (state) -> { if (state.isIn(EndTags.END_GROUND)) { @@ -165,14 +178,15 @@ public class PythadendronTreeFeature extends DefaultFeature { } return state.getMaterial().isReplaceable(); }; - + IGNORE = (state) -> { return EndBlocks.PYTHADENDRON.isTreeLog(state); }; - + POST = (info) -> { - if (EndBlocks.PYTHADENDRON.isTreeLog(info.getStateUp()) && EndBlocks.PYTHADENDRON.isTreeLog(info.getStateDown())) { - return EndBlocks.PYTHADENDRON.log.getDefaultState(); + if (EndBlocks.PYTHADENDRON.isTreeLog(info.getStateUp()) + && EndBlocks.PYTHADENDRON.isTreeLog(info.getStateDown())) { + return EndBlocks.PYTHADENDRON.log.defaultBlockState(); } return info.getState(); }; diff --git a/src/main/java/ru/betterend/world/features/trees/TenaneaFeature.java b/src/main/java/ru/betterend/world/features/trees/TenaneaFeature.java index 5fba3b10..1ebf07b3 100644 --- a/src/main/java/ru/betterend/world/features/trees/TenaneaFeature.java +++ b/src/main/java/ru/betterend/world/features/trees/TenaneaFeature.java @@ -6,13 +6,13 @@ import java.util.function.Function; import com.google.common.collect.Lists; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -39,14 +39,16 @@ public class TenaneaFeature extends DefaultFeature { private static final Function REPLACE; private static final Function IGNORE; private static final List SPLINE; - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false; - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)) + return false; + float size = MHelper.randRange(7, 10, random); int count = (int) (size * 0.45F); - float var = MHelper.PI2 / (float) (count * 3); + float var = MHelper.PI2 / (float) (count * 3); float start = MHelper.randRange(0, MHelper.PI2, random); for (int i = 0; i < count; i++) { float angle = (float) i / (float) count * MHelper.PI2 + MHelper.randRange(0, var, random) + start; @@ -54,63 +56,72 @@ public class TenaneaFeature extends DefaultFeature { SplineHelper.rotateSpline(spline, angle); SplineHelper.scale(spline, size + MHelper.randRange(0, size * 0.5F, random)); SplineHelper.offsetParts(spline, random, 1F, 0, 1F); - SplineHelper.fillSpline(spline, world, EndBlocks.TENANEA.bark.getDefaultState(), pos, REPLACE); + SplineHelper.fillSpline(spline, world, EndBlocks.TENANEA.bark.defaultBlockState(), pos, REPLACE); Vector3f last = spline.get(spline.size() - 1); float leavesRadius = (size * 0.3F + MHelper.randRange(0.8F, 1.5F, random)) * 1.4F; OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong()); - leavesBall(world, pos.add(last.getX(), last.getY(), last.getZ()), leavesRadius, random, noise); + leavesBall(world, pos.offset(last.getX(), last.getY(), last.getZ()), leavesRadius, random, noise); } - + return true; } - - private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) { - SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.TENANEA_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 6)); + + private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random, + OpenSimplexNoise noise) { + SDF sphere = new SDFSphere().setRadius(radius) + .setBlock(EndBlocks.TENANEA_LEAVES.defaultBlockState().with(LeavesBlock.DISTANCE, 6)); SDF sub = new SDFScale().setScale(5).setSource(sphere); sub = new SDFTranslate().setTranslate(0, -radius * 5, 0).setSource(sub); sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub); sphere = new SDFScale3D().setScale(1, 0.75F, 1).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 2F; }).setSource(sphere); - sphere = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-1.5F, 1.5F, random); }).setSource(sphere); - - Mutable mut = new Mutable(); - for (Direction d1: BlocksHelper.HORIZONTAL) { + sphere = new SDFDisplacement().setFunction((vec) -> { + return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 2F; + }).setSource(sphere); + sphere = new SDFDisplacement().setFunction((vec) -> { + return MHelper.randRange(-1.5F, 1.5F, random); + }).setSource(sphere); + + MutableBlockPos mut = new MutableBlockPos(); + for (Direction d1 : BlocksHelper.HORIZONTAL) { BlockPos p = mut.set(pos).move(Direction.UP).move(d1).toImmutable(); - BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TENANEA.bark.getDefaultState()); - for (Direction d2: BlocksHelper.HORIZONTAL) { + BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TENANEA.bark.defaultBlockState()); + for (Direction d2 : BlocksHelper.HORIZONTAL) { mut.set(p).move(Direction.UP).move(d2); - BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TENANEA.bark.getDefaultState()); + BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TENANEA.bark.defaultBlockState()); } } - - BlockState top = EndBlocks.TENANEA_FLOWERS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP); - BlockState middle = EndBlocks.TENANEA_FLOWERS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE); - BlockState bottom = EndBlocks.TENANEA_FLOWERS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM); - BlockState outer = EndBlocks.TENANEA_OUTER_LEAVES.getDefaultState(); - + + BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, + TripleShape.TOP); + BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, + TripleShape.MIDDLE); + BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, + TripleShape.BOTTOM); + BlockState outer = EndBlocks.TENANEA_OUTER_LEAVES.defaultBlockState(); + List support = Lists.newArrayList(); sphere.addPostProcess((info) -> { if (random.nextInt(6) == 0 && info.getStateDown().isAir()) { - BlockPos d = info.getPos().down(); + BlockPos d = info.getPos().below(); support.add(d); } if (random.nextInt(5) == 0) { - for (Direction dir: Direction.values()) { + for (Direction dir : Direction.values()) { BlockState state = info.getState(dir, 2); if (state.isAir()) { return info.getState(); } } - info.setState(EndBlocks.TENANEA.bark.getDefaultState()); + info.setState(EndBlocks.TENANEA.bark.defaultBlockState()); } - + MHelper.shuffle(DIRECTIONS, random); - for (Direction d: DIRECTIONS) { + for (Direction d : DIRECTIONS) { if (info.getState(d).isAir()) { info.setBlockPos(info.getPos().offset(d), outer.with(FurBlock.FACING, d)); } } - + if (EndBlocks.TENANEA.isTreeLog(info.getState())) { for (int x = -6; x < 7; x++) { int ax = Math.abs(x); @@ -125,7 +136,7 @@ public class TenaneaFeature extends DefaultFeature { mut.setY(y + info.getPos().getY()); BlockState state = info.getState(mut); if (state.getBlock() instanceof LeavesBlock) { - int distance = state.get(LeavesBlock.DISTANCE); + int distance = state.getValue(LeavesBlock.DISTANCE); if (d < distance) { info.setState(mut, state.with(LeavesBlock.DISTANCE, d)); } @@ -139,20 +150,19 @@ public class TenaneaFeature extends DefaultFeature { }); sphere.fillRecursiveIgnore(world, pos, IGNORE); BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.TENANEA.bark); - + support.forEach((bpos) -> { BlockState state = world.getBlockState(bpos); - if (state.isAir() || state.isOf(EndBlocks.TENANEA_OUTER_LEAVES)) { + if (state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) { int count = MHelper.randRange(3, 8, random); mut.set(bpos); - if (world.getBlockState(mut.up()).isOf(EndBlocks.TENANEA_LEAVES)) { + if (world.getBlockState(mut.up()).is(EndBlocks.TENANEA_LEAVES)) { BlocksHelper.setWithoutUpdate(world, mut, top); for (int i = 1; i < count; i++) { mut.setY(mut.getY() - 1); - if (world.isAir(mut.down())) { + if (world.isAir(mut.below())) { BlocksHelper.setWithoutUpdate(world, mut, middle); - } - else { + } else { break; } } @@ -161,7 +171,7 @@ public class TenaneaFeature extends DefaultFeature { } }); } - + static { REPLACE = (state) -> { if (state.isIn(EndTags.END_GROUND)) { @@ -175,18 +185,13 @@ public class TenaneaFeature extends DefaultFeature { } return state.getMaterial().isReplaceable(); }; - + IGNORE = (state) -> { return EndBlocks.TENANEA.isTreeLog(state); }; - - SPLINE = Lists.newArrayList( - new Vector3f(0.00F, 0.00F, 0.00F), - new Vector3f(0.10F, 0.35F, 0.00F), - new Vector3f(0.20F, 0.50F, 0.00F), - new Vector3f(0.30F, 0.55F, 0.00F), - new Vector3f(0.42F, 0.70F, 0.00F), - new Vector3f(0.50F, 1.00F, 0.00F) - ); + + SPLINE = Lists.newArrayList(new Vector3f(0.00F, 0.00F, 0.00F), new Vector3f(0.10F, 0.35F, 0.00F), + new Vector3f(0.20F, 0.50F, 0.00F), new Vector3f(0.30F, 0.55F, 0.00F), new Vector3f(0.42F, 0.70F, 0.00F), + new Vector3f(0.50F, 1.00F, 0.00F)); } } diff --git a/src/main/java/ru/betterend/world/features/trees/UmbrellaTreeFeature.java b/src/main/java/ru/betterend/world/features/trees/UmbrellaTreeFeature.java index afd979bd..fe0351db 100644 --- a/src/main/java/ru/betterend/world/features/trees/UmbrellaTreeFeature.java +++ b/src/main/java/ru/betterend/world/features/trees/UmbrellaTreeFeature.java @@ -6,13 +6,13 @@ import java.util.function.Function; import com.google.common.collect.Lists; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.MathHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -38,77 +38,83 @@ public class UmbrellaTreeFeature extends DefaultFeature { private static final Function REPLACE; private static final List SPLINE; private static final List ROOT; - + @Override - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { - if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false; - - BlockState wood = EndBlocks.UMBRELLA_TREE.bark.getDefaultState(); - BlockState membrane = EndBlocks.UMBRELLA_TREE_MEMBRANE.getDefaultState().with(UmbrellaTreeMembraneBlock.COLOR, 1); - BlockState center = EndBlocks.UMBRELLA_TREE_MEMBRANE.getDefaultState().with(UmbrellaTreeMembraneBlock.COLOR, 0); - BlockState fruit = EndBlocks.UMBRELLA_TREE_CLUSTER.getDefaultState().with(UmbrellaTreeClusterBlock.NATURAL, true); - + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, + DefaultFeatureConfig config) { + if (!world.getBlockState(pos.below()).getBlock().isIn(EndTags.END_GROUND)) + return false; + + BlockState wood = EndBlocks.UMBRELLA_TREE.bark.defaultBlockState(); + BlockState membrane = EndBlocks.UMBRELLA_TREE_MEMBRANE.defaultBlockState().with(UmbrellaTreeMembraneBlock.COLOR, + 1); + BlockState center = EndBlocks.UMBRELLA_TREE_MEMBRANE.defaultBlockState().with(UmbrellaTreeMembraneBlock.COLOR, + 0); + BlockState fruit = EndBlocks.UMBRELLA_TREE_CLUSTER.defaultBlockState().with(UmbrellaTreeClusterBlock.NATURAL, + true); + float size = MHelper.randRange(10, 20, random); int count = (int) (size * 0.15F); - float var = MHelper.PI2 / (float) (count * 3); + float var = MHelper.PI2 / (float) (count * 3); float start = MHelper.randRange(0, MHelper.PI2, random); SDF sdf = null; List
centers = Lists.newArrayList(); - + float scale = 1; if (config != null) { scale = MHelper.randRange(1F, 1.7F, random); } - + for (int i = 0; i < count; i++) { float angle = (float) i / (float) count * MHelper.PI2 + MHelper.randRange(0, var, random) + start; List spline = SplineHelper.copySpline(SPLINE); float sizeXZ = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.7F; SplineHelper.scale(spline, sizeXZ, sizeXZ * MHelper.randRange(1F, 2F, random), sizeXZ); - //SplineHelper.offset(spline, new Vector3f((20 - size) * 0.2F, 0, 0)); + // SplineHelper.offset(spline, new Vector3f((20 - size) * 0.2F, 0, 0)); SplineHelper.rotateSpline(spline, angle); SplineHelper.offsetParts(spline, random, 0.5F, 0, 0.5F); - + if (SplineHelper.canGenerate(spline, pos, world, REPLACE)) { float rScale = (scale - 1) * 0.4F + 1; SDF branch = SplineHelper.buildSDF(spline, 1.2F * rScale, 0.8F * rScale, (bpos) -> { return wood; }); - + Vector3f vec = spline.get(spline.size() - 1); float radius = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.4F; - + sdf = (sdf == null) ? branch : new SDFUnion().setSourceA(sdf).setSourceB(branch); SDF mem = makeMembrane(world, radius, random, membrane, center); - + float px = MHelper.floor(vec.getX()) + 0.5F; float py = MHelper.floor(vec.getY()) + 0.5F; float pz = MHelper.floor(vec.getZ()) + 0.5F; mem = new SDFTranslate().setTranslate(px, py, pz).setSource(mem); sdf = new SDFSmoothUnion().setRadius(2).setSourceA(sdf).setSourceB(mem); - centers.add(new Center(pos.getX() + (double) (px * scale), pos.getY() + (double) (py * scale), pos.getZ() + (double) (pz * scale), radius * scale)); - + centers.add(new Center(pos.getX() + (double) (px * scale), pos.getY() + (double) (py * scale), + pos.getZ() + (double) (pz * scale), radius * scale)); + vec = spline.get(0); } } - + if (sdf == null) { return false; } - + if (scale > 1) { sdf = new SDFScale().setScale(scale).setSource(sdf); } - + sdf.setReplaceFunction(REPLACE).addPostProcess((info) -> { - if (EndBlocks.UMBRELLA_TREE.isTreeLog(info.getStateUp()) && EndBlocks.UMBRELLA_TREE.isTreeLog(info.getStateDown())) { - return EndBlocks.UMBRELLA_TREE.log.getDefaultState(); - } - else if (info.getState().equals(membrane)) { + if (EndBlocks.UMBRELLA_TREE.isTreeLog(info.getStateUp()) + && EndBlocks.UMBRELLA_TREE.isTreeLog(info.getStateDown())) { + return EndBlocks.UMBRELLA_TREE.log.defaultBlockState(); + } else if (info.getState().equals(membrane)) { Center min = centers.get(0); double d = Double.MAX_VALUE; BlockPos bpos = info.getPos(); - for (Center c: centers) { + for (Center c : centers) { double d2 = c.distance(bpos.getX(), bpos.getZ()); if (d2 < d) { d = d2; @@ -116,14 +122,14 @@ public class UmbrellaTreeFeature extends DefaultFeature { } } int color = MHelper.floor(d / min.radius * 7); - color = MathHelper.clamp(color, 1, 7); + color = Mth.clamp(color, 1, 7); return info.getState().with(UmbrellaTreeMembraneBlock.COLOR, color); } return info.getState(); }).fillRecursive(world, pos); makeRoots(world, pos, (size * 0.5F + 3) * scale, random, wood); - - for (Center c: centers) { + + for (Center c : centers) { if (!world.getBlockState(new BlockPos(c.px, c.py, c.pz)).isAir()) { count = MHelper.floor(MHelper.randRange(5F, 10F, random) * scale); float startAngle = random.nextFloat() * MHelper.PI2; @@ -136,99 +142,93 @@ public class UmbrellaTreeFeature extends DefaultFeature { } } } - + return true; } - + private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random, BlockState wood) { int count = (int) (radius * 1.5F); for (int i = 0; i < count; i++) { float angle = (float) i / (float) count * MHelper.PI2; float scale = radius * MHelper.randRange(0.85F, 1.15F, random); - + List branch = SplineHelper.copySpline(ROOT); SplineHelper.rotateSpline(branch, angle); SplineHelper.scale(branch, scale); Vector3f last = branch.get(branch.size() - 1); - if (world.getBlockState(pos.add(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) { + if (world.getBlockState(pos.offset(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) { SplineHelper.fillSplineForce(branch, world, wood, pos, REPLACE); } } } - - private SDF makeMembrane(StructureWorldAccess world, float radius, Random random, BlockState membrane, BlockState center) { + + private SDF makeMembrane(StructureWorldAccess world, float radius, Random random, BlockState membrane, + BlockState center) { SDF sphere = new SDFSphere().setRadius(radius).setBlock(membrane); SDF sub = new SDFTranslate().setTranslate(0, -4, 0).setSource(sphere); sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub); sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere); sphere = new SDFTranslate().setTranslate(0, 1 - radius * 0.5F, 0).setSource(sphere); - + float angle = random.nextFloat() * MHelper.PI2; int count = (int) MHelper.randRange(radius, radius * 2, random); if (count < 5) { count = 5; } sphere = new SDFFlatWave().setAngle(angle).setRaysCount(count).setIntensity(0.6F).setSource(sphere); - + SDF cent = new SDFSphere().setRadius(2.5F).setBlock(center); sphere = new SDFUnion().setSourceA(sphere).setSourceB(cent); - + return sphere; } - - private void makeFruits(StructureWorldAccess world, double px, double py, double pz, BlockState fruit, float scale) { - Mutable mut = new Mutable().set(px, py, pz); + + private void makeFruits(StructureWorldAccess world, double px, double py, double pz, BlockState fruit, + float scale) { + MutableBlockPos mut = new MutableBlockPos().set(px, py, pz); for (int i = 0; i < 8; i++) { mut.move(Direction.DOWN); if (world.isAir(mut)) { BlockState state = world.getBlockState(mut.up()); - if (state.isOf(EndBlocks.UMBRELLA_TREE_MEMBRANE) && state.get(UmbrellaTreeMembraneBlock.COLOR) < 2) { + if (state.is(EndBlocks.UMBRELLA_TREE_MEMBRANE) && state.getValue(UmbrellaTreeMembraneBlock.COLOR) < 2) { BlocksHelper.setWithoutUpdate(world, mut, fruit); } break; } } } - + static { - SPLINE = Lists.newArrayList( - new Vector3f(0.00F, 0.00F, 0.00F), - new Vector3f(0.10F, 0.35F, 0.00F), - new Vector3f(0.20F, 0.50F, 0.00F), - new Vector3f(0.30F, 0.55F, 0.00F), - new Vector3f(0.42F, 0.70F, 0.00F), - new Vector3f(0.50F, 1.00F, 0.00F) - ); - - ROOT = Lists.newArrayList( - new Vector3f(0.1F, 0.70F, 0), - new Vector3f(0.3F, 0.30F, 0), - new Vector3f(0.7F, 0.05F, 0), - new Vector3f(0.8F, -0.20F, 0) - ); + SPLINE = Lists.newArrayList(new Vector3f(0.00F, 0.00F, 0.00F), new Vector3f(0.10F, 0.35F, 0.00F), + new Vector3f(0.20F, 0.50F, 0.00F), new Vector3f(0.30F, 0.55F, 0.00F), new Vector3f(0.42F, 0.70F, 0.00F), + new Vector3f(0.50F, 1.00F, 0.00F)); + + ROOT = Lists.newArrayList(new Vector3f(0.1F, 0.70F, 0), new Vector3f(0.3F, 0.30F, 0), + new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.20F, 0)); SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0)); - + REPLACE = (state) -> { - if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.isOf(EndBlocks.UMBRELLA_TREE_MEMBRANE)) { + if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) + || state.is(EndBlocks.UMBRELLA_TREE_MEMBRANE)) { return true; } return state.getMaterial().isReplaceable(); }; } - + private class Center { final double px; final double py; final double pz; final float radius; - + Center(double x, double y, double z, float radius) { this.px = x; this.py = y; this.pz = z; this.radius = radius; } - + double distance(float x, float z) { return MHelper.length(px - x, pz - z); } diff --git a/src/main/java/ru/betterend/world/generator/BetterEndBiomeSource.java b/src/main/java/ru/betterend/world/generator/BetterEndBiomeSource.java index 2c808ebe..b8ef0b75 100644 --- a/src/main/java/ru/betterend/world/generator/BetterEndBiomeSource.java +++ b/src/main/java/ru/betterend/world/generator/BetterEndBiomeSource.java @@ -7,7 +7,7 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.util.math.noise.SimplexNoiseSampler; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; import net.minecraft.util.registry.RegistryLookupCodec; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeKeys; @@ -40,14 +40,14 @@ public class BetterEndBiomeSource extends BiomeSource { public BetterEndBiomeSource(Registry biomeRegistry, long seed) { super(getBiomes(biomeRegistry)); - + this.mapLand = new BiomeMap(seed, GeneratorOptions.getBiomeSizeLand(), EndBiomes.LAND_BIOMES); this.mapVoid = new BiomeMap(seed, GeneratorOptions.getBiomeSizeVoid(), EndBiomes.VOID_BIOMES); this.centerBiome = biomeRegistry.getOrThrow(BiomeKeys.THE_END); this.barrens = biomeRegistry.getOrThrow(BiomeKeys.END_BARRENS); this.biomeRegistry = biomeRegistry; this.seed = seed; - + ChunkRandom chunkRandom = new ChunkRandom(seed); chunkRandom.consume(17292); this.noise = new SimplexNoiseSampler(chunkRandom); @@ -56,7 +56,7 @@ public class BetterEndBiomeSource extends BiomeSource { EndTags.addTerrainTags(biomeRegistry); FeaturesHelper.addFeatures(biomeRegistry); } - + private static List getBiomes(Registry biomeRegistry) { List list = Lists.newArrayList(); biomeRegistry.forEach((biome) -> { @@ -72,53 +72,53 @@ public class BetterEndBiomeSource extends BiomeSource { boolean hasVoid = !GeneratorOptions.useNewGenerator() || !GeneratorOptions.noRingVoid(); long i = (long) biomeX * (long) biomeX; long j = (long) biomeZ * (long) biomeZ; - + long dist = i + j; if (hasVoid) { - if (dist <= 65536L) return this.centerBiome; - } - else if (dist <= 625L) { + if (dist <= 65536L) + return this.centerBiome; + } else if (dist <= 625L) { dist += noise.sample(i * 0.2, j * 0.2) * 10; if (dist <= 625L) { return this.centerBiome; } } - + if (biomeX == 0 && biomeZ == 0) { mapLand.clearCache(); mapVoid.clearCache(); } - + if (GeneratorOptions.useNewGenerator()) { if (TerrainGenerator.isLand(biomeX, biomeZ)) { return mapLand.getBiome(biomeX << 2, biomeZ << 2).getActualBiome(); - } - else { + } else { return mapVoid.getBiome(biomeX << 2, biomeZ << 2).getActualBiome(); } - } - else { - float height = TheEndBiomeSource.getNoiseAt(noise, (biomeX >> 1) + 1, (biomeZ >> 1) + 1) + (float) SMALL_NOISE.eval(biomeX, biomeZ) * 5; - + } else { + float height = TheEndBiomeSource.getNoiseAt(noise, (biomeX >> 1) + 1, (biomeZ >> 1) + 1) + + (float) SMALL_NOISE.eval(biomeX, biomeZ) * 5; + if (height > -20F && height < -5F) { return barrens; } - - EndBiome endBiome = height < -10F ? mapVoid.getBiome(biomeX << 2, biomeZ << 2) : mapLand.getBiome(biomeX << 2, biomeZ << 2); + + EndBiome endBiome = height < -10F ? mapVoid.getBiome(biomeX << 2, biomeZ << 2) + : mapLand.getBiome(biomeX << 2, biomeZ << 2); return endBiome.getActualBiome(); } } - + public Biome getLandBiome(int biomeX, int biomeY, int biomeZ) { boolean hasVoid = !GeneratorOptions.useNewGenerator() || !GeneratorOptions.noRingVoid(); long i = (long) biomeX * (long) biomeX; long j = (long) biomeZ * (long) biomeZ; - + long dist = i + j; if (hasVoid) { - if (dist <= 65536L) return this.centerBiome; - } - else if (dist <= 625L) { + if (dist <= 65536L) + return this.centerBiome; + } else if (dist <= 625L) { dist += noise.sample(i * 0.2, j * 0.2) * 10; if (dist <= 625L) { return this.centerBiome; diff --git a/src/main/java/ru/betterend/world/generator/BiomePicker.java b/src/main/java/ru/betterend/world/generator/BiomePicker.java index 050ab133..159f4a53 100644 --- a/src/main/java/ru/betterend/world/generator/BiomePicker.java +++ b/src/main/java/ru/betterend/world/generator/BiomePicker.java @@ -7,49 +7,49 @@ import java.util.Set; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import ru.betterend.world.biome.EndBiome; public class BiomePicker { - private final Set immutableIDs = Sets.newHashSet(); + private final Set immutableIDs = Sets.newHashSet(); private final List biomes = Lists.newArrayList(); private float maxChanceUnmutable = 0; private float maxChance = 0; private int biomeCount = 0; private WeighTree tree; - + public void addBiome(EndBiome biome) { maxChance = biome.mutateGenChance(maxChance); immutableIDs.add(biome.getID()); maxChanceUnmutable = maxChance; biomes.add(biome); - biomeCount ++; + biomeCount++; } - + public void addBiomeMutable(EndBiome biome) { biomes.add(biome); } - + public void clearMutables() { maxChance = maxChanceUnmutable; for (int i = biomes.size() - 1; i >= biomeCount; i--) { biomes.remove(i); } } - + public EndBiome getBiome(Random random) { return biomes.isEmpty() ? null : tree.getBiome(random.nextFloat() * maxChance); } - + public List getBiomes() { return biomes; } - - public boolean containsImmutable(Identifier id) { + + public boolean containsImmutable(ResourceLocation id) { return immutableIDs.contains(id); } - - public void removeMutableBiome(Identifier id) { + + public void removeMutableBiome(ResourceLocation id) { for (int i = biomeCount; i < biomes.size(); i++) { EndBiome biome = biomes.get(i); if (biome.getID().equals(id)) { @@ -58,7 +58,7 @@ public class BiomePicker { } } } - + public void rebuild() { if (biomes.isEmpty()) { return; diff --git a/src/main/java/ru/betterend/world/generator/GeneratorOptions.java b/src/main/java/ru/betterend/world/generator/GeneratorOptions.java index 6c0918ff..7db78346 100644 --- a/src/main/java/ru/betterend/world/generator/GeneratorOptions.java +++ b/src/main/java/ru/betterend/world/generator/GeneratorOptions.java @@ -1,7 +1,7 @@ package ru.betterend.world.generator; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; import ru.betterend.config.Configs; public class GeneratorOptions { @@ -26,7 +26,7 @@ public class GeneratorOptions { private static BlockPos portal = BlockPos.ORIGIN; private static boolean replacePortal; private static boolean replacePillars; - + public static void init() { biomeSizeLand = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeLand", 256); biomeSizeVoid = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeVoid", 256); @@ -35,45 +35,47 @@ public class GeneratorOptions { hasDragonFights = Configs.GENERATOR_CONFIG.getBooleanRoot("hasDragonFights", true); swapOverworldToEnd = Configs.GENERATOR_CONFIG.getBooleanRoot("swapOverworldToEnd", false); changeChorusPlant = Configs.GENERATOR_CONFIG.getBoolean("chorusPlant", "changeChorusPlant", true); - removeChorusFromVanillaBiomes = Configs.GENERATOR_CONFIG.getBoolean("chorusPlant", "removeChorusFromVanillaBiomes", true); + removeChorusFromVanillaBiomes = Configs.GENERATOR_CONFIG.getBoolean("chorusPlant", + "removeChorusFromVanillaBiomes", true); newGenerator = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "useNewGenerator", true); noRingVoid = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "noRingVoid", false); generateCentralIsland = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "generateCentralIsland", true); endCityFailChance = Configs.GENERATOR_CONFIG.getInt("customGenerator", "endCityFailChance", 5); generateObsidianPlatform = Configs.GENERATOR_CONFIG.getBooleanRoot("generateObsidianPlatform", true); - bigOptions = new LayerOptions("customGenerator.layers.bigIslands", Configs.GENERATOR_CONFIG, 300, 200, 70, 10, false); - mediumOptions = new LayerOptions("customGenerator.layers.mediumIslands", Configs.GENERATOR_CONFIG, 150, 100, 70, 20, true); - smallOptions = new LayerOptions("customGenerator.layers.smallIslands", Configs.GENERATOR_CONFIG, 60, 50, 70, 30, false); + bigOptions = new LayerOptions("customGenerator.layers.bigIslands", Configs.GENERATOR_CONFIG, 300, 200, 70, 10, + false); + mediumOptions = new LayerOptions("customGenerator.layers.mediumIslands", Configs.GENERATOR_CONFIG, 150, 100, 70, + 20, true); + smallOptions = new LayerOptions("customGenerator.layers.smallIslands", Configs.GENERATOR_CONFIG, 60, 50, 70, 30, + false); changeSpawn = Configs.GENERATOR_CONFIG.getBoolean("spawn", "changeSpawn", false); - spawn = new BlockPos( - Configs.GENERATOR_CONFIG.getInt("spawn.point", "x", 20), - Configs.GENERATOR_CONFIG.getInt("spawn.point", "y", 65), - Configs.GENERATOR_CONFIG.getInt("spawn.point", "z", 0) - ); + spawn = new BlockPos(Configs.GENERATOR_CONFIG.getInt("spawn.point", "x", 20), + Configs.GENERATOR_CONFIG.getInt("spawn.point", "y", 65), + Configs.GENERATOR_CONFIG.getInt("spawn.point", "z", 0)); replacePortal = Configs.GENERATOR_CONFIG.getBoolean("portal", "customEndPortal", true); replacePillars = Configs.GENERATOR_CONFIG.getBoolean("spikes", "customObsidianSpikes", true); } public static int getBiomeSizeLand() { - return MathHelper.clamp(biomeSizeLand, 1, 8192); + return Mth.clamp(biomeSizeLand, 1, 8192); } - + public static int getBiomeSizeVoid() { - return MathHelper.clamp(biomeSizeVoid, 1, 8192); + return Mth.clamp(biomeSizeVoid, 1, 8192); } public static boolean hasPortal() { return hasPortal; } - + public static boolean hasPillars() { return hasPillars; } - + public static boolean hasDragonFights() { return hasDragonFights; } - + public static boolean swapOverworldToEnd() { return swapOverworldToEnd; } @@ -85,23 +87,23 @@ public class GeneratorOptions { public static boolean removeChorusFromVanillaBiomes() { return removeChorusFromVanillaBiomes; } - + public static boolean noRingVoid() { return noRingVoid; } - + public static boolean useNewGenerator() { return newGenerator; } - + public static boolean hasCentralIsland() { return generateCentralIsland; } - + public static boolean generateObsidianPlatform() { return generateObsidianPlatform; } - + public static int getEndCityFailChance() { return endCityFailChance; } @@ -121,11 +123,11 @@ public class GeneratorOptions { public static void setPortalPos(BlockPos portal) { GeneratorOptions.portal = portal; } - + public static boolean replacePortal() { return replacePortal; } - + public static boolean replacePillars() { return replacePillars; } diff --git a/src/main/java/ru/betterend/world/generator/IslandLayer.java b/src/main/java/ru/betterend/world/generator/IslandLayer.java index 82a7513f..16ea3d49 100644 --- a/src/main/java/ru/betterend/world/generator/IslandLayer.java +++ b/src/main/java/ru/betterend/world/generator/IslandLayer.java @@ -8,7 +8,7 @@ import java.util.Random; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import ru.betterend.noise.OpenSimplexNoise; import ru.betterend.util.MHelper; import ru.betterend.util.sdf.SDF; @@ -22,7 +22,7 @@ public class IslandLayer { private static final Random RANDOM = new Random(); private final SDFRadialNoiseMap noise; private final SDF island; - + private final List positions = new ArrayList(9); private final Map islands = Maps.newHashMap(); private final OpenSimplexNoise density; @@ -30,33 +30,34 @@ public class IslandLayer { private int lastX = Integer.MIN_VALUE; private int lastZ = Integer.MIN_VALUE; private final LayerOptions options; - + public IslandLayer(int seed, LayerOptions options) { this.density = new OpenSimplexNoise(seed); this.options = options; this.seed = seed; - + SDF cone1 = makeCone(0, 0.4F, 0.2F, -0.3F); SDF cone2 = makeCone(0.4F, 0.5F, 0.1F, -0.1F); SDF cone3 = makeCone(0.5F, 0.45F, 0.03F, 0.0F); SDF cone4 = makeCone(0.45F, 0, 0.02F, 0.03F); - + SDF coneBottom = new SDFSmoothUnion().setRadius(0.02F).setSourceA(cone1).setSourceB(cone2); SDF coneTop = new SDFSmoothUnion().setRadius(0.02F).setSourceA(cone3).setSourceB(cone4); - noise = (SDFRadialNoiseMap) new SDFRadialNoiseMap().setSeed(seed).setRadius(0.5F).setIntensity(0.2F).setSource(coneTop); + noise = (SDFRadialNoiseMap) new SDFRadialNoiseMap().setSeed(seed).setRadius(0.5F).setIntensity(0.2F) + .setSource(coneTop); island = new SDFSmoothUnion().setRadius(0.01F).setSourceA(noise).setSourceB(coneBottom); } - + private int getSeed(int x, int z) { int h = seed + x * 374761393 + z * 668265263; h = (h ^ (h >> 13)) * 1274126177; return h ^ (h >> 16); } - + public void updatePositions(double x, double z) { int ix = MHelper.floor(x / options.distance); int iz = MHelper.floor(z / options.distance); - + if (lastX != ix || lastZ != iz) { lastX = ix; lastZ = iz; @@ -79,7 +80,7 @@ public class IslandLayer { } } } - + if (GeneratorOptions.hasCentralIsland() && ix < 4 && iz < 4 && ix > -4 && iz > -4) { List remove = Lists.newArrayList(); positions.forEach((pos) -> { @@ -94,14 +95,13 @@ public class IslandLayer { } } } - + private SDF getIsland(BlockPos pos) { SDF island = islands.get(pos); if (island == null) { if (pos.getX() == 0 && pos.getZ() == 0) { island = new SDFScale().setScale(1.3F).setSource(this.island); - } - else { + } else { RANDOM.setSeed(getSeed(pos.getX(), pos.getZ())); island = new SDFScale().setScale(RANDOM.nextFloat() + 0.5F).setSource(this.island); } @@ -110,78 +110,74 @@ public class IslandLayer { noise.setOffset(pos.getX(), pos.getZ()); return island; } - + private float getRelativeDistance(SDF sdf, BlockPos center, double px, double py, double pz) { float x = (float) (px - center.getX()) / options.scale; float y = (float) (py - center.getY()) / options.scale; float z = (float) (pz - center.getZ()) / options.scale; return sdf.getDistance(x, y, z); } - + private float calculateSDF(double x, double y, double z) { float distance = 10; - for (BlockPos pos: positions) { + for (BlockPos pos : positions) { SDF island = getIsland(pos); float dist = getRelativeDistance(island, pos, x, y, z); distance = MHelper.min(distance, dist); } return distance; } - + public float getDensity(double x, double y, double z) { return -calculateSDF(x, y, z); } - + public float getDensity(double x, double y, double z, float height) { noise.setIntensity(height); noise.setRadius(0.5F / (1 + height)); return -calculateSDF(x, y, z); } - + public void clearCache() { if (islands.size() > 128) { islands.clear(); } } - + private static SDF makeCone(float radiusBottom, float radiusTop, float height, float minY) { float hh = height * 0.5F; SDF sdf = new SDFCappedCone().setHeight(hh).setRadius1(radiusBottom).setRadius2(radiusTop); return new SDFTranslate().setTranslate(0, minY + hh, 0).setSource(sdf); } - - /*private static NativeImage loadMap(String path) { - InputStream stream = IslandLayer.class.getResourceAsStream(path); - if (stream != null) { - try { - NativeImage map = NativeImage.read(stream); - stream.close(); - return map; - } - catch (IOException e) { - BetterEnd.LOGGER.warning(e.getMessage()); - } - } - return null; - }*/ - - /*static { - NativeImage map = loadMap("/assets/" + BetterEnd.MOD_ID + "/textures/heightmaps/mountain_1.png"); - - SDF cone1 = makeCone(0, 0.4F, 0.2F, -0.3F); - SDF cone2 = makeCone(0.4F, 0.5F, 0.1F, -0.1F); - SDF cone3 = makeCone(0.5F, 0.45F, 0.03F, 0.0F); - SDF cone4 = makeCone(0.45F, 0, 0.02F, 0.03F); - - SDF coneBottom = new SDFSmoothUnion().setRadius(0.02F).setSourceA(cone1).setSourceB(cone2); - SDF coneTop = new SDFSmoothUnion().setRadius(0.02F).setSourceA(cone3).setSourceB(cone4); - - SDF map1 = new SDFHeightmap().setMap(map).setIntensity(0.3F).setSource(coneTop); - NOISE = (SDFRadialNoiseMap) new SDFRadialNoiseMap().setSource(coneTop); - - ISLAND = new SDF[] { - new SDFSmoothUnion().setRadius(0.01F).setSourceA(coneTop).setSourceB(coneBottom), - new SDFSmoothUnion().setRadius(0.01F).setSourceA(map1).setSourceB(coneBottom) - }; - }*/ + + /* + * private static NativeImage loadMap(String path) { InputStream stream = + * IslandLayer.class.getResourceAsStream(path); if (stream != null) { try { + * NativeImage map = NativeImage.read(stream); stream.close(); return map; } + * catch (IOException e) { BetterEnd.LOGGER.warning(e.getMessage()); } } return + * null; } + */ + + /* + * static { NativeImage map = loadMap("/assets/" + BetterEnd.MOD_ID + + * "/textures/heightmaps/mountain_1.png"); + * + * SDF cone1 = makeCone(0, 0.4F, 0.2F, -0.3F); SDF cone2 = makeCone(0.4F, 0.5F, + * 0.1F, -0.1F); SDF cone3 = makeCone(0.5F, 0.45F, 0.03F, 0.0F); SDF cone4 = + * makeCone(0.45F, 0, 0.02F, 0.03F); + * + * SDF coneBottom = new + * SDFSmoothUnion().setRadius(0.02F).setSourceA(cone1).setSourceB(cone2); SDF + * coneTop = new + * SDFSmoothUnion().setRadius(0.02F).setSourceA(cone3).setSourceB(cone4); + * + * SDF map1 = new + * SDFHeightmap().setMap(map).setIntensity(0.3F).setSource(coneTop); NOISE = + * (SDFRadialNoiseMap) new SDFRadialNoiseMap().setSource(coneTop); + * + * ISLAND = new SDF[] { new + * SDFSmoothUnion().setRadius(0.01F).setSourceA(coneTop).setSourceB(coneBottom), + * new SDFSmoothUnion().setRadius(0.01F).setSourceA(map1).setSourceB(coneBottom) + * }; } + */ } diff --git a/src/main/java/ru/betterend/world/generator/LayerOptions.java b/src/main/java/ru/betterend/world/generator/LayerOptions.java index 8bb35716..95371497 100644 --- a/src/main/java/ru/betterend/world/generator/LayerOptions.java +++ b/src/main/java/ru/betterend/world/generator/LayerOptions.java @@ -1,6 +1,6 @@ package ru.betterend.world.generator; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import ru.betterend.config.PathConfig; public class LayerOptions { @@ -13,8 +13,9 @@ public class LayerOptions { public final int maxY; public final long centerDist; public final boolean hasCentralIsland; - - public LayerOptions(String name, PathConfig config, float distance, float scale, int center, int heightVariation, boolean hasCentral) { + + public LayerOptions(String name, PathConfig config, float distance, float scale, int center, int heightVariation, + boolean hasCentral) { this.distance = clampDistance(config.getFloat(name, "distance[1-8192]", distance)); this.scale = clampScale(config.getFloat(name, "scale[0.1-1024]", scale)); this.center = clampCenter(config.getInt(name, "averageHeight[0-255]", center)); @@ -22,27 +23,27 @@ public class LayerOptions { this.coverage = clampCoverage(config.getFloat(name, "coverage[0-1]", 0.5F)); this.minY = this.center - this.heightVariation; this.maxY = this.center + this.heightVariation; - this.centerDist = MathHelper.floor(1000 / this.distance); + this.centerDist = Mth.floor(1000 / this.distance); this.hasCentralIsland = config.getBoolean(name, "hasCentralIsland", hasCentral); } - + private float clampDistance(float value) { - return MathHelper.clamp(value, 1, 8192); + return Mth.clamp(value, 1, 8192); } - + private float clampScale(float value) { - return MathHelper.clamp(value, 0.1F, 1024); + return Mth.clamp(value, 0.1F, 1024); } - + private float clampCoverage(float value) { - return 0.9999F - MathHelper.clamp(value, 0, 1) * 2; + return 0.9999F - Mth.clamp(value, 0, 1) * 2; } - + private int clampCenter(int value) { - return MathHelper.clamp(value, 0, 255); + return Mth.clamp(value, 0, 255); } - + private int clampVariation(int value) { - return MathHelper.clamp(value, 0, 255); + return Mth.clamp(value, 0, 255); } } diff --git a/src/main/java/ru/betterend/world/generator/TerrainGenerator.java b/src/main/java/ru/betterend/world/generator/TerrainGenerator.java index f332b4c6..00d518c7 100644 --- a/src/main/java/ru/betterend/world/generator/TerrainGenerator.java +++ b/src/main/java/ru/betterend/world/generator/TerrainGenerator.java @@ -7,7 +7,7 @@ import java.util.concurrent.locks.ReentrantLock; import com.google.common.collect.Lists; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.source.BiomeSource; import ru.betterend.noise.OpenSimplexNoise; @@ -19,17 +19,18 @@ public class TerrainGenerator { private static final double SCALE_Y = 4.0; private static final float[] COEF; private static final Point[] OFFS; - + private static IslandLayer largeIslands; private static IslandLayer mediumIslands; private static IslandLayer smallIslands; private static OpenSimplexNoise noise1; private static OpenSimplexNoise noise2; - - /*public static boolean canGenerate(int x, int z) { - return GeneratorOptions.noRingVoid() || (long) x + (long) z > CENTER; - }*/ - + + /* + * public static boolean canGenerate(int x, int z) { return + * GeneratorOptions.noRingVoid() || (long) x + (long) z > CENTER; } + */ + public static void initNoise(long seed) { Random random = new Random(seed); largeIslands = new IslandLayer(random.nextInt(), GeneratorOptions.bigOptions); @@ -38,25 +39,27 @@ public class TerrainGenerator { noise1 = new OpenSimplexNoise(random.nextInt()); noise2 = new OpenSimplexNoise(random.nextInt()); } - + public static void fillTerrainDensity(double[] buffer, int x, int z, BiomeSource biomeSource) { LOCKER.lock(); - + largeIslands.clearCache(); mediumIslands.clearCache(); smallIslands.clearCache(); - - double distortion1 = noise1.eval(x * 0.1, z * 0.1) * 20 + noise2.eval(x * 0.2, z * 0.2) * 10 + noise1.eval(x * 0.4, z * 0.4) * 5; - double distortion2 = noise2.eval(x * 0.1, z * 0.1) * 20 + noise1.eval(x * 0.2, z * 0.2) * 10 + noise2.eval(x * 0.4, z * 0.4) * 5; + + double distortion1 = noise1.eval(x * 0.1, z * 0.1) * 20 + noise2.eval(x * 0.2, z * 0.2) * 10 + + noise1.eval(x * 0.4, z * 0.4) * 5; + double distortion2 = noise2.eval(x * 0.1, z * 0.1) * 20 + noise1.eval(x * 0.2, z * 0.2) * 10 + + noise2.eval(x * 0.4, z * 0.4) * 5; double px = (double) x * SCALE_XZ + distortion1; double pz = (double) z * SCALE_XZ + distortion2; - + largeIslands.updatePositions(px, pz); mediumIslands.updatePositions(px, pz); smallIslands.updatePositions(px, pz); - + float height = getAverageDepth(biomeSource, x << 1, z << 1) * 0.5F; - + for (int y = 0; y < buffer.length; y++) { double py = (double) y * SCALE_Y; float dist = largeIslands.getDensity(px, py, pz, height); @@ -69,10 +72,10 @@ public class TerrainGenerator { } buffer[y] = dist; } - + LOCKER.unlock(); } - + private static float getAverageDepth(BiomeSource biomeSource, int x, int z) { if (getBiome(biomeSource, x, z).getDepth() < 0.1F) { return 0F; @@ -85,34 +88,37 @@ public class TerrainGenerator { } return depth; } - + private static Biome getBiome(BiomeSource biomeSource, int x, int z) { if (biomeSource instanceof BetterEndBiomeSource) { return ((BetterEndBiomeSource) biomeSource).getLandBiome(x, 0, z); } return biomeSource.getBiomeForNoiseGen(x, 0, z); } - + /** * Check if this is land + * * @param x - biome pos x * @param z - biome pos z */ public static boolean isLand(int x, int z) { LOCKER.lock(); - + double px = (x >> 1) + 0.5; double pz = (z >> 1) + 0.5; - - double distortion1 = noise1.eval(px * 0.1, pz * 0.1) * 20 + noise2.eval(px * 0.2, pz * 0.2) * 10 + noise1.eval(px * 0.4, pz * 0.4) * 5; - double distortion2 = noise2.eval(px * 0.1, pz * 0.1) * 20 + noise1.eval(px * 0.2, pz * 0.2) * 10 + noise2.eval(px * 0.4, pz * 0.4) * 5; + + double distortion1 = noise1.eval(px * 0.1, pz * 0.1) * 20 + noise2.eval(px * 0.2, pz * 0.2) * 10 + + noise1.eval(px * 0.4, pz * 0.4) * 5; + double distortion2 = noise2.eval(px * 0.1, pz * 0.1) * 20 + noise1.eval(px * 0.2, pz * 0.2) * 10 + + noise2.eval(px * 0.4, pz * 0.4) * 5; px = px * SCALE_XZ + distortion1; pz = pz * SCALE_XZ + distortion2; - + largeIslands.updatePositions(px, pz); mediumIslands.updatePositions(px, pz); smallIslands.updatePositions(px, pz); - + for (int y = 0; y < 32; y++) { double py = (double) y * SCALE_Y; float dist = largeIslands.getDensity(px, py, pz); @@ -128,31 +134,34 @@ public class TerrainGenerator { return true; } } - + LOCKER.unlock(); return false; } - + /** * Get something like height + * * @param x - block pos x * @param z - block pos z */ public static int getHeight(int x, int z) { LOCKER.lock(); - + double px = (double) x / 8.0; double pz = (double) z / 8.0; - - double distortion1 = noise1.eval(px * 0.1, pz * 0.1) * 20 + noise2.eval(px * 0.2, pz * 0.2) * 10 + noise1.eval(px * 0.4, pz * 0.4) * 5; - double distortion2 = noise2.eval(px * 0.1, pz * 0.1) * 20 + noise1.eval(px * 0.2, pz * 0.2) * 10 + noise2.eval(px * 0.4, pz * 0.4) * 5; + + double distortion1 = noise1.eval(px * 0.1, pz * 0.1) * 20 + noise2.eval(px * 0.2, pz * 0.2) * 10 + + noise1.eval(px * 0.4, pz * 0.4) * 5; + double distortion2 = noise2.eval(px * 0.1, pz * 0.1) * 20 + noise1.eval(px * 0.2, pz * 0.2) * 10 + + noise2.eval(px * 0.4, pz * 0.4) * 5; px = (double) x * SCALE_XZ + distortion1; pz = (double) z * SCALE_XZ + distortion2; - + largeIslands.updatePositions(px, pz); mediumIslands.updatePositions(px, pz); smallIslands.updatePositions(px, pz); - + for (int y = 32; y >= 0; y--) { double py = (double) y * SCALE_Y; float dist = largeIslands.getDensity(px, py, pz); @@ -165,14 +174,14 @@ public class TerrainGenerator { } if (dist > 0) { LOCKER.unlock(); - return MathHelper.floor(MathHelper.clamp(y + dist, y, y + 1) * SCALE_Y); + return Mth.floor(Mth.clamp(y + dist, y, y + 1) * SCALE_Y); } } - + LOCKER.unlock(); return 0; } - + static { float sum = 0; List coef = Lists.newArrayList(); @@ -183,7 +192,7 @@ public class TerrainGenerator { if (dist <= 1) { sum += dist; coef.add(dist); - pos.add(new Point(x, z)); + pos.offset(new Point(x, z)); } } } diff --git a/src/main/java/ru/betterend/world/processors/DestructionStructureProcessor.java b/src/main/java/ru/betterend/world/processors/DestructionStructureProcessor.java index 16e386a4..2ff4898c 100644 --- a/src/main/java/ru/betterend/world/processors/DestructionStructureProcessor.java +++ b/src/main/java/ru/betterend/world/processors/DestructionStructureProcessor.java @@ -4,21 +4,25 @@ import net.minecraft.structure.Structure.StructureBlockInfo; import net.minecraft.structure.StructurePlacementData; import net.minecraft.structure.processor.StructureProcessor; import net.minecraft.structure.processor.StructureProcessorType; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.WorldView; import ru.betterend.registry.EndBlocks; import ru.betterend.util.MHelper; public class DestructionStructureProcessor extends StructureProcessor { private int chance = 4; - + public void setChance(int chance) { this.chance = chance; } - + @Override - public StructureBlockInfo process(WorldView worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlacementData structurePlacementData) { - if (!structureBlockInfo2.state.isOf(EndBlocks.ETERNAL_PEDESTAL) && !structureBlockInfo2.state.isOf(EndBlocks.FLAVOLITE_RUNED_ETERNAL) && MHelper.RANDOM.nextInt(chance) == 0) { + public StructureBlockInfo process(WorldView worldView, BlockPos pos, BlockPos blockPos, + StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, + StructurePlacementData structurePlacementData) { + if (!structureBlockInfo2.state.is(EndBlocks.ETERNAL_PEDESTAL) + && !structureBlockInfo2.state.is(EndBlocks.FLAVOLITE_RUNED_ETERNAL) + && MHelper.RANDOM.nextInt(chance) == 0) { return null; } return structureBlockInfo2; diff --git a/src/main/java/ru/betterend/world/processors/TerrainStructureProcessor.java b/src/main/java/ru/betterend/world/processors/TerrainStructureProcessor.java index a809249a..ca87776f 100644 --- a/src/main/java/ru/betterend/world/processors/TerrainStructureProcessor.java +++ b/src/main/java/ru/betterend/world/processors/TerrainStructureProcessor.java @@ -1,20 +1,23 @@ package ru.betterend.world.processors; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; import net.minecraft.structure.Structure.StructureBlockInfo; import net.minecraft.structure.StructurePlacementData; import net.minecraft.structure.processor.StructureProcessor; import net.minecraft.structure.processor.StructureProcessorType; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.world.WorldView; public class TerrainStructureProcessor extends StructureProcessor { @Override - public StructureBlockInfo process(WorldView worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlacementData structurePlacementData) { + public StructureBlockInfo process(WorldView worldView, BlockPos pos, BlockPos blockPos, + StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, + StructurePlacementData structurePlacementData) { BlockPos bpos = structureBlockInfo2.pos; - if (structureBlockInfo2.state.isOf(Blocks.END_STONE) && worldView.isAir(bpos.up())) { - BlockState top = worldView.getBiome(structureBlockInfo2.pos).getGenerationSettings().getSurfaceConfig().getTopMaterial(); + if (structureBlockInfo2.state.is(Blocks.END_STONE) && worldView.isAir(bpos.up())) { + BlockState top = worldView.getBiome(structureBlockInfo2.pos).getGenerationSettings().getSurfaceConfig() + .getTopMaterial(); return new StructureBlockInfo(bpos, top, structureBlockInfo2.tag); } return structureBlockInfo2; diff --git a/src/main/java/ru/betterend/world/structures/EndStructureFeature.java b/src/main/java/ru/betterend/world/structures/EndStructureFeature.java index 5e10a5fa..bf545278 100644 --- a/src/main/java/ru/betterend/world/structures/EndStructureFeature.java +++ b/src/main/java/ru/betterend/world/structures/EndStructureFeature.java @@ -3,7 +3,7 @@ package ru.betterend.world.structures; import java.util.Random; import net.fabricmc.fabric.api.structure.v1.FabricStructureBuilder; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.feature.ConfiguredStructureFeature; @@ -16,18 +16,17 @@ public class EndStructureFeature { private final StructureFeature structure; private final ConfiguredStructureFeature featureConfigured; private final GenerationStep.Feature featureStep; - - public EndStructureFeature(String name, StructureFeature structure, GenerationStep.Feature step, int spacing, int separation) { - Identifier id = BetterEnd.makeID(name); - + + public EndStructureFeature(String name, StructureFeature structure, + GenerationStep.Feature step, int spacing, int separation) { + ResourceLocation id = BetterEnd.makeID(name); + this.featureStep = step; - this.structure = FabricStructureBuilder.create(id, structure) - .step(step) - .defaultConfig(spacing, separation, RANDOM.nextInt(8192)) - .register(); + this.structure = FabricStructureBuilder.create(id, structure).step(step) + .defaultConfig(spacing, separation, RANDOM.nextInt(8192)).register(); this.featureConfigured = this.structure.configure(DefaultFeatureConfig.DEFAULT); - + BuiltinRegistries.add(BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE, id, this.featureConfigured); } diff --git a/src/main/java/ru/betterend/world/structures/StructureWorld.java b/src/main/java/ru/betterend/world/structures/StructureWorld.java index ef736c8f..6c42d831 100644 --- a/src/main/java/ru/betterend/world/structures/StructureWorld.java +++ b/src/main/java/ru/betterend/world/structures/StructureWorld.java @@ -4,13 +4,13 @@ import java.util.Map; import com.google.common.collect.Maps; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtHelper; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.chunk.Chunk; @@ -25,9 +25,10 @@ public class StructureWorld { private int maxX = Integer.MIN_VALUE; private int maxY = Integer.MIN_VALUE; private int maxZ = Integer.MIN_VALUE; - - public StructureWorld() {} - + + public StructureWorld() { + } + public StructureWorld(CompoundTag tag) { minX = tag.getInt("minX"); maxX = tag.getInt("maxX"); @@ -35,7 +36,7 @@ public class StructureWorld { maxY = tag.getInt("maxY"); minZ = tag.getInt("minZ"); maxZ = tag.getInt("maxZ"); - + ListTag map = tag.getList("parts", 10); map.forEach((element) -> { CompoundTag compound = (CompoundTag) element; @@ -45,33 +46,39 @@ public class StructureWorld { parts.put(new ChunkPos(x, z), part); }); } - + public void setBlock(BlockPos pos, BlockState state) { ChunkPos cPos = new ChunkPos(pos); - + if (cPos.equals(lastPos)) { lastPart.addBlock(pos, state); return; } - + Part part = parts.get(cPos); if (part == null) { part = new Part(); parts.put(cPos, part); - - if (cPos.x < minX) minX = cPos.x; - if (cPos.x > maxX) maxX = cPos.x; - if (cPos.z < minZ) minZ = cPos.z; - if (cPos.z > maxZ) maxZ = cPos.z; + + if (cPos.x < minX) + minX = cPos.x; + if (cPos.x > maxX) + maxX = cPos.x; + if (cPos.z < minZ) + minZ = cPos.z; + if (cPos.z > maxZ) + maxZ = cPos.z; } - if (pos.getY() < minY) minY = pos.getY(); - if (pos.getY() > maxY) maxY = pos.getY(); + if (pos.getY() < minY) + minY = pos.getY(); + if (pos.getY() > maxY) + maxY = pos.getY(); part.addBlock(pos, state); - + lastPos = cPos; lastPart = part; } - + public boolean placeChunk(StructureWorldAccess world, ChunkPos chunkPos) { Part part = parts.get(chunkPos); if (part != null) { @@ -81,7 +88,7 @@ public class StructureWorld { } return false; } - + public CompoundTag toBNT() { CompoundTag tag = new CompoundTag(); tag.putInt("minX", minX); @@ -97,19 +104,21 @@ public class StructureWorld { }); return tag; } - + public BlockBox getBounds() { - if (minX == Integer.MAX_VALUE || maxX == Integer.MIN_VALUE || minZ == Integer.MAX_VALUE || maxZ == Integer.MIN_VALUE) { + if (minX == Integer.MAX_VALUE || maxX == Integer.MIN_VALUE || minZ == Integer.MAX_VALUE + || maxZ == Integer.MIN_VALUE) { return BlockBox.empty(); } return new BlockBox(minX << 4, minY, minZ << 4, (maxX << 4) | 15, maxY, (maxZ << 4) | 15); } - + private static final class Part { Map blocks = Maps.newHashMap(); - - public Part() {} - + + public Part() { + } + public Part(CompoundTag tag) { ListTag map = tag.getList("blocks", 10); ListTag map2 = tag.getList("states", 10); @@ -117,7 +126,7 @@ public class StructureWorld { for (int i = 0; i < states.length; i++) { states[i] = NbtHelper.toBlockState((CompoundTag) map2.get(i)); } - + map.forEach((element) -> { CompoundTag block = (CompoundTag) element; BlockPos pos = NbtHelper.toBlockPos(block.getCompound("pos")); @@ -126,18 +135,18 @@ public class StructureWorld { blocks.put(pos, state); }); } - + void addBlock(BlockPos pos, BlockState state) { BlockPos inner = new BlockPos(pos.getX() & 15, pos.getY(), pos.getZ() & 15); blocks.put(inner, state); } - + void placeChunk(Chunk chunk) { blocks.forEach((pos, state) -> { - chunk.setBlockState(pos, state, false); + chunk.setBlockAndUpdate(pos, state, false); }); } - + CompoundTag toNBT(int x, int z) { CompoundTag tag = new CompoundTag(); tag.putInt("x", x); @@ -146,24 +155,24 @@ public class StructureWorld { tag.put("blocks", map); ListTag stateMap = new ListTag(); tag.put("states", stateMap); - + int[] id = new int[1]; Map states = Maps.newHashMap(); - + blocks.forEach((pos, state) -> { int stateID = states.getOrDefault(states, -1); if (stateID < 0) { - stateID = id[0] ++; + stateID = id[0]++; states.put(state, stateID); stateMap.add(NbtHelper.fromBlockState(state)); } - + CompoundTag block = new CompoundTag(); block.put("pos", NbtHelper.fromBlockPos(pos)); block.putInt("state", stateID); map.add(block); }); - + return tag; } } diff --git a/src/main/java/ru/betterend/world/structures/features/EternalPortalStructure.java b/src/main/java/ru/betterend/world/structures/features/EternalPortalStructure.java index 3874615e..1ce2a06e 100644 --- a/src/main/java/ru/betterend/world/structures/features/EternalPortalStructure.java +++ b/src/main/java/ru/betterend/world/structures/features/EternalPortalStructure.java @@ -3,9 +3,9 @@ package ru.betterend.world.structures.features; import net.minecraft.structure.Structure; import net.minecraft.structure.StructureManager; import net.minecraft.structure.StructureStart; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.world.Heightmap; @@ -22,11 +22,13 @@ import ru.betterend.util.StructureHelper; import ru.betterend.world.structures.piece.NBTPiece; public class EternalPortalStructure extends FeatureBaseStructure { - private static final Identifier STRUCTURE_ID = BetterEnd.makeID("portal/eternal_portal"); + private static final ResourceLocation STRUCTURE_ID = BetterEnd.makeID("portal/eternal_portal"); private static final Structure STRUCTURE = StructureHelper.readStructure(STRUCTURE_ID); - + @Override - protected boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom chunkRandom, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, DefaultFeatureConfig featureConfig) { + protected boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, + ChunkRandom chunkRandom, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, + DefaultFeatureConfig featureConfig) { long x = chunkPos.x; long z = chunkPos.z; if (x * x + z * z < 10000) { @@ -35,26 +37,30 @@ public class EternalPortalStructure extends FeatureBaseStructure { if (chunkGenerator.getHeight((chunkX << 4) | 8, (chunkZ << 4) | 8, Heightmap.Type.WORLD_SURFACE_WG) < 10) { return false; } - return super.shouldStartAt(chunkGenerator, biomeSource, worldSeed, chunkRandom, chunkX, chunkZ, biome, chunkPos, featureConfig); + return super.shouldStartAt(chunkGenerator, biomeSource, worldSeed, chunkRandom, chunkX, chunkZ, biome, chunkPos, + featureConfig); } - + @Override public StructureFeature.StructureStartFactory getStructureStartFactory() { return SDFStructureStart::new; } - + public static class SDFStructureStart extends StructureStart { - public SDFStructureStart(StructureFeature feature, int chunkX, int chunkZ, BlockBox box, int references, long seed) { + public SDFStructureStart(StructureFeature feature, int chunkX, int chunkZ, BlockBox box, + int references, long seed) { super(feature, chunkX, chunkZ, box, references, seed); } @Override - public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) { + public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, + StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) { int x = (chunkX << 4) | MHelper.randRange(4, 12, random); int z = (chunkZ << 4) | MHelper.randRange(4, 12, random); int y = chunkGenerator.getHeight(x, z, Type.WORLD_SURFACE_WG); if (y > 4) { - this.children.add(new NBTPiece(STRUCTURE_ID, STRUCTURE, new BlockPos(x, y - 4, z), random.nextInt(5), true, random)); + this.children.add(new NBTPiece(STRUCTURE_ID, STRUCTURE, new BlockPos(x, y - 4, z), random.nextInt(5), + true, random)); } this.setBoundingBoxFromChildren(); } diff --git a/src/main/java/ru/betterend/world/structures/features/FeatureBaseStructure.java b/src/main/java/ru/betterend/world/structures/features/FeatureBaseStructure.java index 3be74a16..83fbb458 100644 --- a/src/main/java/ru/betterend/world/structures/features/FeatureBaseStructure.java +++ b/src/main/java/ru/betterend/world/structures/features/FeatureBaseStructure.java @@ -2,9 +2,9 @@ package ru.betterend.world.structures.features; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.BlockRotation; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.Rotation; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.Heightmap; import net.minecraft.world.biome.Biome; @@ -15,27 +15,29 @@ import net.minecraft.world.gen.feature.DefaultFeatureConfig; import net.minecraft.world.gen.feature.StructureFeature; public abstract class FeatureBaseStructure extends StructureFeature { - protected static final BlockState AIR = Blocks.AIR.getDefaultState(); - + protected static final BlockState AIR = Blocks.AIR.defaultBlockState(); + public FeatureBaseStructure() { super(DefaultFeatureConfig.CODEC); } - - protected boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom chunkRandom, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, DefaultFeatureConfig featureConfig) { + + protected boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, + ChunkRandom chunkRandom, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, + DefaultFeatureConfig featureConfig) { return getGenerationHeight(chunkX, chunkZ, chunkGenerator) >= 20; } private static int getGenerationHeight(int chunkX, int chunkZ, ChunkGenerator chunkGenerator) { Random random = new Random((long) (chunkX + chunkZ * 10387313)); - BlockRotation blockRotation = BlockRotation.random(random); + Rotation blockRotation = Rotation.random(random); int i = 5; int j = 5; - if (blockRotation == BlockRotation.CLOCKWISE_90) { + if (blockRotation == Rotation.CLOCKWISE_90) { i = -5; - } else if (blockRotation == BlockRotation.CLOCKWISE_180) { + } else if (blockRotation == Rotation.CLOCKWISE_180) { i = -5; j = -5; - } else if (blockRotation == BlockRotation.COUNTERCLOCKWISE_90) { + } else if (blockRotation == Rotation.COUNTERCLOCKWISE_90) { j = -5; } diff --git a/src/main/java/ru/betterend/world/structures/features/GiantIceStarStructure.java b/src/main/java/ru/betterend/world/structures/features/GiantIceStarStructure.java index 41c695e4..2abb0015 100644 --- a/src/main/java/ru/betterend/world/structures/features/GiantIceStarStructure.java +++ b/src/main/java/ru/betterend/world/structures/features/GiantIceStarStructure.java @@ -4,12 +4,12 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.util.math.Vector3f; import net.minecraft.structure.StructureManager; import net.minecraft.structure.StructureStart; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.chunk.ChunkGenerator; @@ -29,59 +29,58 @@ public class GiantIceStarStructure extends SDFStructureFeature { private final float maxSize = 35; private final int minCount = 25; private final int maxCount = 40; - + @Override protected SDF getSDF(BlockPos pos, Random random) { float size = MHelper.randRange(minSize, maxSize, random); int count = MHelper.randRange(minCount, maxCount, random); List points = getFibonacciPoints(count); SDF sdf = null; - SDF spike = new SDFCappedCone().setRadius1(3 + (size - 5) * 0.2F).setRadius2(0).setHeight(size).setBlock(EndBlocks.DENSE_SNOW); + SDF spike = new SDFCappedCone().setRadius1(3 + (size - 5) * 0.2F).setRadius2(0).setHeight(size) + .setBlock(EndBlocks.DENSE_SNOW); spike = new SDFTranslate().setTranslate(0, size - 0.5F, 0).setSource(spike); - for (Vector3f point: points) { + for (Vector3f point : points) { SDF rotated = spike; point = MHelper.normalize(point); float angle = MHelper.angle(Vector3f.POSITIVE_Y, point); if (angle > 0.01F && angle < 3.14F) { Vector3f axis = MHelper.normalize(MHelper.cross(Vector3f.POSITIVE_Y, point)); rotated = new SDFRotation().setRotation(axis, angle).setSource(spike); - } - else if (angle > 1) { + } else if (angle > 1) { rotated = new SDFRotation().setRotation(Vector3f.POSITIVE_Y, (float) Math.PI).setSource(spike); } sdf = (sdf == null) ? rotated : new SDFUnion().setSourceA(sdf).setSourceB(rotated); } - + final float ancientRadius = size * 0.7F; final float denseRadius = size * 0.9F; final float iceRadius = size < 7 ? size * 5 : size * 1.3F; final float randScale = size * 0.3F; - + final BlockPos center = pos; - final BlockState ice = EndBlocks.EMERALD_ICE.getDefaultState(); - final BlockState dense = EndBlocks.DENSE_EMERALD_ICE.getDefaultState(); - final BlockState ancient = EndBlocks.ANCIENT_EMERALD_ICE.getDefaultState(); + final BlockState ice = EndBlocks.EMERALD_ICE.defaultBlockState(); + final BlockState dense = EndBlocks.DENSE_EMERALD_ICE.defaultBlockState(); + final BlockState ancient = EndBlocks.ANCIENT_EMERALD_ICE.defaultBlockState(); final SDF sdfCopy = sdf; - + return sdf.addPostProcess((info) -> { BlockPos bpos = info.getPos(); float px = bpos.getX() - center.getX(); float py = bpos.getY() - center.getY(); float pz = bpos.getZ() - center.getZ(); - float distance = MHelper.length(px, py, pz) + sdfCopy.getDistance(px, py, pz) * 0.4F + random.nextFloat() * randScale; + float distance = MHelper.length(px, py, pz) + sdfCopy.getDistance(px, py, pz) * 0.4F + + random.nextFloat() * randScale; if (distance < ancientRadius) { return ancient; - } - else if (distance < denseRadius) { + } else if (distance < denseRadius) { return dense; - } - else if (distance < iceRadius) { + } else if (distance < iceRadius) { return ice; } return info.getState(); }); } - + private List getFibonacciPoints(int count) { float max = count - 1; List result = new ArrayList(count); @@ -95,23 +94,27 @@ public class GiantIceStarStructure extends SDFStructureFeature { } return result; } - + @Override public StructureFeature.StructureStartFactory getStructureStartFactory() { return StarStructureStart::new; } - + public static class StarStructureStart extends StructureStart { - public StarStructureStart(StructureFeature feature, int chunkX, int chunkZ, BlockBox box, int references, long seed) { + public StarStructureStart(StructureFeature feature, int chunkX, int chunkZ, BlockBox box, + int references, long seed) { super(feature, chunkX, chunkZ, box, references, seed); } @Override - public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) { + public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, + StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) { int x = (chunkX << 4) | MHelper.randRange(4, 12, random); int z = (chunkZ << 4) | MHelper.randRange(4, 12, random); BlockPos start = new BlockPos(x, MHelper.randRange(32, 128, random), z); - VoxelPiece piece = new VoxelPiece((world) -> { ((SDFStructureFeature) this.getFeature()).getSDF(start, this.random).fillRecursive(world, start); }, random.nextInt()); + VoxelPiece piece = new VoxelPiece((world) -> { + ((SDFStructureFeature) this.getFeature()).getSDF(start, this.random).fillRecursive(world, start); + }, random.nextInt()); this.children.add(piece); this.setBoundingBoxFromChildren(); } diff --git a/src/main/java/ru/betterend/world/structures/features/GiantMossyGlowshroomStructure.java b/src/main/java/ru/betterend/world/structures/features/GiantMossyGlowshroomStructure.java index 11b50168..36148bea 100644 --- a/src/main/java/ru/betterend/world/structures/features/GiantMossyGlowshroomStructure.java +++ b/src/main/java/ru/betterend/world/structures/features/GiantMossyGlowshroomStructure.java @@ -4,8 +4,8 @@ import java.util.List; import java.util.Random; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import ru.betterend.blocks.MossyGlowshroomCapBlock; import ru.betterend.blocks.basis.FurBlock; import ru.betterend.noise.OpenSimplexNoise; @@ -34,89 +34,95 @@ public class GiantMossyGlowshroomStructure extends SDFStructureFeature { SDFCappedCone cone1 = new SDFCappedCone().setHeight(2.5F).setRadius1(1.5F).setRadius2(2.5F); SDFCappedCone cone2 = new SDFCappedCone().setHeight(3F).setRadius1(2.5F).setRadius2(13F); SDF posedCone2 = new SDFTranslate().setTranslate(0, 5, 0).setSource(cone2); - SDF posedCone3 = new SDFTranslate().setTranslate(0, 12F, 0).setSource(new SDFScale().setScale(2).setSource(cone2)); + SDF posedCone3 = new SDFTranslate().setTranslate(0, 12F, 0) + .setSource(new SDFScale().setScale(2).setSource(cone2)); SDF upCone = new SDFSubtraction().setSourceA(posedCone2).setSourceB(posedCone3); SDF wave = new SDFFlatWave().setRaysCount(12).setIntensity(1.3F).setSource(upCone); SDF cones = new SDFSmoothUnion().setRadius(3).setSourceA(cone1).setSourceB(wave); - + SDF innerCone = new SDFTranslate().setTranslate(0, 1.25F, 0).setSource(upCone); innerCone = new SDFScale3D().setScale(1.2F, 1F, 1.2F).setSource(innerCone); cones = new SDFUnion().setSourceA(cones).setSourceB(innerCone); - + SDF glowCone = new SDFCappedCone().setHeight(3F).setRadius1(2F).setRadius2(12.5F); SDFPrimitive priGlowCone = (SDFPrimitive) glowCone; glowCone = new SDFTranslate().setTranslate(0, 4.25F, 0).setSource(glowCone); glowCone = new SDFSubtraction().setSourceA(glowCone).setSourceB(posedCone3); - + cones = new SDFUnion().setSourceA(cones).setSourceB(glowCone); - + OpenSimplexNoise noise = new OpenSimplexNoise(1234); cones = new SDFCoordModify().setFunction((pos) -> { float dist = MHelper.length(pos.getX(), pos.getZ()); - float y = pos.getY() + (float) noise.eval(pos.getX() * 0.1 + center.getX(), pos.getZ() * 0.1 + center.getZ()) * dist * 0.3F - dist * 0.15F; + float y = pos.getY() + + (float) noise.eval(pos.getX() * 0.1 + center.getX(), pos.getZ() * 0.1 + center.getZ()) * dist + * 0.3F + - dist * 0.15F; pos.set(pos.getX(), y, pos.getZ()); }).setSource(cones); - - SDFTranslate HEAD_POS = (SDFTranslate) new SDFTranslate().setSource(new SDFTranslate().setTranslate(0, 2.5F, 0).setSource(cones)); - + + SDFTranslate HEAD_POS = (SDFTranslate) new SDFTranslate() + .setSource(new SDFTranslate().setTranslate(0, 2.5F, 0).setSource(cones)); + SDF roots = new SDFSphere().setRadius(4F); SDFPrimitive primRoots = (SDFPrimitive) roots; roots = new SDFScale3D().setScale(1, 0.7F, 1).setSource(roots); SDFFlatWave rotRoots = (SDFFlatWave) new SDFFlatWave().setRaysCount(5).setIntensity(1.5F).setSource(roots); - - SDFBinary function = new SDFSmoothUnion().setRadius(4).setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(rotRoots)); - + + SDFBinary function = new SDFSmoothUnion().setRadius(4) + .setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(rotRoots)); + cone1.setBlock(EndBlocks.MOSSY_GLOWSHROOM_CAP); cone2.setBlock(EndBlocks.MOSSY_GLOWSHROOM_CAP); priGlowCone.setBlock(EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE); primRoots.setBlock(EndBlocks.MOSSY_GLOWSHROOM.bark); - + float height = MHelper.randRange(10F, 25F, random); int count = MHelper.floor(height / 4); List spline = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, count); SplineHelper.offsetParts(spline, random, 1F, 0, 1F); SDF sdf = SplineHelper.buildSDF(spline, 2.1F, 1.5F, (pos) -> { - return EndBlocks.MOSSY_GLOWSHROOM.log.getDefaultState(); + return EndBlocks.MOSSY_GLOWSHROOM.log.defaultBlockState(); }); Vector3f pos = spline.get(spline.size() - 1); float scale = MHelper.randRange(2F, 3.5F, random); - + HEAD_POS.setTranslate(pos.getX(), pos.getY(), pos.getZ()); rotRoots.setAngle(random.nextFloat() * MHelper.PI2); function.setSourceA(sdf); - - return new SDFRound().setRadius(1.5F).setSource(new SDFScale() - .setScale(scale) - .setSource(function)) + + return new SDFRound().setRadius(1.5F).setSource(new SDFScale().setScale(scale).setSource(function)) .addPostProcess((info) -> { if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getState())) { if (random.nextBoolean() && info.getStateUp().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) { - info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.getDefaultState().with(MossyGlowshroomCapBlock.TRANSITION, true)); + info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState() + .with(MossyGlowshroomCapBlock.TRANSITION, true)); + return info.getState(); + } else if (!EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateUp()) + || !EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown())) { + info.setState(EndBlocks.MOSSY_GLOWSHROOM.bark.defaultBlockState()); return info.getState(); } - else if (!EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateUp()) || !EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown())) { - info.setState(EndBlocks.MOSSY_GLOWSHROOM.bark.getDefaultState()); - return info.getState(); - } - } - else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) { + } else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) { if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown().getBlock())) { - info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.getDefaultState().with(MossyGlowshroomCapBlock.TRANSITION, true)); + info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState() + .with(MossyGlowshroomCapBlock.TRANSITION, true)); return info.getState(); } - - info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.getDefaultState()); + + info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState()); return info.getState(); - } - else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) { - for (Direction dir: BlocksHelper.HORIZONTAL) { + } else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) { + for (Direction dir : BlocksHelper.HORIZONTAL) { if (info.getState(dir) == AIR) { - info.setBlockPos(info.getPos().offset(dir), EndBlocks.MOSSY_GLOWSHROOM_FUR.getDefaultState().with(FurBlock.FACING, dir)); + info.setBlockPos(info.getPos().offset(dir), + EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().with(FurBlock.FACING, dir)); } } - + if (info.getStateDown().getBlock() != EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) { - info.setBlockPos(info.getPos().down(), EndBlocks.MOSSY_GLOWSHROOM_FUR.getDefaultState().with(FurBlock.FACING, Direction.DOWN)); + info.setBlockPos(info.getPos().below(), EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState() + .with(FurBlock.FACING, Direction.DOWN)); } } return info.getState(); diff --git a/src/main/java/ru/betterend/world/structures/features/MegaLakeSmallStructure.java b/src/main/java/ru/betterend/world/structures/features/MegaLakeSmallStructure.java index 344d92e3..21bf867a 100644 --- a/src/main/java/ru/betterend/world/structures/features/MegaLakeSmallStructure.java +++ b/src/main/java/ru/betterend/world/structures/features/MegaLakeSmallStructure.java @@ -3,7 +3,7 @@ package ru.betterend.world.structures.features; import net.minecraft.structure.StructureManager; import net.minecraft.structure.StructureStart; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.world.Heightmap.Type; import net.minecraft.world.biome.Biome; @@ -18,14 +18,16 @@ public class MegaLakeSmallStructure extends FeatureBaseStructure { public StructureFeature.StructureStartFactory getStructureStartFactory() { return SDFStructureStart::new; } - + public static class SDFStructureStart extends StructureStart { - public SDFStructureStart(StructureFeature feature, int chunkX, int chunkZ, BlockBox box, int references, long seed) { + public SDFStructureStart(StructureFeature feature, int chunkX, int chunkZ, BlockBox box, + int references, long seed) { super(feature, chunkX, chunkZ, box, references, seed); } @Override - public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) { + public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, + StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) { int x = (chunkX << 4) | MHelper.randRange(4, 12, random); int z = (chunkZ << 4) | MHelper.randRange(4, 12, random); int y = chunkGenerator.getHeight(x, z, Type.WORLD_SURFACE_WG); diff --git a/src/main/java/ru/betterend/world/structures/features/MegaLakeStructure.java b/src/main/java/ru/betterend/world/structures/features/MegaLakeStructure.java index 1ae60a72..1ff03a96 100644 --- a/src/main/java/ru/betterend/world/structures/features/MegaLakeStructure.java +++ b/src/main/java/ru/betterend/world/structures/features/MegaLakeStructure.java @@ -3,7 +3,7 @@ package ru.betterend.world.structures.features; import net.minecraft.structure.StructureManager; import net.minecraft.structure.StructureStart; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.world.Heightmap.Type; import net.minecraft.world.biome.Biome; @@ -18,14 +18,16 @@ public class MegaLakeStructure extends FeatureBaseStructure { public StructureFeature.StructureStartFactory getStructureStartFactory() { return SDFStructureStart::new; } - + public static class SDFStructureStart extends StructureStart { - public SDFStructureStart(StructureFeature feature, int chunkX, int chunkZ, BlockBox box, int references, long seed) { + public SDFStructureStart(StructureFeature feature, int chunkX, int chunkZ, BlockBox box, + int references, long seed) { super(feature, chunkX, chunkZ, box, references, seed); } @Override - public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) { + public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, + StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) { int x = (chunkX << 4) | MHelper.randRange(4, 12, random); int z = (chunkZ << 4) | MHelper.randRange(4, 12, random); int y = chunkGenerator.getHeight(x, z, Type.WORLD_SURFACE_WG); diff --git a/src/main/java/ru/betterend/world/structures/features/MountainStructure.java b/src/main/java/ru/betterend/world/structures/features/MountainStructure.java index 6efc808c..136e647e 100644 --- a/src/main/java/ru/betterend/world/structures/features/MountainStructure.java +++ b/src/main/java/ru/betterend/world/structures/features/MountainStructure.java @@ -3,7 +3,7 @@ package ru.betterend.world.structures.features; import net.minecraft.structure.StructureManager; import net.minecraft.structure.StructureStart; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.world.Heightmap.Type; import net.minecraft.world.biome.Biome; @@ -18,21 +18,24 @@ public class MountainStructure extends FeatureBaseStructure { public StructureFeature.StructureStartFactory getStructureStartFactory() { return SDFStructureStart::new; } - + public static class SDFStructureStart extends StructureStart { - public SDFStructureStart(StructureFeature feature, int chunkX, int chunkZ, BlockBox box, int references, long seed) { + public SDFStructureStart(StructureFeature feature, int chunkX, int chunkZ, BlockBox box, + int references, long seed) { super(feature, chunkX, chunkZ, box, references, seed); } @Override - public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) { + public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, + StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) { int x = (chunkX << 4) | MHelper.randRange(4, 12, random); int z = (chunkZ << 4) | MHelper.randRange(4, 12, random); int y = chunkGenerator.getHeight(x, z, Type.WORLD_SURFACE_WG); if (y > 5) { float radius = MHelper.randRange(50, 100, random); float height = radius * MHelper.randRange(0.8F, 1.2F, random); - CrystalMountainPiece piece = new CrystalMountainPiece(new BlockPos(x, y, z), radius, height, random, biome); + CrystalMountainPiece piece = new CrystalMountainPiece(new BlockPos(x, y, z), radius, height, random, + biome); this.children.add(piece); } this.setBoundingBoxFromChildren(); diff --git a/src/main/java/ru/betterend/world/structures/features/PaintedMountainStructure.java b/src/main/java/ru/betterend/world/structures/features/PaintedMountainStructure.java index 07d262a0..ac2e1ac4 100644 --- a/src/main/java/ru/betterend/world/structures/features/PaintedMountainStructure.java +++ b/src/main/java/ru/betterend/world/structures/features/PaintedMountainStructure.java @@ -1,11 +1,11 @@ package ru.betterend.world.structures.features; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; import net.minecraft.structure.StructureManager; import net.minecraft.structure.StructureStart; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.world.Heightmap.Type; import net.minecraft.world.biome.Biome; @@ -18,19 +18,21 @@ import ru.betterend.world.structures.piece.PaintedMountainPiece; public class PaintedMountainStructure extends FeatureBaseStructure { private static final BlockState[] VARIANTS; - + @Override public StructureFeature.StructureStartFactory getStructureStartFactory() { return SDFStructureStart::new; } - + public static class SDFStructureStart extends StructureStart { - public SDFStructureStart(StructureFeature feature, int chunkX, int chunkZ, BlockBox box, int references, long seed) { + public SDFStructureStart(StructureFeature feature, int chunkX, int chunkZ, BlockBox box, + int references, long seed) { super(feature, chunkX, chunkZ, box, references, seed); } @Override - public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) { + public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, + StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) { int x = (chunkX << 4) | MHelper.randRange(4, 12, random); int z = (chunkZ << 4) | MHelper.randRange(4, 12, random); int y = chunkGenerator.getHeight(x, z, Type.WORLD_SURFACE_WG); @@ -42,17 +44,15 @@ public class PaintedMountainStructure extends FeatureBaseStructure { for (int i = 0; i < count; i++) { slises[i] = VARIANTS[random.nextInt(VARIANTS.length)]; } - this.children.add(new PaintedMountainPiece(new BlockPos(x, y, z), radius, height, random, biome, slises )); + this.children + .add(new PaintedMountainPiece(new BlockPos(x, y, z), radius, height, random, biome, slises)); } this.setBoundingBoxFromChildren(); } } - + static { - VARIANTS = new BlockState[] { - Blocks.END_STONE.getDefaultState(), - EndBlocks.FLAVOLITE.stone.getDefaultState(), - EndBlocks.VIOLECITE.stone.getDefaultState(), - }; + VARIANTS = new BlockState[] { Blocks.END_STONE.defaultBlockState(), + EndBlocks.FLAVOLITE.stone.defaultBlockState(), EndBlocks.VIOLECITE.stone.defaultBlockState(), }; } } diff --git a/src/main/java/ru/betterend/world/structures/features/SDFStructureFeature.java b/src/main/java/ru/betterend/world/structures/features/SDFStructureFeature.java index 21f9edd2..8baee4bc 100644 --- a/src/main/java/ru/betterend/world/structures/features/SDFStructureFeature.java +++ b/src/main/java/ru/betterend/world/structures/features/SDFStructureFeature.java @@ -5,7 +5,7 @@ import java.util.Random; import net.minecraft.structure.StructureManager; import net.minecraft.structure.StructureStart; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.world.Heightmap.Type; import net.minecraft.world.biome.Biome; @@ -17,27 +17,31 @@ import ru.betterend.util.sdf.SDF; import ru.betterend.world.structures.piece.VoxelPiece; public abstract class SDFStructureFeature extends FeatureBaseStructure { - + protected abstract SDF getSDF(BlockPos pos, Random random); - + @Override public StructureFeature.StructureStartFactory getStructureStartFactory() { return SDFStructureStart::new; } - + public static class SDFStructureStart extends StructureStart { - public SDFStructureStart(StructureFeature feature, int chunkX, int chunkZ, BlockBox box, int references, long seed) { + public SDFStructureStart(StructureFeature feature, int chunkX, int chunkZ, BlockBox box, + int references, long seed) { super(feature, chunkX, chunkZ, box, references, seed); } @Override - public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) { + public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, + StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) { int x = (chunkX << 4) | MHelper.randRange(4, 12, random); int z = (chunkZ << 4) | MHelper.randRange(4, 12, random); int y = chunkGenerator.getHeight(x, z, Type.WORLD_SURFACE_WG); if (y > 5) { BlockPos start = new BlockPos(x, y, z); - VoxelPiece piece = new VoxelPiece((world) -> { ((SDFStructureFeature) this.getFeature()).getSDF(start, this.random).fillRecursive(world, start); }, random.nextInt()); + VoxelPiece piece = new VoxelPiece((world) -> { + ((SDFStructureFeature) this.getFeature()).getSDF(start, this.random).fillRecursive(world, start); + }, random.nextInt()); this.children.add(piece); } this.setBoundingBoxFromChildren(); diff --git a/src/main/java/ru/betterend/world/structures/piece/CavePiece.java b/src/main/java/ru/betterend/world/structures/piece/CavePiece.java index 52a3da9e..37e893fc 100644 --- a/src/main/java/ru/betterend/world/structures/piece/CavePiece.java +++ b/src/main/java/ru/betterend/world/structures/piece/CavePiece.java @@ -2,13 +2,13 @@ package ru.betterend.world.structures.piece; import java.util.Random; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.Blocks; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtHelper; import net.minecraft.structure.StructureManager; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.StructureAccessor; @@ -23,7 +23,7 @@ public class CavePiece extends BasePiece { private OpenSimplexNoise noise; private BlockPos center; private float radius; - + public CavePiece(BlockPos center, float radius, int id) { super(EndStructures.CAVE_PIECE, id); this.center = center; @@ -36,19 +36,20 @@ public class CavePiece extends BasePiece { super(EndStructures.CAVE_PIECE, tag); makeBoundingBox(); } - + @Override - public boolean generate(StructureWorldAccess world, StructureAccessor arg, ChunkGenerator chunkGenerator, Random random, BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) { + public boolean generate(StructureWorldAccess world, StructureAccessor arg, ChunkGenerator chunkGenerator, + Random random, BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) { int x1 = MHelper.max(this.boundingBox.minX, blockBox.minX); int z1 = MHelper.max(this.boundingBox.minZ, blockBox.minZ); int x2 = MHelper.min(this.boundingBox.maxX, blockBox.maxX); int z2 = MHelper.min(this.boundingBox.maxZ, blockBox.maxZ); int y1 = this.boundingBox.minY; int y2 = this.boundingBox.maxY; - + double hr = radius * 0.75; double nr = radius * 0.25; - Mutable pos = new Mutable(); + MutableBlockPos pos = new MutableBlockPos(); for (int x = x1; x <= x2; x++) { int xsq = x - center.getX(); xsq *= xsq; @@ -69,8 +70,7 @@ public class CavePiece extends BasePiece { if (world.getBlockState(pos).isIn(EndTags.END_GROUND)) { BlocksHelper.setWithoutUpdate(world, pos, AIR); } - } - else if (dist < r * r) { + } else if (dist < r * r) { if (world.getBlockState(pos).getMaterial().isReplaceable()) { BlocksHelper.setWithoutUpdate(world, pos, Blocks.END_STONE); } @@ -78,7 +78,7 @@ public class CavePiece extends BasePiece { } } } - + return true; } @@ -94,7 +94,7 @@ public class CavePiece extends BasePiece { radius = tag.getFloat("radius"); noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ())); } - + private void makeBoundingBox() { int minX = MHelper.floor(center.getX() - radius); int minY = MHelper.floor(center.getY() - radius); diff --git a/src/main/java/ru/betterend/world/structures/piece/CrystalMountainPiece.java b/src/main/java/ru/betterend/world/structures/piece/CrystalMountainPiece.java index 5267cc2c..7b56ad66 100644 --- a/src/main/java/ru/betterend/world/structures/piece/CrystalMountainPiece.java +++ b/src/main/java/ru/betterend/world/structures/piece/CrystalMountainPiece.java @@ -2,15 +2,15 @@ package ru.betterend.world.structures.piece; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; import net.minecraft.nbt.CompoundTag; import net.minecraft.structure.StructureManager; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; import net.minecraft.world.Heightmap; import net.minecraft.world.Heightmap.Type; import net.minecraft.world.StructureWorldAccess; @@ -26,7 +26,7 @@ import ru.betterend.util.MHelper; public class CrystalMountainPiece extends MountainPiece { private BlockState top; - + public CrystalMountainPiece(BlockPos center, float radius, float height, Random random, Biome biome) { super(EndStructures.MOUNTAIN_PIECE, center, radius, height, random, biome); top = biome.getGenerationSettings().getSurfaceConfig().getTopMaterial(); @@ -43,10 +43,11 @@ public class CrystalMountainPiece extends MountainPiece { } @Override - public boolean generate(StructureWorldAccess world, StructureAccessor arg, ChunkGenerator chunkGenerator, Random random, BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) { + public boolean generate(StructureWorldAccess world, StructureAccessor arg, ChunkGenerator chunkGenerator, + Random random, BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) { int sx = chunkPos.getStartX(); int sz = chunkPos.getStartZ(); - Mutable pos = new Mutable(); + MutableBlockPos pos = new MutableBlockPos(); Chunk chunk = world.getChunk(chunkPos.x, chunkPos.z); Heightmap map = chunk.getHeightmap(Type.WORLD_SURFACE); Heightmap map2 = chunk.getHeightmap(Type.WORLD_SURFACE_WG); @@ -68,7 +69,8 @@ public class CrystalMountainPiece extends MountainPiece { continue; } pos.setY(minY); - while (!chunk.getBlockState(pos).isIn(EndTags.GEN_TERRAIN) && pos.getY() > 56 && !chunk.getBlockState(pos.down()).isOf(Blocks.CAVE_AIR)) { + while (!chunk.getBlockState(pos).isIn(EndTags.GEN_TERRAIN) && pos.getY() > 56 + && !chunk.getBlockState(pos.below()).is(Blocks.CAVE_AIR)) { pos.setY(pos.getY() - 1); } minY = pos.getY(); @@ -81,22 +83,24 @@ public class CrystalMountainPiece extends MountainPiece { maxY += center.getY(); int maxYI = (int) (maxY); int cover = maxYI - 1; - boolean needCover = (noise1.eval(px * 0.1, pz * 0.1) + MHelper.randRange(-0.4, 0.4, random) - (center.getY() + 14) * 0.1) > 0; + boolean needCover = (noise1.eval(px * 0.1, pz * 0.1) + MHelper.randRange(-0.4, 0.4, random) + - (center.getY() + 14) * 0.1) > 0; for (int y = minY - 1; y < maxYI; y++) { pos.setY(y); - chunk.setBlockState(pos, needCover && y == cover ? top : Blocks.END_STONE.getDefaultState(), false); + chunk.setBlockAndUpdate(pos, + needCover && y == cover ? top : Blocks.END_STONE.defaultBlockState(), false); } } } } } } - + map = chunk.getHeightmap(Type.WORLD_SURFACE); - + // Big crystals int count = (map.get(8, 8) - (center.getY() + 24)) / 7; - count = MathHelper.clamp(count, 0, 8); + count = Mth.clamp(count, 0, 8); for (int i = 0; i < count; i++) { int radius = MHelper.randRange(2, 3, random); float fill = MHelper.randRange(0F, 1F, random); @@ -105,16 +109,16 @@ public class CrystalMountainPiece extends MountainPiece { int y = map.get(x, z); if (y > 80) { pos.set(x, y, z); - if (chunk.getBlockState(pos.down()).isOf(Blocks.END_STONE)) { + if (chunk.getBlockState(pos.below()).is(Blocks.END_STONE)) { int height = MHelper.floor(radius * MHelper.randRange(1.5F, 3F, random) + (y - 80) * 0.3F); crystal(chunk, pos, radius, height, fill, random); } } } - + // Small crystals count = (map.get(8, 8) - (center.getY() + 24)) / 2; - count = MathHelper.clamp(count, 4, 8); + count = Mth.clamp(count, 4, 8); for (int i = 0; i < count; i++) { int radius = MHelper.randRange(1, 2, random); float fill = random.nextBoolean() ? 0 : 1; @@ -123,18 +127,18 @@ public class CrystalMountainPiece extends MountainPiece { int y = map.get(x, z); if (y > 80) { pos.set(x, y, z); - if (chunk.getBlockState(pos.down()).getBlock() == Blocks.END_STONE) { + if (chunk.getBlockState(pos.below()).getBlock() == Blocks.END_STONE) { int height = MHelper.floor(radius * MHelper.randRange(1.5F, 3F, random) + (y - 80) * 0.3F); crystal(chunk, pos, radius, height, fill, random); } } } - + return true; } - + private void crystal(Chunk chunk, BlockPos pos, int radius, int height, float fill, Random random) { - Mutable mut = new Mutable(); + MutableBlockPos mut = new MutableBlockPos(); int max = MHelper.floor(fill * radius + radius + 0.5F); height += pos.getY(); Heightmap map = chunk.getHeightmap(Type.WORLD_SURFACE); @@ -156,7 +160,7 @@ public class CrystalMountainPiece extends MountainPiece { int h = coefX * x + coefZ * z + height; for (int y = minY; y < h; y++) { mut.setY(y); - chunk.setBlockState(mut, EndBlocks.AURORA_CRYSTAL.getDefaultState(), false); + chunk.setBlockAndUpdate(mut, EndBlocks.AURORA_CRYSTAL.defaultBlockState(), false); } } } diff --git a/src/main/java/ru/betterend/world/structures/piece/LakePiece.java b/src/main/java/ru/betterend/world/structures/piece/LakePiece.java index ceff886e..386794ac 100644 --- a/src/main/java/ru/betterend/world/structures/piece/LakePiece.java +++ b/src/main/java/ru/betterend/world/structures/piece/LakePiece.java @@ -5,19 +5,19 @@ import java.util.Random; import com.google.common.collect.Maps; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; import net.minecraft.fluid.FluidState; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtHelper; import net.minecraft.structure.StructureManager; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.MathHelper; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; import net.minecraft.world.Heightmap.Type; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.biome.Biome; @@ -33,8 +33,8 @@ import ru.betterend.util.BlocksHelper; import ru.betterend.util.MHelper; public class LakePiece extends BasePiece { - private static final BlockState ENDSTONE = Blocks.END_STONE.getDefaultState(); - private static final BlockState WATER = Blocks.WATER.getDefaultState(); + private static final BlockState ENDSTONE = Blocks.END_STONE.defaultBlockState(); + private static final BlockState WATER = Blocks.WATER.defaultBlockState(); private Map heightmap = Maps.newHashMap(); private OpenSimplexNoise noise; private BlockPos center; @@ -42,9 +42,9 @@ public class LakePiece extends BasePiece { private float aspect; private float depth; private int seed; - - private Identifier biomeID; - + + private ResourceLocation biomeID; + public LakePiece(BlockPos center, float radius, float depth, Random random, Biome biome) { super(EndStructures.LAKE_PIECE, random.nextInt()); this.center = center; @@ -79,16 +79,17 @@ public class LakePiece extends BasePiece { seed = tag.getInt("seed"); noise = new OpenSimplexNoise(seed); aspect = radius / depth; - biomeID = new Identifier(tag.getString("biome")); + biomeID = new ResourceLocation(tag.getString("biome")); } @Override - public boolean generate(StructureWorldAccess world, StructureAccessor arg, ChunkGenerator chunkGenerator, Random random, BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) { + public boolean generate(StructureWorldAccess world, StructureAccessor arg, ChunkGenerator chunkGenerator, + Random random, BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) { int minY = this.boundingBox.minY; int maxY = this.boundingBox.maxY; int sx = chunkPos.x << 4; int sz = chunkPos.z << 4; - Mutable mut = new Mutable(); + MutableBlockPos mut = new MutableBlockPos(); Chunk chunk = world.getChunk(chunkPos.x, chunkPos.z); for (int x = 0; x < 16; x++) { mut.setX(x); @@ -101,12 +102,13 @@ public class LakePiece extends BasePiece { double nz = wz * 0.1; int z2 = wz - center.getZ(); float clamp = getHeightClamp(world, 8, wx, wz); - if (clamp < 0.01) continue; - + if (clamp < 0.01) + continue; + double n = noise.eval(nx, nz) * 1.5 + 1.5; double x3 = MHelper.pow2(x2 + noise.eval(nx, nz, 100) * 10); double z3 = MHelper.pow2(z2 + noise.eval(nx, nz, -100) * 10); - + for (int y = minY; y <= maxY; y++) { mut.setY((int) (y + n)); double y2 = MHelper.pow2((y - center.getY()) * aspect); @@ -119,21 +121,22 @@ public class LakePiece extends BasePiece { BlockState state = chunk.getBlockState(mut); if (state.isIn(EndTags.GEN_TERRAIN) || state.isAir()) { state = mut.getY() < center.getY() ? WATER : AIR; - chunk.setBlockState(mut, state, false); + chunk.setBlockAndUpdate(mut, state, false); } - } - else if (dist <= r3 && mut.getY() < center.getY()) { + } else if (dist <= r3 && mut.getY() < center.getY()) { BlockState state = chunk.getBlockState(mut); BlockPos worldPos = mut.add(sx, 0, sz); if (!state.isFullCube(world, worldPos) && !state.isSolidBlock(world, worldPos)) { state = chunk.getBlockState(mut.up()); if (state.isAir()) { - state = random.nextBoolean() ? ENDSTONE : world.getBiome(worldPos).getGenerationSettings().getSurfaceConfig().getTopMaterial(); + state = random.nextBoolean() ? ENDSTONE + : world.getBiome(worldPos).getGenerationSettings().getSurfaceConfig() + .getTopMaterial(); + } else { + state = state.getFluidState().isEmpty() ? ENDSTONE + : EndBlocks.ENDSTONE_DUST.defaultBlockState(); } - else { - state = state.getFluidState().isEmpty() ? ENDSTONE : EndBlocks.ENDSTONE_DUST.getDefaultState(); - } - chunk.setBlockState(mut, state, false); + chunk.setBlockAndUpdate(mut, state, false); } } } @@ -142,8 +145,8 @@ public class LakePiece extends BasePiece { fixWater(world, chunk, mut, random, sx, sz); return true; } - - private void fixWater(StructureWorldAccess world, Chunk chunk, Mutable mut, Random random, int sx, int sz) { + + private void fixWater(StructureWorldAccess world, Chunk chunk, MutableBlockPos mut, Random random, int sx, int sz) { int minY = this.boundingBox.minY; int maxY = this.boundingBox.maxY; for (int x = 0; x < 16; x++) { @@ -157,39 +160,41 @@ public class LakePiece extends BasePiece { mut.setY(y - 1); if (chunk.getBlockState(mut).isAir()) { mut.setY(y + 1); - + BlockState bState = chunk.getBlockState(mut); if (bState.isAir()) { - bState = random.nextBoolean() ? ENDSTONE : world.getBiome(mut.add(sx, 0, sz)).getGenerationSettings().getSurfaceConfig().getTopMaterial(); + bState = random.nextBoolean() ? ENDSTONE + : world.getBiome(mut.add(sx, 0, sz)).getGenerationSettings().getSurfaceConfig() + .getTopMaterial(); + } else { + bState = bState.getFluidState().isEmpty() ? ENDSTONE + : EndBlocks.ENDSTONE_DUST.defaultBlockState(); } - else { - bState = bState.getFluidState().isEmpty() ? ENDSTONE : EndBlocks.ENDSTONE_DUST.getDefaultState(); - } - + mut.setY(y); - + makeEndstonePillar(chunk, mut, bState); - } - else if (x > 1 && x < 15 && z > 1 && z < 15) { + } else if (x > 1 && x < 15 && z > 1 && z < 15) { mut.setY(y); - for (Direction dir: BlocksHelper.HORIZONTAL) { + for (Direction dir : BlocksHelper.HORIZONTAL) { BlockPos wPos = mut.add(dir.getOffsetX(), 0, dir.getOffsetZ()); if (chunk.getBlockState(wPos).isAir()) { mut.setY(y + 1); BlockState bState = chunk.getBlockState(mut); if (bState.isAir()) { - bState = random.nextBoolean() ? ENDSTONE : world.getBiome(mut.add(sx, 0, sz)).getGenerationSettings().getSurfaceConfig().getTopMaterial(); - } - else { - bState = bState.getFluidState().isEmpty() ? ENDSTONE : EndBlocks.ENDSTONE_DUST.getDefaultState(); + bState = random.nextBoolean() ? ENDSTONE + : world.getBiome(mut.add(sx, 0, sz)).getGenerationSettings() + .getSurfaceConfig().getTopMaterial(); + } else { + bState = bState.getFluidState().isEmpty() ? ENDSTONE + : EndBlocks.ENDSTONE_DUST.defaultBlockState(); } mut.setY(y); makeEndstonePillar(chunk, mut, bState); break; } } - } - else if (chunk.getBlockState(mut.move(Direction.UP)).isAir()) { + } else if (chunk.getBlockState(mut.move(Direction.UP)).isAir()) { chunk.getFluidTickScheduler().schedule(mut.move(Direction.DOWN), state.getFluid(), 0); } } @@ -197,38 +202,38 @@ public class LakePiece extends BasePiece { } } } - - private void makeEndstonePillar(Chunk chunk, Mutable mut, BlockState terrain) { - chunk.setBlockState(mut, terrain, false); + + private void makeEndstonePillar(Chunk chunk, MutableBlockPos mut, BlockState terrain) { + chunk.setBlockAndUpdate(mut, terrain, false); mut.setY(mut.getY() - 1); while (!chunk.getFluidState(mut).isEmpty()) { - chunk.setBlockState(mut, ENDSTONE, false); + chunk.setBlockAndUpdate(mut, ENDSTONE, false); mut.setY(mut.getY() - 1); } } - + private int getHeight(StructureWorldAccess world, BlockPos pos) { int p = ((pos.getX() & 2047) << 11) | (pos.getZ() & 2047); int h = heightmap.getOrDefault(p, Byte.MIN_VALUE); if (h > Byte.MIN_VALUE) { return h; } - + if (!EndBiomes.getBiomeID(world.getBiome(pos)).equals(biomeID)) { heightmap.put(p, (byte) 0); return 0; } - + h = world.getTopY(Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ()); - h = MathHelper.abs(h - center.getY()); + h = Mth.abs(h - center.getY()); h = h < 8 ? 1 : 0; - + heightmap.put(p, (byte) h); return h; } - + private float getHeightClamp(StructureWorldAccess world, int radius, int posX, int posZ) { - Mutable mut = new Mutable(); + MutableBlockPos mut = new MutableBlockPos(); int r2 = radius * radius; float height = 0; float max = 0; @@ -246,9 +251,9 @@ public class LakePiece extends BasePiece { } } height /= max; - return MathHelper.clamp(height, 0, 1); + return Mth.clamp(height, 0, 1); } - + private void makeBoundingBox() { int minX = MHelper.floor(center.getX() - radius - 8); int minY = MHelper.floor(center.getY() - depth - 8); diff --git a/src/main/java/ru/betterend/world/structures/piece/MountainPiece.java b/src/main/java/ru/betterend/world/structures/piece/MountainPiece.java index 22ce829e..fa4cf082 100644 --- a/src/main/java/ru/betterend/world/structures/piece/MountainPiece.java +++ b/src/main/java/ru/betterend/world/structures/piece/MountainPiece.java @@ -9,11 +9,11 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtHelper; import net.minecraft.structure.StructureManager; import net.minecraft.structure.StructurePieceType; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; -import net.minecraft.util.math.MathHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.util.Mth; import net.minecraft.world.Heightmap.Type; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.biome.Biome; @@ -29,11 +29,12 @@ public abstract class MountainPiece extends BasePiece { protected float radius; protected float height; protected float r2; - protected Identifier biomeID; + protected ResourceLocation biomeID; protected int seed1; protected int seed2; - - public MountainPiece(StructurePieceType type, BlockPos center, float radius, float height, Random random, Biome biome) { + + public MountainPiece(StructurePieceType type, BlockPos center, float radius, float height, Random random, + Biome biome) { super(type, random.nextInt()); this.center = center; this.radius = radius; @@ -67,47 +68,48 @@ public abstract class MountainPiece extends BasePiece { center = NbtHelper.toBlockPos(tag.getCompound("center")); radius = tag.getFloat("radius"); height = tag.getFloat("height"); - biomeID = new Identifier(tag.getString("biome")); + biomeID = new ResourceLocation(tag.getString("biome")); r2 = radius * radius; seed1 = tag.getInt("seed1"); seed2 = tag.getInt("seed2"); noise1 = new OpenSimplexNoise(seed1); noise2 = new OpenSimplexNoise(seed2); } - + private int getHeight(StructureWorldAccess world, BlockPos pos) { int p = ((pos.getX() & 2047) << 11) | (pos.getZ() & 2047); int h = heightmap.getOrDefault(p, Integer.MIN_VALUE); if (h > Integer.MIN_VALUE) { return h; } - + if (!EndBiomes.getBiomeID(world.getBiome(pos)).equals(biomeID)) { heightmap.put(p, -10); return -10; } h = world.getTopY(Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ()); - h = MathHelper.abs(h - center.getY()); + h = Mth.abs(h - center.getY()); if (h > 4) { h = 4 - h; heightmap.put(p, h); return h; } - - h = MHelper.floor(noise2.eval(pos.getX() * 0.01, pos.getZ() * 0.01) * noise2.eval(pos.getX() * 0.002, pos.getZ() * 0.002) * 8 + 8); - + + h = MHelper.floor(noise2.eval(pos.getX() * 0.01, pos.getZ() * 0.01) + * noise2.eval(pos.getX() * 0.002, pos.getZ() * 0.002) * 8 + 8); + if (h < 0) { heightmap.put(p, 0); return 0; } - + heightmap.put(p, h); - + return h; } - + protected float getHeightClamp(StructureWorldAccess world, int radius, int posX, int posZ) { - Mutable mut = new Mutable(); + MutableBlockPos mut = new MutableBlockPos(); float height = 0; float max = 0; for (int x = -radius; x <= radius; x++) { @@ -124,9 +126,9 @@ public abstract class MountainPiece extends BasePiece { } } height /= max; - return MathHelper.clamp(height / radius, 0, 1); + return Mth.clamp(height / radius, 0, 1); } - + private void makeBoundingBox() { int minX = MHelper.floor(center.getX() - radius); int minZ = MHelper.floor(center.getZ() - radius); diff --git a/src/main/java/ru/betterend/world/structures/piece/NBTPiece.java b/src/main/java/ru/betterend/world/structures/piece/NBTPiece.java index 5e768f60..4ba6ab13 100644 --- a/src/main/java/ru/betterend/world/structures/piece/NBTPiece.java +++ b/src/main/java/ru/betterend/world/structures/piece/NBTPiece.java @@ -8,10 +8,10 @@ import net.minecraft.structure.Structure; import net.minecraft.structure.StructureManager; import net.minecraft.structure.StructurePlacementData; import net.minecraft.util.BlockMirror; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.Identifier; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.StructureAccessor; @@ -21,19 +21,20 @@ import ru.betterend.util.MHelper; import ru.betterend.util.StructureHelper; public class NBTPiece extends BasePiece { - private Identifier structureID; - private BlockRotation rotation; + private ResourceLocation structureID; + private Rotation rotation; private BlockMirror mirror; private Structure structure; private BlockPos pos; private int erosion; private boolean cover; - - public NBTPiece(Identifier structureID, Structure structure, BlockPos pos, int erosion, boolean cover, Random random) { + + public NBTPiece(ResourceLocation structureID, Structure structure, BlockPos pos, int erosion, boolean cover, + Random random) { super(EndStructures.NBT_PIECE, random.nextInt()); this.structureID = structureID; this.structure = structure; - this.rotation = BlockRotation.random(random); + this.rotation = Rotation.random(random); this.mirror = BlockMirror.values()[random.nextInt(3)]; this.pos = StructureHelper.offsetPos(pos, structure, rotation, mirror); this.erosion = erosion; @@ -58,8 +59,8 @@ public class NBTPiece extends BasePiece { @Override protected void fromNbt(CompoundTag tag) { - structureID = new Identifier(tag.getString("id")); - rotation = BlockRotation.values()[tag.getInt("rotation")]; + structureID = new ResourceLocation(tag.getString("id")); + rotation = Rotation.values()[tag.getInt("rotation")]; mirror = BlockMirror.values()[tag.getInt("mirror")]; erosion = tag.getInt("erosion"); pos = NbtHelper.toBlockPos(tag.getCompound("pos")); @@ -68,11 +69,13 @@ public class NBTPiece extends BasePiece { } @Override - public boolean generate(StructureWorldAccess world, StructureAccessor arg, ChunkGenerator chunkGenerator, Random random, BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) { + public boolean generate(StructureWorldAccess world, StructureAccessor arg, ChunkGenerator chunkGenerator, + Random random, BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) { BlockBox bounds = new BlockBox(blockBox); bounds.maxY = this.boundingBox.maxY; bounds.minY = this.boundingBox.minY; - StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds); + StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror) + .setBoundingBox(bounds); structure.place(world, pos, placementData, random); if (erosion > 0) { bounds.maxX = MHelper.min(bounds.maxX, boundingBox.maxX); @@ -86,7 +89,7 @@ public class NBTPiece extends BasePiece { } return true; } - + private void makeBoundingBox() { this.boundingBox = StructureHelper.getStructureBounds(pos, structure, rotation, mirror); } diff --git a/src/main/java/ru/betterend/world/structures/piece/PaintedMountainPiece.java b/src/main/java/ru/betterend/world/structures/piece/PaintedMountainPiece.java index 3176cf11..ce0a802b 100644 --- a/src/main/java/ru/betterend/world/structures/piece/PaintedMountainPiece.java +++ b/src/main/java/ru/betterend/world/structures/piece/PaintedMountainPiece.java @@ -2,14 +2,14 @@ package ru.betterend.world.structures.piece; import java.util.Random; -import net.minecraft.block.BlockState; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtHelper; import net.minecraft.structure.StructureManager; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.Heightmap; import net.minecraft.world.Heightmap.Type; @@ -23,7 +23,9 @@ import ru.betterend.util.MHelper; public class PaintedMountainPiece extends MountainPiece { private BlockState[] slises; - public PaintedMountainPiece(BlockPos center, float radius, float height, Random random, Biome biome, BlockState[] slises) { + + public PaintedMountainPiece(BlockPos center, float radius, float height, Random random, Biome biome, + BlockState[] slises) { super(EndStructures.PAINTED_MOUNTAIN_PIECE, center, radius, height, random, biome); this.slises = slises; } @@ -36,7 +38,7 @@ public class PaintedMountainPiece extends MountainPiece { protected void toNbt(CompoundTag tag) { super.toNbt(tag); ListTag slise = new ListTag(); - for (BlockState state: slises) { + for (BlockState state : slises) { slise.add(NbtHelper.fromBlockState(state)); } tag.put("slises", slise); @@ -53,10 +55,11 @@ public class PaintedMountainPiece extends MountainPiece { } @Override - public boolean generate(StructureWorldAccess world, StructureAccessor arg, ChunkGenerator chunkGenerator, Random random, BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) { + public boolean generate(StructureWorldAccess world, StructureAccessor arg, ChunkGenerator chunkGenerator, + Random random, BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) { int sx = chunkPos.getStartX(); int sz = chunkPos.getStartZ(); - Mutable pos = new Mutable(); + MutableBlockPos pos = new MutableBlockPos(); Chunk chunk = world.getChunk(chunkPos.x, chunkPos.z); Heightmap map = chunk.getHeightmap(Type.WORLD_SURFACE); Heightmap map2 = chunk.getHeightmap(Type.WORLD_SURFACE_WG); @@ -76,7 +79,7 @@ public class PaintedMountainPiece extends MountainPiece { int minY = map.get(x, z); pos.setY(minY - 1); while (chunk.getBlockState(pos).isAir() && pos.getY() > 50) { - pos.setY(minY --); + pos.setY(minY--); } minY = pos.getY(); minY = Math.max(minY, map2.get(x, z)); @@ -86,18 +89,19 @@ public class PaintedMountainPiece extends MountainPiece { maxY *= (float) noise1.eval(px * 0.05, pz * 0.05) * 0.3F + 0.7F; maxY *= (float) noise1.eval(px * 0.1, pz * 0.1) * 0.1F + 0.9F; maxY += center.getY(); - float offset = (float) (noise1.eval(px * 0.07, pz * 0.07) * 5 + noise1.eval(px * 0.2, pz * 0.2) * 2 + 7); + float offset = (float) (noise1.eval(px * 0.07, pz * 0.07) * 5 + + noise1.eval(px * 0.2, pz * 0.2) * 2 + 7); for (int y = minY - 1; y < maxY; y++) { pos.setY(y); int index = MHelper.floor((y + offset) * 0.65F) % slises.length; - chunk.setBlockState(pos, slises[index], false); + chunk.setBlockAndUpdate(pos, slises[index], false); } } } } } } - + return true; } } diff --git a/src/main/java/ru/betterend/world/structures/piece/VoxelPiece.java b/src/main/java/ru/betterend/world/structures/piece/VoxelPiece.java index f9b6f676..fa3451ea 100644 --- a/src/main/java/ru/betterend/world/structures/piece/VoxelPiece.java +++ b/src/main/java/ru/betterend/world/structures/piece/VoxelPiece.java @@ -6,7 +6,7 @@ import java.util.function.Consumer; import net.minecraft.nbt.CompoundTag; import net.minecraft.structure.StructureManager; import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.StructureAccessor; @@ -16,7 +16,7 @@ import ru.betterend.world.structures.StructureWorld; public class VoxelPiece extends BasePiece { private StructureWorld world; - + public VoxelPiece(Consumer function, int id) { super(EndStructures.VOXEL_PIECE, id); world = new StructureWorld(); @@ -40,7 +40,8 @@ public class VoxelPiece extends BasePiece { } @Override - public boolean generate(StructureWorldAccess world, StructureAccessor arg, ChunkGenerator chunkGenerator, Random random, BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) { + public boolean generate(StructureWorldAccess world, StructureAccessor arg, ChunkGenerator chunkGenerator, + Random random, BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) { this.world.placeChunk(world, chunkPos); return true; } diff --git a/src/main/java/ru/betterend/world/surface/DoubleBlockSurfaceBuilder.java b/src/main/java/ru/betterend/world/surface/DoubleBlockSurfaceBuilder.java index 01b48a5c..94d25ebe 100644 --- a/src/main/java/ru/betterend/world/surface/DoubleBlockSurfaceBuilder.java +++ b/src/main/java/ru/betterend/world/surface/DoubleBlockSurfaceBuilder.java @@ -2,10 +2,10 @@ package ru.betterend.world.surface; import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.Registry; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.gen.surfacebuilder.ConfiguredSurfaceBuilder; @@ -18,35 +18,38 @@ public class DoubleBlockSurfaceBuilder extends SurfaceBuilder 0 ? config1 : config2); + SurfaceBuilder.DEFAULT.generate(random, chunk, biome, x, z, height, noise, defaultBlock, defaultFluid, seaLevel, + seed, noise > 0 ? config1 : config2); } - + public static DoubleBlockSurfaceBuilder register(String name) { return Registry.register(Registry.SURFACE_BUILDER, name, new DoubleBlockSurfaceBuilder()); } - + public ConfiguredSurfaceBuilder configured() { - BlockState stone = Blocks.END_STONE.getDefaultState(); + BlockState stone = Blocks.END_STONE.defaultBlockState(); return this.withConfig(new TernarySurfaceConfig(config1.getTopMaterial(), stone, stone)); } } \ No newline at end of file diff --git a/src/main/java/ru/betterend/world/surface/SulphuricSurfaceBuilder.java b/src/main/java/ru/betterend/world/surface/SulphuricSurfaceBuilder.java index 7c75ea39..746a4b38 100644 --- a/src/main/java/ru/betterend/world/surface/SulphuricSurfaceBuilder.java +++ b/src/main/java/ru/betterend/world/surface/SulphuricSurfaceBuilder.java @@ -2,8 +2,8 @@ package ru.betterend.world.surface; import java.util.Random; -import net.minecraft.block.BlockState; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.Registry; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder; @@ -13,28 +13,32 @@ import ru.betterend.util.MHelper; public class SulphuricSurfaceBuilder extends SurfaceBuilder { private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(5123); - + public SulphuricSurfaceBuilder() { super(TernarySurfaceConfig.CODEC); } @Override - public void generate(Random random, Chunk chunk, Biome biome, int x, int z, int height, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, TernarySurfaceConfig surfaceBlocks) { - double value = NOISE.eval(x * 0.03, z * 0.03) + NOISE.eval(x * 0.1, z * 0.1) * 0.3 + MHelper.randRange(-0.1, 0.1, MHelper.RANDOM); + public void generate(Random random, Chunk chunk, Biome biome, int x, int z, int height, double noise, + BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, + TernarySurfaceConfig surfaceBlocks) { + double value = NOISE.eval(x * 0.03, z * 0.03) + NOISE.eval(x * 0.1, z * 0.1) * 0.3 + + MHelper.randRange(-0.1, 0.1, MHelper.RANDOM); if (value < -0.6) { - SurfaceBuilder.DEFAULT.generate(random, chunk, biome, x, z, height, noise, defaultBlock, defaultFluid, seaLevel, seed, SurfaceBuilders.DEFAULT_END_CONFIG); - } - else if (value < -0.3) { - SurfaceBuilder.DEFAULT.generate(random, chunk, biome, x, z, height, noise, defaultBlock, defaultFluid, seaLevel, seed, SurfaceBuilders.FLAVOLITE_CONFIG); - } - else if (value < 0.5) { - SurfaceBuilder.DEFAULT.generate(random, chunk, biome, x, z, height, noise, defaultBlock, defaultFluid, seaLevel, seed, SurfaceBuilders.SULFURIC_ROCK_CONFIG); - } - else { - SurfaceBuilder.DEFAULT.generate(random, chunk, biome, x, z, height, noise, defaultBlock, defaultFluid, seaLevel, seed, SurfaceBuilders.BRIMSTONE_CONFIG); + SurfaceBuilder.DEFAULT.generate(random, chunk, biome, x, z, height, noise, defaultBlock, defaultFluid, + seaLevel, seed, SurfaceBuilders.DEFAULT_END_CONFIG); + } else if (value < -0.3) { + SurfaceBuilder.DEFAULT.generate(random, chunk, biome, x, z, height, noise, defaultBlock, defaultFluid, + seaLevel, seed, SurfaceBuilders.FLAVOLITE_CONFIG); + } else if (value < 0.5) { + SurfaceBuilder.DEFAULT.generate(random, chunk, biome, x, z, height, noise, defaultBlock, defaultFluid, + seaLevel, seed, SurfaceBuilders.SULFURIC_ROCK_CONFIG); + } else { + SurfaceBuilder.DEFAULT.generate(random, chunk, biome, x, z, height, noise, defaultBlock, defaultFluid, + seaLevel, seed, SurfaceBuilders.BRIMSTONE_CONFIG); } } - + public static SulphuricSurfaceBuilder register(String name) { return Registry.register(Registry.SURFACE_BUILDER, name, new SulphuricSurfaceBuilder()); } diff --git a/src/main/java/ru/betterend/world/surface/SurfaceBuilders.java b/src/main/java/ru/betterend/world/surface/SurfaceBuilders.java index 90c200ef..2246f34a 100644 --- a/src/main/java/ru/betterend/world/surface/SurfaceBuilders.java +++ b/src/main/java/ru/betterend/world/surface/SurfaceBuilders.java @@ -1,9 +1,9 @@ package ru.betterend.world.surface; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.registry.Registry; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.Registry; import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder; import net.minecraft.world.gen.surfacebuilder.TernarySurfaceConfig; import ru.betterend.registry.EndBlocks; @@ -13,17 +13,20 @@ public class SurfaceBuilders { public static final TernarySurfaceConfig FLAVOLITE_CONFIG = makeSimpleConfig(EndBlocks.FLAVOLITE.stone); public static final TernarySurfaceConfig BRIMSTONE_CONFIG = makeSimpleConfig(EndBlocks.BRIMSTONE); public static final TernarySurfaceConfig SULFURIC_ROCK_CONFIG = makeSimpleConfig(EndBlocks.SULPHURIC_ROCK.stone); - - public static final SurfaceBuilder SULPHURIC_SURFACE = register("sulphuric_surface", new SulphuricSurfaceBuilder()); - - private static SurfaceBuilder register(String name, SurfaceBuilder builder) { + + public static final SurfaceBuilder SULPHURIC_SURFACE = register("sulphuric_surface", + new SulphuricSurfaceBuilder()); + + private static SurfaceBuilder register(String name, + SurfaceBuilder builder) { return Registry.register(Registry.SURFACE_BUILDER, name, builder); } - + private static TernarySurfaceConfig makeSimpleConfig(Block block) { - BlockState state = block.getDefaultState(); + BlockState state = block.defaultBlockState(); return new TernarySurfaceConfig(state, state, state); } - - public static void register() {} + + public static void register() { + } }