diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneTileEntity.java index 6df1a0a5f..d9c9fe512 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneTileEntity.java @@ -1,9 +1,12 @@ package com.simibubi.create.content.contraptions.components.millstone; +import java.util.List; import java.util.Optional; import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.content.contraptions.base.KineticTileEntity; +import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; +import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.block.BlockState; @@ -38,6 +41,12 @@ public class MillstoneTileEntity extends KineticTileEntity { outputInv = new ItemStackHandler(9); capability = LazyOptional.of(MillstoneInventoryHandler::new); } + + @Override + public void addBehaviours(List behaviours) { + behaviours.add(new DirectBeltInputBehaviour(this)); + super.addBehaviours(behaviours); + } @Override public void tick() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java index e37bcd83c..5ff38295f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java @@ -24,7 +24,6 @@ import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.inventory.IInventory; @@ -188,6 +187,9 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { AllSoundEvents.MECHANICAL_PRESS_ACTIVATION_ON_BELT.playOnServer(world, pos); else AllSoundEvents.MECHANICAL_PRESS_ACTIVATION.playOnServer(world, pos); + + if (!world.isRemote) + sendData(); } if (!world.isRemote && runningTicks > CYCLE) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementTraits.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementTraits.java index 9edac0058..5a47573fe 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementTraits.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementTraits.java @@ -13,6 +13,8 @@ import com.simibubi.create.content.contraptions.components.structureMovement.bea import com.simibubi.create.content.contraptions.components.structureMovement.bearing.MechanicalBearingBlock; import com.simibubi.create.content.contraptions.components.structureMovement.bearing.MechanicalBearingTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.bearing.SailBlock; +import com.simibubi.create.content.contraptions.components.structureMovement.bearing.WindmillBearingBlock; +import com.simibubi.create.content.contraptions.components.structureMovement.bearing.WindmillBearingTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.chassis.AbstractChassisBlock; import com.simibubi.create.content.contraptions.components.structureMovement.chassis.StickerBlock; import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerBlock; @@ -88,6 +90,11 @@ public class BlockMovementTraits { if (te instanceof MechanicalBearingTileEntity) return !((MechanicalBearingTileEntity) te).isRunning(); } + if (block instanceof WindmillBearingBlock) { + TileEntity te = world.getTileEntity(pos); + if (te instanceof WindmillBearingTileEntity) + return !((WindmillBearingTileEntity) te).isRunning(); + } if (block instanceof ClockworkBearingBlock) { TileEntity te = world.getTileEntity(pos); if (te instanceof ClockworkBearingTileEntity) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java index 593062e4e..5a7957c92 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java @@ -58,6 +58,7 @@ import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.network.NetworkHooks; @@ -170,7 +171,7 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat return false; if (world instanceof WrappedWorld) return true; - + BlockPos pos = hangingPosition; BlockPos pos2 = pos.offset(getFacingDirection().getOpposite()); return isValidFace(world, pos2, getFacingDirection()) != isValidFace(world, pos, @@ -185,7 +186,8 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat if (!isValidFace(world, pos2, getFacingDirection()) && !isValidFace(world, pos, getFacingDirection().getOpposite())) return false; - if (isSideSticky(world, pos2, getFacingDirection()) || isSideSticky(world, pos, getFacingDirection().getOpposite())) + if (isSideSticky(world, pos2, getFacingDirection()) + || isSideSticky(world, pos, getFacingDirection().getOpposite())) return false; return world.getEntitiesInAABBexcluding(this, getBoundingBox(), e -> e instanceof SuperGlueEntity) .isEmpty(); @@ -209,12 +211,12 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat if (AllBlocks.STICKER.has(state)) return state.get(DirectionalBlock.FACING) == direction; - + if (state.getBlock() == Blocks.SLIME_BLOCK) return true; if (state.getBlock() == Blocks.HONEY_BLOCK) return true; - + if (AllBlocks.CART_ASSEMBLER.has(state)) return Direction.UP == direction; @@ -227,7 +229,8 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat if (state.getBlock() instanceof AbstractChassisBlock) { BooleanProperty glueableSide = ((AbstractChassisBlock) state.getBlock()).getGlueableSide(state, direction); - if (glueableSide == null) return false; + if (glueableSide == null) + return false; return state.get(glueableSide); } @@ -255,7 +258,13 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isInvulnerableTo(source)) return false; - if (isAlive() && !world.isRemote && isVisible()) { + Entity immediateSource = source.getImmediateSource(); + if (!isVisible() && immediateSource instanceof PlayerEntity) { + if (!AllItems.SUPER_GLUE.isIn(((PlayerEntity) immediateSource).getHeldItemMainhand())) + return true; + } + + if (isAlive() && !world.isRemote) { remove(); markVelocityChanged(); onBroken(source.getTrueSource()); @@ -297,6 +306,8 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat @Override public ActionResultType processInitialInteract(PlayerEntity player, Hand hand) { + if (player instanceof FakePlayer) + return ActionResultType.PASS; DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { triggerPlaceBlock(player, hand); }); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonBlock.java index 2c13bebb7..98efed20f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonBlock.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.piston; +import java.util.Random; + import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; import com.simibubi.create.AllSoundEvents; @@ -30,6 +32,7 @@ import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.Tags; public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implements ITE { @@ -97,6 +100,35 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement return ActionResultType.SUCCESS; } + @Override + public void neighborChanged(BlockState state, World world, BlockPos pos, Block p_220069_4_, BlockPos fromPos, + boolean p_220069_6_) { + Direction direction = state.get(FACING); + if (!fromPos.equals(pos.offset(direction.getOpposite()))) + return; + if (!world.isRemote && !world.getPendingBlockTicks() + .isTickPending(pos, this)) + world.getPendingBlockTicks() + .scheduleTick(pos, this, 0); + } + + @Override + public void scheduledTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random r) { + Direction direction = state.get(FACING); + BlockState pole = worldIn.getBlockState(pos.offset(direction.getOpposite())); + if (!AllBlocks.PISTON_EXTENSION_POLE.has(pole)) + return; + if (pole.get(PistonExtensionPoleBlock.FACING) + .getAxis() != direction.getAxis()) + return; + withTileEntityDo(worldIn, pos, te -> { + if (te.lastException == null) + return; + te.lastException = null; + te.sendData(); + }); + } + @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return AllTileEntities.MECHANICAL_PISTON.create(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java index decf128f9..b88ef5c3a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java @@ -41,6 +41,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraftforge.common.ToolType; public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements IWrenchable, IWaterLoggable { @@ -51,6 +52,26 @@ public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements setDefaultState(getDefaultState().with(FACING, Direction.UP).with(BlockStateProperties.WATERLOGGED, false)); } + @Override + public ToolType getHarvestTool(BlockState state) { + return null; + } + + @Override + public boolean canHarvestBlock(BlockState state, IBlockReader world, BlockPos pos, PlayerEntity player) { + for (ToolType toolType : player.getHeldItemMainhand() + .getToolTypes()) { + if (isToolEffective(state, toolType)) + return true; + } + return super.canHarvestBlock(state, world, pos, player); + } + + @Override + public boolean isToolEffective(BlockState state, ToolType tool) { + return tool == ToolType.AXE || tool == ToolType.PICKAXE; + } + @Override public PushReaction getPushReaction(BlockState state) { return PushReaction.NORMAL; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftBlock.java index e206109b2..eac794939 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftBlock.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.contraptions.relays.advanced.sequencer; +import java.util.Random; + import com.simibubi.create.AllItems; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.base.HorizontalAxisKineticBlock; @@ -29,6 +31,7 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; @@ -62,7 +65,14 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen boolean isMoving) { if (worldIn.isRemote) return; + if (!worldIn.getPendingBlockTicks() + .isTickPending(pos, this)) + worldIn.getPendingBlockTicks() + .scheduleTick(pos, this, 0); + } + @Override + public void scheduledTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random r) { boolean previouslyPowered = state.get(STATE) != 0; boolean isPowered = worldIn.isBlockPowered(pos); withTileEntityDo(worldIn, pos, sgte -> sgte.onRedstoneUpdate(isPowered, previouslyPowered)); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteBlock.java index eadcd71fa..55b0b2d52 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/SmartChuteBlock.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.logistics.block.chute; +import java.util.Random; + import com.simibubi.create.AllTileEntities; import net.minecraft.block.Block; @@ -13,6 +15,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; public class SmartChuteBlock extends AbstractChuteBlock { @@ -29,6 +32,14 @@ public class SmartChuteBlock extends AbstractChuteBlock { super.neighborChanged(state, worldIn, pos, blockIn, fromPos, isMoving); if (worldIn.isRemote) return; + if (!worldIn.getPendingBlockTicks() + .isTickPending(pos, this)) + worldIn.getPendingBlockTicks() + .scheduleTick(pos, this, 0); + } + + @Override + public void scheduledTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random r) { boolean previouslyPowered = state.get(POWERED); if (previouslyPowered != worldIn.isBlockPowered(pos)) worldIn.setBlockState(pos, state.cycle(POWERED), 2); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractFunnelBlock.java index 59733e5ce..b71846b3a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AbstractFunnelBlock.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.logistics.block.funnel; +import java.util.Random; + import javax.annotation.Nullable; import com.simibubi.create.AllTileEntities; @@ -25,6 +27,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -42,7 +45,7 @@ public abstract class AbstractFunnelBlock extends Block implements ITE { @@ -116,13 +119,25 @@ public class NixieTubeBlock extends HorizontalBlock implements ITE { @@ -41,8 +44,10 @@ public class RedstoneLinkBlock extends ProperDirectionalBlock implements ITE getTileEntityClass() { return RedstoneLinkTileEntity.class; diff --git a/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java b/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java index 4b89f7a4f..452af3c6c 100644 --- a/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java +++ b/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java @@ -47,9 +47,8 @@ public class TooltipHelper { private static final Map> tooltipReferrals = new HashMap<>(); public static IFormattableTextComponent holdShift(Palette color, boolean highlighted) { - TextFormatting colorFormat = highlighted ? color.hColor : color.color; - return Lang.translate("tooltip.holdKey", Lang.translate("tooltip.keyShift") - .formatted(colorFormat)) + return Lang.translate("tooltip.holdForDescription", Lang.translate("tooltip.keyShift") + .formatted(TextFormatting.GRAY)) .formatted(TextFormatting.DARK_GRAY); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderProgressBar.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderProgressBar.java index 07411ad8f..caf8bbcc6 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderProgressBar.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderProgressBar.java @@ -108,7 +108,7 @@ public class PonderProgressBar extends AbstractSimiWidget { hovered = clicked(mouseX, mouseY); ms.push(); - ms.translate(0, 0, 150); + ms.translate(0, 0, 250); /* * ponderButtons are at z+400 * renderBox is at z+100 @@ -182,9 +182,9 @@ public class PonderProgressBar extends AbstractSimiWidget { if (selected) { FontRenderer font = Minecraft.getInstance().fontRenderer; GuiUtils.drawGradientRect(ms.peek() - .getModel(), 500, keyframePos, 10, keyframePos + 1, 10 + height, endColor, startColor); + .getModel(), 100, keyframePos, 10, keyframePos + 1, 10 + height, endColor, startColor); ms.push(); - ms.translate(0, 0, 400); + ms.translate(0, 0, 100); String text; int offset; if (activeScene.currentTime < keyframeTime) { diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java index 60f10f109..b7393efd6 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java @@ -449,6 +449,7 @@ public class PonderScene { } else { // For block breaking overlay; Don't ask ms.scale(f, f, f); + ms.translate(0.525, .2975, .9); ms.translate((basePlateSize + basePlateOffsetX) / -2f, -yOffset, (basePlateSize + basePlateOffsetZ) / -2f); float y = (float) (0.5065 * Math.pow(2.2975, Math.log(1 / scaleFactor) / Math.log(2))) / 30; diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java index fe97ce39c..2e9c14f23 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java @@ -537,7 +537,7 @@ public class PonderUI extends NavigatableSimiScreen { { // Chapter title ms.push(); - ms.translate(0, 0, 100); + ms.translate(0, 0, 300); int x = 31 + 20 + 8; int y = 31; diff --git a/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderButton.java b/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderButton.java index deb018c6e..fb40f8784 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderButton.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderButton.java @@ -110,7 +110,7 @@ public class PonderButton extends AbstractSimiWidget { borderColorStart = ColorHelper.applyAlpha(borderColorStart, fade); borderColorEnd = ColorHelper.applyAlpha(borderColorEnd, fade); - ms.translate(0, 0, 300); + ms.translate(0, 0, 400); PonderUI.renderBox(ms, x, y, width, height, backgroundColor, borderColorStart, borderColorEnd); ms.translate(0, 0, 100); diff --git a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java index d0c37472e..93309a030 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java @@ -14,12 +14,14 @@ import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.VirtualEmptyModelData; +import com.simibubi.create.foundation.utility.placement.PlacementHelpers; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; +import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.texture.OverlayTexture; @@ -35,16 +37,17 @@ import net.minecraft.util.math.vector.Vector4f; public abstract class GhostBlockRenderer { private static final GhostBlockRenderer transparent = new TransparentGhostBlockRenderer(); + public static GhostBlockRenderer transparent() { return transparent; } private static final GhostBlockRenderer standard = new DefaultGhostBlockRenderer(); + public static GhostBlockRenderer standard() { return standard; } - public abstract void render(MatrixStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params); private static class DefaultGhostBlockRenderer extends GhostBlockRenderer { @@ -52,7 +55,8 @@ public abstract class GhostBlockRenderer { public void render(MatrixStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params) { ms.push(); - BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); + BlockRendererDispatcher dispatcher = Minecraft.getInstance() + .getBlockRendererDispatcher(); IBakedModel model = dispatcher.getModelForState(params.state); @@ -62,7 +66,9 @@ public abstract class GhostBlockRenderer { BlockPos pos = params.pos; ms.translate(pos.getX(), pos.getY(), pos.getZ()); - dispatcher.getBlockModelRenderer().renderModel(ms.peek(), vb, params.state, model, 1f, 1f, 1f, 0xF000F0, OverlayTexture.DEFAULT_UV, VirtualEmptyModelData.INSTANCE); + dispatcher.getBlockModelRenderer() + .renderModel(ms.peek(), vb, params.state, model, 1f, 1f, 1f, 0xF000F0, OverlayTexture.DEFAULT_UV, + VirtualEmptyModelData.INSTANCE); ms.pop(); } @@ -73,48 +79,61 @@ public abstract class GhostBlockRenderer { public void render(MatrixStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params) { - //prepare + // prepare ms.push(); - //RenderSystem.pushMatrix(); + // RenderSystem.pushMatrix(); - BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); + Minecraft mc = Minecraft.getInstance(); + BlockRendererDispatcher dispatcher = mc.getBlockRendererDispatcher(); IBakedModel model = dispatcher.getModelForState(params.state); - //RenderType layer = RenderTypeLookup.getEntityBlockLayer(params.state); + // RenderType layer = RenderTypeLookup.getEntityBlockLayer(params.state); RenderType layer = RenderType.getTranslucent(); IVertexBuilder vb = buffer.getEarlyBuffer(layer); BlockPos pos = params.pos; ms.translate(pos.getX(), pos.getY(), pos.getZ()); - //dispatcher.getBlockModelRenderer().renderModel(ms.peek(), vb, params.state, model, 1f, 1f, 1f, 0xF000F0, OverlayTexture.DEFAULT_UV, VirtualEmptyModelData.INSTANCE); - renderModel(params, ms.peek(), vb, params.state, model, 1f, 1f, 1f, 0xF000F0, OverlayTexture.DEFAULT_UV, VirtualEmptyModelData.INSTANCE); + ms.translate(.5, .5, .5); + ms.scale(.85f, .85f, .85f); + ms.translate(-.5, -.5, -.5); - //buffer.draw(); - //clean - //RenderSystem.popMatrix(); + // dispatcher.getBlockModelRenderer().renderModel(ms.peek(), vb, params.state, model, 1f, 1f, 1f, 0xF000F0, OverlayTexture.DEFAULT_UV, VirtualEmptyModelData.INSTANCE); + renderModel(params, ms.peek(), vb, params.state, model, 1f, 1f, 1f, + WorldRenderer.getLightmapCoordinates(mc.world, pos), OverlayTexture.DEFAULT_UV, + VirtualEmptyModelData.INSTANCE); + + // buffer.draw(); + // clean + // RenderSystem.popMatrix(); ms.pop(); } - //BlockModelRenderer - public void renderModel(GhostBlockParams params, MatrixStack.Entry entry, IVertexBuilder vb, @Nullable BlockState state, IBakedModel model, float p_228804_5_, float p_228804_6_, float p_228804_7_, int p_228804_8_, int p_228804_9_, net.minecraftforge.client.model.data.IModelData modelData) { + // BlockModelRenderer + public void renderModel(GhostBlockParams params, MatrixStack.Entry entry, IVertexBuilder vb, + @Nullable BlockState state, IBakedModel model, float p_228804_5_, float p_228804_6_, float p_228804_7_, + int p_228804_8_, int p_228804_9_, net.minecraftforge.client.model.data.IModelData modelData) { Random random = new Random(); for (Direction direction : Direction.values()) { random.setSeed(42L); - renderQuad(params, entry, vb, p_228804_5_, p_228804_6_, p_228804_7_, model.getQuads(state, direction, random, modelData), p_228804_8_, p_228804_9_); + renderQuad(params, entry, vb, p_228804_5_, p_228804_6_, p_228804_7_, + model.getQuads(state, direction, random, modelData), p_228804_8_, p_228804_9_); } random.setSeed(42L); - renderQuad(params, entry, vb, p_228804_5_, p_228804_6_, p_228804_7_, model.getQuads(state, (Direction) null, random, modelData), p_228804_8_, p_228804_9_); + renderQuad(params, entry, vb, p_228804_5_, p_228804_6_, p_228804_7_, + model.getQuads(state, (Direction) null, random, modelData), p_228804_8_, p_228804_9_); } - //BlockModelRenderer - private static void renderQuad(GhostBlockParams params, MatrixStack.Entry p_228803_0_, IVertexBuilder p_228803_1_, float p_228803_2_, float p_228803_3_, float p_228803_4_, List p_228803_5_, int p_228803_6_, int p_228803_7_) { - Float alpha = params.alphaSupplier.get(); + // BlockModelRenderer + private static void renderQuad(GhostBlockParams params, MatrixStack.Entry p_228803_0_, + IVertexBuilder p_228803_1_, float p_228803_2_, float p_228803_3_, float p_228803_4_, + List p_228803_5_, int p_228803_6_, int p_228803_7_) { + Float alpha = params.alphaSupplier.get() * .75f * PlacementHelpers.getCurrentAlpha(); for (BakedQuad bakedquad : p_228803_5_) { float f; @@ -130,15 +149,19 @@ public abstract class GhostBlockRenderer { f2 = 1.0F; } - quad(alpha, p_228803_1_, p_228803_0_, bakedquad, new float[]{1f, 1f, 1f, 1f}, f, f1, f2, new int[]{p_228803_6_, p_228803_6_, p_228803_6_, p_228803_6_}, p_228803_7_); + quad(alpha, p_228803_1_, p_228803_0_, bakedquad, new float[] { 1f, 1f, 1f, 1f }, f, f1, f2, + new int[] { p_228803_6_, p_228803_6_, p_228803_6_, p_228803_6_ }, p_228803_7_); } } - //IVertexBuilder - static void quad(float alpha, IVertexBuilder vb, MatrixStack.Entry p_227890_1_, BakedQuad p_227890_2_, float[] p_227890_3_, float p_227890_4_, float p_227890_5_, float p_227890_6_, int[] p_227890_7_, int p_227890_8_) { + // IVertexBuilder + static void quad(float alpha, IVertexBuilder vb, MatrixStack.Entry p_227890_1_, BakedQuad p_227890_2_, + float[] p_227890_3_, float p_227890_4_, float p_227890_5_, float p_227890_6_, int[] p_227890_7_, + int p_227890_8_) { int[] aint = p_227890_2_.getVertexData(); - Vector3i Vector3i = p_227890_2_.getFace().getDirectionVec(); + Vector3i Vector3i = p_227890_2_.getFace() + .getDirectionVec(); Vector3f vector3f = new Vector3f((float) Vector3i.getX(), (float) Vector3i.getY(), (float) Vector3i.getZ()); Matrix4f matrix4f = p_227890_1_.getModel(); vector3f.transform(p_227890_1_.getNormal()); @@ -163,14 +186,14 @@ public abstract class GhostBlockRenderer { g = p_227890_3_[k] * p_227890_5_; b = p_227890_3_[k] * p_227890_6_; - int l = vb.applyBakedLighting(p_227890_7_[k], bytebuffer); float f9 = bytebuffer.getFloat(16); float f10 = bytebuffer.getFloat(20); Vector4f vector4f = new Vector4f(f, f1, f2, 1.0F); vector4f.transform(matrix4f); vb.applyBakedNormals(vector3f, bytebuffer, p_227890_1_.getNormal()); - vb.vertex(vector4f.getX(), vector4f.getY(), vector4f.getZ(), r, g, b, alpha, f9, f10, p_227890_8_, l, vector3f.getX(), vector3f.getY(), vector3f.getZ()); + vb.vertex(vector4f.getX(), vector4f.getY(), vector4f.getZ(), r, g, b, alpha, f9, f10, p_227890_8_, + l, vector3f.getX(), vector3f.getY(), vector3f.getZ()); } } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementHelpers.java b/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementHelpers.java index b70ec6246..09f98b72f 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementHelpers.java +++ b/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementHelpers.java @@ -157,12 +157,16 @@ public class PlacementHelpers { float screenY = res.getScaledHeight() / 2f; float screenX = res.getScaledWidth() / 2f; - float progress = Math.min(animationTick / 10f/* + event.getPartialTicks()*/, 1f); + float progress = getCurrentAlpha(); drawDirectionIndicator(event.getMatrixStack(), event.getPartialTicks(), screenX, screenY, progress); } } + public static float getCurrentAlpha() { + return Math.min(animationTick / 10f/* + event.getPartialTicks()*/, 1f); + } + @OnlyIn(Dist.CLIENT) private static void drawDirectionIndicator(MatrixStack ms, float partialTicks, float centerX, float centerY, float progress) { float r = .8f;