diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 444f80625..8d936a3a9 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -1,29 +1,10 @@ package com.simibubi.create; -import static com.simibubi.create.AllMovementBehaviours.addMovementBehaviour; -import static com.simibubi.create.AllTags.tagBlockAndItem; -import static com.simibubi.create.content.AllSections.SCHEMATICS; -import static com.simibubi.create.foundation.data.BlockStateGen.axisBlock; -import static com.simibubi.create.foundation.data.BlockStateGen.oxidizedBlockstate; -import static com.simibubi.create.foundation.data.CreateRegistrate.connectedTextures; -import static com.simibubi.create.foundation.data.ModelGen.customItemModel; -import static com.simibubi.create.foundation.data.ModelGen.oxidizedItemModel; - import com.simibubi.create.AllTags.AllBlockTags; import com.simibubi.create.AllTags.AllItemTags; import com.simibubi.create.content.AllSections; import com.simibubi.create.content.contraptions.base.CasingBlock; -import com.simibubi.create.content.contraptions.components.actors.DrillBlock; -import com.simibubi.create.content.contraptions.components.actors.DrillMovementBehaviour; -import com.simibubi.create.content.contraptions.components.actors.HarvesterBlock; -import com.simibubi.create.content.contraptions.components.actors.HarvesterMovementBehaviour; -import com.simibubi.create.content.contraptions.components.actors.PloughBlock; -import com.simibubi.create.content.contraptions.components.actors.PloughMovementBehaviour; -import com.simibubi.create.content.contraptions.components.actors.PortableStorageInterfaceBlock; -import com.simibubi.create.content.contraptions.components.actors.PortableStorageInterfaceMovement; -import com.simibubi.create.content.contraptions.components.actors.SawMovementBehaviour; -import com.simibubi.create.content.contraptions.components.actors.SeatBlock; -import com.simibubi.create.content.contraptions.components.actors.SeatMovementBehaviour; +import com.simibubi.create.content.contraptions.components.actors.*; import com.simibubi.create.content.contraptions.components.clock.CuckooClockBlock; import com.simibubi.create.content.contraptions.components.crafter.CrafterCTBehaviour; import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterBlock; @@ -46,11 +27,7 @@ import com.simibubi.create.content.contraptions.components.motor.CreativeMotorGe import com.simibubi.create.content.contraptions.components.press.MechanicalPressBlock; import com.simibubi.create.content.contraptions.components.saw.SawBlock; import com.simibubi.create.content.contraptions.components.saw.SawGenerator; -import com.simibubi.create.content.contraptions.components.structureMovement.bearing.ClockworkBearingBlock; -import com.simibubi.create.content.contraptions.components.structureMovement.bearing.MechanicalBearingBlock; -import com.simibubi.create.content.contraptions.components.structureMovement.bearing.SailBlock; -import com.simibubi.create.content.contraptions.components.structureMovement.bearing.StabilizedBearingMovementBehaviour; -import com.simibubi.create.content.contraptions.components.structureMovement.bearing.WindmillBearingBlock; +import com.simibubi.create.content.contraptions.components.structureMovement.bearing.*; import com.simibubi.create.content.contraptions.components.structureMovement.chassis.LinearChassisBlock; import com.simibubi.create.content.contraptions.components.structureMovement.chassis.LinearChassisBlock.ChassisCTBehaviour; import com.simibubi.create.content.contraptions.components.structureMovement.chassis.RadialChassisBlock; @@ -73,15 +50,7 @@ import com.simibubi.create.content.contraptions.fluids.PumpBlock; import com.simibubi.create.content.contraptions.fluids.actors.HosePulleyBlock; import com.simibubi.create.content.contraptions.fluids.actors.ItemDrainBlock; import com.simibubi.create.content.contraptions.fluids.actors.SpoutBlock; -import com.simibubi.create.content.contraptions.fluids.pipes.BracketBlock; -import com.simibubi.create.content.contraptions.fluids.pipes.BracketBlockItem; -import com.simibubi.create.content.contraptions.fluids.pipes.BracketGenerator; -import com.simibubi.create.content.contraptions.fluids.pipes.EncasedPipeBlock; -import com.simibubi.create.content.contraptions.fluids.pipes.FluidPipeBlock; -import com.simibubi.create.content.contraptions.fluids.pipes.FluidValveBlock; -import com.simibubi.create.content.contraptions.fluids.pipes.GlassFluidPipeBlock; -import com.simibubi.create.content.contraptions.fluids.pipes.SmartFluidPipeBlock; -import com.simibubi.create.content.contraptions.fluids.pipes.SmartFluidPipeGenerator; +import com.simibubi.create.content.contraptions.fluids.pipes.*; import com.simibubi.create.content.contraptions.fluids.tank.FluidTankBlock; import com.simibubi.create.content.contraptions.fluids.tank.FluidTankGenerator; import com.simibubi.create.content.contraptions.fluids.tank.FluidTankItem; @@ -103,13 +72,7 @@ import com.simibubi.create.content.contraptions.relays.elementary.BracketedKinet import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock; import com.simibubi.create.content.contraptions.relays.elementary.CogwheelBlockItem; import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock; -import com.simibubi.create.content.contraptions.relays.encased.AdjustablePulleyBlock; -import com.simibubi.create.content.contraptions.relays.encased.ClutchBlock; -import com.simibubi.create.content.contraptions.relays.encased.EncasedBeltBlock; -import com.simibubi.create.content.contraptions.relays.encased.EncasedBeltGenerator; -import com.simibubi.create.content.contraptions.relays.encased.EncasedCTBehaviour; -import com.simibubi.create.content.contraptions.relays.encased.EncasedShaftBlock; -import com.simibubi.create.content.contraptions.relays.encased.GearshiftBlock; +import com.simibubi.create.content.contraptions.relays.encased.*; import com.simibubi.create.content.contraptions.relays.gauge.GaugeBlock; import com.simibubi.create.content.contraptions.relays.gauge.GaugeGenerator; import com.simibubi.create.content.contraptions.relays.gearbox.GearboxBlock; @@ -121,50 +84,23 @@ import com.simibubi.create.content.logistics.block.chute.ChuteGenerator; import com.simibubi.create.content.logistics.block.chute.ChuteItem; import com.simibubi.create.content.logistics.block.chute.SmartChuteBlock; import com.simibubi.create.content.logistics.block.depot.DepotBlock; -import com.simibubi.create.content.logistics.block.diodes.AbstractDiodeGenerator; -import com.simibubi.create.content.logistics.block.diodes.AdjustableRepeaterBlock; -import com.simibubi.create.content.logistics.block.diodes.AdjustableRepeaterGenerator; -import com.simibubi.create.content.logistics.block.diodes.PoweredLatchBlock; -import com.simibubi.create.content.logistics.block.diodes.PoweredLatchGenerator; -import com.simibubi.create.content.logistics.block.diodes.PulseRepeaterBlock; -import com.simibubi.create.content.logistics.block.diodes.PulseRepeaterGenerator; -import com.simibubi.create.content.logistics.block.diodes.ToggleLatchBlock; -import com.simibubi.create.content.logistics.block.diodes.ToggleLatchGenerator; -import com.simibubi.create.content.logistics.block.funnel.AndesiteFunnelBlock; -import com.simibubi.create.content.logistics.block.funnel.BeltFunnelBlock; -import com.simibubi.create.content.logistics.block.funnel.BeltFunnelGenerator; -import com.simibubi.create.content.logistics.block.funnel.BrassFunnelBlock; -import com.simibubi.create.content.logistics.block.funnel.FunnelGenerator; -import com.simibubi.create.content.logistics.block.funnel.FunnelItem; -import com.simibubi.create.content.logistics.block.funnel.FunnelMovementBehaviour; +import com.simibubi.create.content.logistics.block.diodes.*; +import com.simibubi.create.content.logistics.block.funnel.*; import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateBlock; import com.simibubi.create.content.logistics.block.inventories.CreativeCrateBlock; import com.simibubi.create.content.logistics.block.mechanicalArm.ArmBlock; import com.simibubi.create.content.logistics.block.mechanicalArm.ArmItem; -import com.simibubi.create.content.logistics.block.redstone.AnalogLeverBlock; -import com.simibubi.create.content.logistics.block.redstone.ContactMovementBehaviour; -import com.simibubi.create.content.logistics.block.redstone.ContentObserverBlock; -import com.simibubi.create.content.logistics.block.redstone.NixieTubeBlock; -import com.simibubi.create.content.logistics.block.redstone.NixieTubeGenerator; -import com.simibubi.create.content.logistics.block.redstone.RedstoneContactBlock; -import com.simibubi.create.content.logistics.block.redstone.RedstoneLinkBlock; -import com.simibubi.create.content.logistics.block.redstone.RedstoneLinkGenerator; -import com.simibubi.create.content.logistics.block.redstone.StockpileSwitchBlock; +import com.simibubi.create.content.logistics.block.redstone.*; import com.simibubi.create.content.palettes.MetalBlock; import com.simibubi.create.content.schematics.block.SchematicTableBlock; import com.simibubi.create.content.schematics.block.SchematicannonBlock; +import com.simibubi.create.foundation.block.ItemUseOverrides; import com.simibubi.create.foundation.config.StressConfigDefaults; -import com.simibubi.create.foundation.data.AssetLookup; -import com.simibubi.create.foundation.data.BlockStateGen; -import com.simibubi.create.foundation.data.BuilderTransformers; -import com.simibubi.create.foundation.data.CreateRegistrate; -import com.simibubi.create.foundation.data.ModelGen; -import com.simibubi.create.foundation.data.SharedProperties; +import com.simibubi.create.foundation.data.*; import com.simibubi.create.foundation.item.TooltipHelper; import com.simibubi.create.foundation.utility.DyeHelper; import com.simibubi.create.foundation.worldgen.OxidizingBlock; import com.tterrag.registrate.util.entry.BlockEntry; - import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.block.SoundType; @@ -183,6 +119,15 @@ import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.common.Tags; import net.minecraftforge.common.ToolType; +import static com.simibubi.create.AllMovementBehaviours.addMovementBehaviour; +import static com.simibubi.create.AllTags.tagBlockAndItem; +import static com.simibubi.create.content.AllSections.SCHEMATICS; +import static com.simibubi.create.foundation.data.BlockStateGen.axisBlock; +import static com.simibubi.create.foundation.data.BlockStateGen.oxidizedBlockstate; +import static com.simibubi.create.foundation.data.CreateRegistrate.connectedTextures; +import static com.simibubi.create.foundation.data.ModelGen.customItemModel; +import static com.simibubi.create.foundation.data.ModelGen.oxidizedItemModel; + public class AllBlocks { private static final CreateRegistrate REGISTRATE = Create.registrate() @@ -373,6 +318,7 @@ public class AllBlocks { .blockstate(BlockStateGen.directionalBlockProvider(true)) .transform(StressConfigDefaults.setCapacity(8.0)) .tag(AllBlockTags.BRITTLE.tag) + .onRegister(ItemUseOverrides::addBlock) .item() .transform(customItemModel()) .register(); @@ -1197,6 +1143,7 @@ public class AllBlocks { .initialProperties(() -> Blocks.LEVER) .tag(AllBlockTags.SAFE_NBT.tag) .blockstate((c, p) -> p.horizontalFaceBlock(c.get(), AssetLookup.partialBaseModel(c, p))) + .onRegister(ItemUseOverrides::addBlock) .item() .transform(customItemModel()) .register(); diff --git a/src/main/java/com/simibubi/create/AllSpriteShifts.java b/src/main/java/com/simibubi/create/AllSpriteShifts.java index 9aafdc586..650c1d6ab 100644 --- a/src/main/java/com/simibubi/create/AllSpriteShifts.java +++ b/src/main/java/com/simibubi/create/AllSpriteShifts.java @@ -44,7 +44,10 @@ public class AllSpriteShifts { SHADOW_STEEL_CASING = omni("shadow_steel_casing"), REFINED_RADIANCE_CASING = omni("refined_radiance_casing"), CREATIVE_CASING = getCT(CTType.CROSS, "creative_casing"); - public static final CTSpriteShiftEntry CHASSIS = getCT(CTType.OMNIDIRECTIONAL, "linear_chassis_end"), + public static final CTSpriteShiftEntry + CHASSIS_SIDE = getCT(CTType.OMNIDIRECTIONAL, "linear_chassis_side"), + SECONDARY_CHASSIS_SIDE = getCT(CTType.OMNIDIRECTIONAL, "secondary_linear_chassis_side"), + CHASSIS = getCT(CTType.OMNIDIRECTIONAL, "linear_chassis_end"), CHASSIS_STICKY = getCT(CTType.OMNIDIRECTIONAL, "linear_chassis_end_sticky"); public static final CTSpriteShiftEntry BRASS_TUNNEL_TOP = vertical("brass_tunnel_top"), diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java index f3814c3e3..6ff654402 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java @@ -58,7 +58,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer { @@ -36,7 +37,8 @@ public class HarvesterRenderer extends SafeTileEntityRenderer te.turn(player.isSneaking())); player.addExhaustion(getRotationSpeed() * AllConfigs.SERVER.kinetics.crankHungerMultiplier.getF()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java index 3eaa412a0..267763ce0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java @@ -89,7 +89,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer ms.translate(0, isBlockItem ? 9 / 16f : 11 / 16f, 0); ms.scale(scale, scale, scale); transform = TransformType.GROUND; - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(AnimationTickHolder.getRenderTime())); + ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(AnimationTickHolder.getRenderTime(te.getWorld()))); } else { float scale = punching ? .75f : isBlockItem ? .75f - 1 / 64f : .5f; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java index 6421411d3..cb469d615 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java @@ -41,7 +41,7 @@ public class EncasedFanRenderer extends KineticTileEntityRenderer { SuperByteBuffer fanInner = AllBlockPartials.ENCASED_FAN_INNER.renderOnDirectionalSouth(te.getBlockState(), direction.getOpposite()); - float time = AnimationTickHolder.getRenderTime(); + float time = AnimationTickHolder.getRenderTime(te.getWorld()); float speed = te.getSpeed() * 5; if (speed > 0) speed = MathHelper.clamp(speed, 80, 64 * 20); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java index 5ad5963e0..41635cb02 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java @@ -46,7 +46,7 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer { int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, pos); float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks); float speed = mixer.getRenderedHeadRotationSpeed(partialTicks); - float time = AnimationTickHolder.getRenderTime(); + float time = AnimationTickHolder.getRenderTime(te.getWorld()); float angle = ((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI; SuperByteBuffer poleRender = AllBlockPartials.MECHANICAL_MIXER_POLE.renderOn(blockState); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisTileEntity.java index 1f8396922..0c21d2b83 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisTileEntity.java @@ -125,8 +125,6 @@ public class ChassisTileEntity extends SmartTileEntity { // Collect group of connected linear chassis for (Direction offset : Iterate.directions) { - if (offset.getAxis() == axis) - continue; BlockPos current = pos.offset(offset); if (visited.contains(current)) continue; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/LinearChassisBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/LinearChassisBlock.java index 30c6f95db..7450247d2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/LinearChassisBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/LinearChassisBlock.java @@ -73,14 +73,49 @@ public class LinearChassisBlock extends AbstractChassisBlock { Block block = state.getBlock(); BooleanProperty glueableSide = ((LinearChassisBlock) block).getGlueableSide(state, direction); if (glueableSide == null) - return null; + return AllBlocks.LINEAR_CHASSIS.has(state) ? AllSpriteShifts.CHASSIS_SIDE + : AllSpriteShifts.SECONDARY_CHASSIS_SIDE; return state.get(glueableSide) ? AllSpriteShifts.CHASSIS_STICKY : AllSpriteShifts.CHASSIS; } + @Override + protected Direction getUpDirection(ILightReader reader, BlockPos pos, BlockState state, Direction face) { + Axis axis = state.get(AXIS); + if (face.getAxis() == axis) + return super.getUpDirection(reader, pos, state, face); + return Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); + } + + @Override + protected Direction getRightDirection(ILightReader reader, BlockPos pos, BlockState state, Direction face) { + Axis axis = state.get(AXIS); + return axis != face.getAxis() && axis.isHorizontal() ? (face.getAxis() + .isHorizontal() ? Direction.DOWN : (axis == Axis.X ? Direction.NORTH : Direction.EAST)) + : super.getRightDirection(reader, pos, state, face); + } + + @Override + protected boolean reverseUVsHorizontally(BlockState state, Direction face) { + Axis axis = state.get(AXIS); + boolean side = face.getAxis() != axis; + if (side && axis == Axis.X && face.getAxis() + .isHorizontal()) + return true; + return super.reverseUVsHorizontally(state, face); + } + + @Override + protected boolean reverseUVsVertically(BlockState state, Direction face) { + return super.reverseUVsVertically(state, face); + } + @Override public boolean reverseUVs(BlockState state, Direction face) { Axis axis = state.get(AXIS); - if (axis.isHorizontal() && (face.getAxisDirection() == AxisDirection.POSITIVE)) + boolean end = face.getAxis() == axis; + if (end && axis.isHorizontal() && (face.getAxisDirection() == AxisDirection.POSITIVE)) + return true; + if (!end && axis.isHorizontal() && face == Direction.DOWN) return true; return super.reverseUVs(state, face); } @@ -88,7 +123,10 @@ public class LinearChassisBlock extends AbstractChassisBlock { @Override public boolean connectsTo(BlockState state, BlockState other, ILightReader reader, BlockPos pos, BlockPos otherPos, Direction face) { - return sameKind(state, other) && state.get(AXIS) == other.get(AXIS); + Axis axis = state.get(AXIS); + boolean superConnect = face.getAxis() == axis ? super.connectsTo(state, other, reader, pos, otherPos, face) + : sameKind(state, other); + return superConnect && axis == other.get(AXIS); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java index 0010a4755..271992288 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java @@ -72,7 +72,7 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer { } public static float getAngleForTe(KineticTileEntity te, final BlockPos pos, Axis axis) { - float time = AnimationTickHolder.getRenderTime(); + float time = AnimationTickHolder.getRenderTime(te.getWorld()); float offset = getRotationOffsetForPosition(te, pos, axis); return ((time * te.getSpeed() * 3f / 20 + offset) % 360) / 180 * (float) Math.PI; } 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 547aeb02c..c5a019872 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 @@ -1,29 +1,25 @@ package com.simibubi.create.content.contraptions.components.structureMovement.glue; -import javax.annotation.Nullable; - -import org.apache.commons.lang3.Validate; - +import com.simibubi.create.AllBlocks; import com.simibubi.create.AllEntityTypes; import com.simibubi.create.AllItems; import com.simibubi.create.AllSoundEvents; +import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock; import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementTraits; +import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingBlock; +import com.simibubi.create.content.contraptions.components.structureMovement.chassis.AbstractChassisBlock; import com.simibubi.create.content.schematics.ISpecialEntityItemRequirement; import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.content.schematics.ItemRequirement.ItemUseType; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.BlockFace; - import net.minecraft.block.BlockState; +import net.minecraft.block.DirectionalBlock; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntitySize; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.MoverType; -import net.minecraft.entity.Pose; +import net.minecraft.entity.*; import net.minecraft.entity.effect.LightningBoltEntity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.player.PlayerEntity; @@ -31,21 +27,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.IPacket; import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.DamageSource; -import net.minecraft.util.Direction; +import net.minecraft.state.BooleanProperty; +import net.minecraft.util.*; import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.*; import net.minecraft.util.math.RayTraceResult.Type; -import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -53,6 +39,9 @@ import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.fml.network.PacketDistributor; +import org.apache.commons.lang3.Validate; + +import javax.annotation.Nullable; public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnData, ISpecialEntityItemRequirement { @@ -173,6 +162,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())) + return false; return world.getEntitiesInAABBexcluding(this, getBoundingBox(), e -> e instanceof SuperGlueEntity) .isEmpty(); } @@ -188,6 +179,30 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat return true; } + public static boolean isSideSticky(World world, BlockPos pos, Direction direction) { + BlockState state = world.getBlockState(pos); + if (AllBlocks.STICKY_MECHANICAL_PISTON.has(state)) + return state.get(DirectionalKineticBlock.FACING) == direction; + + if (AllBlocks.STICKER.has(state)) + return state.get(DirectionalBlock.FACING) == direction; + + if (AllBlocks.GANTRY_CARRIAGE.has(state)) + return state.get(DirectionalKineticBlock.FACING) == direction; + + if (state.getBlock() instanceof BearingBlock) { + return state.get(DirectionalKineticBlock.FACING) == direction; + } + + if (state.getBlock() instanceof AbstractChassisBlock) { + BooleanProperty glueableSide = ((AbstractChassisBlock) state.getBlock()).getGlueableSide(state, direction); + if (glueableSide == null) return false; + return state.get(glueableSide); + } + + return false; + } + @Override public boolean canBeCollidedWith() { return true; diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/RotationIndicatorParticle.java b/src/main/java/com/simibubi/create/content/contraptions/particle/RotationIndicatorParticle.java index f9b754484..43e871aa2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/RotationIndicatorParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/RotationIndicatorParticle.java @@ -67,7 +67,7 @@ public class RotationIndicatorParticle extends SimpleAnimatedParticle { } public void move(double x, double y, double z) { - float time = AnimationTickHolder.getTicks(); + float time = AnimationTickHolder.getTicks(world); float angle = (float) ((time * speed) % 360) - (speed / 2 * age * (((float) age) / maxAge)); if (speed < 0 && axis.isVertical()) angle += 180; diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRenderer.java index 618816da2..72d80ad6b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRenderer.java @@ -72,8 +72,9 @@ public class BasinRenderer extends SmartTileEntityRenderer { if (fluidLevel > 0) { ms.translate(0, - (MathHelper.sin(AnimationTickHolder.getRenderTime() / 12f + anglePartition * itemCount) + 1.5f) * 1 - / 32f, + (MathHelper.sin( + AnimationTickHolder.getRenderTime(basin.getWorld()) / 12f + anglePartition * itemCount) + 1.5f) + * 1 / 32f, 0); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java index 458035ec9..df11ef484 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java @@ -27,7 +27,7 @@ public class BlazeBurnerRenderer extends SafeTileEntityRenderer { MatrixStack localTransforms = new MatrixStack(); MatrixStacker msr = MatrixStacker.of(localTransforms); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); - float renderTick = AnimationTickHolder.getRenderTime(); + float renderTick = AnimationTickHolder.getRenderTime(te.getWorld()); msr.centre(); msr.rotateY(AngleHelper.horizontalAngle(facing) + (upward ? 180 : 0) + (sideways ? 270 : 0)); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java index 1d4531a36..a1cf575af 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java @@ -32,7 +32,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer { Block block = te.getBlockState().getBlock(); final Axis boxAxis = ((IRotate) block).getRotationAxis(te.getBlockState()); final BlockPos pos = te.getPos(); - float time = AnimationTickHolder.getRenderTime(); + float time = AnimationTickHolder.getRenderTime(te.getWorld()); for (Direction direction : Iterate.directions) { Axis axis = direction.getAxis(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java index 601aedc49..45463f007 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java @@ -30,7 +30,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer { final Axis boxAxis = te.getBlockState().get(BlockStateProperties.AXIS); final BlockPos pos = te.getPos(); - float time = AnimationTickHolder.getRenderTime(); + float time = AnimationTickHolder.getRenderTime(te.getWorld()); for (Direction direction : Iterate.directions) { final Axis axis = direction.getAxis(); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java index 2675f8550..e4e00e69c 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java @@ -95,7 +95,7 @@ public class ArmInstance extends SingleRotatingInstance implements ITickableInst float headAngle = arm.headAngle.get(pt); if (rave) { - float renderTick = AnimationTickHolder.getRenderTime() + (tile.hashCode() % 64); + float renderTick = AnimationTickHolder.getRenderTime(arm.getWorld()) + (tile.hashCode() % 64); baseAngle = (renderTick * 10) % 360; lowerArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 4) + 1) / 2, -45, 15); upperArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 8) + 1) / 4, -45, 95); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java index 79d3c3765..9f4c6224e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java @@ -69,7 +69,7 @@ public class ArmRenderer extends KineticTileEntityRenderer { float headAngle = arm.headAngle.get(pt); boolean rave = arm.phase == Phase.DANCING; - float renderTick = AnimationTickHolder.getRenderTime() + (te.hashCode() % 64); + float renderTick = AnimationTickHolder.getRenderTime(te.getWorld()) + (te.hashCode() % 64); if (rave) { baseAngle = (renderTick * 10) % 360; lowerArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 4) + 1) / 2, -45, 15); diff --git a/src/main/java/com/simibubi/create/foundation/block/ItemUseOverrides.java b/src/main/java/com/simibubi/create/foundation/block/ItemUseOverrides.java new file mode 100644 index 000000000..8aa1000f9 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/block/ItemUseOverrides.java @@ -0,0 +1,44 @@ +package com.simibubi.create.foundation.block; + +import com.simibubi.create.AllItems; +import com.simibubi.create.foundation.utility.VecHelper; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; + +import java.util.HashSet; +import java.util.Set; + +@Mod.EventBusSubscriber +public class ItemUseOverrides { + + private static final Set overrides = new HashSet<>(); + + public static void addBlock(Block block) { + overrides.add(block.getRegistryName()); + } + + @SubscribeEvent + public static void onBlockActivated(PlayerInteractEvent.RightClickBlock event) { + if (AllItems.WRENCH.isIn(event.getItemStack())) return; + + BlockState state = event.getWorld().getBlockState(event.getPos()); + ResourceLocation id = state.getBlock().getRegistryName(); + + if (!overrides.contains(id)) return; + + BlockRayTraceResult blockTrace = new BlockRayTraceResult(VecHelper.getCenterOf(event.getPos()), event.getFace(), event.getPos(), true); + ActionResultType result = state.onUse(event.getWorld(), event.getPlayer(), event.getHand(), blockTrace); + + if (!result.isAccepted()) return; + + event.setCanceled(true); + event.setCancellationResult(result); + + } +} diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/ConnectedTextureBehaviour.java b/src/main/java/com/simibubi/create/foundation/block/connected/ConnectedTextureBehaviour.java index 5b9edc03b..64e655d9c 100644 --- a/src/main/java/com/simibubi/create/foundation/block/connected/ConnectedTextureBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/block/connected/ConnectedTextureBehaviour.java @@ -55,10 +55,9 @@ public abstract class ConnectedTextureBehaviour { if (textureEntry == null) return context; - Axis axis = face.getAxis(); boolean positive = face.getAxisDirection() == AxisDirection.POSITIVE; - Direction h = axis == Axis.X ? Direction.SOUTH : Direction.WEST; - Direction v = axis.isHorizontal() ? Direction.UP : Direction.NORTH; + Direction h = getRightDirection(reader, pos, state, face); + Direction v = getUpDirection(reader, pos, state, face); h = positive ? h.getOpposite() : h; if (face == Direction.DOWN) { v = v.getOpposite(); @@ -95,6 +94,16 @@ public abstract class ConnectedTextureBehaviour { return context; } + protected Direction getUpDirection(ILightReader reader, BlockPos pos, BlockState state, Direction face) { + Axis axis = face.getAxis(); + return axis.isHorizontal() ? Direction.UP : Direction.NORTH; + } + + protected Direction getRightDirection(ILightReader reader, BlockPos pos, BlockState state, Direction face) { + Axis axis = face.getAxis(); + return axis == Axis.X ? Direction.SOUTH : Direction.WEST; + } + private boolean testConnection(ILightReader reader, BlockPos pos, BlockState state, Direction face, final Direction horizontal, final Direction vertical, int sh, int sv) { BlockPos p = pos.offset(horizontal, sh) diff --git a/src/main/java/com/simibubi/create/foundation/command/PonderCommand.java b/src/main/java/com/simibubi/create/foundation/command/PonderCommand.java index b69b5664b..ddc439925 100644 --- a/src/main/java/com/simibubi/create/foundation/command/PonderCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/PonderCommand.java @@ -1,13 +1,26 @@ package com.simibubi.create.foundation.command; +import com.google.common.collect.ImmutableList; import com.mojang.brigadier.builder.ArgumentBuilder; +import com.mojang.brigadier.suggestion.SuggestionProvider; import com.simibubi.create.foundation.networking.AllPackets; +import com.simibubi.create.foundation.networking.PonderPacket; +import com.simibubi.create.foundation.ponder.PonderRegistry; import net.minecraft.command.CommandSource; import net.minecraft.command.Commands; +import net.minecraft.command.ISuggestionProvider; +import net.minecraft.command.arguments.EntityArgument; +import net.minecraft.command.arguments.ResourceLocationArgument; +import net.minecraft.command.arguments.SuggestionProviders; import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.fml.network.PacketDistributor; +import java.util.Collection; + public class PonderCommand { + public static final SuggestionProvider ALL_PONDERS = SuggestionProviders.register(new ResourceLocation("all_ponders"), (iSuggestionProviderCommandContext, builder) -> ISuggestionProvider.func_212476_a(PonderRegistry.all.keySet().stream(), builder)); static ArgumentBuilder register() { return Commands.literal("ponder") @@ -20,6 +33,21 @@ public class PonderCommand { new ConfigureConfigPacket(ConfigureConfigPacket.Actions.ponderIndex.name(), "")); return 1; - }); + }) + .then(Commands.argument("scene", ResourceLocationArgument.resourceLocation()).suggests(ALL_PONDERS) + .executes(context -> openScene(ResourceLocationArgument.getResourceLocation(context, "scene"), ImmutableList.of(context.getSource().asPlayer()))) + .then(Commands.argument("targets", EntityArgument.players()) + .requires(cs -> cs.hasPermissionLevel(2)) + .executes(context -> openScene(ResourceLocationArgument.getResourceLocation(context, "scene"), EntityArgument.getPlayers(context, "targets"))))); + + } + + private static int openScene(ResourceLocation scene, Collection players) { + for (ServerPlayerEntity player : players) { + if (player instanceof FakePlayer) + continue; + AllPackets.channel.send(PacketDistributor.PLAYER.with(() -> player), new PonderPacket(scene)); + } + return 1; } } diff --git a/src/main/java/com/simibubi/create/foundation/data/BuilderTransformers.java b/src/main/java/com/simibubi/create/foundation/data/BuilderTransformers.java index 3eec801c2..d84bced3d 100644 --- a/src/main/java/com/simibubi/create/foundation/data/BuilderTransformers.java +++ b/src/main/java/com/simibubi/create/foundation/data/BuilderTransformers.java @@ -1,14 +1,5 @@ package com.simibubi.create.foundation.data; -import static com.simibubi.create.foundation.data.BlockStateGen.axisBlock; -import static com.simibubi.create.foundation.data.CreateRegistrate.casingConnectivity; -import static com.simibubi.create.foundation.data.CreateRegistrate.connectedTextures; - -import java.util.HashMap; -import java.util.Map; - -import javax.annotation.Nullable; - import com.simibubi.create.AllBlocks; import com.simibubi.create.AllTags.AllBlockTags; import com.simibubi.create.AllTags.AllItemTags; @@ -22,12 +13,12 @@ import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock; import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock.Shape; import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelItem; import com.simibubi.create.content.logistics.block.inventories.CrateBlock; +import com.simibubi.create.foundation.block.ItemUseOverrides; import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; import com.simibubi.create.foundation.config.StressConfigDefaults; import com.simibubi.create.foundation.item.TooltipHelper; import com.tterrag.registrate.builders.BlockBuilder; import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; - import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderType; import net.minecraft.item.DyeColor; @@ -39,6 +30,14 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.client.model.generators.ModelFile; +import javax.annotation.Nullable; +import java.util.HashMap; +import java.util.Map; + +import static com.simibubi.create.foundation.data.BlockStateGen.axisBlock; +import static com.simibubi.create.foundation.data.CreateRegistrate.casingConnectivity; +import static com.simibubi.create.foundation.data.CreateRegistrate.connectedTextures; + public class BuilderTransformers { public static NonNullUnaryOperator> cuckooClock() { @@ -81,6 +80,7 @@ public class BuilderTransformers { TooltipHelper.referTo(v, AllBlocks.COPPER_VALVE_HANDLE); }) .tag(AllBlockTags.BRITTLE.tag, AllBlockTags.VALVE_HANDLES.tag) + .onRegister(ItemUseOverrides::addBlock) .item() .tag(AllItemTags.VALVE_HANDLES.tag) .build(); diff --git a/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java b/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java index 17806fb70..577ea8028 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java @@ -122,7 +122,8 @@ public class AllIcons implements IScreenRenderable { I_MTD_CLOSE = next(), I_MTD_RIGHT = next(), I_MTD_SCAN = next(), - I_MTD_REPLAY = next(); + I_MTD_REPLAY = next(), + I_MTD_USER_MODE = next(); public AllIcons(int x, int y) { iconX = x * 16; diff --git a/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java b/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java index 044e806d5..4ead9e86e 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java +++ b/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java @@ -91,6 +91,7 @@ public enum AllPackets { BLOCK_HIGHLIGHT(HighlightPacket.class, HighlightPacket::new, PLAY_TO_CLIENT), TUNNEL_FLAP(TunnelFlapPacket.class, TunnelFlapPacket::new, PLAY_TO_CLIENT), FUNNEL_FLAP(FunnelFlapPacket.class, FunnelFlapPacket::new, PLAY_TO_CLIENT), + OPEN_PONDER(PonderPacket.class, PonderPacket::new, PLAY_TO_CLIENT) ; diff --git a/src/main/java/com/simibubi/create/foundation/networking/PonderPacket.java b/src/main/java/com/simibubi/create/foundation/networking/PonderPacket.java new file mode 100644 index 000000000..c9de06967 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/networking/PonderPacket.java @@ -0,0 +1,45 @@ +package com.simibubi.create.foundation.networking; + +import com.simibubi.create.Create; +import com.simibubi.create.foundation.gui.ScreenOpener; +import com.simibubi.create.foundation.ponder.PonderRegistry; +import com.simibubi.create.foundation.ponder.PonderUI; +import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.network.NetworkDirection; +import net.minecraftforge.fml.network.NetworkEvent; + +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.function.Supplier; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class PonderPacket extends SimplePacketBase { + private final ResourceLocation scene; + + public PonderPacket(ResourceLocation scene) { + this.scene = scene; + } + + public PonderPacket(PacketBuffer buffer) { + this.scene = buffer.readResourceLocation(); + } + + @Override + public void write(PacketBuffer buffer) { + buffer.writeResourceLocation(scene); + } + + @Override + public void handle(Supplier context) { + NetworkEvent.Context ctx = context.get(); + if (ctx.getDirection() != NetworkDirection.PLAY_TO_CLIENT) + return; + if (PonderRegistry.all.containsKey(scene)) + ScreenOpener.transitionTo(new PonderUI(PonderRegistry.compile(PonderRegistry.all.get(scene)))); + else + Create.logger.error("Could not find ponder scene: " + scene); + ctx.setPacketHandled(true); + } +} 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 357b82820..93816d125 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderProgressBar.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderProgressBar.java @@ -97,13 +97,17 @@ public class PonderProgressBar extends AbstractSimiWidget { isHovered = clicked(mouseX, mouseY); + RenderSystem.pushMatrix(); + RenderSystem.translated(0, 0, 400); PonderUI.renderBox(x, y, width, height, false); + RenderSystem.popMatrix(); + RenderSystem.pushMatrix(); RenderSystem.translated(x - 2, y - 2, 0); RenderSystem.pushMatrix(); RenderSystem.scaled((width + 4) * progress.getValue(partialTicks), 1, 1); - GuiUtils.drawGradientRect(200, 0, 3, 1, 4, 0x60ffeedd, 0x60ffeedd); + GuiUtils.drawGradientRect(500, 0, 3, 1, 4, 0x60ffeedd, 0x60ffeedd); RenderSystem.popMatrix(); renderKeyframes(mouseX, partialTicks); @@ -139,7 +143,7 @@ public class PonderProgressBar extends AbstractSimiWidget { int endColor = i == hoverIndex ? hoverEndColor : 0x60ffeedd; int keyframePos = (int) (((float) keyframeTime) / ((float) activeScene.totalTime) * (width + 4)); - GuiUtils.drawGradientRect(200, keyframePos, 1, keyframePos + 1, 4, startColor, endColor); + GuiUtils.drawGradientRect(500, keyframePos, 1, keyframePos + 1, 4, startColor, endColor); } } 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 db47f742e..155f88c22 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java @@ -80,9 +80,11 @@ public class PonderScene { WorldSectionElement baseWorldSection; Entity renderViewEntity; - int offsetX; - int offsetZ; - int size; + int basePlateOffsetX; + int basePlateOffsetZ; + int basePlateSize; + float scaleFactor; + float yOffset; boolean stoppedCounting; int totalTime; @@ -102,11 +104,13 @@ public class PonderScene { schedule = new ArrayList<>(); activeSchedule = new ArrayList<>(); transform = new SceneTransform(); - size = getBounds().getXSize(); + basePlateSize = getBounds().getXSize(); info = new SceneRenderInfo(); baseWorldSection = new WorldSectionElement(); renderViewEntity = new ArmorStandEntity(world, 0, 0, 0); keyframeTimes = new IntegerList(4); + scaleFactor = 1; + yOffset = 0; setPointOfInterest(new Vec3d(0, 4, 0)); } @@ -141,11 +145,12 @@ public class PonderScene { BlockPos selectedPos = nearestHit.getValue() .getSecond(); - BlockPos origin = new BlockPos(offsetX, 0, offsetZ); + BlockPos origin = new BlockPos(basePlateOffsetX, 0, basePlateOffsetZ); if (!world.getBounds() .isVecInside(selectedPos)) return Pair.of(ItemStack.EMPTY, null); - if (new MutableBoundingBox(origin, origin.add(new Vec3i(size - 1, 0, size - 1))).isVecInside(selectedPos)) { + if (new MutableBoundingBox(origin, origin.add(new Vec3i(basePlateSize - 1, 0, basePlateSize - 1))) + .isVecInside(selectedPos)) { if (PonderIndex.EDITOR_MODE) nearestHit.getValue() .getFirst() @@ -404,11 +409,11 @@ public class PonderScene { } public MatrixStack apply(MatrixStack ms) { - return apply(ms, AnimationTickHolder.getPartialTicks()); + return apply(ms, AnimationTickHolder.getPartialTicks(world)); } public MatrixStack apply(MatrixStack ms, float pt) { - ms.translate(width / 2, height / 2, 200); + ms.translate(width / 2, height / 2, 200 + offset); MatrixStacker.of(ms) .rotateX(-35) @@ -417,12 +422,15 @@ public class PonderScene { MatrixStacker.of(ms) .rotateY(-55) .rotateX(35); - MatrixStacker.of(ms) .rotateX(xRotation.getValue(pt)) .rotateY(yRotation.getValue(pt)); - ms.scale(30, -30, 30); - ms.translate((size + offsetX) / -2f, -1f, (size + offsetZ) / -2f); + + float f = 30 * scaleFactor; + + ms.scale(f, -f, f); + ms.translate((basePlateSize + basePlateOffsetX) / -2f, -1f + yOffset, + (basePlateSize + basePlateOffsetZ) / -2f); return ms; } @@ -437,7 +445,7 @@ public class PonderScene { float pt = AnimationTickHolder.getPartialTicks(); Vec3d vec = new Vec3d(x, y, depth); - vec = vec.subtract(width / 2, height / 2, 200); + vec = vec.subtract(width / 2, height / 2, 200 + offset); vec = VecHelper.rotate(vec, 35, Axis.X); vec = VecHelper.rotate(vec, -55, Axis.Y); vec = vec.subtract(offset, 0, 0); @@ -445,8 +453,12 @@ public class PonderScene { vec = VecHelper.rotate(vec, -35, Axis.X); vec = VecHelper.rotate(vec, -xRotation.getValue(pt), Axis.X); vec = VecHelper.rotate(vec, -yRotation.getValue(pt), Axis.Y); - vec = vec.mul(1f / 30, 1f / -30, 1f / 30); - vec = vec.subtract((size + offsetX) / -2f, -1f, (size + offsetZ) / -2f); + + float f = 1f / (30 * scaleFactor); + + vec = vec.mul(f, -f, f); + vec = vec.subtract((basePlateSize + basePlateOffsetX) / -2f, -1f + yOffset, + (basePlateSize + basePlateOffsetZ) / -2f); return vec; } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderTooltipHandler.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderTooltipHandler.java index 6209624bc..2f1abec45 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderTooltipHandler.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderTooltipHandler.java @@ -95,7 +95,8 @@ public class PonderTooltipHandler { } public static void addToTooltip(List toolTip, ItemStack stack) { - float renderPartialTicks = AnimationTickHolder.getPartialTicks(); + float renderPartialTicks = Minecraft.getInstance() + .getRenderPartialTicks(); if (lastHoveredStack != stack) return; ITextComponent component = subject ? Lang.createTranslationTextComponent(SUBJECT) 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 cc7bbcde4..6ee2a01bb 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java @@ -24,7 +24,6 @@ import com.simibubi.create.foundation.ponder.content.PonderTag; import com.simibubi.create.foundation.ponder.content.PonderTagScreen; import com.simibubi.create.foundation.ponder.ui.PonderButton; import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; -import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; @@ -38,6 +37,7 @@ import net.minecraft.client.GameSettings; import net.minecraft.client.MainWindow; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.widget.Widget; import net.minecraft.client.settings.KeyBinding; import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; @@ -55,6 +55,9 @@ import net.minecraftforge.registries.ForgeRegistries; public class PonderUI extends AbstractSimiScreen { + public static int ponderTicks; + public static float ponderPartialTicksPaused; + public static final String PONDERING = PonderLocalization.LANG_PREFIX + "pondering"; public static final String IDENTIFY_MODE = PonderLocalization.LANG_PREFIX + "identify_mode"; public static final String IN_CHAPTER = PonderLocalization.LANG_PREFIX + "in_chapter"; @@ -67,6 +70,7 @@ public class PonderUI extends AbstractSimiScreen { ItemStack stack; PonderChapter chapter = null; + private boolean userViewMode; private boolean identifyMode; private ItemStack hoveredTooltipItem; private BlockPos hoveredBlockPos; @@ -78,7 +82,7 @@ public class PonderUI extends AbstractSimiScreen { private int index = 0; private PonderTag referredToByTag; - private PonderButton left, right, scan, chap; + private PonderButton left, right, scan, chap, userMode; private PonderProgressBar progressBar; public static PonderUI of(ItemStack item) { @@ -132,7 +136,7 @@ public class PonderUI extends AbstractSimiScreen { tags.forEach(t -> { int i = tagButtons.size(); int x = 31; - int y = 71 + i * 30; + int y = 81 + i * 30; PonderButton b = new PonderButton(x, y, (mouseX, mouseY) -> { centerScalingOn(mouseX, mouseY); ScreenOpener.transitionTo(new PonderTagScreen(t)); @@ -158,20 +162,31 @@ public class PonderUI extends AbstractSimiScreen { int bX = (width - 20) / 2 - (70 + 2 * spacing); int bY = height - 20 - 31; - int pX = (width / 2) - 110; - int pY = bY + PonderButton.SIZE + 4; - int pW = width - 2 * pX; - widgets.add(progressBar = new PonderProgressBar(this, pX, pY, pW, 1)); + { + int pX = (width / 2) - 110; + int pY = bY + PonderButton.SIZE + 4; + int pW = width - 2 * pX; + widgets.add(progressBar = new PonderProgressBar(this, pX, pY, pW, 1)); + } widgets.add(scan = new PonderButton(bX, bY, () -> { identifyMode = !identifyMode; if (!identifyMode) scenes.get(index) .deselect(); + else + ponderPartialTicksPaused = minecraft.getRenderPartialTicks(); }).showing(AllIcons.I_MTD_SCAN) .shortcut(bindings.keyBindDrop) .fade(0, -1)); + if (PonderIndex.EDITOR_MODE) { + widgets.add(userMode = new PonderButton(31, bY, () -> { + userViewMode = !userViewMode; + }).showing(AllIcons.I_MTD_USER_MODE) + .fade(0, -1)); + } + bX += 50 + spacing; widgets.add(left = new PonderButton(bX, bY, () -> this.scroll(false)).showing(AllIcons.I_MTD_LEFT) .shortcut(bindings.keyBindLeft) @@ -217,8 +232,10 @@ public class PonderUI extends AbstractSimiScreen { } PonderScene activeScene = scenes.get(index); - if (!identifyMode) + if (!identifyMode) { + ponderTicks++; activeScene.tick(); + } lazyIndex.tickChaser(); fadeIn.tickChaser(); progressBar.tick(); @@ -307,8 +324,13 @@ public class PonderUI extends AbstractSimiScreen { @Override protected void renderWindow(int mouseX, int mouseY, float partialTicks) { RenderSystem.enableBlend(); - renderVisibleScenes(mouseX, mouseY, identifyMode ? 0 : partialTicks); - renderWidgets(mouseX, mouseY, identifyMode ? 0 : partialTicks); + renderVisibleScenes(mouseX, mouseY, identifyMode ? ponderPartialTicksPaused : partialTicks); + renderWidgets(mouseX, mouseY, identifyMode ? ponderPartialTicksPaused : partialTicks); + } + + @Override + public void renderBackground() { + super.renderBackground(); } protected void renderVisibleScenes(int mouseX, int mouseY, float partialTicks) { @@ -322,7 +344,7 @@ public class PonderUI extends AbstractSimiScreen { SuperRenderTypeBuffer buffer = SuperRenderTypeBuffer.getInstance(); PonderScene story = scenes.get(i); MatrixStack ms = new MatrixStack(); - double value = lazyIndex.getValue(AnimationTickHolder.getPartialTicks()); + double value = lazyIndex.getValue(minecraft.getRenderPartialTicks()); double diff = i - value; double slide = MathHelper.lerp(diff * diff, 200, 600) * diff; @@ -337,15 +359,36 @@ public class PonderUI extends AbstractSimiScreen { story.renderScene(buffer, ms, partialTicks); buffer.draw(); - // coords for debug - if (PonderIndex.EDITOR_MODE) { - MutableBoundingBox bounds = story.getBounds(); + MutableBoundingBox bounds = story.getBounds(); + RenderSystem.pushMatrix(); + RenderSystem.multMatrix(ms.peek() + .getModel()); + // kool shadow fx + { + RenderSystem.enableCull(); + RenderSystem.enableDepthTest(); RenderSystem.pushMatrix(); - RenderSystem.multMatrix(ms.peek() - .getModel()); + RenderSystem.translated(story.basePlateOffsetX, 0, story.basePlateOffsetZ); + RenderSystem.scaled(1, -1, 1); + for (int f = 0; f < 4; f++) { + RenderSystem.translated(story.basePlateSize, 0, 0); + RenderSystem.pushMatrix(); + RenderSystem.translated(0, 0, 1/1024f); + GuiUtils.drawGradientRect(0, 0, 0, -story.basePlateSize, 4, 0x66_000000, 0x00_000000); + RenderSystem.popMatrix(); + RenderSystem.rotatef(-90, 0, 1, 0); + } + RenderSystem.popMatrix(); + RenderSystem.disableCull(); + RenderSystem.disableDepthTest(); + } - RenderSystem.scaled(-1 / 16d, -1 / 16d, 1 / 16d); + // coords for debug + if (PonderIndex.EDITOR_MODE && !userViewMode) { + + RenderSystem.scaled(-1, -1, 1); + RenderSystem.scaled(1 / 16d, 1 / 16d, 1 / 16d); RenderSystem.translated(1, -8, -1 / 64f); // X AXIS @@ -385,11 +428,11 @@ public class PonderUI extends AbstractSimiScreen { RenderSystem.popMatrix(); } RenderSystem.popMatrix(); - buffer.draw(); - RenderSystem.popMatrix(); } + RenderSystem.popMatrix(); + ms.pop(); } @@ -400,6 +443,10 @@ public class PonderUI extends AbstractSimiScreen { PonderScene activeScene = scenes.get(index); int textColor = 0xeeeeee; + boolean noWidgetsHovered = true; + for (Widget widget : widgets) + noWidgetsHovered &= !widget.isMouseOver(mouseX, mouseY); + { // Chapter title RenderSystem.pushMatrix(); @@ -408,7 +455,7 @@ public class PonderUI extends AbstractSimiScreen { int y = 31; String title = activeScene.getTitle(); - int wordWrappedHeight = font.getWordWrappedHeight(title, left.x); + int wordWrappedHeight = font.getWordWrappedHeight(title, left.x - 51); int streakHeight = 35 - 9 + wordWrappedHeight; UIRenderHelper.streak(0, x - 4, y - 12 + streakHeight / 2, streakHeight, (int) (150 * fade), 0x101010); @@ -427,7 +474,7 @@ public class PonderUI extends AbstractSimiScreen { RenderSystem.translated(x, y, 0); RenderSystem.rotatef(indexDiff * -75, 1, 0, 0); RenderSystem.translated(0, 0, 5); - font.drawSplitString(title, 0, 0, left.x, ColorHelper.applyAlpha(textColor, 1 - indexDiff)); + font.drawSplitString(title, 0, 0, left.x - 51, ColorHelper.applyAlpha(textColor, 1 - indexDiff)); RenderSystem.popMatrix(); if (chapter != null) { @@ -445,34 +492,42 @@ public class PonderUI extends AbstractSimiScreen { } if (identifyMode) { - RenderSystem.pushMatrix(); - RenderSystem.translated(mouseX, mouseY, 100); - if (hoveredTooltipItem.isEmpty()) { - String tooltip = Lang - .createTranslationTextComponent(IDENTIFY_MODE, - new StringTextComponent(minecraft.gameSettings.keyBindDrop.getKeyBinding() - .getLocalizedName()).applyTextStyle(TextFormatting.WHITE)) - .applyTextStyle(TextFormatting.GRAY) - .getFormattedText(); - renderTooltip(font.listFormattedStringToWidth(tooltip, width / 3), 0, 0); - } else - renderTooltip(hoveredTooltipItem, 0, 0); - if (hoveredBlockPos != null && PonderIndex.EDITOR_MODE) { - RenderSystem.translated(0, -15, 0); - boolean copied = copiedBlockPos != null && hoveredBlockPos.equals(copiedBlockPos); - String coords = new StringTextComponent( - hoveredBlockPos.getX() + ", " + hoveredBlockPos.getY() + ", " + hoveredBlockPos.getZ()) - .applyTextStyles(copied ? TextFormatting.GREEN : TextFormatting.GOLD) + if (noWidgetsHovered) { + RenderSystem.pushMatrix(); + RenderSystem.translated(mouseX, mouseY, 100); + if (hoveredTooltipItem.isEmpty()) { + String tooltip = Lang + .createTranslationTextComponent(IDENTIFY_MODE, + new StringTextComponent(minecraft.gameSettings.keyBindDrop.getKeyBinding() + .getLocalizedName()).applyTextStyle(TextFormatting.WHITE)) + .applyTextStyle(TextFormatting.GRAY) .getFormattedText(); - renderTooltip(coords, 0, 0); + renderTooltip(font.listFormattedStringToWidth(tooltip, width / 3), 0, 0); + } else + renderTooltip(hoveredTooltipItem, 0, 0); + if (hoveredBlockPos != null && PonderIndex.EDITOR_MODE && !userViewMode) { + RenderSystem.translated(0, -15, 0); + boolean copied = copiedBlockPos != null && hoveredBlockPos.equals(copiedBlockPos); + String coords = new StringTextComponent( + hoveredBlockPos.getX() + ", " + hoveredBlockPos.getY() + ", " + hoveredBlockPos.getZ()) + .applyTextStyles(copied ? TextFormatting.GREEN : TextFormatting.GOLD) + .getFormattedText(); + renderTooltip(coords, 0, 0); + } + RenderSystem.popMatrix(); } - RenderSystem.popMatrix(); - scan.flash(); } else { scan.dim(); } + if (PonderIndex.EDITOR_MODE) { + if (userViewMode) + userMode.flash(); + else + userMode.dim(); + } + { // Scene overlay RenderSystem.pushMatrix(); @@ -777,8 +832,25 @@ public class PonderUI extends AbstractSimiScreen { @Override public void shareContextWith(AbstractSimiScreen other) { - if (other instanceof PonderUI) - ((PonderUI) other).referredToByTag = referredToByTag; + if (other instanceof PonderUI) { + PonderUI ponderUI = (PonderUI) other; + ponderUI.referredToByTag = referredToByTag; + } + } + + public static float getPartialTicks() { + if (Minecraft.getInstance().currentScreen instanceof PonderUI) { + PonderUI ui = (PonderUI) Minecraft.getInstance().currentScreen; + if (ui.identifyMode) + return ponderPartialTicksPaused; + } + return Minecraft.getInstance() + .getRenderPartialTicks(); + } + + @Override + public boolean isPauseScreen() { + return true; } } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java b/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java index 13fe61832..fa463b3cc 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java @@ -123,9 +123,29 @@ public class SceneBuilder { * assumes it to be square */ public void configureBasePlate(int xOffset, int zOffset, int basePlateSize) { - scene.offsetX = xOffset; - scene.offsetZ = zOffset; - scene.size = basePlateSize; + scene.basePlateOffsetX = xOffset; + scene.basePlateOffsetZ = zOffset; + scene.basePlateSize = basePlateSize; + } + + /** + * Use this in case you are not happy with the scale of the scene relative to + * the overlay + * + * @param factor >1 will make the scene appear larger, smaller otherwise + */ + public void scaleSceneView(float factor) { + scene.scaleFactor = factor; + } + + /** + * Use this in case you are not happy with the vertical alignment of the scene + * relative to the overlay + * + * @param yOffset >0 moves the scene up, down otherwise + */ + public void setSceneOffsetY(float yOffset) { + scene.yOffset = yOffset; } /** @@ -133,8 +153,10 @@ public class SceneBuilder { * of the schematic's structure. Makes for a nice opener */ public void showBasePlate() { - world.showSection(scene.getSceneBuildingUtil().select.cuboid(new BlockPos(scene.offsetX, 0, scene.offsetZ), - new Vec3i(scene.size, 0, scene.size)), Direction.UP); + world.showSection( + scene.getSceneBuildingUtil().select.cuboid(new BlockPos(scene.basePlateOffsetX, 0, scene.basePlateOffsetZ), + new Vec3i(scene.basePlateSize, 0, scene.basePlateSize)), + Direction.UP); } /** @@ -511,7 +533,7 @@ public class SceneBuilder { return; behaviour.handleInsertion(stack, insertionSide.getOpposite(), false); }); - flapFunnels(scene.getSceneBuildingUtil().select.position(location.up()), true); + flapFunnel(location.up(), true); } public ElementLink createItemOnBelt(BlockPos beltLocation, Direction insertionSide, @@ -539,9 +561,8 @@ public class SceneBuilder { scene.linkElement(tracker, link); return TransportedResult.doNothing(); }); - }); - flapFunnels(scene.getSceneBuildingUtil().select.position(beltLocation.up()), true); + flapFunnel(beltLocation.up(), true); return link; } @@ -619,11 +640,8 @@ public class SceneBuilder { }, reDrawBlocks)); } - public void flapFunnels(Selection selection, boolean outward) { - addInstruction(new TileEntityDataInstruction(selection, FunnelTileEntity.class, nbt -> { - nbt.putInt("Flap", outward ? -1 : 1); - return nbt; - }, false)); + public void flapFunnel(BlockPos position, boolean outward) { + modifyTileEntity(position, FunnelTileEntity.class, funnel -> funnel.flap(!outward)); } } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/BearingScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/BearingScenes.java index a1526380d..689a14165 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/BearingScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/BearingScenes.java @@ -21,6 +21,9 @@ public class BearingScenes { public static void windmillsAsSource(SceneBuilder scene, SceneBuildingUtil util) { scene.title("windmill_source", "Generating Rotational Force using Windmill Bearings"); + scene.configureBasePlate(1, 1, 5); + scene.setSceneOffsetY(-1); + scene.world.showSection(util.select.fromTo(1, 0, 1, 5, 0, 5), Direction.UP); scene.world.setBlock(util.grid.at(2, -1, 0), AllBlocks.SAIL.getDefaultState() .with(SailBlock.FACING, Direction.NORTH), false); @@ -144,6 +147,8 @@ public class BearingScenes { public static void windmillsAnyStructure(SceneBuilder scene, SceneBuildingUtil util) { scene.title("windmill_structure", "Windmill Contraptions"); + scene.configureBasePlate(1, 1, 5); + scene.setSceneOffsetY(-1); scene.world.showSection(util.select.layer(0), Direction.UP); scene.idle(5); @@ -191,6 +196,8 @@ public class BearingScenes { public static void mechanicalBearing(SceneBuilder scene, SceneBuildingUtil util) { scene.title("mechanical_bearing", "Movings Structures using the Mechanical Bearing"); + scene.configureBasePlate(1, 1, 5); + scene.setSceneOffsetY(-1); scene.world.showSection(util.select.layer(0), Direction.UP); scene.idle(5); scene.world.showSection(util.select.layer(1), Direction.DOWN); @@ -268,6 +275,9 @@ public class BearingScenes { public static void bearingModes(SceneBuilder scene, SceneBuildingUtil util) { scene.title("bearing_modes", "Movement Modes of the Mechanical Bearing"); + scene.configureBasePlate(1, 1, 6); + scene.setSceneOffsetY(-1); + Selection sideCog = util.select.position(util.grid.at(7, 0, 3)); Selection cogColumn = util.select.fromTo(6, 1, 3, 6, 4, 3); Selection cogAndClutch = util.select.fromTo(5, 3, 1, 5, 4, 2); @@ -350,6 +360,8 @@ public class BearingScenes { public static void stabilizedBearings(SceneBuilder scene, SceneBuildingUtil util) { scene.title("stabilized_bearings", "Stabilized Contraptions"); + scene.configureBasePlate(1, 1, 5); + scene.setSceneOffsetY(-1); Selection beltAndBearing = util.select.fromTo(3, 3, 4, 3, 1, 6); Selection largeCog = util.select.position(2, 0, 6); @@ -419,6 +431,8 @@ public class BearingScenes { public static void clockwork(SceneBuilder scene, SceneBuildingUtil util) { scene.title("clockwork_bearing", "Animating Structures using Clockwork Bearings"); + scene.configureBasePlate(1, 1, 5); + scene.setSceneOffsetY(-1); Selection kinetics = util.select.fromTo(3, 3, 4, 3, 1, 6); Selection largeCog = util.select.position(2, 0, 6); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/BeltScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/BeltScenes.java index 547a8c348..ed9604071 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/BeltScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/BeltScenes.java @@ -161,6 +161,7 @@ public class BeltScenes { public static void directions(SceneBuilder scene, SceneBuildingUtil util) { scene.title("belt_directions", "Valid Orientations for Mechanical Belts"); scene.configureBasePlate(0, 0, 5); + scene.setSceneOffsetY(-1); scene.showBasePlate(); scene.idle(5); @@ -305,6 +306,7 @@ public class BeltScenes { public static void transport(SceneBuilder scene, SceneBuildingUtil util) { scene.title("belt_transport", "Using Mechanical Belts for Logistics"); scene.configureBasePlate(0, 0, 5); + scene.setSceneOffsetY(-1); scene.world.modifyKineticSpeed(util.select.everywhere(), f -> -.6f * f); scene.showBasePlate(); scene.idle(5); @@ -379,6 +381,7 @@ public class BeltScenes { public static void beltsCanBeEncased(SceneBuilder scene, SceneBuildingUtil util) { scene.title("belt_casing", "Encasing Belts"); scene.configureBasePlate(0, 0, 5); + scene.setSceneOffsetY(-1); scene.showBasePlate(); scene.idle(5); scene.world.showSection(util.select.layersFrom(1), Direction.DOWN); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/ChainDriveScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/ChainDriveScenes.java index 841646d57..168e171c2 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/ChainDriveScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/ChainDriveScenes.java @@ -92,7 +92,8 @@ public class ChainDriveScenes { public static void adjustableChainGearshift(SceneBuilder scene, SceneBuildingUtil util) { scene.title("chain_gearshift", "Controlling rotational speed with Chain Gearshifts"); - scene.configureBasePlate(0, 0, 7); + scene.configureBasePlate(0, 0, 5); + scene.setSceneOffsetY(-1); scene.world.showSection(util.select.layer(0), Direction.UP); BlockPos leverPos = util.grid.at(3, 1, 0); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/FunnelScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/FunnelScenes.java index f6fee510c..c8f9c6c44 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/FunnelScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/FunnelScenes.java @@ -52,12 +52,11 @@ public class FunnelScenes { BlockPos entryBeltPos = util.grid.at(3, 1, 2); BlockPos exitBeltPos = util.grid.at(1, 1, 2); ItemStack itemStack = AllBlocks.BRASS_BLOCK.asStack(); - Selection exitFunnel = util.select.position(exitBeltPos.up()); for (int i = 0; i < 8; i++) { scene.idle(8); scene.world.removeItemsFromBelt(exitBeltPos); - scene.world.flapFunnels(exitFunnel, false); + scene.world.flapFunnel(exitBeltPos.up(), false); if (i == 2) scene.rotateCameraY(70); if (i < 6) @@ -94,7 +93,7 @@ public class FunnelScenes { for (int i = 0; i < 3; i++) { scene.idle(8); - scene.world.flapFunnels(outputFunnel, false); + scene.world.flapFunnel(util.grid.at(1, 2, 4), false); scene.world.createItemEntity(sideItemSpawn, util.vector.of(-.05, 0, 0), itemStack); } @@ -198,7 +197,7 @@ public class FunnelScenes { scene.idle(20); - scene.world.flapFunnels(sideFunnelSelection, true); + scene.world.flapFunnel(sideFunnel, true); itemLink = scene.world.createItemEntity(sideCenter.subtract(0, .45, 0), util.vector.of(0, 0, -0.1), itemStack); scene.idle(60); scene.world.hideSection(sideFunnelSelection, Direction.UP); @@ -233,7 +232,7 @@ public class FunnelScenes { scene.idle(35); scene.world.removeItemsFromBelt(beltPos); - scene.world.flapFunnels(beltFunnelSetup, false); + scene.world.flapFunnel(util.grid.at(2, 2, 2), false); if (i == 0) { scene.idle(50); @@ -374,7 +373,7 @@ public class FunnelScenes { scene.idle(10); scene.world.createItemOnBeltLike(andesiteFunnel.down() .north(), Direction.SOUTH, itemStack); - scene.world.flapFunnels(util.select.position(andesiteFunnel), true); + scene.world.flapFunnel(andesiteFunnel, true); scene.idle(60); scene.overlay.showText(60) @@ -384,7 +383,7 @@ public class FunnelScenes { scene.idle(10); scene.world.createItemOnBeltLike(brassFunnel.down() .north(), Direction.SOUTH, ItemHandlerHelper.copyStackWithSize(itemStack, 64)); - scene.world.flapFunnels(util.select.position(brassFunnel), true); + scene.world.flapFunnel(brassFunnel, true); scene.idle(60); AxisAlignedBB filterSlot = new AxisAlignedBB(brassFunnel).grow(-.35, -.35, -.35) @@ -421,7 +420,7 @@ public class FunnelScenes { if (i > 0 && (i < 3 || i % 3 == 0)) { scene.world.removeItemsFromBelt(brassFunnel.down()); - scene.world.flapFunnels(util.select.position(brassFunnel), false); + scene.world.flapFunnel(brassFunnel, false); } scene.world.modifyEntities(ItemEntity.class, e -> { diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/GantryScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/GantryScenes.java index f1487a4e5..bdda5d67a 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/GantryScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/GantryScenes.java @@ -80,6 +80,7 @@ public class GantryScenes { .placeNearTarget(); scene.special.addKeyframe(); scene.idle(80); + scene.special.addKeyframe(); scene.world.modifyKineticSpeed(util.select.layer(0), f -> 32f); scene.world.modifyKineticSpeed(util.select.layer(1), f -> -64f); @@ -111,7 +112,6 @@ public class GantryScenes { scene.idle(15); scene.world.moveSection(gantry, util.vector.of(-3, 0, 0), 40); scene.idle(40); - scene.special.addKeyframe(); scene.world.toggleRedstonePower(shaft); scene.world.toggleRedstonePower(util.select.position(3, 1, 0)); @@ -250,6 +250,7 @@ public class GantryScenes { public static void subgantry(SceneBuilder scene, SceneBuildingUtil util) { scene.title("gantry_cascaded", "Cascaded Gantries"); scene.configureBasePlate(0, 0, 5); + scene.setSceneOffsetY(-1); scene.world.modifyKineticSpeed(util.select.everywhere(), f -> -2 * f); scene.world.showSection(util.select.layer(0) .add(util.select.column(5, 3)) diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/KineticsScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/KineticsScenes.java index 28ff3e051..03ab44c64 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/KineticsScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/KineticsScenes.java @@ -279,6 +279,8 @@ public class KineticsScenes { public static void gearbox(SceneBuilder scene, SceneBuildingUtil util) { scene.title("gearbox", "Relaying rotational force using Gearboxes"); scene.configureBasePlate(1, 1, 5); + scene.setSceneOffsetY(-1); + scene.world.showSection(util.select.layer(0), Direction.UP); scene.world.showSection(util.select.fromTo(4, 1, 6, 3, 2, 5), Direction.UP); scene.idle(10); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/MovementActorScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/MovementActorScenes.java index 5203f0756..8c262ceca 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/MovementActorScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/MovementActorScenes.java @@ -22,7 +22,9 @@ public class MovementActorScenes { public static void psiTransfer(SceneBuilder scene, SceneBuildingUtil util) { scene.title("portable_storage_interface", "Contraption Storage Exchange"); - scene.configureBasePlate(0, 0, 8); + scene.configureBasePlate(0, 0, 6); + scene.scaleSceneView(0.95f); + scene.setSceneOffsetY(-1); scene.world.showSection(util.select.layer(0), Direction.UP); scene.idle(5); @@ -112,7 +114,7 @@ public class MovementActorScenes { scene.world.modifyEntity(entity2, Entity::remove); scene.overlay - .showControls(new InputWindowElement(util.vector.topOf(6, 3, 2), Pointing.DOWN).withItem(itemStack), 40); + .showControls(new InputWindowElement(util.vector.topOf(5, 3, 2), Pointing.DOWN).withItem(itemStack), 40); scene.idle(30); scene.world.hideSection(util.select.position(hopper), Direction.UP); @@ -148,7 +150,8 @@ public class MovementActorScenes { public static void psiRedstone(SceneBuilder scene, SceneBuildingUtil util) { scene.title("portable_storage_interface_redstone", "Redstone Control"); - scene.configureBasePlate(0, 0, 6); + scene.configureBasePlate(0, 0, 5); + scene.setSceneOffsetY(-1); Class psiClass = PortableItemInterfaceTileEntity.class; Selection psis = util.select.fromTo(1, 1, 3, 1, 3, 3); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndexScreen.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndexScreen.java index 364ce0797..15f3e70f8 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndexScreen.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndexScreen.java @@ -49,43 +49,39 @@ public class PonderIndexScreen extends AbstractSimiScreen { protected void init() { super.init(); - //populate lists + // populate lists widgets.clear(); chapters.clear(); - //chapters.addAll(PonderRegistry.chapters.getAllChapters()); + // chapters.addAll(PonderRegistry.chapters.getAllChapters()); items.clear(); PonderRegistry.all.keySet() - .stream() - .map(key -> { - Item item = ForgeRegistries.ITEMS.getValue(key); - if (item == null) { - Block b = ForgeRegistries.BLOCKS.getValue(key); - if (b != null) - item = b.asItem(); - } - return item; - }) - .filter(Objects::nonNull) - .filter(PonderIndexScreen::exclusions) - .forEach(items::add); + .stream() + .map(key -> { + Item item = ForgeRegistries.ITEMS.getValue(key); + if (item == null) { + Block b = ForgeRegistries.BLOCKS.getValue(key); + if (b != null) + item = b.asItem(); + } + return item; + }) + .filter(Objects::nonNull) + .filter(PonderIndexScreen::exclusions) + .forEach(items::add); boolean hasChapters = !chapters.isEmpty(); - //setup chapters - LayoutHelper layout = LayoutHelper.centeredHorizontal( - chapters.size(), - MathHelper.clamp((int) Math.ceil(chapters.size() / 4f), 1, 4), - 200, - 38, - 16 - ); + // setup chapters + LayoutHelper layout = LayoutHelper.centeredHorizontal(chapters.size(), + MathHelper.clamp((int) Math.ceil(chapters.size() / 4f), 1, 4), 200, 38, 16); chapterArea = layout.getArea(); int chapterCenterX = (int) (width * chapterXmult); int chapterCenterY = (int) (height * chapterYmult); - //todo at some point pagination or horizontal scrolling may be needed for chapters/items + // todo at some point pagination or horizontal scrolling may be needed for + // chapters/items for (PonderChapter chapter : chapters) { ChapterLabel label = new ChapterLabel(chapter, chapterCenterX + layout.getX(), chapterCenterY + layout.getY(), (mouseX, mouseY) -> { @@ -97,44 +93,40 @@ public class PonderIndexScreen extends AbstractSimiScreen { layout.next(); } - //setup items + // setup items if (!hasChapters) { itemYmult = 0.5; } int maxItemRows = hasChapters ? 4 : 7; - layout = LayoutHelper.centeredHorizontal( - items.size(), - MathHelper.clamp((int) Math.ceil(items.size() / 11f), 1, maxItemRows), - 28, - 28, - 8 - ); + layout = LayoutHelper.centeredHorizontal(items.size(), + MathHelper.clamp((int) Math.ceil(items.size() / 11f), 1, maxItemRows), 28, 28, 8); itemArea = layout.getArea(); int itemCenterX = (int) (width * itemXmult); int itemCenterY = (int) (height * itemYmult); for (Item item : items) { - PonderButton button = new PonderButton(itemCenterX + layout.getX() + 4, itemCenterY + layout.getY() + 4, (x, y) -> { - if (!PonderRegistry.all.containsKey(item.getRegistryName())) - return; + PonderButton button = + new PonderButton(itemCenterX + layout.getX() + 4, itemCenterY + layout.getY() + 4, (x, y) -> { + if (!PonderRegistry.all.containsKey(item.getRegistryName())) + return; - centerScalingOn(x, y); - ScreenOpener.transitionTo(PonderUI.of(new ItemStack(item))); - }).showing(new ItemStack(item)); + centerScalingOn(x, y); + ScreenOpener.transitionTo(PonderUI.of(new ItemStack(item))); + }).showing(new ItemStack(item)); button.fade(1); widgets.add(button); layout.next(); } - } private static boolean exclusions(Item item) { if (item instanceof BlockItem) { Block block = ((BlockItem) item).getBlock(); - if (block instanceof ValveHandleBlock && !AllBlocks.COPPER_VALVE_HANDLE.is(item)) return false; + if (block instanceof ValveHandleBlock && !AllBlocks.COPPER_VALVE_HANDLE.is(item)) + return false; } return true; @@ -143,6 +135,7 @@ public class PonderIndexScreen extends AbstractSimiScreen { @Override public void tick() { super.tick(); + PonderUI.ponderTicks++; hoveredItem = ItemStack.EMPTY; MainWindow w = minecraft.getWindow(); @@ -224,4 +217,9 @@ public class PonderIndexScreen extends AbstractSimiScreen { public ItemStack getHoveredTooltipItem() { return hoveredItem; } + + @Override + public boolean isPauseScreen() { + return true; + } } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagScreen.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagScreen.java index 8c03321c9..a443af1f2 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagScreen.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagScreen.java @@ -77,13 +77,16 @@ public class PonderTagScreen extends AbstractSimiScreen { int itemCenterY = getItemsY(); for (Item i : items) { + final boolean canClick = PonderRegistry.all.containsKey(i.getRegistryName()); PonderButton button = new PonderButton(itemCenterX + layout.getX() + 4, itemCenterY + layout.getY() + 4, (mouseX, mouseY) -> { - if (!PonderRegistry.all.containsKey(i.getRegistryName())) + if (!canClick) return; centerScalingOn(mouseX, mouseY); ScreenOpener.transitionTo(PonderUI.of(new ItemStack(i), tag)); }).showing(new ItemStack(i)); + if (!canClick) + button.noClickEvent(); button.fade(1); widgets.add(button); @@ -92,18 +95,20 @@ public class PonderTagScreen extends AbstractSimiScreen { if (!tag.getMainItem() .isEmpty()) { + final boolean canClick = PonderRegistry.all.containsKey(tag.getMainItem() + .getItem() + .getRegistryName()); PonderButton button = new PonderButton(itemCenterX - layout.getTotalWidth() / 2 - 42, itemCenterY - 10, (mouseX, mouseY) -> { - if (!PonderRegistry.all.containsKey(tag.getMainItem() - .getItem() - .getRegistryName())) + if (!canClick) return; centerScalingOn(mouseX, mouseY); ScreenOpener.transitionTo(PonderUI.of(tag.getMainItem(), tag)); }).showing(tag.getMainItem()); + if (!canClick) + button.noClickEvent(); button.fade(1); -// button.flash(); widgets.add(button); } @@ -133,6 +138,7 @@ public class PonderTagScreen extends AbstractSimiScreen { @Override public void tick() { super.tick(); + PonderUI.ponderTicks++; hoveredItem = ItemStack.EMPTY; MainWindow w = minecraft.getWindow(); @@ -291,5 +297,10 @@ public class PonderTagScreen extends AbstractSimiScreen { return tag == ((PonderTagScreen) other).tag; return super.isEquivalentTo(other); } + + @Override + public boolean isPauseScreen() { + return true; + } } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PulleyScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PulleyScenes.java index b4712e67c..8b11d693e 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PulleyScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PulleyScenes.java @@ -16,7 +16,9 @@ public class PulleyScenes { public static void movement(SceneBuilder scene, SceneBuildingUtil util) { scene.title("rope_pulley", "Moving Structures using Rope Pulleys"); - scene.configureBasePlate(0, 0, 8); + scene.configureBasePlate(0, 0, 5); + scene.scaleSceneView(0.95f); + scene.setSceneOffsetY(-1); Selection reversable = util.select.fromTo(2, 3, 4, 2, 4, 2); BlockPos leverPos = util.grid.at(1, 2, 4); @@ -101,7 +103,9 @@ public class PulleyScenes { public static void movementModes(SceneBuilder scene, SceneBuildingUtil util) { scene.title("rope_pulley_modes", "Movement Modes of the Rope Pulley"); - scene.configureBasePlate(0, 0, 8); + scene.configureBasePlate(0, 0, 5); + scene.scaleSceneView(0.95f); + scene.setSceneOffsetY(-1); Selection reversable = util.select.fromTo(2, 3, 4, 2, 4, 2); BlockPos leverPos = util.grid.at(1, 2, 4); @@ -172,7 +176,9 @@ public class PulleyScenes { public static void attachment(SceneBuilder scene, SceneBuildingUtil util) { scene.title("rope_pulley_attachment", "Moving Pulleys as part of a Contraption"); - scene.configureBasePlate(0, 0, 8); + scene.configureBasePlate(0, 0, 5); + scene.scaleSceneView(0.95f); + scene.setSceneOffsetY(-1); scene.world.showSection(util.select.layer(0), Direction.UP); scene.idle(5); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/ParrotElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/ParrotElement.java index cd7043524..c2ea78695 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/ParrotElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/ParrotElement.java @@ -6,9 +6,9 @@ import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.foundation.ponder.PonderScene; +import com.simibubi.create.foundation.ponder.PonderUI; import com.simibubi.create.foundation.ponder.PonderWorld; import com.simibubi.create.foundation.utility.AngleHelper; -import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.MatrixStacker; import net.minecraft.client.MainWindow; @@ -170,7 +170,7 @@ public class ParrotElement extends AnimatedSceneElement { .length(); entity.onGround = false; double phase = Math.min(length * 15, 8); - float f = (float) ((AnimationTickHolder.getTicks() % 100) * phase); + float f = (float) ((PonderUI.ponderTicks % 100) * phase); entity.flapSpeed = MathHelper.sin(f) + 1; if (length == 0) entity.flapSpeed = 0; diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java index e4f24ed6a..f1e05c489 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java @@ -313,10 +313,9 @@ public class WorldSectionElement extends AnimatedSceneElement { transformMS(ms, pt); RenderSystem.disableTexture(); WorldRenderer.drawBox(ms, buffer.getBuffer(RenderType.getLines()), shape.getBoundingBox() - .offset(selectedBlock), 1, 1, 1, 1); - if (buffer instanceof SuperRenderTypeBuffer) - ((SuperRenderTypeBuffer) buffer).draw(RenderType.getLines()); - RenderSystem.enableTexture(); + .offset(selectedBlock), 1, 1, 1, 0.6f); +// if (buffer instanceof SuperRenderTypeBuffer) +// ((SuperRenderTypeBuffer) buffer).draw(RenderType.getLines()); ms.pop(); } 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 c5ff15c2a..defd97deb 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 @@ -7,7 +7,6 @@ import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.IScreenRenderable; import com.simibubi.create.foundation.gui.widgets.AbstractSimiWidget; import com.simibubi.create.foundation.ponder.PonderUI; -import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.LerpedFloat; @@ -26,6 +25,7 @@ public class PonderButton extends AbstractSimiWidget { private float fade; private KeyBinding shortcut; private LerpedFloat flash; + private boolean noClickEvent; public static final int SIZE = 20; @@ -54,6 +54,11 @@ public class PonderButton extends AbstractSimiWidget { return this; } + public PonderButton noClickEvent() { + this.noClickEvent = true; + return this; + } + public PonderButton shortcut(KeyBinding key) { this.shortcut = key; return this; @@ -86,7 +91,7 @@ public class PonderButton extends AbstractSimiWidget { if (fade < .1f) return; - isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height && fade > .75f; + isHovered = isMouseOver(mouseX, mouseY) && fade > .75f; RenderSystem.pushMatrix(); RenderSystem.disableDepthTest(); @@ -95,11 +100,13 @@ public class PonderButton extends AbstractSimiWidget { float flashValue = flash.getValue(partialTicks); if (flashValue > .1f) - fade *= 3 * flashValue + Math.sin((AnimationTickHolder.getTicks() + partialTicks) / 6); + fade *= 3 * flashValue + Math.sin((PonderUI.ponderTicks + partialTicks) / 6); int backgroundColor = ColorHelper.applyAlpha(0xdd000000, fade); - int borderColorStart = ColorHelper.applyAlpha(isHovered ? 0x70ffffff : 0x40aa9999, fade); - int borderColorEnd = ColorHelper.applyAlpha(isHovered ? 0x30ffffff : 0x20aa9999, fade); + int borderColorStart = + ColorHelper.applyAlpha(noClickEvent ? 0x70984500 : isHovered ? 0x70ffffff : 0x40aa9999, fade); + int borderColorEnd = + ColorHelper.applyAlpha(noClickEvent ? 0x70692400 : isHovered ? 0x30ffffff : 0x20aa9999, fade); PonderUI.renderBox(x, y, width, height, backgroundColor, borderColorStart, borderColorEnd); RenderSystem.translated(0, 0, 800); @@ -153,4 +160,13 @@ public class PonderButton extends AbstractSimiWidget { public ItemStack getItem() { return item; } + + @Override + public boolean isMouseOver(double x, double y) { + double m = 4; + x = Math.floor(x); + y = Math.floor(y); + return active && visible + && !(x < this.x - m || x > this.x + width + m - 1 || y < this.y - m || y > this.y + height + m - 1); + } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java b/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java index b86ac025a..1da015fd6 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java +++ b/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java @@ -1,6 +1,10 @@ package com.simibubi.create.foundation.utility; +import com.simibubi.create.foundation.ponder.PonderUI; +import com.simibubi.create.foundation.ponder.PonderWorld; + import net.minecraft.client.Minecraft; +import net.minecraft.world.IWorld; public class AnimationTickHolder { @@ -15,6 +19,10 @@ public class AnimationTickHolder { ticks = (ticks + 1) % 1_728_000; // wrap around every 24 hours so we maintain enough floating point precision } } + + public static int getTicks() { + return ticks; + } public static float getRenderTime() { return getTicks() + getPartialTicks(); @@ -24,8 +32,16 @@ public class AnimationTickHolder { Minecraft mc = Minecraft.getInstance(); return (mc.isGamePaused() ? mc.renderPartialTicksPaused : mc.getRenderPartialTicks()); } - - public static int getTicks() { - return ticks; + + public static int getTicks(IWorld world) { + return world instanceof PonderWorld ? PonderUI.ponderTicks : getTicks(); + } + + public static float getRenderTime(IWorld world) { + return getTicks(world) + getPartialTicks(world); + } + + public static float getPartialTicks(IWorld world) { + return world instanceof PonderWorld ? PonderUI.getPartialTicks() : getPartialTicks(); } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java b/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java index 32923920b..1432d99ff 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java +++ b/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java @@ -208,7 +208,7 @@ public class TreeCutter { } private static boolean isLeaf(BlockState state) { - return state.has(LeavesBlock.DISTANCE); + return state.has(LeavesBlock.DISTANCE) || state.isIn(BlockTags.LEAVES); } } diff --git a/src/main/resources/assets/create/textures/block/linear_chassis_side_connected.png b/src/main/resources/assets/create/textures/block/linear_chassis_side_connected.png new file mode 100644 index 000000000..b1398a957 Binary files /dev/null and b/src/main/resources/assets/create/textures/block/linear_chassis_side_connected.png differ diff --git a/src/main/resources/assets/create/textures/block/secondary_linear_chassis_side_connected.png b/src/main/resources/assets/create/textures/block/secondary_linear_chassis_side_connected.png new file mode 100644 index 000000000..2b9ab5f1d Binary files /dev/null and b/src/main/resources/assets/create/textures/block/secondary_linear_chassis_side_connected.png differ diff --git a/src/main/resources/assets/create/textures/gui/icons.png b/src/main/resources/assets/create/textures/gui/icons.png index 000090faf..c9d661aee 100644 Binary files a/src/main/resources/assets/create/textures/gui/icons.png and b/src/main/resources/assets/create/textures/gui/icons.png differ