From 4360916316d147a2b8e776e550f0bfbfab53c564 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Sat, 1 Apr 2023 12:42:16 +0200 Subject: [PATCH] Playtest I - Fixed classloading issues when flywheel is not present serverside - Fixed missing texture on the mechanical arm item - Added back deprecated register method for display behaviours - Fixed Redstone/Elevator Contacts not switching type after rotated by wrench - Fixed edited clipboard entry not rendering at correct y in some gui scales - Fan transparency of copycat blocks now refers to their material - Fixed new metal bars not being fan transparent --- src/generated/resources/.cache/cache | 2 +- .../create/tags/blocks/fan_transparent.json | 4 +++ .../java/com/simibubi/create/AllBlocks.java | 1 + .../components/fan/AirCurrent.java | 4 ++- .../elevator/ElevatorContactBlock.java | 25 ++++++++++++++++ .../glue/GlueEffectPacket.java | 18 +++++++----- .../clipboard/ClipboardScreen.java | 5 ++-- .../block/display/AllDisplayBehaviours.java | 10 +++++++ .../block/redstone/RedstoneContactBlock.java | 29 +++++++++++++++++++ .../block/connected/CTSpriteShifter.java | 4 ++- .../block/render/SpriteShifter.java | 4 ++- .../create/foundation/data/MetalBarsGen.java | 1 + .../models/block/mechanical_arm/item.json | 10 +++---- 13 files changed, 99 insertions(+), 18 deletions(-) diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 6eddaeb38..9e67be95f 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -5263,7 +5263,7 @@ d99d5c67bdffff60789a19bd51a5c5267c75e0a4 data/create/tags/blocks/casing.json 74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/create/tags/blocks/contraption_inventory_deny.json bc203f09dd7f48965d146d0bd035fb904cb75e7d data/create/tags/blocks/copycat_allow.json d4a3b66f4b763b9a2dcdea74b7273f0ae85cb335 data/create/tags/blocks/copycat_deny.json -2b4c93e5a752ebf54217594766f30d8d60cb4343 data/create/tags/blocks/fan_transparent.json +73c2c85233075d2854d209b71ff2160308a7919c data/create/tags/blocks/fan_transparent.json ee6d2b53d81f2bed492662b6c06f46c4f2b9ef9b data/create/tags/blocks/movable_empty_collider.json 6e5d3b2123fbb00e7f439c091623619502551bca data/create/tags/blocks/non_movable.json 10781e8cfcbb3486327aace3aa00e437fb44b331 data/create/tags/blocks/ore_override_stone.json diff --git a/src/generated/resources/data/create/tags/blocks/fan_transparent.json b/src/generated/resources/data/create/tags/blocks/fan_transparent.json index 6d6d04226..f7df78dbc 100644 --- a/src/generated/resources/data/create/tags/blocks/fan_transparent.json +++ b/src/generated/resources/data/create/tags/blocks/fan_transparent.json @@ -4,6 +4,10 @@ "create:blaze_burner", "create:lit_blaze_burner", "create:sail_frame", + "create:andesite_bars", + "create:brass_bars", + "create:copper_bars", + "create:copycat_base", "minecraft:iron_bars", "#minecraft:campfires", "#minecraft:fences", diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 6ec2659e7..03742e9d8 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -2103,6 +2103,7 @@ public class AllBlocks { .initialProperties(SharedProperties::softMetal) .properties(p -> p.color(MaterialColor.GLOW_LICHEN)) .addLayer(() -> RenderType::cutoutMipped) + .tag(AllBlockTags.FAN_TRANSPARENT.tag) .transform(pickaxeOnly()) .blockstate((c, p) -> p.simpleBlock(c.get(), AssetLookup.partialBaseModel(c, p))) .register(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java index 288b30386..bed00e48f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java @@ -10,6 +10,7 @@ import com.simibubi.create.AllTags; import com.simibubi.create.content.contraptions.particle.AirFlowParticleData; import com.simibubi.create.content.contraptions.processing.InWorldProcessing; import com.simibubi.create.content.contraptions.processing.InWorldProcessing.Type; +import com.simibubi.create.content.curiosities.frames.CopycatBlock; import com.simibubi.create.foundation.advancement.AllAdvancements; import com.simibubi.create.foundation.blockEntity.BlockEntityBehaviour; import com.simibubi.create.foundation.blockEntity.behaviour.belt.TransportedItemStackHandlerBehaviour; @@ -214,7 +215,8 @@ public class AirCurrent { if (!world.isLoaded(currentPos)) break; BlockState state = world.getBlockState(currentPos); - if (shouldAlwaysPass(state)) + BlockState copycatState = CopycatBlock.getMaterial(world, currentPos); + if (shouldAlwaysPass(copycatState.isAir() ? state : copycatState)) continue; VoxelShape voxelshape = state.getCollisionShape(world, currentPos, CollisionContext.empty()); if (voxelshape.isEmpty()) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/elevator/ElevatorContactBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/elevator/ElevatorContactBlock.java index 4b9c62648..0efa840fa 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/elevator/ElevatorContactBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/elevator/ElevatorContactBlock.java @@ -16,17 +16,20 @@ import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.foundation.block.IBE; import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import com.simibubi.create.foundation.gui.ScreenOpener; +import com.simibubi.create.foundation.utility.BlockHelper; import net.minecraft.client.player.LocalPlayer; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.NonNullList; +import net.minecraft.core.Direction.Axis; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; @@ -63,6 +66,28 @@ public class ElevatorContactBlock extends WrenchableDirectionalBlock super.createBlockStateDefinition(builder.add(CALLING, POWERING, POWERED)); } + @Override + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + InteractionResult onWrenched = super.onWrenched(state, context); + if (onWrenched != InteractionResult.SUCCESS) + return onWrenched; + + Level level = context.getLevel(); + if (level.isClientSide()) + return onWrenched; + + BlockPos pos = context.getClickedPos(); + state = level.getBlockState(pos); + Direction facing = state.getValue(RedstoneContactBlock.FACING); + if (facing.getAxis() != Axis.Y + && ElevatorColumn.get(level, new ColumnCoords(pos.getX(), pos.getZ(), facing)) != null) + return onWrenched; + + level.setBlockAndUpdate(pos, BlockHelper.copyProperties(state, AllBlocks.REDSTONE_CONTACT.getDefaultState())); + + return onWrenched; + } + @Nullable public static ColumnCoords getColumnCoords(LevelAccessor level, BlockPos pos) { BlockState blockState = level.getBlockState(pos); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueEffectPacket.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueEffectPacket.java index 6cec474aa..dafedabb2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueEffectPacket.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueEffectPacket.java @@ -7,6 +7,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.network.NetworkEvent.Context; @@ -37,13 +38,16 @@ public class GlueEffectPacket extends SimplePacketBase { @Override public boolean handle(Context context) { - context.enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { - Minecraft mc = Minecraft.getInstance(); - if (!mc.player.blockPosition().closerThan(pos, 100)) - return; - SuperGlueItem.spawnParticles(mc.level, pos, direction, fullBlock); - })); + context.enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::handleClient)); return true; } - + + @OnlyIn(Dist.CLIENT) + public void handleClient() { + Minecraft mc = Minecraft.getInstance(); + if (!mc.player.blockPosition().closerThan(pos, 100)) + return; + SuperGlueItem.spawnParticles(mc.level, pos, direction, fullBlock); + } + } diff --git a/src/main/java/com/simibubi/create/content/curiosities/clipboard/ClipboardScreen.java b/src/main/java/com/simibubi/create/content/curiosities/clipboard/ClipboardScreen.java index 80dd935d7..592fdfb84 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/clipboard/ClipboardScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/clipboard/ClipboardScreen.java @@ -520,12 +520,13 @@ public class ClipboardScreen extends AbstractSimiScreen { } private Pos2i convertScreenToLocal(Pos2i pScreenPos) { - return new Pos2i(pScreenPos.x - (width - 192) / 2 - 36 + 10, pScreenPos.y - 32 - 24 - yOffsetOfEditingEntry()); + return new Pos2i(pScreenPos.x - (width - 192) / 2 - 36 + 10, + pScreenPos.y - 32 - 24 - yOffsetOfEditingEntry() - guiTop + 14); } private Pos2i convertLocalToScreen(Pos2i pLocalScreenPos) { return new Pos2i(pLocalScreenPos.x + (width - 192) / 2 + 36 - 10, - pLocalScreenPos.y + 32 + 24 + yOffsetOfEditingEntry()); + pLocalScreenPos.y + 32 + 24 + yOffsetOfEditingEntry() + guiTop - 14); } public boolean mouseClicked(double pMouseX, double pMouseY, int pButton) { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/display/AllDisplayBehaviours.java b/src/main/java/com/simibubi/create/content/logistics/block/display/AllDisplayBehaviours.java index 3f7bc2231..395df3671 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/display/AllDisplayBehaviours.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/display/AllDisplayBehaviours.java @@ -60,6 +60,11 @@ public class AllDisplayBehaviours { } } + @Deprecated + public static void assignTile(DisplayBehaviour behaviour, ResourceLocation beType) { + assignBlockEntity(behaviour, beType); + } + public static void assignBlockEntity(DisplayBehaviour behaviour, ResourceLocation beType) { if (behaviour instanceof DisplaySource source) { List sources = SOURCES_BY_BLOCK_ENTITY.get(beType); @@ -88,6 +93,11 @@ public class AllDisplayBehaviours { } } + @Deprecated + public static void assignTile(DisplayBehaviour behaviour, BlockEntityType beType) { + assignBlockEntity(behaviour, beType); + } + public static void assignBlockEntity(DisplayBehaviour behaviour, BlockEntityType beType) { if (behaviour instanceof DisplaySource source) { List sources = SOURCES_BY_BLOCK_ENTITY.get(beType); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneContactBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneContactBlock.java index 7803a2198..d5623e291 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneContactBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneContactBlock.java @@ -6,13 +6,19 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; import com.simibubi.create.AllBlocks; +import com.simibubi.create.content.contraptions.components.structureMovement.elevator.ElevatorColumn; +import com.simibubi.create.content.contraptions.components.structureMovement.elevator.ElevatorColumn.ColumnCoords; import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; +import com.simibubi.create.foundation.utility.BlockHelper; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.InteractionResult; import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; @@ -57,6 +63,29 @@ public class RedstoneContactBlock extends WrenchableDirectionalBlock { return state; } + @Override + public InteractionResult onWrenched(BlockState state, UseOnContext context) { + InteractionResult onWrenched = super.onWrenched(state, context); + if (onWrenched != InteractionResult.SUCCESS) + return onWrenched; + + Level level = context.getLevel(); + if (level.isClientSide()) + return onWrenched; + + BlockPos pos = context.getClickedPos(); + state = level.getBlockState(pos); + Direction facing = state.getValue(RedstoneContactBlock.FACING); + if (facing.getAxis() == Axis.Y) + return onWrenched; + if (ElevatorColumn.get(level, new ColumnCoords(pos.getX(), pos.getZ(), facing)) == null) + return onWrenched; + + level.setBlockAndUpdate(pos, BlockHelper.copyProperties(state, AllBlocks.ELEVATOR_CONTACT.getDefaultState())); + + return onWrenched; + } + @Override public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) { diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShifter.java b/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShifter.java index e3c61883c..7fb456fb8 100644 --- a/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShifter.java +++ b/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShifter.java @@ -6,6 +6,8 @@ import java.util.Map; import com.simibubi.create.foundation.block.render.SpriteShiftEntry; import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.fml.DistExecutor; public class CTSpriteShifter { @@ -17,7 +19,7 @@ public class CTSpriteShifter { return (CTSpriteShiftEntry) ENTRY_CACHE.get(key); CTSpriteShiftEntry entry = new CTSpriteShiftEntry(type); - entry.set(blockTexture, connectedTexture); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> entry.set(blockTexture, connectedTexture)); ENTRY_CACHE.put(key, entry); return entry; } diff --git a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java index 0b97d60b7..a9bcb3644 100644 --- a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java +++ b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java @@ -4,6 +4,8 @@ import java.util.HashMap; import java.util.Map; import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.fml.DistExecutor; public class SpriteShifter { @@ -15,7 +17,7 @@ public class SpriteShifter { return ENTRY_CACHE.get(key); SpriteShiftEntry entry = new SpriteShiftEntry(); - entry.set(originalLocation, targetLocation); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> entry.set(originalLocation, targetLocation)); ENTRY_CACHE.put(key, entry); return entry; } diff --git a/src/main/java/com/simibubi/create/foundation/data/MetalBarsGen.java b/src/main/java/com/simibubi/create/foundation/data/MetalBarsGen.java index 71a6b98a8..3f583a8f9 100644 --- a/src/main/java/com/simibubi/create/foundation/data/MetalBarsGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/MetalBarsGen.java @@ -127,6 +127,7 @@ public class MetalBarsGen { .initialProperties(() -> Blocks.IRON_BARS) .properties(p -> p.sound(SoundType.COPPER)) .tag(AllBlockTags.WRENCH_PICKUP.tag) + .tag(AllBlockTags.FAN_TRANSPARENT.tag) .blockstate(barsBlockState(name, specialEdge)) .item() .model((c, p) -> { diff --git a/src/main/resources/assets/create/models/block/mechanical_arm/item.json b/src/main/resources/assets/create/models/block/mechanical_arm/item.json index 6e7626c7f..ee95d2733 100644 --- a/src/main/resources/assets/create/models/block/mechanical_arm/item.json +++ b/src/main/resources/assets/create/models/block/mechanical_arm/item.json @@ -2,7 +2,7 @@ "credit": "Made with Blockbench", "parent": "block/block", "textures": { - "4": "create:block/belt/brass_belt_casing_sideways", + "4": "create:block/mechanical_arm_side", "5": "create:block/mechanical_arm", "7": "create:block/brass_block", "particle": "create:block/crafter_top" @@ -110,10 +110,10 @@ "to": [16, -10, 16], "rotation": {"angle": 0, "axis": "y", "origin": [8, -8, 8]}, "faces": { - "north": {"uv": [0, 6.5, 8, 9.5], "texture": "#4"}, - "east": {"uv": [0, 6.5, 8, 9.5], "texture": "#4"}, - "south": {"uv": [0, 6.5, 8, 9.5], "texture": "#4"}, - "west": {"uv": [0, 6.5, 8, 9.5], "texture": "#4"}, + "north": {"uv": [0, 0, 16, 6], "texture": "#4"}, + "east": {"uv": [0, 0, 16, 6], "texture": "#4"}, + "south": {"uv": [0, 0, 16, 6], "texture": "#4"}, + "west": {"uv": [0, 0, 16, 6], "texture": "#4"}, "up": {"uv": [0, 0, 16, 16], "texture": "#7"}, "down": {"uv": [0, 0, 16, 16], "texture": "#7"} }