From 1751f103f959a2c226340f7a9b9060b561da78f0 Mon Sep 17 00:00:00 2001 From: gnembon <41132274+gnembon@users.noreply.github.com> Date: Wed, 5 Apr 2023 20:12:21 +0200 Subject: [PATCH] 23w14a --- gradle.properties | 6 +-- .../carpet/helpers/OptimizedExplosion.java | 10 ++--- ...lowingFluid_liquidDamageDisabledMixin.java | 5 +-- .../script/command/CommandArgument.java | 5 ++- src/main/java/carpet/script/utils/Colors.java | 44 +------------------ src/main/java/carpet/utils/BlockInfo.java | 4 +- .../carpet/utils/PerimeterDiagnostics.java | 4 +- src/main/java/carpet/utils/WoolTool.java | 10 ++++- 8 files changed, 27 insertions(+), 61 deletions(-) diff --git a/gradle.properties b/gradle.properties index 796a39df..206ee066 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check https://fabricmc.net/develop/ - minecraft_version=23w13a - loader_version=0.14.18 + minecraft_version=23w14a + loader_version=0.14.19 jsr305_version=3.0.2 - fabric_version=0.76.0+1.19.4 + fabric_version=0.77.0+1.19.4 # Mod Properties mod_version = 1.4.103 diff --git a/src/main/java/carpet/helpers/OptimizedExplosion.java b/src/main/java/carpet/helpers/OptimizedExplosion.java index d42a738f..cd869d50 100644 --- a/src/main/java/carpet/helpers/OptimizedExplosion.java +++ b/src/main/java/carpet/helpers/OptimizedExplosion.java @@ -241,7 +241,7 @@ public class OptimizedExplosion BlockState state = world.getBlockState(blockpos); Block block = state.getBlock(); - if (state.getMaterial() != Material.AIR) + if (!state.isAir()) { if (block.dropFromExplosion(e) && world instanceof ServerLevel serverLevel) { @@ -281,7 +281,7 @@ public class OptimizedExplosion BlockPos down = blockpos1.below(1); if (eAccess.getRandom().nextInt(3) == 0 && - chunk.getBlockState(blockpos1).getMaterial() == Material.AIR && + chunk.getBlockState(blockpos1).isAir() && chunk.getBlockState(down).isSolidRender(world, down) ) { @@ -346,7 +346,7 @@ public class OptimizedExplosion BlockState state = eAccess.getLevel().getBlockState(blockpos); FluidState fluidState = eAccess.getLevel().getFluidState(blockpos); - if (state.getMaterial() != Material.AIR) { + if (!state.isAir()) { float f2 = Math.max(state.getBlock().getExplosionResistance(), fluidState.getExplosionResistance()); if (eAccess.getSource() != null) f2 = eAccess.getSource().getBlockExplosionResistance(e, eAccess.getLevel(), blockpos, state, fluidState, f2); @@ -475,7 +475,7 @@ public class OptimizedExplosion fluidCache.put(posImmutable, fluid); } - if (state.getMaterial() != Material.AIR) + if (!state.isAir()) { float resistance = Math.max(state.getBlock().getExplosionResistance(), fluid.getExplosionResistance()); @@ -538,7 +538,7 @@ public class OptimizedExplosion BlockState state = eAccess.getLevel().getBlockState(blockpos); FluidState fluidState = eAccess.getLevel().getFluidState(blockpos); - if (state.getMaterial() != Material.AIR) { + if (!state.isAir()) { float f2 = Math.max(state.getBlock().getExplosionResistance(), fluidState.getExplosionResistance()); if (eAccess.getSource() != null) f2 = eAccess.getSource().getBlockExplosionResistance(e, eAccess.getLevel(), blockpos, state, fluidState, f2); diff --git a/src/main/java/carpet/mixins/FlowingFluid_liquidDamageDisabledMixin.java b/src/main/java/carpet/mixins/FlowingFluid_liquidDamageDisabledMixin.java index 0ce97ecc..5d980f37 100644 --- a/src/main/java/carpet/mixins/FlowingFluid_liquidDamageDisabledMixin.java +++ b/src/main/java/carpet/mixins/FlowingFluid_liquidDamageDisabledMixin.java @@ -3,10 +3,10 @@ package carpet.mixins; import carpet.CarpetSettings; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.FlowingFluid; import net.minecraft.world.level.material.Fluid; -import net.minecraft.world.level.material.Material; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -27,8 +27,7 @@ public class FlowingFluid_liquidDamageDisabledMixin { if (CarpetSettings.liquidDamageDisabled) { - Material material = state.getMaterial(); - cir.setReturnValue(material == Material.AIR || material.isLiquid()); + cir.setReturnValue(state.isAir() || state.is(Blocks.WATER) || state.is(Blocks.LAVA)); } } } diff --git a/src/main/java/carpet/script/command/CommandArgument.java b/src/main/java/carpet/script/command/CommandArgument.java index a0e43b50..93276819 100644 --- a/src/main/java/carpet/script/command/CommandArgument.java +++ b/src/main/java/carpet/script/command/CommandArgument.java @@ -104,6 +104,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.commands.BossBarCommands; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.storage.loot.LootDataType; import net.minecraft.world.phys.Vec2; import net.minecraft.world.scores.Scoreboard; @@ -210,10 +211,10 @@ public abstract class CommandArgument (c, p) -> ValueConversions.of(ResourceLocationArgument.getAdvancement(c, p).getId()), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getAdvancements().getAllAdvancements().stream().map(Advancement::getId), builder) ), new VanillaUnconfigurableArgument("lootcondition", ResourceLocationArgument::id, - (c, p) -> ValueConversions.of(c.getSource().registryAccess().registryOrThrow(Registries.LOOT_CONDITION_TYPE).getKey(ResourceLocationArgument.getPredicate(c, p).getType())), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getPredicateManager().getKeys(), builder) + (c, p) -> ValueConversions.of(c.getSource().registryAccess().registryOrThrow(Registries.LOOT_CONDITION_TYPE).getKey(ResourceLocationArgument.getPredicate(c, p).getType())), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getLootData().getKeys(LootDataType.PREDICATE), builder) ), new VanillaUnconfigurableArgument("loottable", ResourceLocationArgument::id, - (c, p) -> ValueConversions.of(ResourceLocationArgument.getId(c, p)), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getLootTables().getIds(), builder) + (c, p) -> ValueConversions.of(ResourceLocationArgument.getId(c, p)), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getLootData().getKeys(LootDataType.TABLE), builder) ), new VanillaUnconfigurableArgument("attribute", Registries.ATTRIBUTE), diff --git a/src/main/java/carpet/script/utils/Colors.java b/src/main/java/carpet/script/utils/Colors.java index d6c01eac..7503cb9f 100644 --- a/src/main/java/carpet/script/utils/Colors.java +++ b/src/main/java/carpet/script/utils/Colors.java @@ -156,51 +156,11 @@ public class Colors ); public static final Map materialName = Map.ofEntries( - entry(Material.AIR , "air" ), - entry(Material.STRUCTURAL_AIR , "void" ), - entry(Material.PORTAL , "portal" ), - entry(Material.CLOTH_DECORATION , "carpet" ), entry(Material.PLANT , "plant" ), - entry(Material.WATER_PLANT, "water_plant" ), - entry(Material.REPLACEABLE_PLANT, "vegetation" ), - entry(Material.REPLACEABLE_FIREPROOF_PLANT, "nether_shoots" ), - entry(Material.REPLACEABLE_WATER_PLANT, "sea_grass" ), - entry(Material.WATER , "water" ), - entry(Material.BUBBLE_COLUMN , "bubble_column"), - entry(Material.LAVA , "lava" ), - entry(Material.TOP_SNOW , "snow_layer" ), - entry(Material.FIRE , "fire" ), - entry(Material.DECORATION , "decoration" ), - entry(Material.WEB , "cobweb" ), - entry(Material.SCULK , "sculk" ), - entry(Material.BUILDABLE_GLASS , "redstone_lamp"), - entry(Material.CLAY, "clay" ), - entry(Material.DIRT , "dirt" ), - entry(Material.GRASS , "grass" ), - entry(Material.ICE_SOLID , "packed_ice" ), + entry(Material.DEPRECATED_REPLACEABLE, "vegetation" ), entry(Material.SAND , "sand" ), - entry(Material.SPONGE , "sponge" ), - entry(Material.SHULKER_SHELL , "shulker" ), entry(Material.WOOD , "wood" ), - entry(Material.BAMBOO_SAPLING , "shoots" ), - entry(Material.BAMBOO , "bamboo" ), - entry(Material.WOOL , "wool" ), - entry(Material.EXPLOSIVE , "tnt" ), - entry(Material.LEAVES , "leaves" ), entry(Material.GLASS , "glass" ), - entry(Material.ICE , "ice" ), - entry(Material.CACTUS , "cactus" ), - entry(Material.STONE , "stone" ), - entry(Material.METAL , "metal" ), - entry(Material.SNOW , "snow" ), - entry(Material.HEAVY_METAL , "anvil" ), - entry(Material.BARRIER , "barrier" ), - entry(Material.PISTON , "piston" ), - entry(Material.MOSS , "moss" ), - entry(Material.VEGETABLE , "gourd" ), - entry(Material.EGG , "dragon_egg" ), - entry(Material.CAKE , "cake" ), - entry(Material.AMETHYST , "amethyst" ), - entry(Material.POWDER_SNOW , "powder_snow") + entry(Material.STONE , "stone" ) ); } diff --git a/src/main/java/carpet/utils/BlockInfo.java b/src/main/java/carpet/utils/BlockInfo.java index 755e4103..70e417e9 100644 --- a/src/main/java/carpet/utils/BlockInfo.java +++ b/src/main/java/carpet/utils/BlockInfo.java @@ -17,6 +17,7 @@ import net.minecraft.world.entity.ai.util.DefaultRandomPos; import net.minecraft.world.entity.monster.ZombifiedPiglin; import net.minecraft.world.level.LightLayer; 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.material.Material; import net.minecraft.world.level.pathfinder.PathComputationType; @@ -39,13 +40,12 @@ public class BlockInfo lst.add(Messenger.s("")); lst.add(Messenger.s("=====================================")); lst.add(Messenger.s(String.format("Block info for %s%s (id %d%s):", blocks.getKey(block),metastring, blocks.getId(block), metastring ))); - lst.add(Messenger.s(String.format(" - Material: %s", Colors.materialName.get(material)))); lst.add(Messenger.s(String.format(" - Map colour: %s", Colors.mapColourName.get(state.getMapColor(world, pos))))); lst.add(Messenger.s(String.format(" - Sound type: %s", Colors.soundName.get(block.getSoundType(state))))); lst.add(Messenger.s("")); lst.add(Messenger.s(String.format(" - Full block: %s", state.isCollisionShapeFullBlock(world, pos)))); // isFullCube() ))); lst.add(Messenger.s(String.format(" - Normal cube: %s", state.isRedstoneConductor(world, pos)))); //isNormalCube()))); isSimpleFullBlock - lst.add(Messenger.s(String.format(" - Is liquid: %s", material.isLiquid()))); + lst.add(Messenger.s(String.format(" - Is liquid: %s", state.is(Blocks.WATER) || state.is(Blocks.LAVA)))); lst.add(Messenger.s("")); lst.add(Messenger.s(String.format(" - Light in: %d, above: %d", Math.max(world.getBrightness(LightLayer.BLOCK, pos),world.getBrightness(LightLayer.SKY, pos)) , diff --git a/src/main/java/carpet/utils/PerimeterDiagnostics.java b/src/main/java/carpet/utils/PerimeterDiagnostics.java index c24dd384..0245419d 100644 --- a/src/main/java/carpet/utils/PerimeterDiagnostics.java +++ b/src/main/java/carpet/utils/PerimeterDiagnostics.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.tags.FluidTags; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; @@ -18,7 +19,6 @@ import net.minecraft.world.level.biome.MobSpawnSettings; 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.material.Material; public class PerimeterDiagnostics { @@ -114,7 +114,7 @@ public class PerimeterDiagnostics BlockState iblockstate_down = worldserver.getBlockState(pos.below()); BlockState iblockstate_up = worldserver.getBlockState(pos.above()); - if ( iblockstate.getMaterial() == Material.WATER && iblockstate_down.getMaterial() == Material.WATER && !iblockstate_up.isRedstoneConductor(worldserver, pos)) // isSimpleFUllBLock + if ( iblockstate.getFluidState().is(FluidTags.WATER) && !iblockstate_up.isRedstoneConductor(worldserver, pos)) // isSimpleFUllBLock { result.liquid++; if (add_water && diagnostic.check_entity_spawn(pos)) diff --git a/src/main/java/carpet/utils/WoolTool.java b/src/main/java/carpet/utils/WoolTool.java index b09a57a7..69e327ae 100644 --- a/src/main/java/carpet/utils/WoolTool.java +++ b/src/main/java/carpet/utils/WoolTool.java @@ -13,14 +13,16 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; +import net.minecraft.tags.BlockTags; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.DyeColor; import net.minecraft.world.level.Level; 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.phys.Vec3; +import javax.annotation.Nullable; + import static java.util.Map.entry; /** @@ -129,11 +131,15 @@ public class WoolTool /** * Gets the colour of wool at the position, for hoppers to be able to decide whether to add their items to the global counter. */ + @Nullable public static DyeColor getWoolColorAtPosition(Level worldIn, BlockPos pos) { BlockState state = worldIn.getBlockState(pos); - if (state.getMaterial() != Material.WOOL || !state.isRedstoneConductor(worldIn, pos)) //isSimpleFullBlock + // wool and wool carpets + if (!state.is(BlockTags.WOOL)) + { return null; + } return Material2Dye.get(state.getMapColor(worldIn, pos)); } }