diff --git a/game/client/src/main/java/net/minecraft/client/render/block/color/BlockColorRubyglassConduit.java b/game/client/src/main/java/net/minecraft/client/render/block/color/BlockColorConduit.java similarity index 55% rename from game/client/src/main/java/net/minecraft/client/render/block/color/BlockColorRubyglassConduit.java rename to game/client/src/main/java/net/minecraft/client/render/block/color/BlockColorConduit.java index 679cad0ca..c6a3a258f 100644 --- a/game/client/src/main/java/net/minecraft/client/render/block/color/BlockColorRubyglassConduit.java +++ b/game/client/src/main/java/net/minecraft/client/render/block/color/BlockColorConduit.java @@ -2,50 +2,39 @@ package net.minecraft.client.render.block.color; import com.mojang.logging.LogUtils; import net.minecraft.client.Minecraft; -import net.minecraft.core.block.BlockLogicRubyglassConduit; +import net.minecraft.core.block.BlockLogicConduit; import net.minecraft.core.world.WorldSource; import net.minecraft.core.world.pos.TilePosc; +import org.jetbrains.annotations.NotNull; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.InputStream; -public class BlockColorRubyglassConduit extends BlockColor { +public class BlockColorConduit extends BlockColor { private static final org.slf4j.Logger LOGGER = LogUtils.getLogger(); - private final int[] powerColors = new int[11]; + private final int[] powerColors = new int[16]; - public BlockColorRubyglassConduit() { + public BlockColorConduit() { loadPalette(); } private void loadPalette() { - boolean loadedSuccessfully = false; String palettePath = "/assets/minecraft/textures/misc/colors_conduit.png"; try (InputStream stream = Minecraft.getMinecraft().texturePackList.getResourceAsStream(palettePath)) { if (stream != null) { BufferedImage image = ImageIO.read(stream); - for (int i = 0; i < 11; i++) { + for (int i = 0; i < 16; i++) { int x = Math.min(i, image.getWidth() - 1); powerColors[i] = image.getRGB(x, 0) & 0xFFFFFF; } - loadedSuccessfully = true; } } catch (Exception e) { LOGGER.error("Failed to load conduit palette at {}", palettePath, e); } - - if (!loadedSuccessfully) { - powerColors[0] = 0x330000; - int minRed = 80; - int maxRed = 255; - for (int strength = 1; strength <= 10; strength++) { - int redValue = minRed + (int)(((strength - 1) / 9.0f) * (maxRed - minRed)); - powerColors[strength] = (redValue << 16); - } - } } @Override @@ -54,10 +43,10 @@ public class BlockColorRubyglassConduit extends BlockColor { } @Override - public int getWorldColor(WorldSource world, TilePosc pos, int tintIndex) { - int data = world.getBlockData(pos); - int strength = data / BlockLogicRubyglassConduit.STATE_COUNT; - strength = Math.max(0, Math.min(10, strength)); + public int getWorldColor(WorldSource world, @NotNull TilePosc tilePos, int tintIndex) { + int data = world.getBlockData(tilePos); + int strength = data / BlockLogicConduit.STATE_COUNT; + strength = Math.max(0, Math.min(15, strength)); return powerColors[strength]; } } \ No newline at end of file diff --git a/game/client/src/main/java/net/minecraft/client/render/block/color/BlockColorDispatcher.java b/game/client/src/main/java/net/minecraft/client/render/block/color/BlockColorDispatcher.java index 023ec10ad..31a3fd172 100644 --- a/game/client/src/main/java/net/minecraft/client/render/block/color/BlockColorDispatcher.java +++ b/game/client/src/main/java/net/minecraft/client/render/block/color/BlockColorDispatcher.java @@ -48,7 +48,7 @@ public final class BlockColorDispatcher addDispatch(Blocks.WIRE_REDSTONE, new BlockColorWireRedstone()); addDispatch(Blocks.TALLGRASS, new BlockColorCustom(Colorizers.grass)); addDispatch(Blocks.TALLGRASS_FERN, new BlockColorCustom(Colorizers.grass)); - addDispatch(Blocks.RUBYGLASS_CONDUIT, new BlockColorRubyglassConduit()); + addDispatch(Blocks.CONDUIT, new BlockColorConduit()); } diff --git a/game/client/src/main/java/net/minecraft/client/render/block/model/BlockModelRubyglassConduit.java b/game/client/src/main/java/net/minecraft/client/render/block/model/BlockModelConduit.java similarity index 52% rename from game/client/src/main/java/net/minecraft/client/render/block/model/BlockModelRubyglassConduit.java rename to game/client/src/main/java/net/minecraft/client/render/block/model/BlockModelConduit.java index 5faddc642..7c09ff5fc 100644 --- a/game/client/src/main/java/net/minecraft/client/render/block/model/BlockModelRubyglassConduit.java +++ b/game/client/src/main/java/net/minecraft/client/render/block/model/BlockModelConduit.java @@ -4,77 +4,73 @@ import net.minecraft.client.render.block.model.generic.BlockModelGeneric; import net.minecraft.client.render.tessellator.TessellatorGeneral; import net.minecraft.client.render.texture.stitcher.IconCoordinate; import net.minecraft.core.block.Block; -import net.minecraft.core.block.BlockLogicRubyglassConduit; +import net.minecraft.core.block.BlockLogicConduit; import net.minecraft.core.world.WorldSource; import net.minecraft.core.world.pos.TilePosc; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.useless.dragonfly.models.block.StaticBlockModel; -public class BlockModelRubyglassConduit extends BlockModelGeneric { +public class BlockModelConduit extends BlockModelGeneric { private record ModelState(StaticBlockModel model, int rotX, int rotY, int rotZ) { } - private final ModelState[] stateMapOn = new ModelState[BlockLogicRubyglassConduit.STATE_COUNT]; - private final ModelState[] stateMapOff = new ModelState[BlockLogicRubyglassConduit.STATE_COUNT]; + private final ModelState[] stateMapOn = new ModelState[BlockLogicConduit.STATE_COUNT]; + private final ModelState[] stateMapOff = new ModelState[BlockLogicConduit.STATE_COUNT]; + private final ModelState inertState; - public BlockModelRubyglassConduit(Block block) { + public BlockModelConduit(Block block) { super(block, BlockModelDispatcher.loadDataModel("minecraft:block/rubyglass/conduit/conduit_core").asModel()); StaticBlockModel onCore = BlockModelDispatcher.loadDataModel("minecraft:block/rubyglass/conduit/conduit_core").asModel(); - StaticBlockModel onCap = BlockModelDispatcher.loadDataModel("minecraft:block/rubyglass/conduit/conduit_cap").asModel(); StaticBlockModel onStraight = BlockModelDispatcher.loadDataModel("minecraft:block/rubyglass/conduit/conduit_straight").asModel(); StaticBlockModel onCorner = BlockModelDispatcher.loadDataModel("minecraft:block/rubyglass/conduit/conduit_corner").asModel(); StaticBlockModel offCore = BlockModelDispatcher.loadDataModel("minecraft:block/rubyglass/conduit/conduit_core_off").asModel(); - StaticBlockModel offCap = BlockModelDispatcher.loadDataModel("minecraft:block/rubyglass/conduit/conduit_cap_off").asModel(); StaticBlockModel offStraight = BlockModelDispatcher.loadDataModel("minecraft:block/rubyglass/conduit/conduit_straight_off").asModel(); StaticBlockModel offCorner = BlockModelDispatcher.loadDataModel("minecraft:block/rubyglass/conduit/conduit_corner_off").asModel(); + this.inertState = new ModelState(onCore, 0, 0, 0); - populateStateMap(stateMapOn, onCore, onCap, onStraight, onCorner); - populateStateMap(stateMapOff, offCore, offCap, offStraight, offCorner); + populateStateMap(stateMapOn, onCore, onStraight, onCorner); + populateStateMap(stateMapOff, offCore, offStraight, offCorner); } - private void populateStateMap(ModelState[] map, StaticBlockModel core, StaticBlockModel cap, StaticBlockModel straight, StaticBlockModel corner) { - // 0: Core - map[0] = new ModelState(core, 0, 0, 0); - - // 1-6: End Caps - map[1] = new ModelState(cap, 0, 0, 0); - map[2] = new ModelState(cap, 2, 0, 0); - map[3] = new ModelState(cap, 1, 0, 0); - map[4] = new ModelState(cap, 3, 0, 0); - map[5] = new ModelState(cap, 0, 0, 3); - map[6] = new ModelState(cap, 0, 0, 1); - - // 7-9: Straights - map[7] = new ModelState(straight, 0, 0, 0); - map[8] = new ModelState(straight, 1, 0, 0); - map[9] = new ModelState(straight, 0, 0, 1); - - // 10-13: Bottom Corners - map[10] = new ModelState(corner, 0, 0, 0); - map[11] = new ModelState(corner, 0, 2, 0); - map[12] = new ModelState(corner, 0, 1, 0); - map[13] = new ModelState(corner, 0, 3, 0); - - // 14-17: Top Corners - map[14] = new ModelState(corner, 2, 2, 0); - map[15] = new ModelState(corner, 2, 0, 0); - map[16] = new ModelState(corner, 2, 3, 0); - map[17] = new ModelState(corner, 2, 1, 0); - - // 18-21: Horizontal Corners - map[18] = new ModelState(corner, 0, 0, 3); - map[19] = new ModelState(corner, 0, 0, 1); - map[20] = new ModelState(corner, 0, 2, 3); - map[21] = new ModelState(corner, 0, 2, 1); + private void populateStateMap(ModelState[] map, StaticBlockModel core, StaticBlockModel straight, StaticBlockModel corner) { + // Core + map[0] = new ModelState(core, 0, 0, 0); //Closed + + // Straights + map[1] = new ModelState(straight, 0, 0, 0); //Y + map[2] = new ModelState(straight, 1, 0, 0); //X + map[3] = new ModelState(straight, 0, 0, 1); //Z + + // Bottom Corners + map[4] = new ModelState(corner, 0, 0, 0); //BN + map[5] = new ModelState(corner, 0, 2, 0); //BS + map[6] = new ModelState(corner, 0, 1, 0); //BW + map[7] = new ModelState(corner, 0, 3, 0); //BE + + // Top Corners + map[8] = new ModelState(corner, 2, 2, 0); //TN + map[9] = new ModelState(corner, 2, 0, 0); //TS + map[10] = new ModelState(corner, 2, 3, 0); //TW + map[11] = new ModelState(corner, 2, 1, 0); //TE + + // Horizontal Corners + map[12] = new ModelState(corner, 0, 0, 3); //NW + map[13] = new ModelState(corner, 0, 0, 1); //NE + map[14] = new ModelState(corner, 0, 2, 3); //SW + map[15] = new ModelState(corner, 0, 2, 1); //SE } @Override public @NotNull StaticBlockModel getModelFromData(int data) { - int state = data % BlockLogicRubyglassConduit.STATE_COUNT; - int strength = data / BlockLogicRubyglassConduit.STATE_COUNT; + int state = data & BlockLogicConduit.STATE_MASK; + int strength = (data >> BlockLogicConduit.POWER_SHIFT) & BlockLogicConduit.POWER_MASK; + + if (state == 0 && strength == 15) { + return inertState.model; + } if (strength == 0) { return stateMapOff[state].model; @@ -86,11 +82,13 @@ public class BlockModelRubyglassConduit ex @Override public boolean renderAttached(final @NotNull TessellatorGeneral tessellator, @NotNull final WorldSource worldSource, @NotNull TilePosc tilePos, boolean cullFaces, final @Nullable IconCoordinate overrideTexture) { int data = worldSource.getBlockData(tilePos); - int state = data % BlockLogicRubyglassConduit.STATE_COUNT; - int strength = data / BlockLogicRubyglassConduit.STATE_COUNT; + int state = data & BlockLogicConduit.STATE_MASK; + int strength = (data >> BlockLogicConduit.POWER_SHIFT) & BlockLogicConduit.POWER_MASK; ModelState activeState; - if (strength == 0) { + if (state == 0 && strength == 15) { + activeState = inertState; + } else if (strength == 0) { activeState = stateMapOff[state]; } else { activeState = stateMapOn[state]; diff --git a/game/client/src/main/java/net/minecraft/client/render/block/model/BlockModelDispatcher.java b/game/client/src/main/java/net/minecraft/client/render/block/model/BlockModelDispatcher.java index af8a9e2a4..326f64167 100644 --- a/game/client/src/main/java/net/minecraft/client/render/block/model/BlockModelDispatcher.java +++ b/game/client/src/main/java/net/minecraft/client/render/block/model/BlockModelDispatcher.java @@ -347,7 +347,7 @@ public final class BlockModelDispatcher addDispatch(new BlockModelGeneric<>(Blocks.RUBYGLASS_NODE, loadDataModel("minecraft:block/rubyglass/node"))); addDispatch(new BlockModelGeneric<>(Blocks.BLOCK_RUBYGLASS, loadDataModel("minecraft:block/rubyglass/block")).forceCullSelf(true)); addDispatch(new BlockModelCrystalBud<>(Blocks.RUBYGLASS_SPROUT, loadDataModel("minecraft:block/rubyglass/sprout")).render3D(false)); - addDispatch(new BlockModelRubyglassConduit<>(Blocks.RUBYGLASS_CONDUIT)); + addDispatch(new BlockModelConduit<>(Blocks.CONDUIT)); addDispatch(new BlockModelGeneric<>(Blocks.ORE_NETHERCOAL_NETHERRACK, loadDataModel("minecraft:block/ore/nethercoal/netherrack"))); addDispatch(new BlockModelGeneric<>(Blocks.ORE_NETHERCOAL_BASALT, loadDataModel("minecraft:block/ore/nethercoal/basalt"))); diff --git a/game/client/src/main/java/net/minecraft/client/render/item/model/ItemModelBucketIron.java b/game/client/src/main/java/net/minecraft/client/render/item/model/ItemModelBucketIron.java index 0e6313688..fc70c6e39 100644 --- a/game/client/src/main/java/net/minecraft/client/render/item/model/ItemModelBucketIron.java +++ b/game/client/src/main/java/net/minecraft/client/render/item/model/ItemModelBucketIron.java @@ -9,12 +9,7 @@ import java.util.Set; public class ItemModelBucketIron extends ItemModelBucket { public ItemModelBucketIron(Item item, String namespace) { super(item, namespace); - Set validStates = Set.of( - ItemBucket.STATE_WATER, - ItemBucket.STATE_LAVA, - ItemBucket.STATE_MILK, - ItemBucket.STATE_ICECREAM - ); + Set validStates = ItemBucket.getRegisteredStateIds(); this.initializeIcons(namespace, "bucket_iron", 1, validStates); } } \ No newline at end of file diff --git a/game/client/src/main/java/net/minecraft/client/render/item/model/ItemModelBucketSteel.java b/game/client/src/main/java/net/minecraft/client/render/item/model/ItemModelBucketSteel.java index dff72dccb..13600c632 100644 --- a/game/client/src/main/java/net/minecraft/client/render/item/model/ItemModelBucketSteel.java +++ b/game/client/src/main/java/net/minecraft/client/render/item/model/ItemModelBucketSteel.java @@ -9,13 +9,7 @@ import java.util.Set; public class ItemModelBucketSteel extends ItemModelBucket { public ItemModelBucketSteel(Item item, String namespace) { super(item, namespace); - Set validStates = Set.of( - ItemBucket.STATE_WATER, - ItemBucket.STATE_LAVA, - ItemBucket.STATE_MILK, - ItemBucket.STATE_ICECREAM - ); - + Set validStates = ItemBucket.getRegisteredStateIds(); this.initializeIcons(namespace, "bucket_steel", 3, validStates); } } \ No newline at end of file diff --git a/game/client/src/main/java/net/minecraft/client/render/texture/generator/TextureGeneratorRubyglassConduit.java b/game/client/src/main/java/net/minecraft/client/render/texture/generator/TextureGeneratorRubyglassConduit.java deleted file mode 100644 index fa494b0f2..000000000 --- a/game/client/src/main/java/net/minecraft/client/render/texture/generator/TextureGeneratorRubyglassConduit.java +++ /dev/null @@ -1,81 +0,0 @@ -package net.minecraft.client.render.texture.generator; - -import net.minecraft.client.Minecraft; -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; -import java.io.InputStream; - -public class TextureGeneratorRubyglassConduit { - - private static int[] palette = null; - - public static BufferedImage generateConduitTexture(String shape, int strength, String layer) { - loadPalette(); - int color = palette[Math.max(0, Math.min(10, strength))]; - - String basePath = "/assets/minecraft/textures/block/rubyglass/conduit/" + shape + "_base.png"; - String maskPath = "/assets/minecraft/textures/block/rubyglass/conduit/" + shape + "_mask.png"; - - try { - BufferedImage baseImg = loadImage(basePath); - BufferedImage maskImg = loadImage(maskPath); - - if (baseImg == null || maskImg == null) return null; - - int width = baseImg.getWidth(); - int height = baseImg.getHeight(); - BufferedImage result = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - - for (int x = 0; x < width; x++) { - for (int y = 0; y < height; y++) { - int basePixel = baseImg.getRGB(x, y); - int maskPixel = maskImg.getRGB(x, y); - - boolean isRedstone = ((maskPixel >> 24) & 0xFF) > 128 && ((maskPixel >> 16) & 0xFF) > 128; - - if (layer.equals("emissive")) { - if (isRedstone) { - result.setRGB(x, y, (0xFF << 24) | color); - } else { - result.setRGB(x, y, 0x00000000); - } - } else { - if (isRedstone) { - result.setRGB(x, y, (0xFF << 24) | color); - } else { - result.setRGB(x, y, basePixel); - } - } - } - } - return result; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - private static BufferedImage loadImage(String path) { - try (InputStream stream = Minecraft.getMinecraft().texturePackList.getResourceAsStream(path)) { - if (stream != null) return ImageIO.read(stream); - } catch (Exception ignored) {} - return null; - } - - private static void loadPalette() { - if (palette != null) return; - palette = new int[11]; - - try { - BufferedImage img = loadImage("/assets/minecraft/textures/block/rubyglass/palette.png"); - if (img != null) { - for (int i = 0; i < 11; i++) { - int x = Math.min(i, img.getWidth() - 1); - palette[i] = img.getRGB(x, 0) & 0xFFFFFF; - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/game/client/src/main/java/net/minecraft/client/render/tileentity/UnusedRendererRubyglassConduit.java b/game/client/src/main/java/net/minecraft/client/render/tileentity/UnusedRendererRubyglassConduit.java index 27ca73ba7..3575bac33 100644 --- a/game/client/src/main/java/net/minecraft/client/render/tileentity/UnusedRendererRubyglassConduit.java +++ b/game/client/src/main/java/net/minecraft/client/render/tileentity/UnusedRendererRubyglassConduit.java @@ -1,12 +1,12 @@ package net.minecraft.client.render.tileentity; -class UnusedRendererRubyglassConduit { +class UnusedRendererConduit { /*private static final long MAGIC_PRIME_X = 3129871L; private static final long MAGIC_PRIME_Y = 116129781L; private long fastRandomSeed; - public void doRender(TessellatorGeneral tessellator, TileEntityRubyglassConduit conduitTileEntity, double x, double y, double z, float partialTick) { + public void doRender(TessellatorGeneral tessellator, TileEntityConduit conduitTileEntity, double x, double y, double z, float partialTick) { Player player = Minecraft.getMinecraft().thePlayer; if (!shouldRender(conduitTileEntity, player, partialTick)) @@ -84,7 +84,7 @@ class UnusedRendererRubyglassConduit { return strength == 0 ? baseJitter * 0.25 : baseJitter; } - private boolean shouldRender(TileEntityRubyglassConduit conduitTileEntity, Player player, float partialTick) { + private boolean shouldRender(TileEntityConduit conduitTileEntity, Player player, float partialTick) { if (player == null) return false; ItemStack boots = player.inventory.armorItemInSlot(HumanArmorShape.BOOTS); @@ -263,7 +263,7 @@ class UnusedRendererRubyglassConduit { } } - private boolean shouldCull(TileEntityRubyglassConduit conduitTileEntity, Player player, float partialTick) { + private boolean shouldCull(TileEntityConduit conduitTileEntity, Player player, float partialTick) { double deltaX = (conduitTileEntity.tilePos.x + 0.5) - player.x; double deltaY = (conduitTileEntity.tilePos.y + 0.5) - (player.y + player.getHeadHeight()); double deltaZ = (conduitTileEntity.tilePos.z + 0.5) - player.z; diff --git a/game/client/src/main/java/net/minecraft/client/util/helper/Colors.java b/game/client/src/main/java/net/minecraft/client/util/helper/Colors.java index 2993e33f2..d8eadb4c5 100644 --- a/game/client/src/main/java/net/minecraft/client/util/helper/Colors.java +++ b/game/client/src/main/java/net/minecraft/client/util/helper/Colors.java @@ -20,7 +20,7 @@ public abstract class Colors { public static final Color[] allFlagColors = new Color[16]; public static final Color[] allSignColors = new Color[16]; public static final Color[] allRedstoneColors = new Color[16]; - public static final Color[] allConduitColors = new Color[11]; + public static final Color[] allConduitColors = new Color[16]; public static final Color[] allPortalColors = new Color[16]; public static void loadDummyColors() { diff --git a/game/client/src/main/resources/assets/minecraft/models/block/rubyglass/conduit/conduit_cap.json b/game/client/src/main/resources/assets/minecraft/models/block/rubyglass/conduit/conduit_cap.json deleted file mode 100644 index 04f04c2a6..000000000 --- a/game/client/src/main/resources/assets/minecraft/models/block/rubyglass/conduit/conduit_cap.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "format_version": "1.21.6", - "credit": "Made with Blockbench", - "textures": { - "closed": "minecraft:block/rubyglass/conduit/closed/closed", - "closed_overlay": "minecraft:block/rubyglass/conduit/closed/closed_overlay", - "open": "minecraft:block/rubyglass/conduit/open/open", - "open_overlay": "minecraft:block/rubyglass/conduit/open/open_overlay", - "plug": "minecraft:block/rubyglass/conduit/plug/plug", - "plug_overlay": "minecraft:block/rubyglass/conduit/plug/plug_overlay", - "particle": "minecraft:block/rubyglass/conduit/closed/closed" - }, - "elements": [ - { - "name": "Conduit Casing", - "from": [0, 0, 0], - "to": [16, 16, 16], - "faces": { - "north": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#plug", "cullface": "north"}, - "east": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#plug", "cullface": "east"}, - "south": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#plug", "cullface": "south"}, - "west": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#plug", "cullface": "west"}, - "up": {"uv": [0, 0, 16, 16], "texture": "#closed", "cullface": "up"}, - "down": {"uv": [0, 0, 16, 16], "texture": "#open", "cullface": "down"} - } - }, - { - "name": "Redstone Overlay", - "from": [0, 0, 0], - "to": [16, 16, 16], - "faces": { - "north": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#plug_overlay", "cullface": "north", "tintindex": 0, "shade": false}, - "east": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#plug_overlay", "cullface": "east", "tintindex": 0, "shade": false}, - "south": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#plug_overlay", "cullface": "south", "tintindex": 0, "shade": false}, - "west": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#plug_overlay", "cullface": "west", "tintindex": 0, "shade": false}, - "down": {"uv": [0, 0, 16, 16], "texture": "#open_overlay", "cullface": "down", "tintindex": 0, "shade": false} - } - } - ] -} \ No newline at end of file diff --git a/game/client/src/main/resources/assets/minecraft/models/block/rubyglass/conduit/conduit_cap_off.json b/game/client/src/main/resources/assets/minecraft/models/block/rubyglass/conduit/conduit_cap_off.json deleted file mode 100644 index c823c86d8..000000000 --- a/game/client/src/main/resources/assets/minecraft/models/block/rubyglass/conduit/conduit_cap_off.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "format_version": "1.21.6", - "credit": "Made with Blockbench", - "textures": { - "closed": "minecraft:block/rubyglass/conduit/closed/closed", - "closed_overlay": "minecraft:block/rubyglass/conduit/closed/closed_overlay", - "open": "minecraft:block/rubyglass/conduit/open/open", - "open_overlay": "minecraft:block/rubyglass/conduit/open/open_overlay", - "plug": "minecraft:block/rubyglass/conduit/plug/plug", - "particle": "minecraft:block/rubyglass/conduit/closed/closed" - }, - "elements": [ - { - "name": "Conduit Casing", - "from": [0, 0, 0], - "to": [16, 16, 16], - "faces": { - "north": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#plug", "cullface": "north"}, - "east": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#plug", "cullface": "east"}, - "south": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#plug", "cullface": "south"}, - "west": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#plug", "cullface": "west"}, - "up": {"uv": [0, 0, 16, 16], "texture": "#closed", "cullface": "up"}, - "down": {"uv": [0, 0, 16, 16], "texture": "#open", "cullface": "down"} - } - } - ] -} \ No newline at end of file diff --git a/game/client/src/main/resources/assets/minecraft/textures/misc/colors_conduit.png b/game/client/src/main/resources/assets/minecraft/textures/misc/colors_conduit.png index 5f2489fb5..8df108da8 100644 Binary files a/game/client/src/main/resources/assets/minecraft/textures/misc/colors_conduit.png and b/game/client/src/main/resources/assets/minecraft/textures/misc/colors_conduit.png differ diff --git a/game/core/src/main/java/net/minecraft/core/block/BlockLogicActivator.java b/game/core/src/main/java/net/minecraft/core/block/BlockLogicActivator.java index 46c4fb18b..4aa798ee7 100644 --- a/game/core/src/main/java/net/minecraft/core/block/BlockLogicActivator.java +++ b/game/core/src/main/java/net/minecraft/core/block/BlockLogicActivator.java @@ -18,7 +18,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Objects; import java.util.Random; -import static net.minecraft.core.block.BlockLogicRubyglassConduit.packEventConduitData; +import static net.minecraft.core.block.BlockLogicConduit.packEventConduitData; public class BlockLogicActivator extends BlockLogicVeryRotatable { diff --git a/game/core/src/main/java/net/minecraft/core/block/BlockLogicRubyglassConduit.java b/game/core/src/main/java/net/minecraft/core/block/BlockLogicConduit.java similarity index 71% rename from game/core/src/main/java/net/minecraft/core/block/BlockLogicRubyglassConduit.java rename to game/core/src/main/java/net/minecraft/core/block/BlockLogicConduit.java index 8e527e43f..448a650a7 100644 --- a/game/core/src/main/java/net/minecraft/core/block/BlockLogicRubyglassConduit.java +++ b/game/core/src/main/java/net/minecraft/core/block/BlockLogicConduit.java @@ -3,6 +3,8 @@ package net.minecraft.core.block; import net.minecraft.core.block.material.Material; import net.minecraft.core.entity.Mob; import net.minecraft.core.entity.player.Player; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.item.Items; import net.minecraft.core.sound.SoundCategory; import net.minecraft.core.util.helper.Direction; import net.minecraft.core.util.helper.Side; @@ -19,33 +21,30 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; -public class BlockLogicRubyglassConduit extends BlockLogic { +public class BlockLogicConduit extends BlockLogic { public static final Side[][] STATE_TABLE = { - {}, // 0 - {Side.BOTTOM}, {Side.TOP}, // 1-2 - {Side.NORTH}, {Side.SOUTH}, // 3-4 - {Side.WEST}, {Side.EAST}, // 5-6 - - {Side.BOTTOM, Side.TOP}, // 7 Y-Axis - {Side.NORTH, Side.SOUTH}, // 8 Z-Axis - {Side.WEST, Side.EAST}, // 9 X-Axis - - {Side.BOTTOM, Side.NORTH}, {Side.BOTTOM, Side.SOUTH}, // 10-11 - {Side.BOTTOM, Side.WEST}, {Side.BOTTOM, Side.EAST}, // 12-13 - {Side.TOP, Side.NORTH}, {Side.TOP, Side.SOUTH}, // 14-15 - {Side.TOP, Side.WEST}, {Side.TOP, Side.EAST}, // 16-17 - {Side.NORTH, Side.WEST}, {Side.NORTH, Side.EAST}, // 18-19 - {Side.SOUTH, Side.WEST}, {Side.SOUTH, Side.EAST} // 20-21 + {}, // 0 + {Side.BOTTOM, Side.TOP}, // 1 Y-Axis + {Side.NORTH, Side.SOUTH}, // 2 Z-Axis + {Side.WEST, Side.EAST}, // 3 X-Axis + + {Side.BOTTOM, Side.NORTH}, {Side.BOTTOM, Side.SOUTH}, // 4-5 + {Side.BOTTOM, Side.WEST}, {Side.BOTTOM, Side.EAST}, // 6-7 + {Side.TOP, Side.NORTH}, {Side.TOP, Side.SOUTH}, // 8-9 + {Side.TOP, Side.WEST}, {Side.TOP, Side.EAST}, // 10-11 + {Side.NORTH, Side.WEST}, {Side.NORTH, Side.EAST}, // 12-13 + {Side.SOUTH, Side.WEST}, {Side.SOUTH, Side.EAST} // 14-15 }; - //PROPAGATION_LENGTH can ONLY BE A MAXIMUM OF 10. Anymore and the data will become mangled. - //if changed after implementation, data of existing conduits will become mangled without a converter. - //TODO There are a couple of hardcoded segments of code that do not account for PROPAGATION_LENGTH - private static final int PROPAGATION_LENGTH = 10; - public static final int STATE_COUNT = 22; + private static final int PROPAGATION_LENGTH = 15; + public static final int STATE_COUNT = 16; - public BlockLogicRubyglassConduit(@NotNull Block block, @NotNull Material material) { + public static final int STATE_MASK = 0b1111; + public static final int POWER_MASK = 0b1111; + public static final int POWER_SHIFT = 4; + + public BlockLogicConduit(@NotNull Block block, @NotNull Material material) { super(block, material); } @@ -62,7 +61,12 @@ public class BlockLogicRubyglassConduit extends BlockLogic { @Override public void animationTick(final @NotNull World world, final @NotNull TilePosc tilePos, final @NotNull Random rand) { int data = world.getBlockData(tilePos); - int strength = data / STATE_COUNT; + + if (data == 15 << POWER_SHIFT) { + return; + } + + int strength = (data >> POWER_SHIFT) & POWER_MASK; if (strength > 0) { world.playBlockEvent(tilePos, LevelListener.EVENT_CONDUIT_SURFACE_PARTICLES, packEventConduitData(Side.NONE, strength)); @@ -108,13 +112,15 @@ public class BlockLogicRubyglassConduit extends BlockLogic { /** * Defines the placement and routing behavior of the conduit when placed into the world by an entity. *

- * This method handles two distinct placement modes: + * This method handles three distinct placement modes: *

    + *
  • Rotation Lock: Absolute override. Forces the conduit to place as a straight pipe aligned + * with the player's active rotation lock direction.
  • *
  • Sneaking (Manual Placement): Bypasses auto-connection. If placed against a closed conduit port, - * it will force that port open and connect to it. Otherwise, it defaults to routing a connection from the + * it will force that port open and connect to it. Otherwise, defaults to routing a connection from the * clicked block face toward the placing entity.
  • - *
  • Standard (Auto-connection): Scans adjacent blocks for valid, open conduit ports. - *
      + *
    • Standard (Auto-connection): Scans adjacent blocks for valid, open conduit ports to link up with.
    • + *
    *
  • 1 Valid Neighbor: Routes from the neighbor toward the entity.
  • *
  • 2 Valid Neighbors: Creates a straight or corner connection linking both neighbors.
  • *
  • 3+ Valid Neighbors: Defaults to routing from the block placed against toward the entity.
  • @@ -124,7 +130,7 @@ public class BlockLogicRubyglassConduit extends BlockLogic { * @param world World the block is being placed in. * @param cTilePos The position where this new conduit is being placed. * @param sidePlacedOnto The face of the existing block that the entity clicked against to place this block. - * @param mob The entity (usually a Player) placing the block. + * @param mob The mob placing the block. * @param xHit The X coordinate of the cursor hit on the block face. * @param yHit The Y coordinate of the cursor hit on the block face. */ @@ -134,7 +140,15 @@ public class BlockLogicRubyglassConduit extends BlockLogic { Side sideClickedAgainst = sidePlacedOnto.getOpposite(); int stateToPlaceAs = 0; - if (mob.isSneaking()) { + + if (mob instanceof Player player) { + if (player.rotationLock != null && player.rotationLock != Direction.NONE) { + Side lockSide = player.rotationLock.getSide(); + stateToPlaceAs = getStateFromTwoSides(lockSide, lockSide.getOpposite()); + } + } + + if (stateToPlaceAs == 0 && mob.isSneaking()) { boolean openedClosedFace = false; TilePos clickedPos = new TilePos(cTilePos.x() + sideClickedAgainst.getOffsetX(), cTilePos.y() + sideClickedAgainst.getOffsetY(), cTilePos.z() + sideClickedAgainst.getOffsetZ()); @@ -142,12 +156,12 @@ public class BlockLogicRubyglassConduit extends BlockLogic { int clickedData = world.getBlockData(clickedPos); if (!isSideOpen(clickedData, sidePlacedOnto)) { - int clickedState = clickedData % STATE_COUNT; - int clickedStrength = clickedData / STATE_COUNT; + int clickedState = clickedData & STATE_MASK; + int clickedStrength = (clickedData >> POWER_SHIFT) & POWER_MASK; int newClickedState = getNextState(clickedState, sidePlacedOnto); if (newClickedState != clickedState) { - world.setBlockDataNotify(clickedPos, clickedStrength * STATE_COUNT + newClickedState); + world.setBlockDataNotify(clickedPos, (clickedStrength << POWER_SHIFT) | newClickedState); this.onNeighborChanged(world, clickedPos, this.block); openedClosedFace = true; } @@ -156,16 +170,16 @@ public class BlockLogicRubyglassConduit extends BlockLogic { } if (openedClosedFace) { - stateToPlaceAs = getNextState(0, sideClickedAgainst); + stateToPlaceAs = getStateFromTwoSides(sideClickedAgainst, sideClickedAgainst.getOpposite()); } else { if (sideClickedAgainst != sideFacingPlayer && sideFacingPlayer != Side.NONE) { stateToPlaceAs = getStateFromTwoSides(sideClickedAgainst, sideFacingPlayer); } else { - stateToPlaceAs = getNextState(0, sideClickedAgainst); + stateToPlaceAs = getStateFromTwoSides(sideClickedAgainst, sideClickedAgainst.getOpposite()); } } } - else { + else if (stateToPlaceAs == 0) { List validSides = new ArrayList<>(); for (Side side : Side.values()) { @@ -188,7 +202,7 @@ public class BlockLogicRubyglassConduit extends BlockLogic { if (sideFacingPlayer != autoConnectedSide && sideFacingPlayer != Side.NONE) { stateToPlaceAs = getStateFromTwoSides(autoConnectedSide, sideFacingPlayer); } else { - stateToPlaceAs = getNextState(0, autoConnectedSide); + stateToPlaceAs = getStateFromTwoSides(autoConnectedSide, autoConnectedSide.getOpposite()); } } else if (numOfValidSides == 2) { stateToPlaceAs = getStateFromTwoSides(validSides.get(0), validSides.get(1)); @@ -202,7 +216,7 @@ public class BlockLogicRubyglassConduit extends BlockLogic { if (sideFacingPlayer != sideClickedAgainst && sideFacingPlayer != Side.NONE) { stateToPlaceAs = getStateFromTwoSides(sideClickedAgainst, sideFacingPlayer); } else { - stateToPlaceAs = getNextState(0, sideClickedAgainst); + stateToPlaceAs = getStateFromTwoSides(sideClickedAgainst, sideClickedAgainst.getOpposite()); } } } @@ -251,23 +265,42 @@ public class BlockLogicRubyglassConduit extends BlockLogic { } int cData = world.getBlockData(cTilePos); + int cState = cData & STATE_MASK; + int cStrength = (cData >> POWER_SHIFT) & POWER_MASK; + + if (holdingNothing && player.isSneaking() && cState == 0) { + if (cStrength == 0) { + world.setBlockDataNotify(cTilePos, (15 << POWER_SHIFT)); + world.playSoundEffect(player, SoundCategory.WORLD_SOUNDS, cTilePos.x(), cTilePos.y(), cTilePos.z(), "random.fizz", 0.5f, 2.6f + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8f); + world.playSoundEffect(player, SoundCategory.WORLD_SOUNDS, cTilePos.x(), cTilePos.y(), cTilePos.z(), "tile.activator.use", 1, 1.2f); + world.playSoundEffect(player, SoundCategory.WORLD_SOUNDS, cTilePos.x(), cTilePos.y(), cTilePos.z(), "note.hat", 0.7f, 0.4f); + } else if (cStrength == 15) { + world.setBlockDataNotify(cTilePos, 0); + world.playSoundEffect(player, SoundCategory.WORLD_SOUNDS, cTilePos.x(), cTilePos.y(), cTilePos.z(), "tile.activator.use", 1, 1.2f); + world.playSoundEffect(player, SoundCategory.WORLD_SOUNDS, cTilePos.x(), cTilePos.y(), cTilePos.z(), "note.hat", 0.7f, 0.4f); + } + return true; + } if (holdingConduit && isSideOpen(cData, side)) { return false; } - int cState = cData % STATE_COUNT; - int cStrength = cData / STATE_COUNT; - int nextState = getNextState(cState, side); if (nextState != cState) { - world.setBlockDataNotify(cTilePos, cStrength * STATE_COUNT + nextState); + int newStrength = cStrength; + + if (nextState == 0 || (cState == 0 && cStrength == 15)) { + newStrength = 0; + } + + world.setBlockDataNotify(cTilePos, (newStrength << POWER_SHIFT) | nextState); onNeighborChanged(world, cTilePos, this.block); world.playSoundEffect(player, SoundCategory.WORLD_SOUNDS, cTilePos.x(), cTilePos.y(), cTilePos.z(), "tile.activator.use", 1, 1.2f); world.playSoundEffect(player, SoundCategory.WORLD_SOUNDS, cTilePos.x(), cTilePos.y(), cTilePos.z(), "note.hat", 0.7f, 0.4f); - world.playBlockEvent(cTilePos, LevelListener.EVENT_CONDUIT_PORT_PARTICLES, packEventConduitData(side, cStrength)); + world.playBlockEvent(cTilePos, LevelListener.EVENT_CONDUIT_PORT_PARTICLES, packEventConduitData(side, newStrength)); return true; } @@ -277,75 +310,54 @@ public class BlockLogicRubyglassConduit extends BlockLogic { public static byte packEventConduitData(Side side, int strength) { if (side == null) side = Side.NONE; - int s = Math.max(0, Math.min(10, strength)); + int s = Math.max(0, Math.min(PROPAGATION_LENGTH, strength)); int sideId = side.getId() & 0x07; - return (byte) ((sideId << 4) | (s & 0x0F)); + return (byte) ((sideId << POWER_SHIFT) | (s & POWER_MASK)); } @Override public boolean isEmittingSignal(final @NotNull WorldSource world, final @NotNull TilePosc tilePos, final @NotNull Side side) { - int data = world.getBlockData(tilePos); - int currentPower = data / STATE_COUNT; - - if (currentPower == 0) { - return false; - } - - //can only emit signal out of an open face - Side conduitFace = side.getOpposite(); - return isSideOpen(data, conduitFace); + return isEmitting(world, tilePos, side); } @Override public boolean isEmittingDirectSignal(final @NotNull World world, final @NotNull TilePosc tilePos, final @NotNull Side side) { + return isEmitting(world, tilePos, side); + } + + private static boolean isEmitting(@NotNull WorldSource world, @NotNull TilePosc tilePos, @NotNull Side side) { int data = world.getBlockData(tilePos); - int currentPower = data / STATE_COUNT; + int currentPower = (data >> POWER_SHIFT) & POWER_MASK; + + if (currentPower == 0) return false; - if (currentPower == 0) { + TilePos receiverPos = new TilePos(tilePos).add(side.getOpposite()); + if (world.getBlockType(receiverPos) == Blocks.WIRE_REDSTONE) { return false; } - //can only emit signal out of an open face - Side conduitFace = side.getOpposite(); - return isSideOpen(data, conduitFace); + return isSideOpen(data, side.getOpposite()); } - - /** - * Dynamically determines the next state of a conduit based on a queried side (interacted with, placed against, trying to connect to). - * @param currentState The current state of the conduit - * @param sideQueried The side that was queried. - * @return The new conduit state based on the interaction - */ private int getNextState(int currentState, @NotNull Side sideQueried) { - Side[] nestState = STATE_TABLE[currentState]; + if (currentState == 0) { + return getStateFromTwoSides(sideQueried, sideQueried.getOpposite()); + } - for (Side side : nestState) { + Side[] currentSides = STATE_TABLE[currentState]; + for (Side side : currentSides) { if (side == sideQueried) { - if (nestState.length == 1) return 0; - Side remainingSide = (nestState[0] == sideQueried) ? nestState[1] : nestState[0]; - return remainingSide.getId() + 1; + return 0; } } - if (nestState.length == 0) { - return sideQueried.getId() + 1; - } - else if (nestState.length == 1) { - return getStateFromTwoSides(nestState[0], sideQueried); - } - return currentState; } - /** - * Determines a state that contains the two provided sides. - * @param s1 The first open side - * @param s2 The second open side - * @return The conduit state that matches the two side parameters or 0 if no match is found - */ private int getStateFromTwoSides(@NotNull Side s1, @NotNull Side s2) { - for (int i = 7; i < STATE_TABLE.length; i++) { + if (s1 == s2) return 0; + + for (int i = 1; i < STATE_TABLE.length; i++) { Side[] pair = STATE_TABLE[i]; boolean match1 = (pair[0] == s1 || pair[1] == s1); @@ -367,25 +379,25 @@ public class BlockLogicRubyglassConduit extends BlockLogic { * @param world The world * @param cTilePos The position of the conduit * @param side The side to check - * @return A converted signal value from 0 to 7 + * @return A converted signal integer value */ public static int getAndConvertNeighborSignal(@NotNull WorldSource world, @NotNull TilePosc cTilePos, @NotNull Side side) { TilePos nTilePos = new TilePos(cTilePos.x() + side.getOffsetX(), cTilePos.y() + side.getOffsetY(), cTilePos.z() + side.getOffsetZ()); Block nBlockType = world.getBlockType(nTilePos); - int cStrength = world.getBlockData(cTilePos) / STATE_COUNT; + int cStrength = (world.getBlockData(cTilePos) >> POWER_SHIFT) & POWER_MASK; if(nBlockType == Blocks.WIRE_REDSTONE) { int nData = world.getBlockData(nTilePos); int nStrength = nData & BlockLogicWireRedstone.MASK_POWER; - return signalConverter(nStrength, false); + return Math.max(0, signalConverter(nStrength, false) - 1); } - if (nBlockType == Blocks.RUBYGLASS_CONDUIT) { + if (nBlockType == Blocks.CONDUIT) { int nData = world.getBlockData(nTilePos); if (isSideOpen(nData, side.getOpposite())) { - int nStrength = nData / STATE_COUNT; + int nStrength = (nData >> POWER_SHIFT) & POWER_MASK; if (nStrength <= cStrength) return 0; @@ -395,18 +407,14 @@ public class BlockLogicRubyglassConduit extends BlockLogic { } if (world instanceof World world1) { - - boolean isPowerCube = nBlockType == - Blocks.BLOCK_REDSTONE || - nBlockType == Blocks.PUMPKIN_REDSTONE || - nBlockType == Blocks.MATCHER_ACTIVE; + boolean isPowerCube = nBlockType == Blocks.BLOCK_REDSTONE || nBlockType == Blocks.PUMPKIN_REDSTONE || nBlockType == Blocks.MATCHER_ACTIVE; if (world1.isBlockNormalCube(nTilePos) && !isPowerCube) { for (Side s : Side.sides) { TilePos queryPos = new TilePos(nTilePos.x() + s.getOffsetX(), nTilePos.y() + s.getOffsetY(), nTilePos.z() + s.getOffsetZ()); Block queryBlock = world1.getBlockType(queryPos); - if (queryBlock != Blocks.WIRE_REDSTONE && queryBlock != Blocks.RUBYGLASS_CONDUIT) { + if (queryBlock != Blocks.WIRE_REDSTONE && queryBlock != Blocks.CONDUIT) { if (queryBlock.isEmittingDirectSignal(world1, queryPos, s)) { return PROPAGATION_LENGTH; } @@ -433,7 +441,7 @@ public class BlockLogicRubyglassConduit extends BlockLogic { * @return Conduit power (0-{@link #PROPAGATION_LENGTH}) */ public static int getOutputPower(int cData, @NotNull Side sideTowardReceiver) { - return isSideOpen(cData, sideTowardReceiver) ? cData / STATE_COUNT : 0; + return isSideOpen(cData, sideTowardReceiver) ? (cData >> POWER_SHIFT) & POWER_MASK : 0; } /** @@ -444,7 +452,7 @@ public class BlockLogicRubyglassConduit extends BlockLogic { * @return true if the side is open, false otherwise. */ public static boolean isSideOpen(int cData, @NotNull Side side) { - int cState = cData % STATE_COUNT; + int cState = cData & STATE_MASK; if (cState == 0) { return false; @@ -468,23 +476,16 @@ public class BlockLogicRubyglassConduit extends BlockLogic { * @return a {@link Side} {@link Array} of sides that are open. */ public static Side[] getOpenSides(int cData){ - return STATE_TABLE[cData % STATE_COUNT]; + return STATE_TABLE[cData & STATE_MASK]; } - public static final int[] REDSTONE_TO_CONDUIT = {0, 0, 1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10}; - public static final int[] CONDUIT_TO_REDSTONE = {0, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14}; - /** * Converts signal strengths between redstone and conduit. * @param strength The signal strength to convert * @param conduitToRedstone Whether to convert conduit -> redstone or vice versa - * @return The converted signal strength (0-10)->(0-15) or (0-15)->(0-10) + * @return The converted signal strength */ public static int signalConverter(int strength, boolean conduitToRedstone) { - return conduitToRedstone - ? CONDUIT_TO_REDSTONE[Math.max(0, Math.min(PROPAGATION_LENGTH, strength))] - : REDSTONE_TO_CONDUIT[Math.max(0, Math.min(15, strength))]; + return Math.max(0, Math.min(PROPAGATION_LENGTH, strength)); } -} - - +} \ No newline at end of file diff --git a/game/core/src/main/java/net/minecraft/core/block/BlockLogicMatcher.java b/game/core/src/main/java/net/minecraft/core/block/BlockLogicMatcher.java index 852fcacc4..639ef05cc 100644 --- a/game/core/src/main/java/net/minecraft/core/block/BlockLogicMatcher.java +++ b/game/core/src/main/java/net/minecraft/core/block/BlockLogicMatcher.java @@ -20,7 +20,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Random; import static net.minecraft.core.block.BlockLogicFarmland.isWet; -import static net.minecraft.core.block.BlockLogicRubyglassConduit.packEventConduitData; +import static net.minecraft.core.block.BlockLogicConduit.packEventConduitData; public class BlockLogicMatcher extends BlockLogicAxisAligned { public final boolean isActive; diff --git a/game/core/src/main/java/net/minecraft/core/block/BlockLogicSpikes.java b/game/core/src/main/java/net/minecraft/core/block/BlockLogicSpikes.java index b52c96889..185255109 100644 --- a/game/core/src/main/java/net/minecraft/core/block/BlockLogicSpikes.java +++ b/game/core/src/main/java/net/minecraft/core/block/BlockLogicSpikes.java @@ -36,7 +36,7 @@ public class BlockLogicSpikes extends BlockLogic } @Override - public void onPlacedOnSide(@NotNull World world, @NotNull TilePosc tilePos, @NotNull Side side, double xHit, double yHit) { + public void onPlacedByMob(final @NotNull World world, final @NotNull TilePosc tilePos, final @NotNull Side sidePlacedOnto, final @NotNull Mob mob, final double xHit, final double yHit) { if (world.isClientSide) { return; } @@ -46,7 +46,16 @@ public class BlockLogicSpikes extends BlockLogic meta |= MASK_POWERED; } - meta |= ((side.getOpposite().getId() << 1) & MASK_DIRECTION); + Direction placeDir = sidePlacedOnto.getOpposite().getDirection(); + + if (mob instanceof Player player) { + if (player.rotationLock != null && player.rotationLock != Direction.NONE) { + placeDir = player.rotationLock; + } + } + + meta &= ~MASK_DIRECTION; + meta |= ((placeDir.getId() << 1) & MASK_DIRECTION); world.setBlockDataNotify(tilePos, meta); } diff --git a/game/core/src/main/java/net/minecraft/core/block/BlockLogicWireRedstone.java b/game/core/src/main/java/net/minecraft/core/block/BlockLogicWireRedstone.java index 04bb1f4eb..0754aeb82 100644 --- a/game/core/src/main/java/net/minecraft/core/block/BlockLogicWireRedstone.java +++ b/game/core/src/main/java/net/minecraft/core/block/BlockLogicWireRedstone.java @@ -265,9 +265,10 @@ public class BlockLogicWireRedstone extends BlockLogic implements ISupportable { } private int checkTarget(@NotNull World world, @NotNull TilePos tilePos, int sourceStrength) { - if(world.getBlockType(tilePos) == Blocks.RUBYGLASS_CONDUIT){ - int cStrength = world.getBlockData(tilePos) / BlockLogicRubyglassConduit.STATE_COUNT; - return Math.max(BlockLogicRubyglassConduit.signalConverter(cStrength, true), sourceStrength); + if(world.getBlockType(tilePos) == Blocks.CONDUIT){ + int cData = world.getBlockData(tilePos); + int cStrength = (cData >> BlockLogicConduit.POWER_SHIFT) & BlockLogicConduit.POWER_MASK; + return Math.max(BlockLogicConduit.signalConverter(cStrength, true), sourceStrength); } if (world.getBlockType(tilePos) != this.block) { @@ -426,8 +427,8 @@ public class BlockLogicWireRedstone extends BlockLogic implements ISupportable { final Side direction = BlockLogicRepeater.getSideFromMeta(source.getBlockData(tilePos)); return side == direction || side == direction.getOpposite(); } - if (block == Blocks.RUBYGLASS_CONDUIT) { - return BlockLogicRubyglassConduit.isSideOpen(source.getBlockData(tilePos), side.getOpposite()); + if (block == Blocks.CONDUIT) { + return BlockLogicConduit.isSideOpen(source.getBlockData(tilePos), side.getOpposite()); } return block.isSignalSource(); } @@ -523,15 +524,15 @@ public class BlockLogicWireRedstone extends BlockLogic implements ISupportable { /** Helper to determine if a block acts as a solid cube for redstone climbing.
    **/ private static boolean isSolidWallForWire(WorldSource world, TilePos pos, Side faceToCheck) { if (world.isBlockNormalCube(pos)) return true; - if (world.getBlockType(pos) == Blocks.RUBYGLASS_CONDUIT) { - return !BlockLogicRubyglassConduit.isSideOpen(world.getBlockData(pos), faceToCheck); + if (world.getBlockType(pos) == Blocks.CONDUIT) { + return !BlockLogicConduit.isSideOpen(world.getBlockData(pos), faceToCheck); } return false; } private static boolean isBlockingConduit(WorldSource world, TilePos pos, Side openSide) { - if (world.getBlockType(pos) == Blocks.RUBYGLASS_CONDUIT) { - return BlockLogicRubyglassConduit.isSideOpen(world.getBlockData(pos), openSide); + if (world.getBlockType(pos) == Blocks.CONDUIT) { + return BlockLogicConduit.isSideOpen(world.getBlockData(pos), openSide); } return false; } @@ -544,8 +545,8 @@ public class BlockLogicWireRedstone extends BlockLogic implements ISupportable { if (world.isBlockNormalCube(wallTilePos)) { return true; } - if (world.getBlockType(wallTilePos) == Blocks.RUBYGLASS_CONDUIT) { - return !BlockLogicRubyglassConduit.isSideOpen(world.getBlockData(wallTilePos), directionToWall.getOpposite()); + if (world.getBlockType(wallTilePos) == Blocks.CONDUIT) { + return !BlockLogicConduit.isSideOpen(world.getBlockData(wallTilePos), directionToWall.getOpposite()); } return false; } diff --git a/game/core/src/main/java/net/minecraft/core/block/Blocks.java b/game/core/src/main/java/net/minecraft/core/block/Blocks.java index 40b7fd06f..197abfabe 100644 --- a/game/core/src/main/java/net/minecraft/core/block/Blocks.java +++ b/game/core/src/main/java/net/minecraft/core/block/Blocks.java @@ -1142,7 +1142,7 @@ public final class Blocks { .withSound(BlockSounds.GLASS).withDisabledNeighborNotifyOnMetadataChange().withLightEmission(0.5F) .withTags(BlockTags.MINEABLE_BY_PICKAXE) .withOverrideColor(MaterialColor.rubyglass); - public static final Block RUBYGLASS_CONDUIT = register("rubyglass.conduit", "minecraft:block/rubyglass_conduit", 824, (BlockLogicSupplier) b -> new BlockLogicRubyglassConduit(b, Materials.STONE)) + public static final Block CONDUIT = register("rubyglass.conduit", "minecraft:block/conduit", 824, (BlockLogicSupplier) b -> new BlockLogicConduit(b, Materials.STONE)) .withSound(BlockSounds.STONE).withHardness(1.5F).withDisabledNeighborNotifyOnMetadataChange() .withTags(BlockTags.MINEABLE_BY_PICKAXE, BlockTags.CHAINLINK_FENCES_CONNECT, BlockTags.PREVENT_MOB_SPAWNS) .withOverrideColor(MaterialColor.rubyglass); diff --git a/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityActivator.java b/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityActivator.java index de011dcfe..247dc4f2f 100644 --- a/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityActivator.java +++ b/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityActivator.java @@ -216,8 +216,8 @@ public class TileEntityActivator extends TileEntity implements Container { if (i1 > itemstack.stackSize) { i1 = itemstack.stackSize; } - itemstack.stackSize -= i1; - EntityItem item = new EntityItem(world, (float) x + f, (float) y + f1, (float) z + f2, new ItemStack(itemstack.itemID, i1, itemstack.getMetadata())); + ItemStack droppedStack = itemstack.splitStack(i1); + EntityItem item = new EntityItem(world, (float) x + f, (float) y + f1, (float) z + f2, droppedStack); float f3 = 0.05F; item.xd = (float) random.nextGaussian() * f3; item.yd = (float) random.nextGaussian() * f3 + 0.2F; diff --git a/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityFurnace.java b/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityFurnace.java index 3a407f60c..8e56b16a6 100644 --- a/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityFurnace.java +++ b/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityFurnace.java @@ -200,11 +200,11 @@ public class TileEntityFurnace extends TileEntity if(furnaceItemStacks[SLOT_FUEL] != null) { ItemStack fuelStack = furnaceItemStacks[SLOT_FUEL]; - if (fuelStack.getItem() instanceof ItemBucket && ItemBucket.getState(fuelStack) == ItemBucket.STATE_LAVA) { + if (fuelStack.getItem() instanceof ItemBucket && ItemBucket.STATE_LAVA.equals(ItemBucket.getState(fuelStack))) { ItemBucket.setCharges(fuelStack, ItemBucket.getCharges(fuelStack) - 1); - if (ItemBucket.getCharges(fuelStack) == 0) { + if (ItemBucket.getCharges(fuelStack) <= 0) { ItemBucket.setState(fuelStack, ItemBucket.STATE_EMPTY); } } diff --git a/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityMesh.java b/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityMesh.java index 906ad1fc5..73fac3ed1 100644 --- a/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityMesh.java +++ b/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityMesh.java @@ -27,9 +27,8 @@ public class TileEntityMesh extends TileEntity { } @Override - public void tick() - { - if (this.worldObj == null || this.worldObj.isClientSide) { + public void tick() { + if (this.worldObj == null) { return; } @@ -56,14 +55,17 @@ public class TileEntityMesh extends TileEntity { } protected void handleSiphon(@NotNull Map validSiphonDirections){ - //null-checks were already made assert this.worldObj != null; Direction direction = getSingleValidFace(validSiphonDirections); - if(direction == Direction.NONE){return;} + if(direction == Direction.NONE) { return; } + AABBdc siphonBox = getSiphonBox(tilePos, direction); List entitiesWithinSiphonBox = this.worldObj.getEntitiesWithinAABBExcludingEntity(null, siphonBox); - removeTrackedItems(entitiesWithinSiphonBox); + + if (!this.worldObj.isClientSide) { + removeTrackedItems(entitiesWithinSiphonBox); + } for (Entity entity : entitiesWithinSiphonBox) { @@ -74,15 +76,16 @@ public class TileEntityMesh extends TileEntity { item.meshSiphoning = this; } - if(direction.getOpposite().equals(item.siphonDirection) && item.meshSiphoning == this){ + if(direction.getOpposite().equals(item.siphonDirection) && item.meshSiphoning == this) { - Player player = entity.world.getClosestPlayer(tilePos.x, tilePos.y, tilePos.z, 12); - if(player != null) { - player.triggerAchievement(Achievements.DOWN_THE_DRAIN); + if (!this.worldObj.isClientSide) { + Player player = entity.world.getClosestPlayer(tilePos.x, tilePos.y, tilePos.z, 12); + if(player != null) { + player.triggerAchievement(Achievements.DOWN_THE_DRAIN); + } + addItemsToBeTracked(item); } - siphonItemIntoBlock(item, direction); - addItemsToBeTracked(item); } } } @@ -159,7 +162,6 @@ public class TileEntityMesh extends TileEntity { double hw = siphonWidth / 2.0; // expand/inflate - // (would be amazing if AABBd had .inflate(), but we are decrepit old bastards don't even get me started on the mental processing it took to work on this shitty ass code for the first time I need sleep and want to die) double minX = Math.min(centerX, farX); double minY = Math.min(centerY, farY); double minZ = Math.min(centerZ, farZ); diff --git a/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityTrommel.java b/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityTrommel.java index 39d1731ce..2c305f854 100644 --- a/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityTrommel.java +++ b/game/core/src/main/java/net/minecraft/core/block/entity/TileEntityTrommel.java @@ -220,7 +220,7 @@ public class TileEntityTrommel extends TileEntity if(this.itemStacks[SLOT_FUEL] != null) { ItemStack fuelStack = this.itemStacks[SLOT_FUEL]; - if (fuelStack.getItem() instanceof ItemBucket && ItemBucket.getState(fuelStack) == ItemBucket.STATE_LAVA) { + if (fuelStack.getItem() instanceof ItemBucket && ItemBucket.STATE_LAVA.equals(ItemBucket.getState(fuelStack))) { ItemBucket.setCharges(fuelStack, ItemBucket.getCharges(fuelStack) - 1); diff --git a/game/core/src/main/java/net/minecraft/core/crafting/LookupFuelFurnace.java b/game/core/src/main/java/net/minecraft/core/crafting/LookupFuelFurnace.java index addeb075d..43327171c 100644 --- a/game/core/src/main/java/net/minecraft/core/crafting/LookupFuelFurnace.java +++ b/game/core/src/main/java/net/minecraft/core/crafting/LookupFuelFurnace.java @@ -87,7 +87,7 @@ public class LookupFuelFurnace { addFuelEntry(Items.COAL.id, 1600); addFuelEntry(Items.NETHERCOAL.id, 6400); - addAdvancedFuelEntry(stack -> stack.getItem() instanceof ItemBucket && ItemBucket.getState(stack) == ItemBucket.STATE_LAVA, 12800); + addAdvancedFuelEntry(stack -> stack.getItem() instanceof ItemBucket && ItemBucket.STATE_LAVA.equals(ItemBucket.getState(stack)), 12800); } public void addFuelEntry(int id, int fuelYield) { diff --git a/game/core/src/main/java/net/minecraft/core/current/conduit/ConduitNode.java b/game/core/src/main/java/net/minecraft/core/current/conduit/ConduitNode.java deleted file mode 100644 index 2a829e0e1..000000000 --- a/game/core/src/main/java/net/minecraft/core/current/conduit/ConduitNode.java +++ /dev/null @@ -1,13 +0,0 @@ -package net.minecraft.core.current.conduit; - -import net.minecraft.core.world.pos.TilePos; - -public class ConduitNode { - TilePos tilePos; - int currentPower; - - ConduitNode(TilePos tilePos, int currentPower) { - this.tilePos = tilePos; - this.currentPower = currentPower; - } -} diff --git a/game/core/src/main/java/net/minecraft/core/current/conduit/ConduitHandler.java b/game/core/src/main/java/net/minecraft/core/current/wire/ConduitHandler.java similarity index 75% rename from game/core/src/main/java/net/minecraft/core/current/conduit/ConduitHandler.java rename to game/core/src/main/java/net/minecraft/core/current/wire/ConduitHandler.java index d0a6ea9b8..6db86a5c8 100644 --- a/game/core/src/main/java/net/minecraft/core/current/conduit/ConduitHandler.java +++ b/game/core/src/main/java/net/minecraft/core/current/wire/ConduitHandler.java @@ -1,27 +1,31 @@ -package net.minecraft.core.current.conduit; +package net.minecraft.core.current.wire; import net.minecraft.core.block.Block; import net.minecraft.core.block.Blocks; -import net.minecraft.core.block.BlockLogicRubyglassConduit; +import net.minecraft.core.block.BlockLogicConduit; import net.minecraft.core.util.helper.Side; import net.minecraft.core.world.World; import net.minecraft.core.world.pos.TilePos; import net.minecraft.core.world.pos.TilePosc; import java.util.*; +import java.util.PriorityQueue; /** - * One-Dimensional Implementation of Alternate Current for rubyglass conduits.
    + * One-Dimensional Implementation of Alternate Current for conduits.
    * Handles the logic and updates for any given conduit network and seamlessly integrates with other redstone components.
    * * @author Melon Mojito (@melon_mojito) */ public class ConduitHandler { + private final World world; private boolean updating = false; private final Queue updateQueue = new LinkedList<>(); + private record ConduitNode(TilePos tilePos, int currentPower) {} + public ConduitHandler(World world) { this.world = world; } @@ -36,9 +40,9 @@ public class ConduitHandler { public void onConduitRemoved(TilePosc pos, int oldData) { //update the sides this conduit was connected to - for (Side side : BlockLogicRubyglassConduit.getOpenSides(oldData)) { + for (Side side : BlockLogicConduit.getOpenSides(oldData)) { TilePos nPos = new TilePos(pos).add(side); - if (world.getBlockType(nPos) == Blocks.RUBYGLASS_CONDUIT) { + if (world.getBlockType(nPos) == Blocks.CONDUIT) { queueUpdate(nPos); } } @@ -58,7 +62,7 @@ public class ConduitHandler { TilePos startPos = updateQueue.poll(); // Ensure the block is still a conduit before updating the network, // as it could have been broken while sitting in the queue. - if (world.getBlockType(startPos) == Blocks.RUBYGLASS_CONDUIT) { + if (world.getBlockType(startPos) == Blocks.CONDUIT) { updateNetwork(startPos); } } @@ -69,6 +73,11 @@ public class ConduitHandler { private void updateNetwork(TilePos startPos) { //build the network + + if ((world.getBlockData(startPos) & BlockLogicConduit.STATE_MASK) == 0) { + return; + } + Set network = new HashSet<>(); Queue toSearch = new LinkedList<>(); toSearch.add(startPos); @@ -77,10 +86,10 @@ public class ConduitHandler { TilePos pos = toSearch.poll(); if (network.add(pos)) { int data = world.getBlockData(pos); - for (Side side : BlockLogicRubyglassConduit.getOpenSides(data)) { + for (Side side : BlockLogicConduit.getOpenSides(data)) { TilePos nPos = new TilePos(pos).add(side); - if (world.getBlockType(nPos) == Blocks.RUBYGLASS_CONDUIT && - BlockLogicRubyglassConduit.isSideOpen(world.getBlockData(nPos), side.getOpposite())) { + if (world.getBlockType(nPos) == Blocks.CONDUIT && + BlockLogicConduit.isSideOpen(world.getBlockData(nPos), side.getOpposite())) { toSearch.add(nPos); } } @@ -91,15 +100,15 @@ public class ConduitHandler { Map externalPower = new HashMap<>(); for (TilePos tilePos : network) { int data = world.getBlockData(tilePos); - int currentPower = data / BlockLogicRubyglassConduit.STATE_COUNT; + int currentPower = (data >> BlockLogicConduit.POWER_SHIFT) & BlockLogicConduit.POWER_MASK; int maxExternalPower = 0; - for (Side side : BlockLogicRubyglassConduit.getOpenSides(data)) { + for (Side side : BlockLogicConduit.getOpenSides(data)) { TilePos nTilePos = new TilePos(tilePos).add(side); Block nBlockType = world.getBlockType(nTilePos); - if (nBlockType != Blocks.RUBYGLASS_CONDUIT) { - int external = BlockLogicRubyglassConduit.getAndConvertNeighborSignal(world, tilePos, side); + if (nBlockType != Blocks.CONDUIT) { + int external = BlockLogicConduit.getAndConvertNeighborSignal(world, tilePos, side); //break the recursive loop for redstone dust if (nBlockType == Blocks.WIRE_REDSTONE) { @@ -118,7 +127,7 @@ public class ConduitHandler { Map newPowerLevels = new HashMap<>(); for (TilePos tilePos : network) newPowerLevels.put(tilePos, 0); - PriorityQueue powerQueue = new PriorityQueue<>((a, b) -> Integer.compare(b.currentPower, a.currentPower)); + java.util.PriorityQueue powerQueue = new PriorityQueue<>((a, b) -> Integer.compare(b.currentPower, a.currentPower)); for (Map.Entry entry : externalPower.entrySet()) { if (entry.getValue() > 0) { powerQueue.add(new ConduitNode(entry.getKey(), entry.getValue())); @@ -135,7 +144,7 @@ public class ConduitHandler { //propagate power down the line if (node.currentPower > 1) { int data = world.getBlockData(node.tilePos); - for (Side side : BlockLogicRubyglassConduit.getOpenSides(data)) { + for (Side side : BlockLogicConduit.getOpenSides(data)) { TilePos nPos = new TilePos(node.tilePos).add(side); if (network.contains(nPos)) { powerQueue.add(new ConduitNode(nPos, node.currentPower - 1)); @@ -147,19 +156,19 @@ public class ConduitHandler { Set blocksToNotify = new HashSet<>(); for (TilePos tilePos : network) { int oldData = world.getBlockData(tilePos); - int oldPower = oldData / BlockLogicRubyglassConduit.STATE_COUNT; + int oldPower = (oldData >> BlockLogicConduit.POWER_SHIFT) & BlockLogicConduit.POWER_MASK; int newPower = newPowerLevels.get(tilePos); if (oldPower != newPower) { - int state = oldData % BlockLogicRubyglassConduit.STATE_COUNT; + int state = oldData & BlockLogicConduit.STATE_MASK; //suppress recursive neighbor updates while data is being set world.noNeighborUpdate = true; - world.setBlockDataNotify(tilePos, newPower * BlockLogicRubyglassConduit.STATE_COUNT + state); + world.setBlockDataNotify(tilePos, (newPower << BlockLogicConduit.POWER_SHIFT) | state); world.noNeighborUpdate = false; //queue updates ONLY for blocks facing the open sides that ARE NOT conduits in this network - for (Side side : BlockLogicRubyglassConduit.getOpenSides(state)) { + for (Side side : BlockLogicConduit.getOpenSides(state)) { TilePos targetPos = new TilePos(tilePos).add(side); if (!network.contains(targetPos)) { blocksToNotify.add(targetPos); @@ -171,10 +180,10 @@ public class ConduitHandler { //notify all neighbors after the network is done with its logic/updates for (TilePos nTilePos : blocksToNotify) { Block neighborBlockType = world.getBlockType(nTilePos); - neighborBlockType.onNeighborChanged(world, nTilePos, Blocks.RUBYGLASS_CONDUIT); + neighborBlockType.onNeighborChanged(world, nTilePos, Blocks.CONDUIT); if (neighborBlockType != Blocks.WIRE_REDSTONE) { - world.notifyBlocksOfNeighborChange(nTilePos, Blocks.RUBYGLASS_CONDUIT); + world.notifyBlocksOfNeighborChange(nTilePos, Blocks.CONDUIT); } } } diff --git a/game/core/src/main/java/net/minecraft/core/current/wire/WireConnectionManager.java b/game/core/src/main/java/net/minecraft/core/current/wire/WireConnectionManager.java index 4725ac1a7..2de7e2267 100644 --- a/game/core/src/main/java/net/minecraft/core/current/wire/WireConnectionManager.java +++ b/game/core/src/main/java/net/minecraft/core/current/wire/WireConnectionManager.java @@ -1,6 +1,6 @@ package net.minecraft.core.current.wire; -import net.minecraft.core.block.BlockLogicRubyglassConduit; +import net.minecraft.core.block.BlockLogicConduit; import net.minecraft.core.block.Blocks; import net.minecraft.core.current.wire.WireHandler.Directions; import net.minecraft.core.current.wire.WireHandler.NodeProvider; @@ -79,7 +79,7 @@ public class WireConnectionManager { if (node.isWire()) { boolean offerDown = belowIsConductor || - (ownerDown.state.is(Blocks.RUBYGLASS_CONDUIT) && !isConduitOpenTowards(ownerDown, iDir)); + (ownerDown.state.is(Blocks.CONDUIT) && !isConduitOpenTowards(ownerDown, iDir)); add(node.asWire(), iDir, offerDown, true); } } @@ -94,7 +94,7 @@ public class WireConnectionManager { if (node.isWire()) { boolean acceptUp = sideIsConductor || - (neighbor.state.is(Blocks.RUBYGLASS_CONDUIT) && !isConduitOpenTowards(neighbor, iOppDir)); + (neighbor.state.is(Blocks.CONDUIT) && !isConduitOpenTowards(neighbor, iOppDir)); add(node.asWire(), iDir, true, acceptUp); } } @@ -106,13 +106,13 @@ public class WireConnectionManager { } /** - * Checks if a node is a Rubyglass Conduit and if a specific directional port is open. + * Checks if a node is a Conduit and if a specific directional port is open. * @param node The node to check * @param iDir The Alternate Current direction we are querying * @return true if the node is a conduit AND the port facing iDir is open */ private boolean isConduitOpenTowards(Node node, int iDir) { - if (node.state.is(Blocks.RUBYGLASS_CONDUIT)) { + if (node.state.is(Blocks.CONDUIT)) { Side face = Side.NONE; face = switch (iDir) { case Directions.WEST -> Side.WEST; @@ -123,7 +123,7 @@ public class WireConnectionManager { case Directions.UP -> Side.TOP; default -> face; }; - return face != Side.NONE && BlockLogicRubyglassConduit.isSideOpen(node.state.get(), face); + return face != Side.NONE && BlockLogicConduit.isSideOpen(node.state.get(), face); } return false; } diff --git a/game/core/src/main/java/net/minecraft/core/current/wire/WireHandler.java b/game/core/src/main/java/net/minecraft/core/current/wire/WireHandler.java index 61f8c1841..ec81ad39e 100644 --- a/game/core/src/main/java/net/minecraft/core/current/wire/WireHandler.java +++ b/game/core/src/main/java/net/minecraft/core/current/wire/WireHandler.java @@ -1,6 +1,6 @@ package net.minecraft.core.current.wire; -import net.minecraft.core.block.BlockLogicRubyglassConduit; +import net.minecraft.core.block.BlockLogicConduit; import net.minecraft.core.block.BlockLogicWireRedstone; import net.minecraft.core.block.Block; import net.minecraft.core.block.Blocks; @@ -756,14 +756,14 @@ public class WireHandler { } //conduit logic - if (neighboringNode.state.is(Blocks.RUBYGLASS_CONDUIT)) { + if (neighboringNode.state.is(Blocks.CONDUIT)) { int cData = neighboringNode.state.get(); Side conduitFace = getSide(iDir); - if (BlockLogicRubyglassConduit.isSideOpen(cData, conduitFace)) { - int cStrength = cData / BlockLogicRubyglassConduit.STATE_COUNT; - int convertedStrength = BlockLogicRubyglassConduit.signalConverter(cStrength, true); + if (BlockLogicConduit.isSideOpen(cData, conduitFace)) { + int cStrength = cData / BlockLogicConduit.STATE_COUNT; + int convertedStrength = BlockLogicConduit.signalConverter(cStrength, true); //step down the signal strength when passing from conduit to wire convertedStrength = Math.max(0, convertedStrength - 1); @@ -845,7 +845,7 @@ public class WireHandler { for (int iDir : Directions.I_EXCEPT[except]) { Node neighbor = getNeighbor(node, iDir); - if (neighbor.state.is(Blocks.WIRE_REDSTONE) || neighbor.state.is(Blocks.RUBYGLASS_CONDUIT)) { + if (neighbor.state.is(Blocks.WIRE_REDSTONE) || neighbor.state.is(Blocks.CONDUIT)) { continue; } diff --git a/game/core/src/main/java/net/minecraft/core/item/ItemBucket.java b/game/core/src/main/java/net/minecraft/core/item/ItemBucket.java index cd66d85aa..e98026c07 100644 --- a/game/core/src/main/java/net/minecraft/core/item/ItemBucket.java +++ b/game/core/src/main/java/net/minecraft/core/item/ItemBucket.java @@ -15,7 +15,6 @@ import net.minecraft.core.util.HardIllegalArgumentException; import net.minecraft.core.util.collection.NamespaceID; import net.minecraft.core.util.helper.Direction; import net.minecraft.core.util.helper.Side; -import net.minecraft.core.util.phys.AABB; import net.minecraft.core.util.phys.HitResult; import net.minecraft.core.world.World; import net.minecraft.core.world.pos.TilePos; @@ -23,7 +22,6 @@ import net.minecraft.core.world.pos.TilePosc; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.joml.primitives.AABBd; -import org.joml.primitives.AABBdc; import java.util.*; diff --git a/game/core/src/main/java/net/minecraft/core/item/tool/ItemToolHoe.java b/game/core/src/main/java/net/minecraft/core/item/tool/ItemToolHoe.java index 7034c6fa5..27389ac8b 100644 --- a/game/core/src/main/java/net/minecraft/core/item/tool/ItemToolHoe.java +++ b/game/core/src/main/java/net/minecraft/core/item/tool/ItemToolHoe.java @@ -71,14 +71,9 @@ public class ItemToolHoe extends ItemTool { public boolean onBlockDestroyed(@NotNull ItemStack selfStack, @NotNull World world, @NotNull Mob mob, @NotNull Block removedBlock, @NotNull TilePosc blockPos, @NotNull Side side) { if (!world.isClientSide) { if (removedBlock == Blocks.TALLGRASS || removedBlock == Blocks.TALLGRASS_FERN) { - if (this.material.isSilkTouch()) { - world.dropItem(blockPos, new ItemStack(removedBlock)); + if (world.rand.nextInt(4) == 0) { + world.dropItem(blockPos, new ItemStack(Items.SEEDS_WHEAT)); selfStack.damageItem(1, mob); - } else { - if (world.rand.nextInt(4) == 0) { - world.dropItem(blockPos, new ItemStack(Items.SEEDS_WHEAT)); - selfStack.damageItem(1, mob); - } } } } diff --git a/game/core/src/main/java/net/minecraft/core/world/World.java b/game/core/src/main/java/net/minecraft/core/world/World.java index 97881ef47..96650f788 100644 --- a/game/core/src/main/java/net/minecraft/core/world/World.java +++ b/game/core/src/main/java/net/minecraft/core/world/World.java @@ -12,7 +12,7 @@ import net.minecraft.core.block.material.Material; import net.minecraft.core.block.material.Materials; import net.minecraft.core.block.support.ISupport; import net.minecraft.core.block.tag.BlockTags; -import net.minecraft.core.current.conduit.ConduitHandler; +import net.minecraft.core.current.wire.ConduitHandler; import net.minecraft.core.current.wire.WireHandler; import net.minecraft.core.data.gamerule.GameRule; import net.minecraft.core.data.gamerule.GameRules; diff --git a/game/core/src/main/resources/assets/minecraft/lang/en_US/tile.lang b/game/core/src/main/resources/assets/minecraft/lang/en_US/tile.lang index 887050e81..58413130c 100644 --- a/game/core/src/main/resources/assets/minecraft/lang/en_US/tile.lang +++ b/game/core/src/main/resources/assets/minecraft/lang/en_US/tile.lang @@ -1442,7 +1442,7 @@ tile.block.rubyglass.desc=A translucent glass-like crystal brimming with energy. tile.rubyglass.sprout.name=Rubyglass Bud tile.rubyglass.sprout.desc=A small bud of rubyglass, branching out in many directions. -tile.rubyglass.conduit.name=Rubyglass Conduit +tile.rubyglass.conduit.name=Conduit tile.rubyglass.conduit.desc=Netherrack etched with lines of rubyglass. It resonates with latent power. tile.vent.name=Chimney diff --git a/util/datagen/src/main/java/net/minecraft/datagen/WorkbenchGenerator.java b/util/datagen/src/main/java/net/minecraft/datagen/WorkbenchGenerator.java index b1a0c2994..15b788c19 100644 --- a/util/datagen/src/main/java/net/minecraft/datagen/WorkbenchGenerator.java +++ b/util/datagen/src/main/java/net/minecraft/datagen/WorkbenchGenerator.java @@ -152,7 +152,7 @@ class WorkbenchGenerator { "###") .addInput('#', Blocks.COBBLE_NETHERRACK) .addInput('S', Blocks.SOULSAND) - .addInput('C', Blocks.RUBYGLASS_CONDUIT) + .addInput('C', Blocks.CONDUIT) .addInput('R', Items.DUST_REDSTONE) .create("activator", Blocks.ACTIVATOR_COBBLE_NETHERRACK.getDefaultStack()); @@ -1350,7 +1350,7 @@ class WorkbenchGenerator { ) .addInput('#', Blocks.COBBLE_NETHERRACK) .addInput('Q', Items.QUARTZ) - .addInput('C', Blocks.RUBYGLASS_CONDUIT) + .addInput('C', Blocks.CONDUIT) .create("matcher", new ItemStack(Blocks.MATCHER, 1)); RecipeBuilder.Shaped(CORE_NAMESPACE) @@ -1361,7 +1361,7 @@ class WorkbenchGenerator { .addInput('R', Items.DUST_REDSTONE) .addInput('O', Items.RUBYGLASS_CRYSTAL) .addInput('X', Blocks.COBBLE_NETHERRACK) - .create("rubyglass_conduit", new ItemStack(Blocks.RUBYGLASS_CONDUIT, 1)); + .create("conduit", new ItemStack(Blocks.CONDUIT, 1)); RecipeBuilder.Shaped(CORE_NAMESPACE) .setShape( @@ -1369,7 +1369,7 @@ class WorkbenchGenerator { "CQB", "###") .addInput('#', Blocks.COBBLE_STONE_MOSSY) - .addInput('C', Blocks.RUBYGLASS_CONDUIT) + .addInput('C', Blocks.CONDUIT) .addInput('Q', Items.QUARTZ) .addInput('B', Items.BONE) .create("motion_sensor", Blocks.MOTION_SENSOR_IDLE.getDefaultStack());